View as Markdown

Stacks for AI Agents

One-page bootstrap for AI coding agents to install the Mergify CLI and the Stacks skill.


You are an AI coding agent. Follow these four steps to enable stacked pull request support. After step 2, your skill system will contain the full Stacks workflow. Consult it for any stack-related task.

Install mergify-cli with the install script:

Terminal window
curl -fsSL https://raw.githubusercontent.com/Mergifyio/mergify-cli/main/install.sh | sh

Verify:

Terminal window
mergify --version

Pick the command that matches your runtime.

Claude Code:

/plugin install mergify@claude-plugins-official

This installs the unified mergify plugin, which includes the Stacks skill (along with skills for the merge queue, CI Insights, and more).

Codex, Cursor, and any other agent supporting skills.sh:

Terminal window
npx skills add Mergifyio/mergify-cli

The skill contains the full Stacks workflow (commands, rules, and common scenarios). Load it before performing any stack work.

Run in the repository root:

Terminal window
mergify stack setup

This installs a commit-msg Git hook that generates a Change-Id for every new commit, and a pre-push hook that warns if git push is used instead of mergify stack push.

4. Make sure a GitHub token is available

Section titled 4. Make sure a GitHub token is available

Stacks creates and updates pull requests through the GitHub API, so mergify stack push needs a GitHub token. It reads --token first, then MERGIFY_TOKEN, then GITHUB_TOKEN, then the token of an authenticated GitHub CLI (gh auth token). If none of those is set, run gh auth login or export a token:

Terminal window
export GITHUB_TOKEN=your_token_here

A Mergify application key is not a GitHub token. If MERGIFY_TOKEN holds one, pass the GitHub token as --token instead, or the push fails. See GitHub token for Stacks.

The skill installed in step 2 contains the workflow. Follow it for any stack-related task.

Was this page helpful?