mcpField
S
stacked-prs

stacked-prs

github.com/bobmatnyc開発78366 回インストール15 週間前に更新
リポジトリ

stacked-prs について

前の PR を土台にする依存関係付き PR の計画と管理を扱うスキルです。ブランチの順序、レビューとリベース、マージ方法を説明し、明示的な要望や段階間の依存がある場合にスタックを勧めます。

主な機能

  1. 01順序を示すブランチ命名
  2. 02前のブランチから後続を作成
  3. 03PR の依存関係を記載
  4. 04依存ブランチの安全なリベース
  5. 05マージ方法のガイド

活用シーン

  1. 01大規模機能を依存するレビュー単位に分割
  2. 02ベース PR の指摘後にスタックを更新
  3. 03段階的な実装のブランチを計画

インストール

コマンドをコピーしてターミナルで実行します。

$npx skills add https://github.com/bobmatnyc/claude-mpm-skills --skill stacked-prs

インストール後、Claude Code で/stacked-prsを入力して読み込まれたか確認します。

同梱ファイルmetadata.json

詳細

積み重ね型プルリクエスト

概要

積み重ね型 PR は、各 PR が前の PR をベースにして構築される、依存関係のあるプルリクエストです。論理的に分割し、並行してレビューする必要がある複雑な機能にこのパターンを使用します。

使用するタイミング

✅ 積み重ね型 PR を使用する場合:
  • ユーザーが「積み重ね型 PR」または「依存関係のある PR」を明示的にリクエストしている
  • 大規模な機能を論理的なフェーズに分割する必要がある
  • 各フェーズに、前のフェーズとの明確な依存関係がある
  • ユーザーがリベースのワークフローに慣れている
❌ main ベースの PR を使用する場合(デフォルト):
  • 機能が互いに独立している
  • 簡単なバグ修正や機能強化
  • 複数のエージェントが並行して作業している
  • ユーザーが希望を指定していない

デフォルト:ユーザーが積み重ね型 PR を明示的にリクエストしない限り、常に main ベースの PR を優先してください。

ブランチの命名規則

依存関係を示すために、連番を使用します。

feature/001-base-authentication       # PR-001 (base)
feature/002-user-profile              # PR-002 (depends on 001)
feature/003-admin-panel               # PR-003 (depends on 002)

代替パターン:

auth/01-foundation
auth/02-user-flow
auth/03-admin-features

積み重ね型 PR の作成

ステップ 1:ベース PR(PR-001)を作成する
# Start from main
git checkout main
git pull origin main

# Create base branch
git checkout -b feature/001-base-auth

# Implement base functionality
# ... work ...

# Push and create PR
git push -u origin feature/001-base-auth

# Create PR in GitHub/GitLab
# Title: "[1/3] Base authentication foundation"
# Base: main
# Description: Include stack overview (see template below)
ステップ 2:依存する PR(PR-002)を作成する

重要:main ではなく、前の機能ブランチをベースにします。

# Start from PR-001's branch
git checkout feature/001-base-auth
git pull origin feature/001-base-auth

# Create dependent branch
git checkout -b feature/002-user-profile

# Implement dependent functionality
# ... work ...

# Push and create PR
git push -u origin feature/002-user-profile

# Create PR in GitHub/GitLab
# Title: "[2/3] User profile management"
# Base: feature/001-base-auth  ← NOT main!
# Description: "Depends on PR #123"
ステップ 3:最後の PR(PR-003)を作成する
# Start from PR-002's branch
git checkout feature/002-user-profile
git pull origin feature/002-user-profile

# Create final branch
git checkout -b feature/003-admin-panel

# Implement final functionality
# ... work ...

# Push and create PR
git push -u origin feature/003-admin-panel

# Create PR in GitHub/GitLab
# Title: "[3/3] Admin panel with full auth"
# Base: feature/002-user-profile  ← NOT main!
# Description: "Depends on PR #124"

PR の説明テンプレート

積み重ね型 PR には、次のテンプレートを使用します。

## This PR
[Brief description of changes in THIS PR only]

