Setup
Install Mergify CLI and configure your repository for stacked PRs.
1. Install the Mergify CLI
Section titled 1. Install the Mergify CLISee the CLI installation guide for full instructions.
Quick install:
uv tool install mergify-cli2. Install skills for your AI coding agent
Section titled 2. Install skills for your AI coding agentMergify ships skills that teach AI coding agents how to work with Stacks, so
they run mergify stack push instead of git push, amend commits instead of
creating fixups, and follow stack conventions automatically.
Claude Code:
/plugin marketplace add Mergifyio/mergify-cli/plugin install mergify-stack@mergify/reload-pluginsOr run /plugin on its own and use the Marketplaces tab to add
Mergifyio/mergify-cli, then pick mergify-stack from Discover.
Any agent supporting skills.sh (Cursor, Cline, and others):
npx skills add Mergifyio/mergify-cli3. Configure GitHub
Section titled 3. Configure GitHubStacks needs access to create PRs. Set the GITHUB_TOKEN environment
variable, or install the GitHub CLI and run
gh auth login.
Enable “Automatically delete head branches”
in your GitHub repository settings (Settings > General > Pull Requests). When
a stacked PR merges, this cleans up its remote branch automatically so the
next PR in the chain can rebase onto main cleanly.
4. Initialize your repository
Section titled 4. Initialize your repositoryRun the setup command in your Git repository:
mergify stack setupThis installs:
-
A
commit-msgGit hook that automatically generates a Change-Id for every new commit. The Change-Id is how Stacks tracks the relationship between your local commits and their GitHub pull requests. -
A
pre-pushhook that warns you if you accidentally usegit pushinstead ofmergify stack push.
Verify It Works
Section titled Verify It WorksCreate a test commit to confirm the hook is active:
echo "test" >> test.txtgit add test.txtgit commit -m "test: verify stack setup"Check the commit message:
git log -1You should see a Change-Id trailer at the bottom of the message:
test: verify stack setup
Change-Id: Ia1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2Clean up the test commit if you don’t need it:
git reset HEAD~1Configuration
Section titled ConfigurationThese optional Git config settings let you customize Stacks behavior:
| Setting | Default | Description |
|---|---|---|
mergify-cli.stack-branch-prefix | stack/{username} | Prefix for remote branch names |
mergify-cli.stack-create-as-draft | false | Create PRs as drafts by default |
mergify-cli.stack-keep-pr-title-body | false | Don’t overwrite PR title/body on updates |
Example:
git config mergify-cli.stack-create-as-draft trueNext Steps
Section titled Next StepsHead to Creating Stacks to push your first stack.
Was this page helpful?
Thanks for your feedback!