gitnexus-pr-review について
gitnexus-pr-reviewは、マージ前のプルリクエストを確認するGitNexusスキルです。コード変更が影響する実行フローやシンボル、テスト範囲を調べ、リスク評価をまとめます。
主な機能
- 01差分を影響する実行フローに対応付け
- 02呼び出し元と変更の影響を追跡
- 03影響を受けるコードのテストを確認
- 04マージリスクを評価
活用シーン
- 01マージ前のプルリクエスト確認
- 02変更後に壊れる可能性のある呼び出し元の特定
- 03影響を受けるコードのテスト確認
MCP 対応
GitNexusのツールと`gitnexus://repo/{name}/processes`リソースを使い、コードへの影響と実行フローを分析します。
インストール
コマンドをコピーしてターミナルで実行します。
$
npx skills add https:/ / github.com/ abhigyanpatwari/ gitnexus --skill gitnexus-pr-reviewインストール後、Claude Code で/gitnexus-pr-reviewを入力して読み込まれたか確認します。
詳細
GitNexus による PR レビュー
使用するタイミング
- 「この PR をレビューして」
- 「PR #42 は何を変更するの?」
- 「これはマージしても安全?」
- 「この PR の影響範囲は?」
- 「この PR に不足しているテストはある?」
- マージ前に他の人のコード変更をレビューするとき
ワークフロー
1. gh pr diff <number> → Get the raw diff
2. detect_changes({scope: "compare", base_ref: "main"}) → Map diff to affected flows
3. For each changed symbol:
impact({target: "<symbol>", direction: "upstream"}) → Blast radius per change
4. context({name: "<key symbol>"}) → Understand callers/callees
5. READ gitnexus://repo/{name}/processes → Check affected execution flows
6. Summarize findings with risk assessment
「Index is stale」と表示された場合 → レビュー前にターミナルで
node .gitnexus/run.cjs analyzeを実行してください。
チェックリスト
- [ ] Fetch PR diff (gh pr diff or git diff base...head)
- [ ] detect_changes to map changes to affected execution flows
- [ ] impact on each non-trivial changed symbol
- [ ] Review d=1 items (WILL BREAK) — are callers updated?
- [ ] context on key changed symbols to understand full picture
- [ ] Check if affected processes have test coverage
- [ ] Assess overall risk level
- [ ] Write review summary with findings
レビューの観点
| 観点 | GitNexus がどのように役立つか |
|---|---|
| 正確性 | context が呼び出し元を表示します — それらはすべて変更と互換性がありますか? |
| 影響範囲 | impact が d=1/d=2/d=3 の依存先を表示します — 見落としはありませんか? |
| 完全性 | detect_changes が影響を受けるすべてのフローを表示します — それらはすべて処理されていますか? |
| テストカバレッジ | impact({includeTests: true}) が変更されたコードに触れるテストを表示します |
| 破壊的変更 | PR で更新されていない d=1 の上流項目 = 破損の可能性 |
リスク評価
| シグナル | リスク |
|---|---|
| 変更が 3 未満のシンボル、0〜1 個のプロセスに触れる | LOW |
| 変更が 3〜10 個のシンボル、2〜5 個のプロセスに触れる | MEDIUM |
| 変更が 10 を超えるシンボルまたは多数のプロセスに触れる | HIGH |
| 変更が認証、決済、データ整合性のコードに触れる | CRITICAL |
| PR の差分の外に d=1 の呼び出し元が存在する | 破損の可能性 — 指摘してください |
ツール
detect_changes — PR の差分を影響を受ける実行フローにマッピングします:
detect_changes({scope: "compare", base_ref: "main"})
→ Changed: 8 symbols in 4 files
→ Affected processes: CheckoutFlow, RefundFlow, WebhookHandler
→ Risk: MEDIUM
impact — 変更されたシンボルごとの影響範囲:
impact({target: "validatePayment", direction: "upstream"})
→ d=1 (WILL BREAK):
- processCheckout (src/checkout.ts:42) [CALLS, 100%]
- webhookHandler (src/webhooks.ts:15) [CALLS, 100%]
→ d=2 (LIKELY AFFECTED):
- checkoutRouter (src/routes/checkout.ts:22) [CALLS, 95%]
テスト付きの impact — テストカバレッジを確認します:
impact({target: "validatePayment", direction: "upstream", includeTests: true})
→ Tests that cover this symbol:
- validatePayment.test.ts [direct]
- checkout.integration.test.ts [via processCheckout]
context — 変更されたシンボルの役割を理解します:
context({name: "validatePayment"})
→ Incoming calls: processCheckout, webhookHandler
→ Outgoing calls: verifyCard, fetchRates
→ Processes: CheckoutFlow (step 3/7), RefundFlow (step 1/5)
例: 「PR #42 をレビューする」
1. gh pr diff 42 > /tmp/pr42.diff
→ 4 files changed: payments.ts, checkout.ts, types.ts, utils.ts
2. detect_changes({scope: "compare", base_ref: "main"})
→ Changed symbols: validatePayment, PaymentInput, formatAmount
→ Affected processes: CheckoutFlow, RefundFlow
→ Risk: MEDIUM
3. impact({target: "validatePayment", direction: "upstream"})
→ d=1: processCheckout, webhookHandler (WILL BREAK)
→ webhookHandler is NOT in the PR diff — potential breakage!
4. impact({target: "PaymentInput", direction: "upstream"})
→ d=1: validatePayment (in PR), createPayment (NOT in PR)
→ createPayment uses the old PaymentInput shape — breaking change!
5. context({name: "formatAmount"})
→ Called by 12 functions — but change is backwards-compatible (added optional param)
6. Review summary:
- MEDIUM risk — 3 changed symbols affect 2 execution flows
- BUG: webhookHandler calls validatePayment but isn't updated for new signature
- BUG: createPayment depends on PaymentInput type which changed
- OK: formatAmount change is backwards-compatible
- Tests: checkout.test.ts covers processCheckout path, but no webhook test
レビュー出力の形式
レビューは次のように構成してください:
## PR Review: <title>
**Risk: LOW / MEDIUM / HIGH / CRITICAL**
### Changes Summary
- <N> symbols changed across <M> files
- <P> execution flows affected
### Findings
1. **[severity]** Description of finding
- Evidence from GitNexus tools
- Affected callers/flows
### Missing Coverage
- Callers not updated in PR: ...
- Untested flows: ...
### Recommendation
APPROVE / REQUEST CHANGES / NEEDS DISCUSSION
コメント
Markdown 対応