/mergify:mergify-stackfrom mergify
Guides use of Mergify stacks for git push, commit, branch, and PR creation in repositories that use stacked workflows. Detects stack usage and falls back to plain git/gh otherwise.
Ships in mergify. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
This skill applies only to a repository that uses Mergify stacks. Check before anything else:
mergify stack hooks # commit-msg "Wrapper: installed" (or "legacy") → uses stacks
git log -n 20 --format=%B | grep -c '^Change-Id: I' # any match → uses stacks
not installed in this clone), run mergify stack setup once before committing: the hook is what adds the Change-Id trailer, and mergify stack push refuses a commit without one.mergify is not installed: the repository does not use stacks. Ignore the rest of this skill and use plain git and gh, following the repository's own conventions. Do not run mergify stack setup or suggest it.A branch is a stack. Keep stacks short and focused:
Proactive stack management:
mergify stack push (never git push)git commit --amend (never create new commits to fix issues)mergify stack note BEFORE mergify stack push to record why the commit was amended. The note appears in the PR's "Revision history" comment and JSON marker, so reviewers can see the reason without diffing.git stash -u), then use mergify stack edit <SHA-or-Change-Id-prefix> to pause the rebase at the target commit. Amend it with git commit --amend, then git rebase --continue, then mergify stack push, then git stash pop. Non-interactive — never use git rebase -i for this. (Calling mergify stack edit with no argument falls back to a fully interactive git rebase -i and will hang in agent contexts — always pass a commit prefix.)git stash -u), then use mergify stack reorder (list all commits in desired order) or mergify stack move (move a single commit) instead of manual git rebase -i — non-interactive and avoids GIT_SEQUENCE_EDITOR quoting issuesgit stash -u), then use mergify stack fixup <SHA>... to fold a commit into its parent (drops the listed commit's message). Non-interactive — never use git rebase -i for this.git stash -u), then use mergify stack squash SRC... into TARGET [-m "msg"] to combine multiple commits into one, with an optional custom message. Non-interactive — never use git rebase -i for this.git stash -u), then use mergify stack reword <SHA> -m "new message" to change a commit's message in place. Non-interactive when -m is given — never use git rebase -i for this.git stash -u), then use mergify stack drop <SHA>... to remove commits from the stack. Non-interactive — never use git rebase -i for this.git log first, and use Conventional Commits (e.g., feat:, fix:) only if the repository doesmergify stack copies the commit message title to the PR title and the commit message body to the PR body — so write commit messages as if they were PR descriptions. Everything that should appear in the PR (ticket references, context, test plans) MUST go in the commit message.MRGFY-1234, Fixes #123) in the commit message body, not added separately to the PR.Depends-On: or Merge-After: line in its commit message body, and follow the mergify-merge-protections skill, which says what to check when an older mergify release drops a Depends-On: #NNN line.mergify stack: NEVER edit PR titles, bodies, or labels with gh pr edit or the GitHub MCP — they will be overwritten on the next push. NEVER close or merge PRs manually — mergify stack handles the entire PR lifecycle (creation, updates, and cleanup).| Wrong | Right | Why |
|---|---|---|
git push | mergify stack push | Git push bypasses stack management and breaks PR relationships |
| New commit to fix lint/typo | git commit --amend (HEAD) or git commit --fixup <SHA> + git rebase --autosquash (mid-stack) | Each commit = a PR; fix commits create unwanted extra PRs |
gh pr edit --title "..." | Edit the commit message, then mergify stack push | PR title/body are overwritten from commit messages on every push |
gh pr merge or gh pr close | PR lifecycle is fully managed — do nothing | PR lifecycle is fully managed by the stack tool |
git commit on main | mergify stack new <name> first | mergify stack push will fail on the default branch |
git rebase -i to fixup a commit | mergify stack fixup <SHA> | Non-interactive — works inside LLM/agent sessions; no editor spawned |
git rebase -i to squash commits | mergify stack squash A B into X [-m "..."] | Non-interactive — works inside LLM/agent sessions; no editor spawned |
git rebase -i to change a commit message | mergify stack reword <SHA> -m "..." | Non-interactive — works inside LLM/agent sessions; no editor spawned |
git rebase -i to amend a mid-stack commit | mergify stack edit <SHA-or-Change-Id-prefix> then git commit --amend then git rebase --continue | Non-interactive — pauses the rebase at the target commit without spawning an editor |
git rebase -i to drop a commit | mergify stack drop <SHA>... | Non-interactive — works inside LLM/agent sessions; no editor spawned |
GIT_SEQUENCE_EDITOR='sed -i ...' git rebase -i (any variant) | One of mergify stack {edit,fixup,squash,reorder,move} | Hand-rolled sequence-editor scripts are brittle; there is already a non-interactive command for every common rewrite |
| Deferring lint fixes to a later commit | Include the fix in the commit that caused it | Each commit runs CI independently; later commits won't save earlier ones |
| Rebase/reorder/checkout/sync with dirty worktree | git stash -u first, then git stash pop after | Uncommitted changes are lost or cause conflicts during these operations |
| Amending a pushed commit with no explanation | mergify stack note -m "why" before mergify stack push | The reason is recorded in the PR's Revision history table and JSON marker, so reviewers don't need to diff to understand the change |
mergify stack new NAME # Create a new stack/branch for new work
mergify stack push # Push and create/update PRs (also registers as a GitHub-native stack by default)
mergify stack push --no-github-native # ...without registering it as a GitHub-native stack
mergify stack checkout BRANCH # Checkout an existing stack from GitHub (e.g. someone else's)
mergify stack checkout PR_URL # Same, from any PR in the stack — middle included
mergify stack sync # Fetch trunk, remove merged commits, rebase
mergify stack list # Show commit <-> PR mapping for current stack
mergify stack list --json # Same, but machine-readable JSON output
mergify stack reorder C A B # Reorder all commits, bottom first (pass SHA or Change-Id prefixes)
mergify stack move X first # Move commit X to the bottom of the stack (next to the trunk)
mergify stack move X last # Move commit X to the top of the stack
mergify stack move X before Y # Move commit X before commit Y
mergify stack move X after Y # Move commit X after commit Y
mergify stack fixup X # Fold commit X into its parent (drops X's message)
mergify stack fixup X Y Z # Fold each into its parent (multi-fixup)
mergify stack squash X into Y # Reorder X adjacent to Y, fold X into Y (keeps Y's message)
mergify stack squash X Y into Z -m "msg" # Fold X Y into Z with a custom message
mergify stack reword X -m "msg" # Change commit X's message non-interactively
mergify stack reword X # Change commit X's message via $GIT_EDITOR (TTY only)
mergify stack edit X # Pause the rebase at X so you can `git commit --amend` it (X is required; no-arg form is interactive)
mergify stack drop X # Drop commit X from the stack
mergify stack drop X Y Z # Drop multiple commits in one rebase
mergify stack note -m "why" # Attach an amend reason to HEAD (shown in PR revision history)
mergify stack note <SHA-or-Change-Id-prefix> -m "why" # Attach to a specific commit in the stack
mergify stack note --append -m "more" # Append to an existing note
mergify stack note --remove # Remove the note from a commit
Use mergify stack checkout to check out a stack that exists on GitHub (e.g. a colleague's stack). The argument is either the stack's remote branch name — whatever prefix it uses, no assumption that it contains an author — or the URL of any pull request in the stack, including one from the middle. It fetches all stacked PRs, creates a local branch, and sets up tracking.
The local branch defaults to the stack branch with your own stack branch prefix removed, so a stack you pushed from feature/login comes back as feature/login and a later mergify stack push updates the same PRs. For a stack that is not under your prefix — a colleague's — the last segment is used and checkout warns you: you can work on those commits, but mergify stack push from that branch would create a separate stack rather than update their pull requests. Use --branch to override the name. A pull request URL carries its own owner/repo, so --repository is ignored in that form.
Use mergify stack sync to bring your stack up to date. It fetches the latest trunk, detects which PRs have been merged, removes those commits from your local branch, and rebases the remaining commits. Run this before starting new work on an existing stack. When a PR's branch took its base branch through a merge on top of your commit (Mergify's conflict resolution, GitHub's "Update branch" or "Resolve conflicts"), sync rebases the change as that merge resolved it, so you do not resolve those conflicts again. mergify stack push does the same when it rebases; when it skips the rebase, it leaves such a PR's branch as it is rather than erase the merge.
Use mergify stack list to see which commits have been pushed, which PRs they map to, and whether the stack is up to date with the remote. It also shows CI status, review status, and merge conflicts for each PR. Use --verbose for detailed check names and reviewer names. Use --json when you need to parse the output programmatically — it includes full CI check details and review data.
mergify stack push registers the stack with GitHub's own Stacks API by
default, so GitHub renders it as a stack. Opt out per invocation with
--no-github-native, or per repo with
git config mergify-cli.stack-github-native false.
Change-Ids, branch layout and revision history are unchanged, and it degrades
quietly: where GitHub does not take the stack, the push reports not registered on GitHub, says why in a closing line (stacked pull requests not
enabled on the repository, a pull request already part of another stack, or a
chain where some base branch is not the head branch below it), and succeeds
exactly as it would have. A registered stack's line links its page on GitHub.
Things to know:
Depends-On: header goes away. A registered stack is the
dependency between two pull requests, so the CLI stops writing a second copy
of it into the PR descriptions. It is keyed off the registration, not off the
flag: when a push degrades to not registered on GitHub, the headers are
written back in the same push and Mergify keeps ordering the stack. Your
commit messages are never touched either way — the header only ever existed
in the rendered PR description.PUT /repos/{owner}/{repo}/pulls/{pull_number}/merge → 403) for
its members. That is GitHub's contract, not ours; it is the reason
--no-github-native exists./repos/{owner}/{repo}/… paths refuses GraphQL), the stack stays
unregistered, and a push that would move that pull request stops before
changing anything; turn auto-merge off on GitHub and push again.Pushing stays cheap. Refreshing commits (amend, reword, force-push) leaves the
registration untouched, and adding a change on top extends the same stack.
Only a push that moves a pull request's base — a reorder, a drop, a change
inserted in the middle — dissolves the registration first and rebuilds it at
the end, because GitHub rejects any base-branch change while a PR is stacked.
An interrupted push therefore leaves the stack merely unregistered — never
half-registered. It can also leave it without its Depends-On: headers, since
those are restored at the end of the push; re-running mergify stack push
settles both, because every push re-renders the descriptions and recomputes the
Depends-On: markers from the stack's current shape — including with
--keep-pull-request-title-and-body, where the description is re-rendered from
the pull request's own body rather than the commit message, and the marker is
still stripped and re-appended rather than carried over.
mergify stack note records why a commit was amended. The note travels with the stack:
refs/notes/mergify/stack against the commit SHA.mergify stack push, the reason is consumed into the change's revision history; the note on the pushed head commit is replaced by the full revision history (human digest + the <!-- mergify-revision-data: {...} --> JSON marker). Git notes — not the PR comment — are the machine-readable source of truth; the PR's "Revision history" comment is rendered from them.git log --notes=mergify/stack on the base branch shows why each change was revised.When to attach a note — any time you amend or rewrite a commit that already has a PR open (i.e. it has been pushed at least once). The note answers "why is this revision different?" so the reviewer doesn't have to diff old vs new SHAs to find out.
Workflow — attach the note BEFORE mergify stack push:
# Edit HEAD, then:
git commit --amend
mergify stack note -m "address review: rename foo() to bar()"
mergify stack push
# Or for a mid-stack commit (after the rebase that amended it):
mergify stack note <SHA-or-Change-Id-prefix> -m "fix lint reported in CI"
mergify stack push
A note is per-commit, not per-revision. Each amend (or other history rewrite) creates a new commit SHA, so you must run mergify stack note again for the new SHA — the previous note stays attached to the old SHA and won't carry over. Use --append only when the current target commit already has a note and you want to add another reason; use --remove to clear it. Notes on commits that haven't changed since the last push are preserved but won't add a new revision row.
BEFORE staging or committing anything, always check the current branch and assess stack state:
git branch --show-current
mergify stack list
main (or the repo's default branch): you MUST create a feature branch firstmain — mergify stack push will failgit add, not after git commitBEFORE running any operation that rewrites history or switches branches, check for uncommitted changes and stash them:
git status --short # Check for uncommitted changes
git stash -u # Stash tracked + untracked changes if any
Operations that require this check:
mergify stack edit <commit> (mid-stack fixes)mergify stack reorder / mergify stack movemergify stack fixupmergify stack squashmergify stack rewordmergify stack dropmergify stack checkoutmergify stack syncmergify stack new (switches to new branch)git checkout <branch>After the operation completes, restore the stashed changes:
git stash pop
If you skip this step, uncommitted work will be silently lost or cause rebase conflicts.
When asked to start a new piece of work, create a new feature, or work on something unrelated to the current stack:
git branch --show-currentmergify stack new <branch-name>
mergify stack pushWhen continuing work on an existing feature branch:
git branch --show-current
main: switch to the feature branch first with git checkout <branch> or create a new stackWhen a rebase causes conflicts (during git rebase -i or mergify stack push):
A stack command whose rebase stops exits with code 4 and names the commit it stopped on (with its PR when it knows it), the files in conflict, and the commands to run next. Any other failure exits 1 with git's own message: a dirty worktree is not a conflict.
git addgit rebase --continueTo abort instead: git rebase --abort
After resolving, run mergify stack push to sync the updated stack.
If mergify rejects a command or flag this skill names, the CLI is probably older than the skill: follow the mergify-cli-upgrade skill.
What SKILL.md sets; muted values are Claude Code's defaults
8 skills in this plugin
/mergify-ciUse Mergify CI commands to upload JUnit test results, detect git references, manage CI scopes, retrieve merge queue metadata, and write the OIDC trust policies that let GitHub Actions jobs reach Mergify without a key. ALWAYS use this skill when running `mergify ci`, `mergify tests` or `mergify oidc` commands, uploading test results to Mergify, managing Mergify test quarantines, turning Mergify test retry on or off, detecting Mergify CI scopes, reading Mergify merge queue CI context, or finding out why a job's ID token was refused. Triggers on mergify ci, mergify tests, mergify oidc, junit-process, Mergify Test Engine, CI Insights, Mergify quarantine, Mergify test retry, Mergify scopes, scopes-send, git-refs, queue-info, trust policy, OIDC, id-token./mergify-cli-upgradeUpgrade the mergify CLI when it is older than a Mergify skill. Use when `mergify` rejects a command or flag a skill names, or when asked to check, update or upgrade the mergify CLI. Triggers on unrecognized subcommand, unexpected argument, outdated CLI, upgrade mergify, update mergify, self-update./mergify-configUse Mergify config commands to validate configuration files, simulate Mergify actions, and write Mergify configuration. ALWAYS use this skill when validating, writing, editing, or simulating Mergify config. Triggers on config validate, config simulate, mergify configuration, mergify.yml, .mergify.yml, Mergify merge queue config, pull_request_rules, Workflow Automation, queue_rules, Mergify conditions, conflict_resolvers, automatic merge conflict resolution./mergify-eventsUse `mergify events` to browse the Mergify activity log — every event Mergify recorded for a repository or one pull request (queue enters/leaves, merges, commands, CI Insights, freezes), as a human timeline or JSON. ALWAYS use this skill when investigating what Mergify did to a PR or repository and when, reconstructing a pull request's merge-queue lifecycle, auditing Mergify actions, or filtering events by type. Triggers on mergify events, Mergify activity log, Mergify event log, what did Mergify do, Mergify queue lifecycle, Mergify queue history, event_type, action.queue./mergify-merge-protectionsUse Mergify merge protections to control when pull requests merge — make one wait for other pull requests to merge (Depends-On header), hold one until a date and time (Merge-After header), and pause merges with scheduled freezes (CLI). In a repository that uses Mergify, ALWAYS use this skill when a pull request must not merge before another pull request, in the same repository or in another repository of the organization; when a change split across repositories has to land in order; when a pull request must not merge before a date or a time; when a ready pull request has to be held back; or when managing Mergify scheduled freezes. Triggers on merge after another PR, wait for a PR to merge first, land in order, merge order across repositories, do not merge before, merge on a date, hold back a PR, hold the merge, Depends-On, Merge-After, mergify freeze, Mergify merge freeze, Mergify merge protection./mergify-merge-queueUse Mergify merge queue to queue/dequeue PRs, to monitor and inspect the queue, to diagnose a dequeued PR — whether it is queued, why it was dequeued, where its CI failure is, and what to do next — and to decide whether a change to a PR already in the queue is worth pushing now. ALWAYS use this skill when queuing or dequeuing a PR in the Mergify merge queue, checking its status, finding out why Mergify dequeued a PR, about to push, amend or rebase a PR that is in the Mergify merge queue, pausing/unpausing the Mergify merge queue, or debugging a merge the Mergify queue did not make. Triggers on mergify queue, @mergifyio queue, @mergifyio dequeue, Mergify merge queue, Mergify queue status, why did Mergify dequeue my PR, Mergify dequeue reason, push to a PR in the Mergify merge queue, review comment on a PR in the Mergify merge queue, Mergify queue pause, Mergify batch, Mergify bisecting, CHECKS_FAILED, PULL_REQUEST_UPDATED, CONFLICT_WITH_BASE_BRANCH, CONFLICT_WITH_PULL_AHEAD, Mergify merge conflict.npx claudepluginhub mergifyio/mergify-cli --plugin mergifyOther plugins' skills for the same job