stacking-prs
できること
このスキルは、gh stackコマンドラインツールを使って、GitHubでスタックされたプルリクエストを作成・管理する方法をAIに示します。大きな変更を、レビューしやすい小さな層に分けたい開発者向けです。
使う場面
- ✓変更が大きすぎて1つのプルリクエストでレビューできず、層に分割したいとき。
- ✓スタックの下の層が変わり、その上の層を更新する必要があるとき。
- ✓プルリクエストのスタックを正しい順序でマージしたいとき。
スキルのリンク
https://github.com/PostHog/posthog/blob/master/.agents/skills/stacking-prs/SKILL.mdコピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。
使い方
いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。
貼り付け用メッセージ
Claude Code、Codex、Cursorの場合:プロジェクトのフォルダで実行するとスキルがインストールされます。
SKILL.mdをダウンロードして、エージェントのスキル用フォルダに入れてください。
AIへの頼み方の例
“大きな機能ブランチを、1つずつレビューできる小さなプルリクエストのスタックに分割してください。”
毎週5つの新しいスキル。1分で読めます。
仕組み
スタックとは、各プルリクエストが1つ下の層の上に積み重なる、順序付きの連なりです。AIは gh stack ツールを使って、各層を作成、提出、更新し、ある層が変わったときは上の層をリベースします。
技術的な内容(元のSKILL.md)
作者による元のテキスト(英語)をGitHubからそのまま表示しています。
Stacked PRs with gh stack
Before you divide a change into layers, check things already tried. It records when a stack cost more review effort than one PR.
GitHub's native stacked PRs are enabled on this repo.
A stack is an ordered chain of PRs where each one targets the branch of the PR below it; the bottom PR targets master.
GitHub tracks the chain as a first-class object: the PR UI shows a stack map, branch protections (code owner approval, required checks) apply to every layer including mid-stack ones, and CI that runs on master PRs runs on every layer.
Setup (this skill is written against gh-stack v0.1.0):
gh extension install github/gh-stack # or: gh extension upgrade stack
Upstream docs: about stacked PRs, CLI commands.
In a cloud task sandbox, use gh_stack instead
The rest of this skill assumes a developer machine.
Cloud task runs block git commit and git push so unsigned commits cannot leave the sandbox, which takes out every gh stack command that publishes a stack — submit, sync, push, and link with branch arguments all push, and gh stack add -m commits.
There, build the stack from the signed-commit tooling and link it with the gh_stack MCP tool, which drives GitHub's Stacks REST API and never pushes:
- Commit each layer with
git_signed_commit, passing a newbranch— the checkout already sits on the layer below, so the branch starts there. - Open each layer's PR with
gh pr create --base <branch of the layer below>. - Link them with
gh_stack, operationcreate, passingpull_requestsbottom to top.
To restack a layer: check that layer out, git rebase <its parent branch>, then republish it with git_signed_rewrite passing onto = the parent branch.
gh stack rebase still does the rebase itself, but nothing may publish the result — gh stack push and gh stack sync both push.
git_signed_rewrite replays whatever local HEAD points at and uses branch only to pick which remote ref moves, so the layer has to be the checked-out branch or you publish the wrong history to it.
Create a stack
gh stack init my-feature-db # bottom branch, based on master
# ...commit...
gh stack add my-feature-api # next layer, based on the previous branch
# ...commit...
gh stack add -Am "add UI" my-feature-ui # stage all + commit in one step
- Adopt existing local branches (bottom to top):
gh stack init branch1 branch2 branch3. - Link PRs that already exist on GitHub, without local tracking:
gh stack link <pr> <pr> <pr>, bottom to top (branch names and PR URLs work too). Pass a stack number first to append to an existing stack:gh stack link <stack> <pr>. - Slice by reviewable unit: migration / backend / frontend, or mechanical-rename / behavior-change. Each PR must make sense to review and merge alone.
- Keep stacks shallow (2–4 layers). Every layer multiplies CI cost and rebase churn, and deep-stack pushes can trip GitHub's dispatch cap (see AGENTS.md, "Stacked PRs").
The pre-push hook and the
Stack depthcheck block a layer above the fifth open one (merged layers don't count). For more work on top, rungh stack init --base <top branch> <new branch>frommaster, because gh-stack refuses to start a stack from a layer of another one. Rebase the new stack ontomasteronce the lower stack lands. - Place a CI-heavy layer by how CI diffs it:
- Most jobs pick their work from the layer's own diff against its parent, so such a layer does not make the layers above it heavy. A push to any layer below it starts its jobs again (see the duplicate-run note under "Iterate and keep in sync"). Put it low, unless it is the layer that still changes most.
- A few steps diff against master, so they repeat on layers above the change. Trunk's impacted-targets job runs on every layer and computes affected crates when
rust/orproto/differs. Backend jobs build the HogQL parser from source whencommon/hogql_parser/orrust/hogql/parser/differs, and Playwright jobs whencommon/hogql_parser/differs. Those builds repeat only on upper layers whose own diff starts backend or Playwright jobs. If upper layers do, put the parser change in the top layer.
- Put every change that moves a visual review snapshot, Storybook
よくある質問
スタックされたプルリクエストとは何ですか?
各プルリクエストが、1つ下のプルリクエストのブランチを対象にする連なりのことです。一番下のものはメインブランチを対象にします。
GitHubのコマンドラインツールが必要ですか?
はい。このスキルは、GitHub CLIで一度インストールする gh stack 拡張を使います。
新しいプルリクエストは下書きで始めますか?
はい。スタックはまず下書きとして作成されるため、誰かがレビューする前に各層を確認できます。
詳細
作者による元の説明
Create and manage GitHub native Stacked PRs in this repo with the `gh stack` CLI. Use when asked to stack PRs, split a large change into a stack, add a layer to a stack, restack or rebase a stack, adopt existing branches or PRs into a stack, check out someone else's stack, or land a stack. Covers creating and submitting stacks (draft-first), cascade rebases with `gh stack sync`, and landing one through the Trunk merge queue via `/merging-prs` — whole-stack via `trunk merge` on the top layer, or bottom-first — never `gh stack merge`.
repo: PostHog/posthog
人気
- GitHubのスター
- 41k
- ランキング
- #6818
- ライセンス
- —
- 更新日
- 2026/11/2
コメント
- …
このリポジトリの他のスキル
depot-ci
41kエージェントが、GitHub Actionsの代替であるDepot CIのワークフローを設定し実行できるよう支援します。既存のワークフローの移行や、実行ログの確認も含みます。
depot-container-builds
41kエージェントが、Depotのリモート・ビルダーでDockerイメージを作れるよう支援します。マルチプラットフォームのイメージ、レジストリへのプッシュ、ビルド失敗の修正を含みます。
depot-github-runners
41kエージェントが、GitHub Actionsのジョブを Depot が管理するランナーに移し、ランナーのサイズとラベルを選び、ランナー設定の問題を解決できるよう支援します。
editing-agents-md
41kエージェントが、AGENTS.mdとCLAUDE.mdのどちらにルールを書くべきかを判断し、ファイルを膨らませずに守られやすい形で書けるよう支援します。
似ているスキル
diffs
394k編集内容の実際の共有可能な差分を、手書きの要約ではなく、ビューアーのリンクや画像ファイルとして作成するようエージェントを支援します。
coding-agent
394kCodex、Claude Code、OpenCodeに大きめのコーディング作業をバックグラウンドのワーカーとして渡し、その進捗を確認するようエージェントを支援します。
gh-issues
394kGitHubのイシューを探し、取り組むものを選び、修正を含むプルリクエストを開くようエージェントを支援します。レビューコメントへの対応も含みます。