submit-stack
Skill0 starsChanged 21 days agoMITView on GitHub
Promote a stack of local commits to stacked GitHub pull requests with gh stack, or scripts/sl-pr-submit in a Sapling checkout, one PR per commit, moving each commit message body into its PR description and leaving each commit with its title alone. Takes "draft" to open the PRs as drafts. Use only when the user invokes /submit-stack or asks to submit the commits as a stack; for a single commit, use submit.
- Deletes or force-pushes
In this repository12 other files it gives its agents.
- autopilotSkill
- commit-msgSkill
- handoffSkill
- land-stackSkill
- planSkill
- principle-minimal-commentsSkill
- recallSkill
- reflectSkill
- review-3p-skillSkill
- submitSkill
- test-planSkill
- trace-flowSkill
The file
We split this skill into the rules it gives an agent
2 rules. About 0 are common, 0 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 22
Read every commit bottom to top, git log --reverse --format='%H' <base>..HEAD, and save each full message to $(git rev-parse …
- Very specific: line 29
Delete submit-backup once every PR shows the right title and body.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Submit stack
The multi-commit counterpart of the submit skill: each commit, prepared with commit-msg and usually squashed into shape first, becomes one layer and one PR. Read the submit skill first; its rules for the description, the saved message, and outward-facing actions apply to every PR here unchanged. For gh stack itself, follow the gh-stack skill, including its non-interactive flags.
Takes an optional draft argument. gh stack submit opens drafts by default, so without draft pass --open.
Preconditions
- Git, or Sapling where git config has
devroot.vcs=sapling, which follows its own section below. - Stacked PRs are same-repository:
originhas to be where the PRs open. In a fork layout, whereupstreamexists and the PRs belong upstream, stop and say so; offer submit for the bottom commit instead. - Two or more commits over the base. One: use submit. When a stack is already checked out (
gh stack view --jsonsucceeds), every layer holds exactly one commit; a layer with several stops the run, with a squash offered to fold it. - Staged and working tree changes stay untouched: rewrite messages with
--only, and stash nothing.
Steps
- Read every commit bottom to top,
git log --reverse --format='%H' <base>..HEAD, and save each full message to$(git rev-parse --git-dir)/submit/<sha>.md. Check which layers are already submitted withscripts/pr-info <checkout> --branch <layer>. - Drop the bodies, keeping each title:
- No stack yet: Rebuild the chain on a detached head:
git branch -f submit-backup HEAD,git checkout --detach <base>, then for each commitgit cherry-pick --no-commit <sha>andgit commit --only -m "<title>". Confirmgit rev-parse HEAD^{tree}matches the old tip's tree; on a mismatch,git reset --hard submit-backupand stop. - Existing stack: For each layer, bottom to top:
gh stack checkout <branch>,git commit --amend --only -m "<title>",gh stack rebase --upstack. Return withgh stack top.
- No stack yet: Rebuild the chain on a detached head:
- No stack yet: Create one branch per commit, bottom to top, each a brief kebab-case name from its title, with the owner prefix when
originis shared (the devroot branch rules apply). Point the original branch at the top commit so it stays the logical branch, thengh stack init <bottom> … <original branch>and check out the top. - Push and open the PRs:
gh stack submit --auto --remote origin, plus--openunlessdraft. For an existing stack this pushes the rewritten layers with lease. - Set each new PR's title and description, since
gh stackgenerates its own: build the description from the layer's saved message as the submit skill does, thengh pr edit <number> --title "<title>" --body-file <file>. Read the numbers fromgh stack view --json. A layer that already had a PR is submitted, so follow the submit skill's resubmit rules instead: its description on GitHub is the source of truth, changed only by a revised summary and only in its summary section, and its title only when the commit's differs. - Delete
submit-backuponce every PR shows the right title and body.
Sapling
scripts/sl-pr-submit stands in for gh stack. It runs sl pr submit, which pushes every draft under the working copy, after pulling and refusing a draft that is not yours; never run sl pr submit directly. The checkout's sl config, set by scripts/checkout, opens one PR per commit, each based on the branch of the PR below, the same shape gh stack makes, and keeps each PR's title and description on later submits. There are no layer branches to create and no backup to keep, since Sapling keeps every rewritten commit (sl undo).
A stack stays with the tool that opened it. When gh stack view --json succeeds, gh stack owns this one: follow the steps above, since sl pr submit opens a second PR for every layer it did not open. The one gh stack command a Sapling stack takes is gh stack link, which only registers existing PRs as a GitHub stack and keeps no local tracking.
- List the stack bottom to top with
sl log -r 'draft() & ::.' -T '{node} {github_pull_request_number}\n'; a number means that commit is already submitted. Save each full message (sl log -r <node> -T '{desc}') to$(git rev-parse --git-dir)/submit/<node>.md. - Drop the bodies top to bottom,
sl metaedit -r <node> -m "<title>", so each edit restacks only commits already done. - Push and open with
scripts/sl-pr-submit <checkout>from the top commit, plus--draftfordraft. - Register the PRs as a GitHub stack so the PR UI shows it:
gh stack link <numbers bottom to top> --remote originfrom inside the checkout. It keeps every PR number, branch and body; on a resubmit that added a layer, pass the stack number it printed first and the new PR after it. Later submits printCannot change the base branch because the pull request is part of a stackfor each PR and still push; the bases are already right. - List the stack again for the numbers, then set each new PR's description from its saved message as step 5 above does, with
gh pr edit <number> --body-file <file>. Leave out the stack footer Sapling appended: a---line, the[//]: # (BEGIN SAPLING FOOTER)marker and one bullet per PR, through the end of the body. The linked stack already shows in the PR UI, so the footer only duplicates it. A layer that already had a PR follows the submit skill's resubmit rules, including resolving the review threads its push addressed. - A later submit that pushes anything rewrites the description of every open PR from the bottom up to the working copy with a fresh footer; a run that pushes nothing leaves them alone. After such a push, strip the footer again from each open PR's body, following the submit skill's rules for editing a submitted description and changing nothing else.
Reporting
The stack, bottom to top: branch, PR number and URL, and title, each PR's state (draft or open), and anything left for the user, such as a Test Plan with nothing to put in it. Say where the saved messages live.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