## Depends On
- PR #123 (feature/001-base-auth) - Must merge first
- Builds on top of authentication foundation

## Stack Overview
1. PR #123: Base authentication (feature/001-base-auth) ← MERGE FIRST
2. PR #124: User profile (feature/002-user-profile) ← THIS PR
3. PR #125: Admin panel (feature/003-admin-panel) - Coming next

## Review Guidance
To see ONLY this PR's changes:
```bash
git diff feature/001-base-auth...feature/002-user-profile

または GitHub で、feature/002-user-profile...feature/001-base-auth(3 つのドット)を比較します。

テスト

  • PR #123 と組み合わせてテスト済み
  • ユーザープロフィール機能のテストを含む
  • ベース認証レイヤーとの統合テストに合格

## Managing Rebase Chains

### When Base PR Changes (Review Feedback)

If PR-001 gets updated, rebase dependent PRs:

```bash
# Update PR-001 (base)
git checkout feature/001-base-auth
git pull origin feature/001-base-auth

# Rebase PR-002 on updated base
git checkout feature/002-user-profile
git rebase feature/001-base-auth
git push --force-with-lease origin feature/002-user-profile

# Rebase PR-003 on updated PR-002
git checkout feature/003-admin-panel
git rebase feature/002-user-profile
git push --force-with-lease origin feature/003-admin-panel

重要:安全のため、--force ではなく --force-with-lease を使用してください。

マージ戦略

オプション A:順次マージ(推奨)

  1. PR-001 を main にマージする
  2. PR-002 のベースを main に変更する(GitHub:PR の「編集」ボタン)
  3. PR-002 を main にマージする
  4. PR-003 のベースを main に変更する
  5. PR-003 を main にマージする

オプション B:最後まで積み重ねた状態を維持する

  1. PR-001 を main にマージする
  2. PR-001 が完全にマージされるまで、PR-002 のベースを feature/001 にしておく
  3. その後、PR-002 を main にリベースする
  4. PR-003 についても同様に繰り返す

よくある落とし穴

❌ 誤り:すべての PR を main から作成する
git checkout main
git checkout -b feature/001-base
# PR: feature/001-base → main

git checkout main  # ← WRONG
git checkout -b feature/002-next
# PR: feature/002-next → main  # ← WRONG (independent, not stacked)
✅ 正解:各 PR を前の PR から作成する
git checkout main
git checkout -b feature/001-base
# PR: feature/001-base → main

git checkout feature/001-base  # ← CORRECT
git checkout -b feature/002-next
# PR: feature/002-next → feature/001-base  # ← CORRECT (stacked)

エージェントへの指示

バージョン管理エージェントに積み重ね型 PR の作成を委任する場合:

Task: Create stacked PR branch structure

Stack Sequence:
1. PR-001: feature/001-base-auth → main (base layer)
2. PR-002: feature/002-user-profile → feature/001-base-auth (depends on 001)
3. PR-003: feature/003-admin-panel → feature/002-user-profile (depends on 002)

Requirements:
- Each branch MUST be based on previous feature branch
- Use sequential numbering (001, 002, 003)
- Include "depends on" notes in commit messages
- Create PR description with stack overview

CRITICAL: PR-002 bases on feature/001-base-auth, NOT on main
CRITICAL: PR-003 bases on feature/002-user-profile, NOT on main

確認チェックリスト

積み重ね型 PR を作成する前に確認してください。

  • ユーザーが積み重ね型 PR を明示的にリクエストしている
  • 機能が明確で論理的なフェーズに分かれている
  • 各フェーズに前のフェーズとの依存関係がある
  • ユーザーがリベースのワークフローを理解している
  • ブランチ名に連番を使用している
  • 各ブランチが正しいベース(前の機能ブランチ)から作成されている
  • PR の説明に依存関係の情報が含まれている
  • 各 PR にスタックの概要が記載されている

関連スキル

  • git-worktrees - 複数の PR を同時に作業する
  • git-workflow - Git の一般的なブランチ運用パターン
  • code-review - 積み重ね型 PR のレビュー戦略

コメント