From 28e1763b2dc16126383766da858e88dd8bec80d6 Mon Sep 17 00:00:00 2001 From: "takemi.ohama" Date: Sat, 8 Aug 2026 02:52:42 +0000 Subject: [PATCH 1/8] =?UTF-8?q?chore:=20feature/inventory-merge-git=20?= =?UTF-8?q?=E3=81=AE=20Draft=20PR=20=E4=BD=9C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From 9344e1b1129eabd3983844d77744a18d46a1038b Mon Sep 17 00:00:00 2001 From: "takemi.ohama" Date: Sat, 8 Aug 2026 03:04:55 +0000 Subject: [PATCH 2/8] =?UTF-8?q?Refactor:=20=E3=83=9E=E3=83=BC=E3=82=B8?= =?UTF-8?q?=E5=BE=8C=E5=87=A6=E7=90=86=E3=81=A8=20cherry-pick=20=E3=81=AE?= =?UTF-8?q?=20Skill=20=E3=82=92=E7=B5=B1=E5=90=88=20(0-4)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - `merged` へ `clean` / `sync-main` を吸収(97 行 → 58 行)。改名しない - `cherry-pick-pr` へ `branch-fix-strategy` を吸収(207 行 → 130 行) - manifest 3 種と `plugins/ndf-claude/.claude-plugin/plugin.json` から統合元を削除 - `pr` / `issue-plan-strategy` / `deploy` / `problem-solving` / `docs` / `README.md` の参照を更新 - `build-runtime-plugins.sh` で 3 ランタイムの生成物を同期 Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_01AGejnYyYFuSkQjBhW2KQNy --- README.md | 8 +- docs/ndf-plugin-reference.md | 2 +- plugins/ndf-claude/.claude-plugin/plugin.json | 3 - .../skills/branch-fix-strategy/SKILL.md | 87 ------------------- .../ndf-claude/skills/cherry-pick-pr/SKILL.md | 24 +++-- plugins/ndf-claude/skills/clean/SKILL.md | 20 ----- plugins/ndf-claude/skills/deploy/SKILL.md | 5 +- .../skills/issue-plan-strategy/SKILL.md | 7 +- plugins/ndf-claude/skills/merged/SKILL.md | 47 ++++++++-- plugins/ndf-claude/skills/pr/SKILL.md | 9 +- .../skills/problem-solving/SKILL.md | 4 +- plugins/ndf-claude/skills/sync-main/SKILL.md | 48 ---------- .../skills/branch-fix-strategy/SKILL.md | 87 ------------------- .../ndf-codex/skills/cherry-pick-pr/SKILL.md | 24 +++-- plugins/ndf-codex/skills/clean/SKILL.md | 20 ----- plugins/ndf-codex/skills/deploy/SKILL.md | 5 +- .../skills/issue-plan-strategy/SKILL.md | 7 +- plugins/ndf-codex/skills/merged/SKILL.md | 47 ++++++++-- plugins/ndf-codex/skills/pr/SKILL.md | 9 +- .../ndf-codex/skills/problem-solving/SKILL.md | 4 +- plugins/ndf-codex/skills/sync-main/SKILL.md | 48 ---------- .../skills/branch-fix-strategy/SKILL.md | 87 ------------------- .../ndf-kiro/skills/cherry-pick-pr/SKILL.md | 24 +++-- plugins/ndf-kiro/skills/clean/SKILL.md | 20 ----- plugins/ndf-kiro/skills/deploy/SKILL.md | 5 +- .../skills/issue-plan-strategy/SKILL.md | 7 +- plugins/ndf-kiro/skills/merged/SKILL.md | 47 ++++++++-- plugins/ndf-kiro/skills/pr/SKILL.md | 9 +- .../ndf-kiro/skills/problem-solving/SKILL.md | 4 +- plugins/ndf-kiro/skills/sync-main/SKILL.md | 48 ---------- .../ndf-shared/manifests/claude-skills.txt | 3 - plugins/ndf-shared/manifests/codex-skills.txt | 3 - plugins/ndf-shared/manifests/kiro-skills.txt | 3 - .../skills/branch-fix-strategy/SKILL.md | 87 ------------------- .../ndf-shared/skills/cherry-pick-pr/SKILL.md | 24 +++-- plugins/ndf-shared/skills/clean/SKILL.md | 20 ----- plugins/ndf-shared/skills/deploy/SKILL.md | 5 +- .../skills/issue-plan-strategy/SKILL.md | 7 +- plugins/ndf-shared/skills/merged/SKILL.md | 47 ++++++++-- plugins/ndf-shared/skills/pr/SKILL.md | 9 +- .../skills/problem-solving/SKILL.md | 4 +- plugins/ndf-shared/skills/sync-main/SKILL.md | 48 ---------- 42 files changed, 265 insertions(+), 761 deletions(-) delete mode 100644 plugins/ndf-claude/skills/branch-fix-strategy/SKILL.md delete mode 100644 plugins/ndf-claude/skills/clean/SKILL.md delete mode 100644 plugins/ndf-claude/skills/sync-main/SKILL.md delete mode 100644 plugins/ndf-codex/skills/branch-fix-strategy/SKILL.md delete mode 100644 plugins/ndf-codex/skills/clean/SKILL.md delete mode 100644 plugins/ndf-codex/skills/sync-main/SKILL.md delete mode 100644 plugins/ndf-kiro/skills/branch-fix-strategy/SKILL.md delete mode 100644 plugins/ndf-kiro/skills/clean/SKILL.md delete mode 100644 plugins/ndf-kiro/skills/sync-main/SKILL.md delete mode 100644 plugins/ndf-shared/skills/branch-fix-strategy/SKILL.md delete mode 100644 plugins/ndf-shared/skills/clean/SKILL.md delete mode 100644 plugins/ndf-shared/skills/sync-main/SKILL.md diff --git a/README.md b/README.md index 97a6176d..95981ebd 100644 --- a/README.md +++ b/README.md @@ -8,10 +8,10 @@ Claude Code / Codex / Kiro CLI向けのスキル・MCP設定を共有するた **NDFプラグイン v4.20.1** は、同じ `ndf@ai-plugins` という名前で Claude Code / Codex / Kiro CLI へ配布されるランタイム別プラグインです。共通ソースは `plugins/ndf-shared/` に集約し、利用者が install する配布物は `plugins/ndf-claude/` / `plugins/ndf-codex/` / `plugins/ndf-kiro/` に分かれています。 -- **公開Skills**: Claude Code向け core 29個、Kiro向け core 28個、Codex向け core 30個に分離。 -- **元Skills(49個)**: - - PR/レビューワークフロー (13): pr, pr-tests, fix, review, review-branch, review-pr-comments, resolve-pr-comments, cherry-pick-pr, deploy, sync-main, merged, clean, browser-test - - 原則・ガイドライン (10): ndf-policies, branch-fix-strategy, implementation-plan, plan-to-spec, investigation-rules, problem-solving, logging-guidelines, markdown-writing, issue-plan-strategy, ml-model-structure +- **公開Skills**: Claude Code向け core 26個、Kiro向け core 25個、Codex向け core 27個に分離。 +- **元Skills(46個)**: + - PR/レビューワークフロー (11): pr, pr-tests, fix, review, review-branch, review-pr-comments, resolve-pr-comments, cherry-pick-pr, deploy, merged, browser-test + - 原則・ガイドライン (9): ndf-policies, implementation-plan, plan-to-spec, investigation-rules, problem-solving, logging-guidelines, markdown-writing, issue-plan-strategy, ml-model-structure - データ分析・品質・環境 (12): data-analyst-sql-optimization, data-analyst-export, qa-security-scan, python-execution, docker-container-access, git-gh-operations, google-auth, codex, deepwiki-transfer, knowledge-reorg, mcp-builder, official-skills-autoloader - E2Eテスト/Playwright (6): playwright-test-planning, playwright-script-creation, playwright-execution, playwright-report, playwright-kit-ops, playwright-scenario-test - 外部サービス連携 (2): google-drive, google-chat diff --git a/docs/ndf-plugin-reference.md b/docs/ndf-plugin-reference.md index 34773d4f..eb046e3d 100644 --- a/docs/ndf-plugin-reference.md +++ b/docs/ndf-plugin-reference.md @@ -65,7 +65,7 @@ NDF の Skill 実装は `plugins/ndf-shared/skills/` が編集元です。公開 主な Skill 領域: - PR / review workflow: `pr`, `pr-tests`, `fix`, `review`, `cross-review`, `resolve-pr-comments` -- branch / release workflow: `deploy`, `cherry-pick-pr`, `sync-main`, `merged`, `clean` +- branch / release workflow: `deploy`, `cherry-pick-pr`, `merged` - planning / documentation: `implementation-plan`, `issue-plan-strategy`, `plan-to-spec`, `markdown-writing` - quality / execution: `playwright-*`, `python-execution`, `docker-container-access`, `git-gh-operations` - external services: `google-drive`, `google-chat`, `data-analyst-*` diff --git a/plugins/ndf-claude/.claude-plugin/plugin.json b/plugins/ndf-claude/.claude-plugin/plugin.json index 1dfb737a..ef688680 100644 --- a/plugins/ndf-claude/.claude-plugin/plugin.json +++ b/plugins/ndf-claude/.claude-plugin/plugin.json @@ -34,18 +34,15 @@ "./skills/review", "./skills/cross-review", "./skills/merged", - "./skills/clean", "./skills/ndf-policies", "./skills/markdown-writing", "./skills/python-execution", "./skills/docker-container-access", "./skills/git-gh-operations", - "./skills/branch-fix-strategy", "./skills/implementation-plan", "./skills/investigation-rules", "./skills/problem-solving", "./skills/logging-guidelines", - "./skills/sync-main", "./skills/cherry-pick-pr", "./skills/deploy", "./skills/review-branch", diff --git a/plugins/ndf-claude/skills/branch-fix-strategy/SKILL.md b/plugins/ndf-claude/skills/branch-fix-strategy/SKILL.md deleted file mode 100644 index a4714a34..00000000 --- a/plugins/ndf-claude/skills/branch-fix-strategy/SKILL.md +++ /dev/null @@ -1,87 +0,0 @@ ---- -name: branch-fix-strategy -description: "Plan multi-branch fixes and cherry-picks." -when_to_use: "同じ修正を複数ブランチ (qa/staging/release等) に適用する必要があるとき。Triggers: 'cherry-pick', '環境ブランチに修正適用', 'qaに反映', 'stagingに反映', 'release branchへ', 'multi-branch fix', 'apply to qa/staging'" ---- - -# ブランチ修正適用戦略 - -## 適用タイミング - -- featureブランチの修正を `qa/*`, `staging/*`, `release/*` 等の環境ブランチにも適用する必要がある場合 -- 同じ修正を複数ブランチに並行適用する場面全般 - -## 核心ルール - -### 1. 修正は feature ブランチに先に commit → cherry-pick で環境ブランチへ - -``` -✅ feature に commit → cherry-pick して短命ブランチ → 環境ブランチへ PR -❌ 短命ブランチに先に commit → feature に手作業で再実装(二重作業・不整合リスク) -``` - -### 2. 環境ブランチを feature ブランチに merge しない(main 汚染禁止) - -``` -❌ feature/xxx ← merge qa/staging(conflict 解消目的でも禁止) -``` - -環境ブランチを featureブランチにmergeすると、後で `feature → main` のPRに環境固有コードが混入する。 - -### 3. origin/main を必ず取り込む - -短命ブランチを push する前に必ず `git merge origin/main` する。CI で最新 main 必須の Workflow があるため。 - -### 4. マージ済みブランチに push しない - -環境ブランチ向けの短命ブランチに push する前に `gh pr list --head ` で PR 状態を確認する。マージ済みなら新ブランチ + 新 PR を作成する(サフィックス `-v2`, `-v3` を付ける)。 - -## 実行手順 - -`/ndf:cherry-pick-pr ` で自動化されている。手動で行う場合のみ以下を参照。 - -```bash -# 1. feature ブランチで修正を commit -git checkout feature/xxx -git add && git commit -m "fix: 修正内容" -git log --oneline -1 # commit hash を記録 - -# 2. 短命ブランチを作成 -git fetch origin qa/staging -git checkout -b feature/xxx-for-staging origin/qa/staging - -# 3. origin/main を取り込む(必須) -git fetch origin main -git merge origin/main --no-edit - -# 4. cherry-pick(-x で元 commit hash を参照に残す) -git cherry-pick -x - -# 5. push して PR 作成 -git push -u origin feature/xxx-for-staging -gh pr create --base qa/staging --title "fix: 修正内容(staging検証用)" - -# 6. 元のブランチに戻る -git checkout feature/xxx -``` - -## なぜこの順序が重要か - -| 観点 | 正しい順序 | 誤った順序 | -|------|-----------|-----------| -| 単一ソース | feature ブランチが唯一の正 | 二箇所で実装 | -| 一貫性 | cherry-pick で完全一致 | 手書き差分でズレる | -| 追跡性 | `-x` で元 commit が明記 | 関連 commit 不明確 | - -## revert 操作の注意 - -revertの連鎖(revert → reapply → revert...)ではなく、**最終的なあるべき状態を直接コミット**するのが望ましい。履歴上の意図が明確になり、後の cherry-pick も簡単になる。 - -## 関連コマンド・スキル - -| リソース | 用途 | -|---------|------| -| `/ndf:cherry-pick-pr` | cherry-pick + 短命ブランチ + origin/main 取り込み + PR 作成を自動化 | -| `/ndf:pr` | 通常のPR作成。非 main ベースは `cherry-pick-pr` に誘導される | -| `/ndf:sync-main` | 現在のブランチに最新 main を取り込む | -| `/ndf:deploy` | 環境ブランチへのデプロイPR作成(ブランチ全体をmerge main経由で適用) | diff --git a/plugins/ndf-claude/skills/cherry-pick-pr/SKILL.md b/plugins/ndf-claude/skills/cherry-pick-pr/SKILL.md index b5dc1341..b44ff420 100644 --- a/plugins/ndf-claude/skills/cherry-pick-pr/SKILL.md +++ b/plugins/ndf-claude/skills/cherry-pick-pr/SKILL.md @@ -1,6 +1,6 @@ --- name: cherry-pick-pr -description: "Create cherry-pick PRs for environment branches." +description: "Create cherry-pick PRs for environment branches and apply the same fix across multiple branches." argument-hint: " (例: qa/staging, release/v2)" disable-model-invocation: true allowed-tools: @@ -11,7 +11,7 @@ allowed-tools: # cherry-pick PR 作成コマンド -featureブランチから指定ベースブランチへ、短命ブランチ経由で cherry-pick PR を作成する。`feature → main` の PR にベースブランチ固有コードが混入するのを防ぐ。 +featureブランチから指定ベースブランチ(`qa/*`, `staging/*`, `release/*` 等の環境ブランチ)へ、短命ブランチ経由で cherry-pick PR を作成する。同じ修正を複数ブランチへ並行適用する場面全般で、この原則と手順に従う。 ## 使用方法 @@ -24,7 +24,18 @@ featureブランチから指定ベースブランチへ、短命ブランチ経 featureブランチに環境ブランチ(`qa/staging`等)を merge して conflict を解消すると、`feature → main` の PR に環境ブランチ固有のコードが混入する(main汚染)。短命ブランチ + cherry-pick で、必要なコミットだけを対象ブランチに届ける。 -詳細な原則は `/ndf:branch-fix-strategy` スキル参照。 +| 観点 | 正しい順序 | 誤った順序 | +|------|-----------|-----------| +| 単一ソース | feature ブランチが唯一の正 | 二箇所で実装 | +| 一貫性 | cherry-pick で完全一致 | 手書き差分でズレる | +| 追跡性 | `-x` で元 commit が明記 | 関連 commit 不明確 | + +## 核心ルール + +1. **修正は feature ブランチに先に commit し、cherry-pick で環境ブランチへ届ける。** 短命ブランチに先に commit して feature へ手作業で再実装すると、二重作業と不整合の原因になる +2. **環境ブランチを feature ブランチに merge しない。** conflict 解消目的でも禁止(main汚染の原因) +3. **短命ブランチを push する前に `origin/main` を必ず取り込む。** CI で最新 main 必須の Workflow があるため(処理フロー 5) +4. **マージ済みブランチには push しない。** 同名の短命ブランチに既存 PR がないか先に確認する(処理フロー 2) ## 処理フロー @@ -110,11 +121,10 @@ git checkout - 短命ブランチは PR マージ後に削除してよい - `feature → main` の PR には影響しない -- ベースブランチを feature ブランチに merge するのは **禁止**(main汚染の原因) -- `-x` オプションで元commit参照を残す(追跡性) +- revert の連鎖(revert → reapply → revert...)ではなく、**最終的なあるべき状態を直接コミット**する。履歴上の意図が明確になり、後の cherry-pick も簡単になる ## 関連 -- `/ndf:branch-fix-strategy` — なぜこの手順が必要かの原則 -- `/ndf:pr` — 通常のPR作成(base=main) +- `/ndf:pr` — 通常のPR作成(base=main)。非 main ベースは本 Skill に誘導される +- `/ndf:merged` — マージ後のブランチ整理と、現ブランチへの main 取り込み - `/ndf:deploy` — ブランチ全体を環境へデプロイ(cherry-pickとは別用途) diff --git a/plugins/ndf-claude/skills/clean/SKILL.md b/plugins/ndf-claude/skills/clean/SKILL.md deleted file mode 100644 index 2f75e54e..00000000 --- a/plugins/ndf-claude/skills/clean/SKILL.md +++ /dev/null @@ -1,20 +0,0 @@ ---- -name: clean -description: "Delete local and remote merged branches." -disable-model-invocation: true -allowed-tools: - - Bash ---- - -# ブランチクリーンアップコマンド - -mainマージ済みブランチをローカル/リモート削除。 - -## 手順 - -1. `git branch --merged main`確認 -2. main・現在ブランチ除外 -3. `git branch -d ` -4. `git push origin --delete ` - -**注意**: 削除前確認・main除外・現在ブランチ除外 diff --git a/plugins/ndf-claude/skills/deploy/SKILL.md b/plugins/ndf-claude/skills/deploy/SKILL.md index 769919d7..f5bffa04 100644 --- a/plugins/ndf-claude/skills/deploy/SKILL.md +++ b/plugins/ndf-claude/skills/deploy/SKILL.md @@ -109,6 +109,5 @@ git checkout "$FEATURE_BRANCH" ## 関連 -- `/ndf:cherry-pick-pr` — 一部コミットだけを環境に届ける場合 -- `/ndf:branch-fix-strategy` — ブランチ運用戦略の原則 -- `/ndf:sync-main` — featureブランチに main を取り込む +- `/ndf:cherry-pick-pr` — 一部コミットだけを環境に届ける場合とブランチ運用戦略の原則 +- `/ndf:merged` — featureブランチに main を取り込む / マージ後のブランチ整理 diff --git a/plugins/ndf-claude/skills/issue-plan-strategy/SKILL.md b/plugins/ndf-claude/skills/issue-plan-strategy/SKILL.md index fdae1ecb..96d19d11 100644 --- a/plugins/ndf-claude/skills/issue-plan-strategy/SKILL.md +++ b/plugins/ndf-claude/skills/issue-plan-strategy/SKILL.md @@ -332,7 +332,7 @@ git checkout release/ /ndf:cherry-pick-pr qa/staging ``` -詳細は `/ndf:cherry-pick-pr` と `/ndf:branch-fix-strategy` を参照。`feature → main` 系 PR を汚染しないため、検証ブランチ向けは必ず短命ブランチ経由で扱う。 +詳細は `/ndf:cherry-pick-pr` を参照。`feature → main` 系 PR を汚染しないため、検証ブランチ向けは必ず短命ブランチ経由で扱う。 ## アンチパターン @@ -345,14 +345,13 @@ git checkout release/ | release PR で個別 PR 範囲の指摘を解決しようとする | 該当 PR が既に閉じている場合、コミット意図がずれる | | release PR の body を個別 PR リンクの列挙だけにする | レビュアーは release PR 単体で変更を把握できず、個別 PR や plan を辿ることになる。body は self-contained 必須 (Step 3 / Step 8) | | body 最終化せずに Ready for review にする | Draft 作成時の plan ベースの暫定 body のままだと実装の最終形と乖離する | -| 検証ブランチを feature/release に merge する | `feature → main` PR への汚染 (詳細: `/ndf:branch-fix-strategy`) | +| 検証ブランチを feature/release に merge する | `feature → main` PR への汚染 (詳細: `/ndf:cherry-pick-pr`) | ## 関連 skill - `/ndf:implementation-plan` — plan ファイルのフォーマット (本 skill が依存) -- `/ndf:branch-fix-strategy` — ブランチ汚染を避ける原則 - `/ndf:pr` — 通常の PR 作成 / 更新 -- `/ndf:cherry-pick-pr` — 検証ブランチへの cherry-pick PR +- `/ndf:cherry-pick-pr` — 検証ブランチへの cherry-pick PR とブランチ汚染を避ける原則 - `/ndf:review` / `/ndf:review-branch` / `/ndf:cross-review` — レビュー - `/ndf:fix` / `/ndf:resolve-pr-comments` — コメント対応 - `/ndf:playwright-scenario-test` — release ブランチでの E2E 結合テスト diff --git a/plugins/ndf-claude/skills/merged/SKILL.md b/plugins/ndf-claude/skills/merged/SKILL.md index 06af6f2a..17568379 100644 --- a/plugins/ndf-claude/skills/merged/SKILL.md +++ b/plugins/ndf-claude/skills/merged/SKILL.md @@ -1,6 +1,6 @@ --- name: merged -description: "Clean up after a PR is merged." +description: "Clean up after a PR is merged: update main, remove the worktree, and delete merged branches." argument-hint: "[PR番号]" disable-model-invocation: true allowed-tools: @@ -10,20 +10,49 @@ allowed-tools: # マージ後クリーンアップコマンド -PRマージ後のクリーンアップを実行。 +PR マージ後の後始末をまとめて実行する。対象 PR のブランチ削除に加えて、残っているマージ済みブランチの整理と main の取り込みもこの Skill で扱う。 ## 手順 -0. **事前確認**: github mcpで引数の(引数が無ければ自身が作成した最新の)PRがmainにmergeされていることを確認。mergeされていなければ終了 -1. **事前確認**: `git status`→変更あればstash -2. **main更新**: `git checkout main`→`git pull` -3. **worktreeクリーンアップ**: `git worktree list` で当該PR番号に対応する worktree (`pr`) を探し、あれば `git worktree remove ` で削除(worktree 内の `.cross_review/` も一緒に消える) -4. **ブランチ削除**: `git branch -d ` → stash復元 +1. **マージ確認**: 引数の(引数がなければ自身が作成した最新の)PR が main に merge されていることを github mcp で確認。merge されていなければ終了 +2. **作業ツリー退避**: `git status` を確認し、変更があれば `git stash` +3. **main 更新**: `git checkout main` → `git pull` +4. **worktree クリーンアップ**: `git worktree list` で当該 PR 番号に対応する worktree (`pr`) を探し、あれば `git worktree remove ` で削除(worktree 内の `.cross_review/` も一緒に消える) +5. **ブランチ削除**: `git branch -d ` +6. **マージ済みブランチの整理**: 下記の手順で残存ブランチをまとめて削除 +7. **復元**: 手順 2 で stash していれば `git stash pop` **注意**: 冪等性保証・エラー時中断・削除済み無視 +## マージ済みブランチの整理 + +```bash +git branch --merged main # 1. マージ済みブランチを列挙 +git branch -d # 2. ローカル削除 +git push origin --delete # 3. リモートにも残っていれば削除 +``` + +- main と現在のブランチは必ず除外する +- 削除対象を提示し、確認を取ってから削除する +- リモート削除は共有ブランチに影響するため、対象を明示してから実行する + +## main の取り込み + +作業中のブランチへ最新のデフォルトブランチ (main/master) を取り込む場合はこちらを使う。 + +1. **ブランチ確認**: `git branch --show-current`。デフォルトブランチ自身なら `git pull` のみ実行して終了 +2. **作業ツリー確認**: 未コミット変更があれば `git stash` で退避 +3. **最新取得**: `git fetch origin ` +4. **マージ実行**: `git merge origin/ --no-edit` + - コンフリクト時は `git diff --name-only --diff-filter=U` で一覧を表示し、**自動解決はしない**。ユーザーに報告し、確認後に作業継続 +5. **後処理**: stash していれば `git stash pop`。コンフリクトがなければ `git push` で反映し、マージ済みコミット数と変更ファイル数を報告 + ## 作業完了報告(必須) -- 実行サマリー(PRタイトル、マージコミット、削除したブランチ、現在のブランチ) -- mainブランチの状態 +- 実行サマリー(PR タイトル、マージコミット、削除したブランチ、現在のブランチ) +- main ブランチの状態 - PR URL + +## 関連 + +- `/ndf:cherry-pick-pr` — 環境ブランチへの cherry-pick PR 作成と、複数ブランチへ同じ修正を適用する原則 diff --git a/plugins/ndf-claude/skills/pr/SKILL.md b/plugins/ndf-claude/skills/pr/SKILL.md index 22000e4c..3bfe6b16 100644 --- a/plugins/ndf-claude/skills/pr/SKILL.md +++ b/plugins/ndf-claude/skills/pr/SKILL.md @@ -54,7 +54,7 @@ allowed-tools: - 引数の末尾が `main`/`master` 以外のベースブランチ名(`qa/staging`, `release/v2` 等)の場合: - **警告を出して `/ndf:cherry-pick-pr ` に誘導する** - - 理由: base非mainのPRに直接pushすると `feature → main` のPRに環境固有コードが混入する(詳細は `/ndf:branch-fix-strategy`) + - 理由: base非mainのPRに直接pushすると `feature → main` のPRに環境固有コードが混入する(詳細は `/ndf:cherry-pick-pr`) - ユーザーが明示的に継続を指示した場合のみ進める ### 3. 変更コミット @@ -137,9 +137,7 @@ feature/xxx ──PR──→ qa/staging ← ❌ qa/staging をmergeするとm ### 正しい手順 -`/ndf:cherry-pick-pr ` を使う(自動化済み)。詳細な理由と手順は: -- `/ndf:cherry-pick-pr` — 自動化コマンド -- `/ndf:branch-fix-strategy` — 原則と手順 +`/ndf:cherry-pick-pr ` を使う(自動化済み)。原則と手順は `/ndf:cherry-pick-pr` に記載のとおり。 ## 作業完了報告(必須) @@ -157,5 +155,4 @@ PR作成/更新完了後、以下を報告: - `/ndf:deploy` — 環境ブランチへのデプロイPR(ブランチ全体) - `/ndf:pr-tests` — Test Plan 自動実行 - `/ndf:review` — PR単位レビュー -- `/ndf:sync-main` — 現ブランチに main を取り込み -- `/ndf:branch-fix-strategy` — ブランチ戦略の原則 +- `/ndf:merged` — マージ後のブランチ整理 / 現ブランチに main を取り込み diff --git a/plugins/ndf-claude/skills/problem-solving/SKILL.md b/plugins/ndf-claude/skills/problem-solving/SKILL.md index 1b3c1108..94133205 100644 --- a/plugins/ndf-claude/skills/problem-solving/SKILL.md +++ b/plugins/ndf-claude/skills/problem-solving/SKILL.md @@ -131,7 +131,7 @@ Layer 4: 出力時検証(結果の妥当性チェック) - 根本原因の修正とデータ修復は**別コミット**にする(Revertしやすい) - 重複コードは発見次第リファクタリングする -- 検証環境向けPRは `cherry-pick-pr` 方式で作成し、mainブランチを汚染しない(詳細は `branch-fix-strategy` スキル参照) +- 検証環境向けPRは `cherry-pick-pr` 方式で作成し、mainブランチを汚染しない(詳細は `cherry-pick-pr` スキル参照) ## 6. 調査レポートの書き方 @@ -158,5 +158,5 @@ SQLクエリ結果をそのまま貼り、「コードを読んだ推測」と ## 関連スキル - `/ndf:investigation-rules` — 調査レポート作成時のエビデンス主義 -- `/ndf:branch-fix-strategy` — 複数ブランチへの修正適用戦略 +- `/ndf:cherry-pick-pr` — 複数ブランチへの修正適用戦略 - `/ndf:logging-guidelines` — ログ設計(原因特定を容易にする) diff --git a/plugins/ndf-claude/skills/sync-main/SKILL.md b/plugins/ndf-claude/skills/sync-main/SKILL.md deleted file mode 100644 index 87aa2230..00000000 --- a/plugins/ndf-claude/skills/sync-main/SKILL.md +++ /dev/null @@ -1,48 +0,0 @@ ---- -name: sync-main -description: "Sync the current branch with main or master." -disable-model-invocation: true -allowed-tools: - - Bash - - Read ---- - -# main取り込みコマンド - -最新のデフォルトブランチ(main/master)を現在のブランチにマージする。 - -## 処理フロー - -1. **ブランチ確認** - - `git branch --show-current` で現在ブランチ確認 - - デフォルトブランチ(main/master)自身の場合は `git pull` のみ実行して終了 - -2. **作業ツリー確認** - - `git status` で未コミット変更を確認 - - 未コミット変更があれば `git stash` で退避 - -3. **最新取得** - - `git fetch origin ` でリモート最新を取得 - -4. **マージ実行** - - `git merge origin/ --no-edit` でマージ - - コンフリクト発生時: - - `git diff --name-only --diff-filter=U` でコンフリクトファイル一覧を表示 - - ユーザーに報告し、**自動解決はしない** - - ユーザー確認後に作業継続 - -5. **後処理** - - stash退避していた場合は `git stash pop` で復元 - - コンフリクトがなければ `git push` でリモートに反映 - - 完了報告(マージ済みコミット数、変更ファイル数) - -## 制約 - -- デフォルトブランチ自身での実行は `git pull` に自動フォールバック -- コンフリクトは自動解決しない(ユーザーが解決) -- 作業ツリーが汚れている場合は必ず stash で退避してから実行 - -## 関連 - -- `/ndf:branch-fix-strategy` — 複数ブランチへの修正適用戦略 -- `/ndf:cherry-pick-pr` — 環境ブランチへのcherry-pick PR作成 diff --git a/plugins/ndf-codex/skills/branch-fix-strategy/SKILL.md b/plugins/ndf-codex/skills/branch-fix-strategy/SKILL.md deleted file mode 100644 index a4714a34..00000000 --- a/plugins/ndf-codex/skills/branch-fix-strategy/SKILL.md +++ /dev/null @@ -1,87 +0,0 @@ ---- -name: branch-fix-strategy -description: "Plan multi-branch fixes and cherry-picks." -when_to_use: "同じ修正を複数ブランチ (qa/staging/release等) に適用する必要があるとき。Triggers: 'cherry-pick', '環境ブランチに修正適用', 'qaに反映', 'stagingに反映', 'release branchへ', 'multi-branch fix', 'apply to qa/staging'" ---- - -# ブランチ修正適用戦略 - -## 適用タイミング - -- featureブランチの修正を `qa/*`, `staging/*`, `release/*` 等の環境ブランチにも適用する必要がある場合 -- 同じ修正を複数ブランチに並行適用する場面全般 - -## 核心ルール - -### 1. 修正は feature ブランチに先に commit → cherry-pick で環境ブランチへ - -``` -✅ feature に commit → cherry-pick して短命ブランチ → 環境ブランチへ PR -❌ 短命ブランチに先に commit → feature に手作業で再実装(二重作業・不整合リスク) -``` - -### 2. 環境ブランチを feature ブランチに merge しない(main 汚染禁止) - -``` -❌ feature/xxx ← merge qa/staging(conflict 解消目的でも禁止) -``` - -環境ブランチを featureブランチにmergeすると、後で `feature → main` のPRに環境固有コードが混入する。 - -### 3. origin/main を必ず取り込む - -短命ブランチを push する前に必ず `git merge origin/main` する。CI で最新 main 必須の Workflow があるため。 - -### 4. マージ済みブランチに push しない - -環境ブランチ向けの短命ブランチに push する前に `gh pr list --head ` で PR 状態を確認する。マージ済みなら新ブランチ + 新 PR を作成する(サフィックス `-v2`, `-v3` を付ける)。 - -## 実行手順 - -`/ndf:cherry-pick-pr ` で自動化されている。手動で行う場合のみ以下を参照。 - -```bash -# 1. feature ブランチで修正を commit -git checkout feature/xxx -git add && git commit -m "fix: 修正内容" -git log --oneline -1 # commit hash を記録 - -# 2. 短命ブランチを作成 -git fetch origin qa/staging -git checkout -b feature/xxx-for-staging origin/qa/staging - -# 3. origin/main を取り込む(必須) -git fetch origin main -git merge origin/main --no-edit - -# 4. cherry-pick(-x で元 commit hash を参照に残す) -git cherry-pick -x - -# 5. push して PR 作成 -git push -u origin feature/xxx-for-staging -gh pr create --base qa/staging --title "fix: 修正内容(staging検証用)" - -# 6. 元のブランチに戻る -git checkout feature/xxx -``` - -## なぜこの順序が重要か - -| 観点 | 正しい順序 | 誤った順序 | -|------|-----------|-----------| -| 単一ソース | feature ブランチが唯一の正 | 二箇所で実装 | -| 一貫性 | cherry-pick で完全一致 | 手書き差分でズレる | -| 追跡性 | `-x` で元 commit が明記 | 関連 commit 不明確 | - -## revert 操作の注意 - -revertの連鎖(revert → reapply → revert...)ではなく、**最終的なあるべき状態を直接コミット**するのが望ましい。履歴上の意図が明確になり、後の cherry-pick も簡単になる。 - -## 関連コマンド・スキル - -| リソース | 用途 | -|---------|------| -| `/ndf:cherry-pick-pr` | cherry-pick + 短命ブランチ + origin/main 取り込み + PR 作成を自動化 | -| `/ndf:pr` | 通常のPR作成。非 main ベースは `cherry-pick-pr` に誘導される | -| `/ndf:sync-main` | 現在のブランチに最新 main を取り込む | -| `/ndf:deploy` | 環境ブランチへのデプロイPR作成(ブランチ全体をmerge main経由で適用) | diff --git a/plugins/ndf-codex/skills/cherry-pick-pr/SKILL.md b/plugins/ndf-codex/skills/cherry-pick-pr/SKILL.md index b5dc1341..b44ff420 100644 --- a/plugins/ndf-codex/skills/cherry-pick-pr/SKILL.md +++ b/plugins/ndf-codex/skills/cherry-pick-pr/SKILL.md @@ -1,6 +1,6 @@ --- name: cherry-pick-pr -description: "Create cherry-pick PRs for environment branches." +description: "Create cherry-pick PRs for environment branches and apply the same fix across multiple branches." argument-hint: " (例: qa/staging, release/v2)" disable-model-invocation: true allowed-tools: @@ -11,7 +11,7 @@ allowed-tools: # cherry-pick PR 作成コマンド -featureブランチから指定ベースブランチへ、短命ブランチ経由で cherry-pick PR を作成する。`feature → main` の PR にベースブランチ固有コードが混入するのを防ぐ。 +featureブランチから指定ベースブランチ(`qa/*`, `staging/*`, `release/*` 等の環境ブランチ)へ、短命ブランチ経由で cherry-pick PR を作成する。同じ修正を複数ブランチへ並行適用する場面全般で、この原則と手順に従う。 ## 使用方法 @@ -24,7 +24,18 @@ featureブランチから指定ベースブランチへ、短命ブランチ経 featureブランチに環境ブランチ(`qa/staging`等)を merge して conflict を解消すると、`feature → main` の PR に環境ブランチ固有のコードが混入する(main汚染)。短命ブランチ + cherry-pick で、必要なコミットだけを対象ブランチに届ける。 -詳細な原則は `/ndf:branch-fix-strategy` スキル参照。 +| 観点 | 正しい順序 | 誤った順序 | +|------|-----------|-----------| +| 単一ソース | feature ブランチが唯一の正 | 二箇所で実装 | +| 一貫性 | cherry-pick で完全一致 | 手書き差分でズレる | +| 追跡性 | `-x` で元 commit が明記 | 関連 commit 不明確 | + +## 核心ルール + +1. **修正は feature ブランチに先に commit し、cherry-pick で環境ブランチへ届ける。** 短命ブランチに先に commit して feature へ手作業で再実装すると、二重作業と不整合の原因になる +2. **環境ブランチを feature ブランチに merge しない。** conflict 解消目的でも禁止(main汚染の原因) +3. **短命ブランチを push する前に `origin/main` を必ず取り込む。** CI で最新 main 必須の Workflow があるため(処理フロー 5) +4. **マージ済みブランチには push しない。** 同名の短命ブランチに既存 PR がないか先に確認する(処理フロー 2) ## 処理フロー @@ -110,11 +121,10 @@ git checkout - 短命ブランチは PR マージ後に削除してよい - `feature → main` の PR には影響しない -- ベースブランチを feature ブランチに merge するのは **禁止**(main汚染の原因) -- `-x` オプションで元commit参照を残す(追跡性) +- revert の連鎖(revert → reapply → revert...)ではなく、**最終的なあるべき状態を直接コミット**する。履歴上の意図が明確になり、後の cherry-pick も簡単になる ## 関連 -- `/ndf:branch-fix-strategy` — なぜこの手順が必要かの原則 -- `/ndf:pr` — 通常のPR作成(base=main) +- `/ndf:pr` — 通常のPR作成(base=main)。非 main ベースは本 Skill に誘導される +- `/ndf:merged` — マージ後のブランチ整理と、現ブランチへの main 取り込み - `/ndf:deploy` — ブランチ全体を環境へデプロイ(cherry-pickとは別用途) diff --git a/plugins/ndf-codex/skills/clean/SKILL.md b/plugins/ndf-codex/skills/clean/SKILL.md deleted file mode 100644 index 2f75e54e..00000000 --- a/plugins/ndf-codex/skills/clean/SKILL.md +++ /dev/null @@ -1,20 +0,0 @@ ---- -name: clean -description: "Delete local and remote merged branches." -disable-model-invocation: true -allowed-tools: - - Bash ---- - -# ブランチクリーンアップコマンド - -mainマージ済みブランチをローカル/リモート削除。 - -## 手順 - -1. `git branch --merged main`確認 -2. main・現在ブランチ除外 -3. `git branch -d ` -4. `git push origin --delete ` - -**注意**: 削除前確認・main除外・現在ブランチ除外 diff --git a/plugins/ndf-codex/skills/deploy/SKILL.md b/plugins/ndf-codex/skills/deploy/SKILL.md index 769919d7..f5bffa04 100644 --- a/plugins/ndf-codex/skills/deploy/SKILL.md +++ b/plugins/ndf-codex/skills/deploy/SKILL.md @@ -109,6 +109,5 @@ git checkout "$FEATURE_BRANCH" ## 関連 -- `/ndf:cherry-pick-pr` — 一部コミットだけを環境に届ける場合 -- `/ndf:branch-fix-strategy` — ブランチ運用戦略の原則 -- `/ndf:sync-main` — featureブランチに main を取り込む +- `/ndf:cherry-pick-pr` — 一部コミットだけを環境に届ける場合とブランチ運用戦略の原則 +- `/ndf:merged` — featureブランチに main を取り込む / マージ後のブランチ整理 diff --git a/plugins/ndf-codex/skills/issue-plan-strategy/SKILL.md b/plugins/ndf-codex/skills/issue-plan-strategy/SKILL.md index fdae1ecb..96d19d11 100644 --- a/plugins/ndf-codex/skills/issue-plan-strategy/SKILL.md +++ b/plugins/ndf-codex/skills/issue-plan-strategy/SKILL.md @@ -332,7 +332,7 @@ git checkout release/ /ndf:cherry-pick-pr qa/staging ``` -詳細は `/ndf:cherry-pick-pr` と `/ndf:branch-fix-strategy` を参照。`feature → main` 系 PR を汚染しないため、検証ブランチ向けは必ず短命ブランチ経由で扱う。 +詳細は `/ndf:cherry-pick-pr` を参照。`feature → main` 系 PR を汚染しないため、検証ブランチ向けは必ず短命ブランチ経由で扱う。 ## アンチパターン @@ -345,14 +345,13 @@ git checkout release/ | release PR で個別 PR 範囲の指摘を解決しようとする | 該当 PR が既に閉じている場合、コミット意図がずれる | | release PR の body を個別 PR リンクの列挙だけにする | レビュアーは release PR 単体で変更を把握できず、個別 PR や plan を辿ることになる。body は self-contained 必須 (Step 3 / Step 8) | | body 最終化せずに Ready for review にする | Draft 作成時の plan ベースの暫定 body のままだと実装の最終形と乖離する | -| 検証ブランチを feature/release に merge する | `feature → main` PR への汚染 (詳細: `/ndf:branch-fix-strategy`) | +| 検証ブランチを feature/release に merge する | `feature → main` PR への汚染 (詳細: `/ndf:cherry-pick-pr`) | ## 関連 skill - `/ndf:implementation-plan` — plan ファイルのフォーマット (本 skill が依存) -- `/ndf:branch-fix-strategy` — ブランチ汚染を避ける原則 - `/ndf:pr` — 通常の PR 作成 / 更新 -- `/ndf:cherry-pick-pr` — 検証ブランチへの cherry-pick PR +- `/ndf:cherry-pick-pr` — 検証ブランチへの cherry-pick PR とブランチ汚染を避ける原則 - `/ndf:review` / `/ndf:review-branch` / `/ndf:cross-review` — レビュー - `/ndf:fix` / `/ndf:resolve-pr-comments` — コメント対応 - `/ndf:playwright-scenario-test` — release ブランチでの E2E 結合テスト diff --git a/plugins/ndf-codex/skills/merged/SKILL.md b/plugins/ndf-codex/skills/merged/SKILL.md index 06af6f2a..17568379 100644 --- a/plugins/ndf-codex/skills/merged/SKILL.md +++ b/plugins/ndf-codex/skills/merged/SKILL.md @@ -1,6 +1,6 @@ --- name: merged -description: "Clean up after a PR is merged." +description: "Clean up after a PR is merged: update main, remove the worktree, and delete merged branches." argument-hint: "[PR番号]" disable-model-invocation: true allowed-tools: @@ -10,20 +10,49 @@ allowed-tools: # マージ後クリーンアップコマンド -PRマージ後のクリーンアップを実行。 +PR マージ後の後始末をまとめて実行する。対象 PR のブランチ削除に加えて、残っているマージ済みブランチの整理と main の取り込みもこの Skill で扱う。 ## 手順 -0. **事前確認**: github mcpで引数の(引数が無ければ自身が作成した最新の)PRがmainにmergeされていることを確認。mergeされていなければ終了 -1. **事前確認**: `git status`→変更あればstash -2. **main更新**: `git checkout main`→`git pull` -3. **worktreeクリーンアップ**: `git worktree list` で当該PR番号に対応する worktree (`pr`) を探し、あれば `git worktree remove ` で削除(worktree 内の `.cross_review/` も一緒に消える) -4. **ブランチ削除**: `git branch -d ` → stash復元 +1. **マージ確認**: 引数の(引数がなければ自身が作成した最新の)PR が main に merge されていることを github mcp で確認。merge されていなければ終了 +2. **作業ツリー退避**: `git status` を確認し、変更があれば `git stash` +3. **main 更新**: `git checkout main` → `git pull` +4. **worktree クリーンアップ**: `git worktree list` で当該 PR 番号に対応する worktree (`pr`) を探し、あれば `git worktree remove ` で削除(worktree 内の `.cross_review/` も一緒に消える) +5. **ブランチ削除**: `git branch -d ` +6. **マージ済みブランチの整理**: 下記の手順で残存ブランチをまとめて削除 +7. **復元**: 手順 2 で stash していれば `git stash pop` **注意**: 冪等性保証・エラー時中断・削除済み無視 +## マージ済みブランチの整理 + +```bash +git branch --merged main # 1. マージ済みブランチを列挙 +git branch -d # 2. ローカル削除 +git push origin --delete # 3. リモートにも残っていれば削除 +``` + +- main と現在のブランチは必ず除外する +- 削除対象を提示し、確認を取ってから削除する +- リモート削除は共有ブランチに影響するため、対象を明示してから実行する + +## main の取り込み + +作業中のブランチへ最新のデフォルトブランチ (main/master) を取り込む場合はこちらを使う。 + +1. **ブランチ確認**: `git branch --show-current`。デフォルトブランチ自身なら `git pull` のみ実行して終了 +2. **作業ツリー確認**: 未コミット変更があれば `git stash` で退避 +3. **最新取得**: `git fetch origin ` +4. **マージ実行**: `git merge origin/ --no-edit` + - コンフリクト時は `git diff --name-only --diff-filter=U` で一覧を表示し、**自動解決はしない**。ユーザーに報告し、確認後に作業継続 +5. **後処理**: stash していれば `git stash pop`。コンフリクトがなければ `git push` で反映し、マージ済みコミット数と変更ファイル数を報告 + ## 作業完了報告(必須) -- 実行サマリー(PRタイトル、マージコミット、削除したブランチ、現在のブランチ) -- mainブランチの状態 +- 実行サマリー(PR タイトル、マージコミット、削除したブランチ、現在のブランチ) +- main ブランチの状態 - PR URL + +## 関連 + +- `/ndf:cherry-pick-pr` — 環境ブランチへの cherry-pick PR 作成と、複数ブランチへ同じ修正を適用する原則 diff --git a/plugins/ndf-codex/skills/pr/SKILL.md b/plugins/ndf-codex/skills/pr/SKILL.md index 22000e4c..3bfe6b16 100644 --- a/plugins/ndf-codex/skills/pr/SKILL.md +++ b/plugins/ndf-codex/skills/pr/SKILL.md @@ -54,7 +54,7 @@ allowed-tools: - 引数の末尾が `main`/`master` 以外のベースブランチ名(`qa/staging`, `release/v2` 等)の場合: - **警告を出して `/ndf:cherry-pick-pr ` に誘導する** - - 理由: base非mainのPRに直接pushすると `feature → main` のPRに環境固有コードが混入する(詳細は `/ndf:branch-fix-strategy`) + - 理由: base非mainのPRに直接pushすると `feature → main` のPRに環境固有コードが混入する(詳細は `/ndf:cherry-pick-pr`) - ユーザーが明示的に継続を指示した場合のみ進める ### 3. 変更コミット @@ -137,9 +137,7 @@ feature/xxx ──PR──→ qa/staging ← ❌ qa/staging をmergeするとm ### 正しい手順 -`/ndf:cherry-pick-pr ` を使う(自動化済み)。詳細な理由と手順は: -- `/ndf:cherry-pick-pr` — 自動化コマンド -- `/ndf:branch-fix-strategy` — 原則と手順 +`/ndf:cherry-pick-pr ` を使う(自動化済み)。原則と手順は `/ndf:cherry-pick-pr` に記載のとおり。 ## 作業完了報告(必須) @@ -157,5 +155,4 @@ PR作成/更新完了後、以下を報告: - `/ndf:deploy` — 環境ブランチへのデプロイPR(ブランチ全体) - `/ndf:pr-tests` — Test Plan 自動実行 - `/ndf:review` — PR単位レビュー -- `/ndf:sync-main` — 現ブランチに main を取り込み -- `/ndf:branch-fix-strategy` — ブランチ戦略の原則 +- `/ndf:merged` — マージ後のブランチ整理 / 現ブランチに main を取り込み diff --git a/plugins/ndf-codex/skills/problem-solving/SKILL.md b/plugins/ndf-codex/skills/problem-solving/SKILL.md index 1b3c1108..94133205 100644 --- a/plugins/ndf-codex/skills/problem-solving/SKILL.md +++ b/plugins/ndf-codex/skills/problem-solving/SKILL.md @@ -131,7 +131,7 @@ Layer 4: 出力時検証(結果の妥当性チェック) - 根本原因の修正とデータ修復は**別コミット**にする(Revertしやすい) - 重複コードは発見次第リファクタリングする -- 検証環境向けPRは `cherry-pick-pr` 方式で作成し、mainブランチを汚染しない(詳細は `branch-fix-strategy` スキル参照) +- 検証環境向けPRは `cherry-pick-pr` 方式で作成し、mainブランチを汚染しない(詳細は `cherry-pick-pr` スキル参照) ## 6. 調査レポートの書き方 @@ -158,5 +158,5 @@ SQLクエリ結果をそのまま貼り、「コードを読んだ推測」と ## 関連スキル - `/ndf:investigation-rules` — 調査レポート作成時のエビデンス主義 -- `/ndf:branch-fix-strategy` — 複数ブランチへの修正適用戦略 +- `/ndf:cherry-pick-pr` — 複数ブランチへの修正適用戦略 - `/ndf:logging-guidelines` — ログ設計(原因特定を容易にする) diff --git a/plugins/ndf-codex/skills/sync-main/SKILL.md b/plugins/ndf-codex/skills/sync-main/SKILL.md deleted file mode 100644 index 87aa2230..00000000 --- a/plugins/ndf-codex/skills/sync-main/SKILL.md +++ /dev/null @@ -1,48 +0,0 @@ ---- -name: sync-main -description: "Sync the current branch with main or master." -disable-model-invocation: true -allowed-tools: - - Bash - - Read ---- - -# main取り込みコマンド - -最新のデフォルトブランチ(main/master)を現在のブランチにマージする。 - -## 処理フロー - -1. **ブランチ確認** - - `git branch --show-current` で現在ブランチ確認 - - デフォルトブランチ(main/master)自身の場合は `git pull` のみ実行して終了 - -2. **作業ツリー確認** - - `git status` で未コミット変更を確認 - - 未コミット変更があれば `git stash` で退避 - -3. **最新取得** - - `git fetch origin ` でリモート最新を取得 - -4. **マージ実行** - - `git merge origin/ --no-edit` でマージ - - コンフリクト発生時: - - `git diff --name-only --diff-filter=U` でコンフリクトファイル一覧を表示 - - ユーザーに報告し、**自動解決はしない** - - ユーザー確認後に作業継続 - -5. **後処理** - - stash退避していた場合は `git stash pop` で復元 - - コンフリクトがなければ `git push` でリモートに反映 - - 完了報告(マージ済みコミット数、変更ファイル数) - -## 制約 - -- デフォルトブランチ自身での実行は `git pull` に自動フォールバック -- コンフリクトは自動解決しない(ユーザーが解決) -- 作業ツリーが汚れている場合は必ず stash で退避してから実行 - -## 関連 - -- `/ndf:branch-fix-strategy` — 複数ブランチへの修正適用戦略 -- `/ndf:cherry-pick-pr` — 環境ブランチへのcherry-pick PR作成 diff --git a/plugins/ndf-kiro/skills/branch-fix-strategy/SKILL.md b/plugins/ndf-kiro/skills/branch-fix-strategy/SKILL.md deleted file mode 100644 index a4714a34..00000000 --- a/plugins/ndf-kiro/skills/branch-fix-strategy/SKILL.md +++ /dev/null @@ -1,87 +0,0 @@ ---- -name: branch-fix-strategy -description: "Plan multi-branch fixes and cherry-picks." -when_to_use: "同じ修正を複数ブランチ (qa/staging/release等) に適用する必要があるとき。Triggers: 'cherry-pick', '環境ブランチに修正適用', 'qaに反映', 'stagingに反映', 'release branchへ', 'multi-branch fix', 'apply to qa/staging'" ---- - -# ブランチ修正適用戦略 - -## 適用タイミング - -- featureブランチの修正を `qa/*`, `staging/*`, `release/*` 等の環境ブランチにも適用する必要がある場合 -- 同じ修正を複数ブランチに並行適用する場面全般 - -## 核心ルール - -### 1. 修正は feature ブランチに先に commit → cherry-pick で環境ブランチへ - -``` -✅ feature に commit → cherry-pick して短命ブランチ → 環境ブランチへ PR -❌ 短命ブランチに先に commit → feature に手作業で再実装(二重作業・不整合リスク) -``` - -### 2. 環境ブランチを feature ブランチに merge しない(main 汚染禁止) - -``` -❌ feature/xxx ← merge qa/staging(conflict 解消目的でも禁止) -``` - -環境ブランチを featureブランチにmergeすると、後で `feature → main` のPRに環境固有コードが混入する。 - -### 3. origin/main を必ず取り込む - -短命ブランチを push する前に必ず `git merge origin/main` する。CI で最新 main 必須の Workflow があるため。 - -### 4. マージ済みブランチに push しない - -環境ブランチ向けの短命ブランチに push する前に `gh pr list --head ` で PR 状態を確認する。マージ済みなら新ブランチ + 新 PR を作成する(サフィックス `-v2`, `-v3` を付ける)。 - -## 実行手順 - -`/ndf:cherry-pick-pr ` で自動化されている。手動で行う場合のみ以下を参照。 - -```bash -# 1. feature ブランチで修正を commit -git checkout feature/xxx -git add && git commit -m "fix: 修正内容" -git log --oneline -1 # commit hash を記録 - -# 2. 短命ブランチを作成 -git fetch origin qa/staging -git checkout -b feature/xxx-for-staging origin/qa/staging - -# 3. origin/main を取り込む(必須) -git fetch origin main -git merge origin/main --no-edit - -# 4. cherry-pick(-x で元 commit hash を参照に残す) -git cherry-pick -x - -# 5. push して PR 作成 -git push -u origin feature/xxx-for-staging -gh pr create --base qa/staging --title "fix: 修正内容(staging検証用)" - -# 6. 元のブランチに戻る -git checkout feature/xxx -``` - -## なぜこの順序が重要か - -| 観点 | 正しい順序 | 誤った順序 | -|------|-----------|-----------| -| 単一ソース | feature ブランチが唯一の正 | 二箇所で実装 | -| 一貫性 | cherry-pick で完全一致 | 手書き差分でズレる | -| 追跡性 | `-x` で元 commit が明記 | 関連 commit 不明確 | - -## revert 操作の注意 - -revertの連鎖(revert → reapply → revert...)ではなく、**最終的なあるべき状態を直接コミット**するのが望ましい。履歴上の意図が明確になり、後の cherry-pick も簡単になる。 - -## 関連コマンド・スキル - -| リソース | 用途 | -|---------|------| -| `/ndf:cherry-pick-pr` | cherry-pick + 短命ブランチ + origin/main 取り込み + PR 作成を自動化 | -| `/ndf:pr` | 通常のPR作成。非 main ベースは `cherry-pick-pr` に誘導される | -| `/ndf:sync-main` | 現在のブランチに最新 main を取り込む | -| `/ndf:deploy` | 環境ブランチへのデプロイPR作成(ブランチ全体をmerge main経由で適用) | diff --git a/plugins/ndf-kiro/skills/cherry-pick-pr/SKILL.md b/plugins/ndf-kiro/skills/cherry-pick-pr/SKILL.md index b5dc1341..b44ff420 100644 --- a/plugins/ndf-kiro/skills/cherry-pick-pr/SKILL.md +++ b/plugins/ndf-kiro/skills/cherry-pick-pr/SKILL.md @@ -1,6 +1,6 @@ --- name: cherry-pick-pr -description: "Create cherry-pick PRs for environment branches." +description: "Create cherry-pick PRs for environment branches and apply the same fix across multiple branches." argument-hint: " (例: qa/staging, release/v2)" disable-model-invocation: true allowed-tools: @@ -11,7 +11,7 @@ allowed-tools: # cherry-pick PR 作成コマンド -featureブランチから指定ベースブランチへ、短命ブランチ経由で cherry-pick PR を作成する。`feature → main` の PR にベースブランチ固有コードが混入するのを防ぐ。 +featureブランチから指定ベースブランチ(`qa/*`, `staging/*`, `release/*` 等の環境ブランチ)へ、短命ブランチ経由で cherry-pick PR を作成する。同じ修正を複数ブランチへ並行適用する場面全般で、この原則と手順に従う。 ## 使用方法 @@ -24,7 +24,18 @@ featureブランチから指定ベースブランチへ、短命ブランチ経 featureブランチに環境ブランチ(`qa/staging`等)を merge して conflict を解消すると、`feature → main` の PR に環境ブランチ固有のコードが混入する(main汚染)。短命ブランチ + cherry-pick で、必要なコミットだけを対象ブランチに届ける。 -詳細な原則は `/ndf:branch-fix-strategy` スキル参照。 +| 観点 | 正しい順序 | 誤った順序 | +|------|-----------|-----------| +| 単一ソース | feature ブランチが唯一の正 | 二箇所で実装 | +| 一貫性 | cherry-pick で完全一致 | 手書き差分でズレる | +| 追跡性 | `-x` で元 commit が明記 | 関連 commit 不明確 | + +## 核心ルール + +1. **修正は feature ブランチに先に commit し、cherry-pick で環境ブランチへ届ける。** 短命ブランチに先に commit して feature へ手作業で再実装すると、二重作業と不整合の原因になる +2. **環境ブランチを feature ブランチに merge しない。** conflict 解消目的でも禁止(main汚染の原因) +3. **短命ブランチを push する前に `origin/main` を必ず取り込む。** CI で最新 main 必須の Workflow があるため(処理フロー 5) +4. **マージ済みブランチには push しない。** 同名の短命ブランチに既存 PR がないか先に確認する(処理フロー 2) ## 処理フロー @@ -110,11 +121,10 @@ git checkout - 短命ブランチは PR マージ後に削除してよい - `feature → main` の PR には影響しない -- ベースブランチを feature ブランチに merge するのは **禁止**(main汚染の原因) -- `-x` オプションで元commit参照を残す(追跡性) +- revert の連鎖(revert → reapply → revert...)ではなく、**最終的なあるべき状態を直接コミット**する。履歴上の意図が明確になり、後の cherry-pick も簡単になる ## 関連 -- `/ndf:branch-fix-strategy` — なぜこの手順が必要かの原則 -- `/ndf:pr` — 通常のPR作成(base=main) +- `/ndf:pr` — 通常のPR作成(base=main)。非 main ベースは本 Skill に誘導される +- `/ndf:merged` — マージ後のブランチ整理と、現ブランチへの main 取り込み - `/ndf:deploy` — ブランチ全体を環境へデプロイ(cherry-pickとは別用途) diff --git a/plugins/ndf-kiro/skills/clean/SKILL.md b/plugins/ndf-kiro/skills/clean/SKILL.md deleted file mode 100644 index 2f75e54e..00000000 --- a/plugins/ndf-kiro/skills/clean/SKILL.md +++ /dev/null @@ -1,20 +0,0 @@ ---- -name: clean -description: "Delete local and remote merged branches." -disable-model-invocation: true -allowed-tools: - - Bash ---- - -# ブランチクリーンアップコマンド - -mainマージ済みブランチをローカル/リモート削除。 - -## 手順 - -1. `git branch --merged main`確認 -2. main・現在ブランチ除外 -3. `git branch -d ` -4. `git push origin --delete ` - -**注意**: 削除前確認・main除外・現在ブランチ除外 diff --git a/plugins/ndf-kiro/skills/deploy/SKILL.md b/plugins/ndf-kiro/skills/deploy/SKILL.md index 769919d7..f5bffa04 100644 --- a/plugins/ndf-kiro/skills/deploy/SKILL.md +++ b/plugins/ndf-kiro/skills/deploy/SKILL.md @@ -109,6 +109,5 @@ git checkout "$FEATURE_BRANCH" ## 関連 -- `/ndf:cherry-pick-pr` — 一部コミットだけを環境に届ける場合 -- `/ndf:branch-fix-strategy` — ブランチ運用戦略の原則 -- `/ndf:sync-main` — featureブランチに main を取り込む +- `/ndf:cherry-pick-pr` — 一部コミットだけを環境に届ける場合とブランチ運用戦略の原則 +- `/ndf:merged` — featureブランチに main を取り込む / マージ後のブランチ整理 diff --git a/plugins/ndf-kiro/skills/issue-plan-strategy/SKILL.md b/plugins/ndf-kiro/skills/issue-plan-strategy/SKILL.md index fdae1ecb..96d19d11 100644 --- a/plugins/ndf-kiro/skills/issue-plan-strategy/SKILL.md +++ b/plugins/ndf-kiro/skills/issue-plan-strategy/SKILL.md @@ -332,7 +332,7 @@ git checkout release/ /ndf:cherry-pick-pr qa/staging ``` -詳細は `/ndf:cherry-pick-pr` と `/ndf:branch-fix-strategy` を参照。`feature → main` 系 PR を汚染しないため、検証ブランチ向けは必ず短命ブランチ経由で扱う。 +詳細は `/ndf:cherry-pick-pr` を参照。`feature → main` 系 PR を汚染しないため、検証ブランチ向けは必ず短命ブランチ経由で扱う。 ## アンチパターン @@ -345,14 +345,13 @@ git checkout release/ | release PR で個別 PR 範囲の指摘を解決しようとする | 該当 PR が既に閉じている場合、コミット意図がずれる | | release PR の body を個別 PR リンクの列挙だけにする | レビュアーは release PR 単体で変更を把握できず、個別 PR や plan を辿ることになる。body は self-contained 必須 (Step 3 / Step 8) | | body 最終化せずに Ready for review にする | Draft 作成時の plan ベースの暫定 body のままだと実装の最終形と乖離する | -| 検証ブランチを feature/release に merge する | `feature → main` PR への汚染 (詳細: `/ndf:branch-fix-strategy`) | +| 検証ブランチを feature/release に merge する | `feature → main` PR への汚染 (詳細: `/ndf:cherry-pick-pr`) | ## 関連 skill - `/ndf:implementation-plan` — plan ファイルのフォーマット (本 skill が依存) -- `/ndf:branch-fix-strategy` — ブランチ汚染を避ける原則 - `/ndf:pr` — 通常の PR 作成 / 更新 -- `/ndf:cherry-pick-pr` — 検証ブランチへの cherry-pick PR +- `/ndf:cherry-pick-pr` — 検証ブランチへの cherry-pick PR とブランチ汚染を避ける原則 - `/ndf:review` / `/ndf:review-branch` / `/ndf:cross-review` — レビュー - `/ndf:fix` / `/ndf:resolve-pr-comments` — コメント対応 - `/ndf:playwright-scenario-test` — release ブランチでの E2E 結合テスト diff --git a/plugins/ndf-kiro/skills/merged/SKILL.md b/plugins/ndf-kiro/skills/merged/SKILL.md index 06af6f2a..17568379 100644 --- a/plugins/ndf-kiro/skills/merged/SKILL.md +++ b/plugins/ndf-kiro/skills/merged/SKILL.md @@ -1,6 +1,6 @@ --- name: merged -description: "Clean up after a PR is merged." +description: "Clean up after a PR is merged: update main, remove the worktree, and delete merged branches." argument-hint: "[PR番号]" disable-model-invocation: true allowed-tools: @@ -10,20 +10,49 @@ allowed-tools: # マージ後クリーンアップコマンド -PRマージ後のクリーンアップを実行。 +PR マージ後の後始末をまとめて実行する。対象 PR のブランチ削除に加えて、残っているマージ済みブランチの整理と main の取り込みもこの Skill で扱う。 ## 手順 -0. **事前確認**: github mcpで引数の(引数が無ければ自身が作成した最新の)PRがmainにmergeされていることを確認。mergeされていなければ終了 -1. **事前確認**: `git status`→変更あればstash -2. **main更新**: `git checkout main`→`git pull` -3. **worktreeクリーンアップ**: `git worktree list` で当該PR番号に対応する worktree (`pr`) を探し、あれば `git worktree remove ` で削除(worktree 内の `.cross_review/` も一緒に消える) -4. **ブランチ削除**: `git branch -d ` → stash復元 +1. **マージ確認**: 引数の(引数がなければ自身が作成した最新の)PR が main に merge されていることを github mcp で確認。merge されていなければ終了 +2. **作業ツリー退避**: `git status` を確認し、変更があれば `git stash` +3. **main 更新**: `git checkout main` → `git pull` +4. **worktree クリーンアップ**: `git worktree list` で当該 PR 番号に対応する worktree (`pr`) を探し、あれば `git worktree remove ` で削除(worktree 内の `.cross_review/` も一緒に消える) +5. **ブランチ削除**: `git branch -d ` +6. **マージ済みブランチの整理**: 下記の手順で残存ブランチをまとめて削除 +7. **復元**: 手順 2 で stash していれば `git stash pop` **注意**: 冪等性保証・エラー時中断・削除済み無視 +## マージ済みブランチの整理 + +```bash +git branch --merged main # 1. マージ済みブランチを列挙 +git branch -d # 2. ローカル削除 +git push origin --delete # 3. リモートにも残っていれば削除 +``` + +- main と現在のブランチは必ず除外する +- 削除対象を提示し、確認を取ってから削除する +- リモート削除は共有ブランチに影響するため、対象を明示してから実行する + +## main の取り込み + +作業中のブランチへ最新のデフォルトブランチ (main/master) を取り込む場合はこちらを使う。 + +1. **ブランチ確認**: `git branch --show-current`。デフォルトブランチ自身なら `git pull` のみ実行して終了 +2. **作業ツリー確認**: 未コミット変更があれば `git stash` で退避 +3. **最新取得**: `git fetch origin ` +4. **マージ実行**: `git merge origin/ --no-edit` + - コンフリクト時は `git diff --name-only --diff-filter=U` で一覧を表示し、**自動解決はしない**。ユーザーに報告し、確認後に作業継続 +5. **後処理**: stash していれば `git stash pop`。コンフリクトがなければ `git push` で反映し、マージ済みコミット数と変更ファイル数を報告 + ## 作業完了報告(必須) -- 実行サマリー(PRタイトル、マージコミット、削除したブランチ、現在のブランチ) -- mainブランチの状態 +- 実行サマリー(PR タイトル、マージコミット、削除したブランチ、現在のブランチ) +- main ブランチの状態 - PR URL + +## 関連 + +- `/ndf:cherry-pick-pr` — 環境ブランチへの cherry-pick PR 作成と、複数ブランチへ同じ修正を適用する原則 diff --git a/plugins/ndf-kiro/skills/pr/SKILL.md b/plugins/ndf-kiro/skills/pr/SKILL.md index 22000e4c..3bfe6b16 100644 --- a/plugins/ndf-kiro/skills/pr/SKILL.md +++ b/plugins/ndf-kiro/skills/pr/SKILL.md @@ -54,7 +54,7 @@ allowed-tools: - 引数の末尾が `main`/`master` 以外のベースブランチ名(`qa/staging`, `release/v2` 等)の場合: - **警告を出して `/ndf:cherry-pick-pr ` に誘導する** - - 理由: base非mainのPRに直接pushすると `feature → main` のPRに環境固有コードが混入する(詳細は `/ndf:branch-fix-strategy`) + - 理由: base非mainのPRに直接pushすると `feature → main` のPRに環境固有コードが混入する(詳細は `/ndf:cherry-pick-pr`) - ユーザーが明示的に継続を指示した場合のみ進める ### 3. 変更コミット @@ -137,9 +137,7 @@ feature/xxx ──PR──→ qa/staging ← ❌ qa/staging をmergeするとm ### 正しい手順 -`/ndf:cherry-pick-pr ` を使う(自動化済み)。詳細な理由と手順は: -- `/ndf:cherry-pick-pr` — 自動化コマンド -- `/ndf:branch-fix-strategy` — 原則と手順 +`/ndf:cherry-pick-pr ` を使う(自動化済み)。原則と手順は `/ndf:cherry-pick-pr` に記載のとおり。 ## 作業完了報告(必須) @@ -157,5 +155,4 @@ PR作成/更新完了後、以下を報告: - `/ndf:deploy` — 環境ブランチへのデプロイPR(ブランチ全体) - `/ndf:pr-tests` — Test Plan 自動実行 - `/ndf:review` — PR単位レビュー -- `/ndf:sync-main` — 現ブランチに main を取り込み -- `/ndf:branch-fix-strategy` — ブランチ戦略の原則 +- `/ndf:merged` — マージ後のブランチ整理 / 現ブランチに main を取り込み diff --git a/plugins/ndf-kiro/skills/problem-solving/SKILL.md b/plugins/ndf-kiro/skills/problem-solving/SKILL.md index 1b3c1108..94133205 100644 --- a/plugins/ndf-kiro/skills/problem-solving/SKILL.md +++ b/plugins/ndf-kiro/skills/problem-solving/SKILL.md @@ -131,7 +131,7 @@ Layer 4: 出力時検証(結果の妥当性チェック) - 根本原因の修正とデータ修復は**別コミット**にする(Revertしやすい) - 重複コードは発見次第リファクタリングする -- 検証環境向けPRは `cherry-pick-pr` 方式で作成し、mainブランチを汚染しない(詳細は `branch-fix-strategy` スキル参照) +- 検証環境向けPRは `cherry-pick-pr` 方式で作成し、mainブランチを汚染しない(詳細は `cherry-pick-pr` スキル参照) ## 6. 調査レポートの書き方 @@ -158,5 +158,5 @@ SQLクエリ結果をそのまま貼り、「コードを読んだ推測」と ## 関連スキル - `/ndf:investigation-rules` — 調査レポート作成時のエビデンス主義 -- `/ndf:branch-fix-strategy` — 複数ブランチへの修正適用戦略 +- `/ndf:cherry-pick-pr` — 複数ブランチへの修正適用戦略 - `/ndf:logging-guidelines` — ログ設計(原因特定を容易にする) diff --git a/plugins/ndf-kiro/skills/sync-main/SKILL.md b/plugins/ndf-kiro/skills/sync-main/SKILL.md deleted file mode 100644 index 87aa2230..00000000 --- a/plugins/ndf-kiro/skills/sync-main/SKILL.md +++ /dev/null @@ -1,48 +0,0 @@ ---- -name: sync-main -description: "Sync the current branch with main or master." -disable-model-invocation: true -allowed-tools: - - Bash - - Read ---- - -# main取り込みコマンド - -最新のデフォルトブランチ(main/master)を現在のブランチにマージする。 - -## 処理フロー - -1. **ブランチ確認** - - `git branch --show-current` で現在ブランチ確認 - - デフォルトブランチ(main/master)自身の場合は `git pull` のみ実行して終了 - -2. **作業ツリー確認** - - `git status` で未コミット変更を確認 - - 未コミット変更があれば `git stash` で退避 - -3. **最新取得** - - `git fetch origin ` でリモート最新を取得 - -4. **マージ実行** - - `git merge origin/ --no-edit` でマージ - - コンフリクト発生時: - - `git diff --name-only --diff-filter=U` でコンフリクトファイル一覧を表示 - - ユーザーに報告し、**自動解決はしない** - - ユーザー確認後に作業継続 - -5. **後処理** - - stash退避していた場合は `git stash pop` で復元 - - コンフリクトがなければ `git push` でリモートに反映 - - 完了報告(マージ済みコミット数、変更ファイル数) - -## 制約 - -- デフォルトブランチ自身での実行は `git pull` に自動フォールバック -- コンフリクトは自動解決しない(ユーザーが解決) -- 作業ツリーが汚れている場合は必ず stash で退避してから実行 - -## 関連 - -- `/ndf:branch-fix-strategy` — 複数ブランチへの修正適用戦略 -- `/ndf:cherry-pick-pr` — 環境ブランチへのcherry-pick PR作成 diff --git a/plugins/ndf-shared/manifests/claude-skills.txt b/plugins/ndf-shared/manifests/claude-skills.txt index bb74879b..0fa23986 100644 --- a/plugins/ndf-shared/manifests/claude-skills.txt +++ b/plugins/ndf-shared/manifests/claude-skills.txt @@ -4,18 +4,15 @@ fix review cross-review merged -clean ndf-policies markdown-writing python-execution docker-container-access git-gh-operations -branch-fix-strategy implementation-plan investigation-rules problem-solving logging-guidelines -sync-main cherry-pick-pr deploy review-branch diff --git a/plugins/ndf-shared/manifests/codex-skills.txt b/plugins/ndf-shared/manifests/codex-skills.txt index 403632f8..888d5ec1 100644 --- a/plugins/ndf-shared/manifests/codex-skills.txt +++ b/plugins/ndf-shared/manifests/codex-skills.txt @@ -1,6 +1,4 @@ -branch-fix-strategy cherry-pick-pr -clean cross-review deploy docker-container-access @@ -27,4 +25,3 @@ resolve-pr-comments review review-branch review-pr-comments -sync-main diff --git a/plugins/ndf-shared/manifests/kiro-skills.txt b/plugins/ndf-shared/manifests/kiro-skills.txt index b58dc6bd..8b420bef 100644 --- a/plugins/ndf-shared/manifests/kiro-skills.txt +++ b/plugins/ndf-shared/manifests/kiro-skills.txt @@ -4,18 +4,15 @@ fix review cross-review merged -clean ndf-policies markdown-writing python-execution docker-container-access git-gh-operations -branch-fix-strategy implementation-plan investigation-rules problem-solving logging-guidelines -sync-main cherry-pick-pr deploy review-branch diff --git a/plugins/ndf-shared/skills/branch-fix-strategy/SKILL.md b/plugins/ndf-shared/skills/branch-fix-strategy/SKILL.md deleted file mode 100644 index a4714a34..00000000 --- a/plugins/ndf-shared/skills/branch-fix-strategy/SKILL.md +++ /dev/null @@ -1,87 +0,0 @@ ---- -name: branch-fix-strategy -description: "Plan multi-branch fixes and cherry-picks." -when_to_use: "同じ修正を複数ブランチ (qa/staging/release等) に適用する必要があるとき。Triggers: 'cherry-pick', '環境ブランチに修正適用', 'qaに反映', 'stagingに反映', 'release branchへ', 'multi-branch fix', 'apply to qa/staging'" ---- - -# ブランチ修正適用戦略 - -## 適用タイミング - -- featureブランチの修正を `qa/*`, `staging/*`, `release/*` 等の環境ブランチにも適用する必要がある場合 -- 同じ修正を複数ブランチに並行適用する場面全般 - -## 核心ルール - -### 1. 修正は feature ブランチに先に commit → cherry-pick で環境ブランチへ - -``` -✅ feature に commit → cherry-pick して短命ブランチ → 環境ブランチへ PR -❌ 短命ブランチに先に commit → feature に手作業で再実装(二重作業・不整合リスク) -``` - -### 2. 環境ブランチを feature ブランチに merge しない(main 汚染禁止) - -``` -❌ feature/xxx ← merge qa/staging(conflict 解消目的でも禁止) -``` - -環境ブランチを featureブランチにmergeすると、後で `feature → main` のPRに環境固有コードが混入する。 - -### 3. origin/main を必ず取り込む - -短命ブランチを push する前に必ず `git merge origin/main` する。CI で最新 main 必須の Workflow があるため。 - -### 4. マージ済みブランチに push しない - -環境ブランチ向けの短命ブランチに push する前に `gh pr list --head ` で PR 状態を確認する。マージ済みなら新ブランチ + 新 PR を作成する(サフィックス `-v2`, `-v3` を付ける)。 - -## 実行手順 - -`/ndf:cherry-pick-pr ` で自動化されている。手動で行う場合のみ以下を参照。 - -```bash -# 1. feature ブランチで修正を commit -git checkout feature/xxx -git add && git commit -m "fix: 修正内容" -git log --oneline -1 # commit hash を記録 - -# 2. 短命ブランチを作成 -git fetch origin qa/staging -git checkout -b feature/xxx-for-staging origin/qa/staging - -# 3. origin/main を取り込む(必須) -git fetch origin main -git merge origin/main --no-edit - -# 4. cherry-pick(-x で元 commit hash を参照に残す) -git cherry-pick -x - -# 5. push して PR 作成 -git push -u origin feature/xxx-for-staging -gh pr create --base qa/staging --title "fix: 修正内容(staging検証用)" - -# 6. 元のブランチに戻る -git checkout feature/xxx -``` - -## なぜこの順序が重要か - -| 観点 | 正しい順序 | 誤った順序 | -|------|-----------|-----------| -| 単一ソース | feature ブランチが唯一の正 | 二箇所で実装 | -| 一貫性 | cherry-pick で完全一致 | 手書き差分でズレる | -| 追跡性 | `-x` で元 commit が明記 | 関連 commit 不明確 | - -## revert 操作の注意 - -revertの連鎖(revert → reapply → revert...)ではなく、**最終的なあるべき状態を直接コミット**するのが望ましい。履歴上の意図が明確になり、後の cherry-pick も簡単になる。 - -## 関連コマンド・スキル - -| リソース | 用途 | -|---------|------| -| `/ndf:cherry-pick-pr` | cherry-pick + 短命ブランチ + origin/main 取り込み + PR 作成を自動化 | -| `/ndf:pr` | 通常のPR作成。非 main ベースは `cherry-pick-pr` に誘導される | -| `/ndf:sync-main` | 現在のブランチに最新 main を取り込む | -| `/ndf:deploy` | 環境ブランチへのデプロイPR作成(ブランチ全体をmerge main経由で適用) | diff --git a/plugins/ndf-shared/skills/cherry-pick-pr/SKILL.md b/plugins/ndf-shared/skills/cherry-pick-pr/SKILL.md index b5dc1341..b44ff420 100644 --- a/plugins/ndf-shared/skills/cherry-pick-pr/SKILL.md +++ b/plugins/ndf-shared/skills/cherry-pick-pr/SKILL.md @@ -1,6 +1,6 @@ --- name: cherry-pick-pr -description: "Create cherry-pick PRs for environment branches." +description: "Create cherry-pick PRs for environment branches and apply the same fix across multiple branches." argument-hint: " (例: qa/staging, release/v2)" disable-model-invocation: true allowed-tools: @@ -11,7 +11,7 @@ allowed-tools: # cherry-pick PR 作成コマンド -featureブランチから指定ベースブランチへ、短命ブランチ経由で cherry-pick PR を作成する。`feature → main` の PR にベースブランチ固有コードが混入するのを防ぐ。 +featureブランチから指定ベースブランチ(`qa/*`, `staging/*`, `release/*` 等の環境ブランチ)へ、短命ブランチ経由で cherry-pick PR を作成する。同じ修正を複数ブランチへ並行適用する場面全般で、この原則と手順に従う。 ## 使用方法 @@ -24,7 +24,18 @@ featureブランチから指定ベースブランチへ、短命ブランチ経 featureブランチに環境ブランチ(`qa/staging`等)を merge して conflict を解消すると、`feature → main` の PR に環境ブランチ固有のコードが混入する(main汚染)。短命ブランチ + cherry-pick で、必要なコミットだけを対象ブランチに届ける。 -詳細な原則は `/ndf:branch-fix-strategy` スキル参照。 +| 観点 | 正しい順序 | 誤った順序 | +|------|-----------|-----------| +| 単一ソース | feature ブランチが唯一の正 | 二箇所で実装 | +| 一貫性 | cherry-pick で完全一致 | 手書き差分でズレる | +| 追跡性 | `-x` で元 commit が明記 | 関連 commit 不明確 | + +## 核心ルール + +1. **修正は feature ブランチに先に commit し、cherry-pick で環境ブランチへ届ける。** 短命ブランチに先に commit して feature へ手作業で再実装すると、二重作業と不整合の原因になる +2. **環境ブランチを feature ブランチに merge しない。** conflict 解消目的でも禁止(main汚染の原因) +3. **短命ブランチを push する前に `origin/main` を必ず取り込む。** CI で最新 main 必須の Workflow があるため(処理フロー 5) +4. **マージ済みブランチには push しない。** 同名の短命ブランチに既存 PR がないか先に確認する(処理フロー 2) ## 処理フロー @@ -110,11 +121,10 @@ git checkout - 短命ブランチは PR マージ後に削除してよい - `feature → main` の PR には影響しない -- ベースブランチを feature ブランチに merge するのは **禁止**(main汚染の原因) -- `-x` オプションで元commit参照を残す(追跡性) +- revert の連鎖(revert → reapply → revert...)ではなく、**最終的なあるべき状態を直接コミット**する。履歴上の意図が明確になり、後の cherry-pick も簡単になる ## 関連 -- `/ndf:branch-fix-strategy` — なぜこの手順が必要かの原則 -- `/ndf:pr` — 通常のPR作成(base=main) +- `/ndf:pr` — 通常のPR作成(base=main)。非 main ベースは本 Skill に誘導される +- `/ndf:merged` — マージ後のブランチ整理と、現ブランチへの main 取り込み - `/ndf:deploy` — ブランチ全体を環境へデプロイ(cherry-pickとは別用途) diff --git a/plugins/ndf-shared/skills/clean/SKILL.md b/plugins/ndf-shared/skills/clean/SKILL.md deleted file mode 100644 index 2f75e54e..00000000 --- a/plugins/ndf-shared/skills/clean/SKILL.md +++ /dev/null @@ -1,20 +0,0 @@ ---- -name: clean -description: "Delete local and remote merged branches." -disable-model-invocation: true -allowed-tools: - - Bash ---- - -# ブランチクリーンアップコマンド - -mainマージ済みブランチをローカル/リモート削除。 - -## 手順 - -1. `git branch --merged main`確認 -2. main・現在ブランチ除外 -3. `git branch -d ` -4. `git push origin --delete ` - -**注意**: 削除前確認・main除外・現在ブランチ除外 diff --git a/plugins/ndf-shared/skills/deploy/SKILL.md b/plugins/ndf-shared/skills/deploy/SKILL.md index 769919d7..f5bffa04 100644 --- a/plugins/ndf-shared/skills/deploy/SKILL.md +++ b/plugins/ndf-shared/skills/deploy/SKILL.md @@ -109,6 +109,5 @@ git checkout "$FEATURE_BRANCH" ## 関連 -- `/ndf:cherry-pick-pr` — 一部コミットだけを環境に届ける場合 -- `/ndf:branch-fix-strategy` — ブランチ運用戦略の原則 -- `/ndf:sync-main` — featureブランチに main を取り込む +- `/ndf:cherry-pick-pr` — 一部コミットだけを環境に届ける場合とブランチ運用戦略の原則 +- `/ndf:merged` — featureブランチに main を取り込む / マージ後のブランチ整理 diff --git a/plugins/ndf-shared/skills/issue-plan-strategy/SKILL.md b/plugins/ndf-shared/skills/issue-plan-strategy/SKILL.md index fdae1ecb..96d19d11 100644 --- a/plugins/ndf-shared/skills/issue-plan-strategy/SKILL.md +++ b/plugins/ndf-shared/skills/issue-plan-strategy/SKILL.md @@ -332,7 +332,7 @@ git checkout release/ /ndf:cherry-pick-pr qa/staging ``` -詳細は `/ndf:cherry-pick-pr` と `/ndf:branch-fix-strategy` を参照。`feature → main` 系 PR を汚染しないため、検証ブランチ向けは必ず短命ブランチ経由で扱う。 +詳細は `/ndf:cherry-pick-pr` を参照。`feature → main` 系 PR を汚染しないため、検証ブランチ向けは必ず短命ブランチ経由で扱う。 ## アンチパターン @@ -345,14 +345,13 @@ git checkout release/ | release PR で個別 PR 範囲の指摘を解決しようとする | 該当 PR が既に閉じている場合、コミット意図がずれる | | release PR の body を個別 PR リンクの列挙だけにする | レビュアーは release PR 単体で変更を把握できず、個別 PR や plan を辿ることになる。body は self-contained 必須 (Step 3 / Step 8) | | body 最終化せずに Ready for review にする | Draft 作成時の plan ベースの暫定 body のままだと実装の最終形と乖離する | -| 検証ブランチを feature/release に merge する | `feature → main` PR への汚染 (詳細: `/ndf:branch-fix-strategy`) | +| 検証ブランチを feature/release に merge する | `feature → main` PR への汚染 (詳細: `/ndf:cherry-pick-pr`) | ## 関連 skill - `/ndf:implementation-plan` — plan ファイルのフォーマット (本 skill が依存) -- `/ndf:branch-fix-strategy` — ブランチ汚染を避ける原則 - `/ndf:pr` — 通常の PR 作成 / 更新 -- `/ndf:cherry-pick-pr` — 検証ブランチへの cherry-pick PR +- `/ndf:cherry-pick-pr` — 検証ブランチへの cherry-pick PR とブランチ汚染を避ける原則 - `/ndf:review` / `/ndf:review-branch` / `/ndf:cross-review` — レビュー - `/ndf:fix` / `/ndf:resolve-pr-comments` — コメント対応 - `/ndf:playwright-scenario-test` — release ブランチでの E2E 結合テスト diff --git a/plugins/ndf-shared/skills/merged/SKILL.md b/plugins/ndf-shared/skills/merged/SKILL.md index 06af6f2a..17568379 100644 --- a/plugins/ndf-shared/skills/merged/SKILL.md +++ b/plugins/ndf-shared/skills/merged/SKILL.md @@ -1,6 +1,6 @@ --- name: merged -description: "Clean up after a PR is merged." +description: "Clean up after a PR is merged: update main, remove the worktree, and delete merged branches." argument-hint: "[PR番号]" disable-model-invocation: true allowed-tools: @@ -10,20 +10,49 @@ allowed-tools: # マージ後クリーンアップコマンド -PRマージ後のクリーンアップを実行。 +PR マージ後の後始末をまとめて実行する。対象 PR のブランチ削除に加えて、残っているマージ済みブランチの整理と main の取り込みもこの Skill で扱う。 ## 手順 -0. **事前確認**: github mcpで引数の(引数が無ければ自身が作成した最新の)PRがmainにmergeされていることを確認。mergeされていなければ終了 -1. **事前確認**: `git status`→変更あればstash -2. **main更新**: `git checkout main`→`git pull` -3. **worktreeクリーンアップ**: `git worktree list` で当該PR番号に対応する worktree (`pr`) を探し、あれば `git worktree remove ` で削除(worktree 内の `.cross_review/` も一緒に消える) -4. **ブランチ削除**: `git branch -d ` → stash復元 +1. **マージ確認**: 引数の(引数がなければ自身が作成した最新の)PR が main に merge されていることを github mcp で確認。merge されていなければ終了 +2. **作業ツリー退避**: `git status` を確認し、変更があれば `git stash` +3. **main 更新**: `git checkout main` → `git pull` +4. **worktree クリーンアップ**: `git worktree list` で当該 PR 番号に対応する worktree (`pr`) を探し、あれば `git worktree remove ` で削除(worktree 内の `.cross_review/` も一緒に消える) +5. **ブランチ削除**: `git branch -d ` +6. **マージ済みブランチの整理**: 下記の手順で残存ブランチをまとめて削除 +7. **復元**: 手順 2 で stash していれば `git stash pop` **注意**: 冪等性保証・エラー時中断・削除済み無視 +## マージ済みブランチの整理 + +```bash +git branch --merged main # 1. マージ済みブランチを列挙 +git branch -d # 2. ローカル削除 +git push origin --delete # 3. リモートにも残っていれば削除 +``` + +- main と現在のブランチは必ず除外する +- 削除対象を提示し、確認を取ってから削除する +- リモート削除は共有ブランチに影響するため、対象を明示してから実行する + +## main の取り込み + +作業中のブランチへ最新のデフォルトブランチ (main/master) を取り込む場合はこちらを使う。 + +1. **ブランチ確認**: `git branch --show-current`。デフォルトブランチ自身なら `git pull` のみ実行して終了 +2. **作業ツリー確認**: 未コミット変更があれば `git stash` で退避 +3. **最新取得**: `git fetch origin ` +4. **マージ実行**: `git merge origin/ --no-edit` + - コンフリクト時は `git diff --name-only --diff-filter=U` で一覧を表示し、**自動解決はしない**。ユーザーに報告し、確認後に作業継続 +5. **後処理**: stash していれば `git stash pop`。コンフリクトがなければ `git push` で反映し、マージ済みコミット数と変更ファイル数を報告 + ## 作業完了報告(必須) -- 実行サマリー(PRタイトル、マージコミット、削除したブランチ、現在のブランチ) -- mainブランチの状態 +- 実行サマリー(PR タイトル、マージコミット、削除したブランチ、現在のブランチ) +- main ブランチの状態 - PR URL + +## 関連 + +- `/ndf:cherry-pick-pr` — 環境ブランチへの cherry-pick PR 作成と、複数ブランチへ同じ修正を適用する原則 diff --git a/plugins/ndf-shared/skills/pr/SKILL.md b/plugins/ndf-shared/skills/pr/SKILL.md index 22000e4c..3bfe6b16 100644 --- a/plugins/ndf-shared/skills/pr/SKILL.md +++ b/plugins/ndf-shared/skills/pr/SKILL.md @@ -54,7 +54,7 @@ allowed-tools: - 引数の末尾が `main`/`master` 以外のベースブランチ名(`qa/staging`, `release/v2` 等)の場合: - **警告を出して `/ndf:cherry-pick-pr ` に誘導する** - - 理由: base非mainのPRに直接pushすると `feature → main` のPRに環境固有コードが混入する(詳細は `/ndf:branch-fix-strategy`) + - 理由: base非mainのPRに直接pushすると `feature → main` のPRに環境固有コードが混入する(詳細は `/ndf:cherry-pick-pr`) - ユーザーが明示的に継続を指示した場合のみ進める ### 3. 変更コミット @@ -137,9 +137,7 @@ feature/xxx ──PR──→ qa/staging ← ❌ qa/staging をmergeするとm ### 正しい手順 -`/ndf:cherry-pick-pr ` を使う(自動化済み)。詳細な理由と手順は: -- `/ndf:cherry-pick-pr` — 自動化コマンド -- `/ndf:branch-fix-strategy` — 原則と手順 +`/ndf:cherry-pick-pr ` を使う(自動化済み)。原則と手順は `/ndf:cherry-pick-pr` に記載のとおり。 ## 作業完了報告(必須) @@ -157,5 +155,4 @@ PR作成/更新完了後、以下を報告: - `/ndf:deploy` — 環境ブランチへのデプロイPR(ブランチ全体) - `/ndf:pr-tests` — Test Plan 自動実行 - `/ndf:review` — PR単位レビュー -- `/ndf:sync-main` — 現ブランチに main を取り込み -- `/ndf:branch-fix-strategy` — ブランチ戦略の原則 +- `/ndf:merged` — マージ後のブランチ整理 / 現ブランチに main を取り込み diff --git a/plugins/ndf-shared/skills/problem-solving/SKILL.md b/plugins/ndf-shared/skills/problem-solving/SKILL.md index 1b3c1108..94133205 100644 --- a/plugins/ndf-shared/skills/problem-solving/SKILL.md +++ b/plugins/ndf-shared/skills/problem-solving/SKILL.md @@ -131,7 +131,7 @@ Layer 4: 出力時検証(結果の妥当性チェック) - 根本原因の修正とデータ修復は**別コミット**にする(Revertしやすい) - 重複コードは発見次第リファクタリングする -- 検証環境向けPRは `cherry-pick-pr` 方式で作成し、mainブランチを汚染しない(詳細は `branch-fix-strategy` スキル参照) +- 検証環境向けPRは `cherry-pick-pr` 方式で作成し、mainブランチを汚染しない(詳細は `cherry-pick-pr` スキル参照) ## 6. 調査レポートの書き方 @@ -158,5 +158,5 @@ SQLクエリ結果をそのまま貼り、「コードを読んだ推測」と ## 関連スキル - `/ndf:investigation-rules` — 調査レポート作成時のエビデンス主義 -- `/ndf:branch-fix-strategy` — 複数ブランチへの修正適用戦略 +- `/ndf:cherry-pick-pr` — 複数ブランチへの修正適用戦略 - `/ndf:logging-guidelines` — ログ設計(原因特定を容易にする) diff --git a/plugins/ndf-shared/skills/sync-main/SKILL.md b/plugins/ndf-shared/skills/sync-main/SKILL.md deleted file mode 100644 index 87aa2230..00000000 --- a/plugins/ndf-shared/skills/sync-main/SKILL.md +++ /dev/null @@ -1,48 +0,0 @@ ---- -name: sync-main -description: "Sync the current branch with main or master." -disable-model-invocation: true -allowed-tools: - - Bash - - Read ---- - -# main取り込みコマンド - -最新のデフォルトブランチ(main/master)を現在のブランチにマージする。 - -## 処理フロー - -1. **ブランチ確認** - - `git branch --show-current` で現在ブランチ確認 - - デフォルトブランチ(main/master)自身の場合は `git pull` のみ実行して終了 - -2. **作業ツリー確認** - - `git status` で未コミット変更を確認 - - 未コミット変更があれば `git stash` で退避 - -3. **最新取得** - - `git fetch origin ` でリモート最新を取得 - -4. **マージ実行** - - `git merge origin/ --no-edit` でマージ - - コンフリクト発生時: - - `git diff --name-only --diff-filter=U` でコンフリクトファイル一覧を表示 - - ユーザーに報告し、**自動解決はしない** - - ユーザー確認後に作業継続 - -5. **後処理** - - stash退避していた場合は `git stash pop` で復元 - - コンフリクトがなければ `git push` でリモートに反映 - - 完了報告(マージ済みコミット数、変更ファイル数) - -## 制約 - -- デフォルトブランチ自身での実行は `git pull` に自動フォールバック -- コンフリクトは自動解決しない(ユーザーが解決) -- 作業ツリーが汚れている場合は必ず stash で退避してから実行 - -## 関連 - -- `/ndf:branch-fix-strategy` — 複数ブランチへの修正適用戦略 -- `/ndf:cherry-pick-pr` — 環境ブランチへのcherry-pick PR作成 From 5a27c72759839eee3aa5476fcd044ce7fca60214 Mon Sep 17 00:00:00 2001 From: "takemi.ohama" Date: Sat, 8 Aug 2026 03:20:49 +0000 Subject: [PATCH 3/8] =?UTF-8?q?Fix:=20=E5=89=8A=E9=99=A4=E6=B8=88=E3=81=BF?= =?UTF-8?q?=20clean=20Skill=20=E3=82=92=E5=8F=82=E7=85=A7=E3=81=99?= =?UTF-8?q?=E3=82=8B=20Kiro=20=E3=83=97=E3=83=AD=E3=83=B3=E3=83=97?= =?UTF-8?q?=E3=83=88=E3=82=92=E5=89=8A=E9=99=A4=20(0-4)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit clean Skill は merged へ統合済みだが、plugins/ndf-kiro/prompts/clean.md が 残存していた。install.sh は prompts 配下の md を無条件に .kiro/prompts へ コピーするため、削除済み Skill への導線が残ってしまう。 merged.md が「main更新、ブランチ削除」を包含するため clean.md を削除する。 Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_01AGejnYyYFuSkQjBhW2KQNy --- plugins/ndf-kiro/prompts/clean.md | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 plugins/ndf-kiro/prompts/clean.md diff --git a/plugins/ndf-kiro/prompts/clean.md b/plugins/ndf-kiro/prompts/clean.md deleted file mode 100644 index 9ccc684f..00000000 --- a/plugins/ndf-kiro/prompts/clean.md +++ /dev/null @@ -1,3 +0,0 @@ -mainマージ済みブランチをローカル/リモート一括削除してください。 - -cleanスキルの手順に従って実行してください。引数があればそのまま使用します。 From 1e49e01acb41e89dd89289f3b2c22c80d26ccf09 Mon Sep 17 00:00:00 2001 From: "takemi.ohama" Date: Sat, 8 Aug 2026 03:32:07 +0000 Subject: [PATCH 4/8] =?UTF-8?q?Fix:=20merged=20=E3=81=AE=E7=94=A8=E9=80=94?= =?UTF-8?q?=E5=88=86=E5=B2=90=E3=82=92=E6=98=8E=E7=A4=BA=E3=81=97=E5=BB=83?= =?UTF-8?q?=E6=AD=A2=20prompt=20=E3=81=AE=E9=99=A4=E5=8E=BB=E3=81=A8=20Ski?= =?UTF-8?q?ll=20=E6=95=B0=E8=A1=A8=E8=A8=98=E3=82=92=E4=BF=AE=E6=AD=A3=20(?= =?UTF-8?q?0-4)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - `merged` に「用途の切り分け」を追加。クリーンアップ目的と main 取り込み 目的で手順が分岐することを明示し、未マージ時に main 取り込みが打ち切られ る誤読を防ぐ - `plugins/ndf-kiro/prompts/merged.md` を main 取り込みにも対応した内容へ更新 - `install.sh` に廃止 prompt の除去を追加。過去のインストールで `.kiro/prompts/clean.md` が残り続ける問題を解消 - README のプラグイン一覧の公開 Skill 数を 26 / 25 / 27 に修正(冒頭の記載と 不一致だった) Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_01AGejnYyYFuSkQjBhW2KQNy --- README.md | 2 +- plugins/ndf-claude/skills/merged/SKILL.md | 15 ++++++++++++--- plugins/ndf-codex/skills/merged/SKILL.md | 15 ++++++++++++--- plugins/ndf-kiro/install.sh | 8 ++++++++ plugins/ndf-kiro/prompts/merged.md | 4 ++-- plugins/ndf-kiro/skills/merged/SKILL.md | 15 ++++++++++++--- plugins/ndf-shared/skills/merged/SKILL.md | 15 ++++++++++++--- 7 files changed, 59 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 95981ebd..cb7803e4 100644 --- a/README.md +++ b/README.md @@ -100,7 +100,7 @@ kiro-cli chat | プラグイン名 | バージョン | 説明 | 詳細 | |------------|----------|------|------| -| **ndf** | 4.20.1 | Claude Code / Codex / Kiro CLI 向けに runtime 別配布物を提供する NDF プラグイン。8個の専門エージェント(Claude版)、公開Skills(Claude Code向け core 29個、Kiro向け core 28個、Codex向け core 30個)、Claude SessionStart/Stopフック、Codex/Kiro向け通知・実行補助を提供。v4.0.0 で Codex MCP サーバを廃止し、`/ndf:codex` skill + `corder` エージェント経由の CLI 直接実行に一本化。 | [Claude](./plugins/ndf-claude/README.md) / [Codex](./plugins/ndf-codex/README.md) / [Kiro](./plugins/ndf-kiro/README.md) | +| **ndf** | 4.20.1 | Claude Code / Codex / Kiro CLI 向けに runtime 別配布物を提供する NDF プラグイン。8個の専門エージェント(Claude版)、公開Skills(Claude Code向け core 26個、Kiro向け core 25個、Codex向け core 27個)、Claude SessionStart/Stopフック、Codex/Kiro向け通知・実行補助を提供。v4.0.0 で Codex MCP サーバを廃止し、`/ndf:codex` skill + `corder` エージェント経由の CLI 直接実行に一本化。 | [Claude](./plugins/ndf-claude/README.md) / [Codex](./plugins/ndf-codex/README.md) / [Kiro](./plugins/ndf-kiro/README.md) | ### NDF v4.20.1 の主な変更 diff --git a/plugins/ndf-claude/skills/merged/SKILL.md b/plugins/ndf-claude/skills/merged/SKILL.md index 17568379..70e7afcc 100644 --- a/plugins/ndf-claude/skills/merged/SKILL.md +++ b/plugins/ndf-claude/skills/merged/SKILL.md @@ -12,9 +12,18 @@ allowed-tools: PR マージ後の後始末をまとめて実行する。対象 PR のブランチ削除に加えて、残っているマージ済みブランチの整理と main の取り込みもこの Skill で扱う。 -## 手順 +## 用途の切り分け(最初に判定する) -1. **マージ確認**: 引数の(引数がなければ自身が作成した最新の)PR が main に merge されていることを github mcp で確認。merge されていなければ終了 +| 依頼の意図 | 実行する節 | +|---|---| +| PR マージ後のクリーンアップ / マージ済みブランチの整理 | 「クリーンアップの手順」→ 必要なら「マージ済みブランチの整理」 | +| 作業中ブランチへ最新 main を取り込む | 「main の取り込み」のみ(クリーンアップの手順は実行しない) | + +main 取り込みが目的の場合、対象 PR は未マージであるのが通常のため、「クリーンアップの手順」の手順 1 で終了してはならない。 + +## クリーンアップの手順 + +1. **マージ確認**: 引数の(引数がなければ自身が作成した最新の)PR が main に merge されていることを github mcp で確認。merge されていなければクリーンアップは実施せず終了 2. **作業ツリー退避**: `git status` を確認し、変更があれば `git stash` 3. **main 更新**: `git checkout main` → `git pull` 4. **worktree クリーンアップ**: `git worktree list` で当該 PR 番号に対応する worktree (`pr`) を探し、あれば `git worktree remove ` で削除(worktree 内の `.cross_review/` も一緒に消える) @@ -38,7 +47,7 @@ git push origin --delete # 3. リモートにも残っていれば削 ## main の取り込み -作業中のブランチへ最新のデフォルトブランチ (main/master) を取り込む場合はこちらを使う。 +作業中のブランチへ最新のデフォルトブランチ (main/master) を取り込む場合はこちらを使う。PR のマージ有無は前提条件にしない。 1. **ブランチ確認**: `git branch --show-current`。デフォルトブランチ自身なら `git pull` のみ実行して終了 2. **作業ツリー確認**: 未コミット変更があれば `git stash` で退避 diff --git a/plugins/ndf-codex/skills/merged/SKILL.md b/plugins/ndf-codex/skills/merged/SKILL.md index 17568379..70e7afcc 100644 --- a/plugins/ndf-codex/skills/merged/SKILL.md +++ b/plugins/ndf-codex/skills/merged/SKILL.md @@ -12,9 +12,18 @@ allowed-tools: PR マージ後の後始末をまとめて実行する。対象 PR のブランチ削除に加えて、残っているマージ済みブランチの整理と main の取り込みもこの Skill で扱う。 -## 手順 +## 用途の切り分け(最初に判定する) -1. **マージ確認**: 引数の(引数がなければ自身が作成した最新の)PR が main に merge されていることを github mcp で確認。merge されていなければ終了 +| 依頼の意図 | 実行する節 | +|---|---| +| PR マージ後のクリーンアップ / マージ済みブランチの整理 | 「クリーンアップの手順」→ 必要なら「マージ済みブランチの整理」 | +| 作業中ブランチへ最新 main を取り込む | 「main の取り込み」のみ(クリーンアップの手順は実行しない) | + +main 取り込みが目的の場合、対象 PR は未マージであるのが通常のため、「クリーンアップの手順」の手順 1 で終了してはならない。 + +## クリーンアップの手順 + +1. **マージ確認**: 引数の(引数がなければ自身が作成した最新の)PR が main に merge されていることを github mcp で確認。merge されていなければクリーンアップは実施せず終了 2. **作業ツリー退避**: `git status` を確認し、変更があれば `git stash` 3. **main 更新**: `git checkout main` → `git pull` 4. **worktree クリーンアップ**: `git worktree list` で当該 PR 番号に対応する worktree (`pr`) を探し、あれば `git worktree remove ` で削除(worktree 内の `.cross_review/` も一緒に消える) @@ -38,7 +47,7 @@ git push origin --delete # 3. リモートにも残っていれば削 ## main の取り込み -作業中のブランチへ最新のデフォルトブランチ (main/master) を取り込む場合はこちらを使う。 +作業中のブランチへ最新のデフォルトブランチ (main/master) を取り込む場合はこちらを使う。PR のマージ有無は前提条件にしない。 1. **ブランチ確認**: `git branch --show-current`。デフォルトブランチ自身なら `git pull` のみ実行して終了 2. **作業ツリー確認**: 未コミット変更があれば `git stash` で退避 diff --git a/plugins/ndf-kiro/install.sh b/plugins/ndf-kiro/install.sh index 8c8a3823..06fe2327 100755 --- a/plugins/ndf-kiro/install.sh +++ b/plugins/ndf-kiro/install.sh @@ -13,6 +13,8 @@ AGENT_FILE="$KIRO_DIR/agents/default.json" TEMPLATE_FILE="$PLUGIN_DIR/agents/default.json.template" PLUGIN_SKILLS_DIR="$PLUGIN_DIR/skills" PLUGIN_PROMPTS_DIR="$PLUGIN_DIR/prompts" +# Skill 統合により配布を終えた prompt。過去のインストールで .kiro/prompts/ に残った分を除去する +DEPRECATED_PROMPTS="clean.md" # Parse options WITH_SLACK=false @@ -102,6 +104,12 @@ if [ "$DRY_RUN" = false ]; then if [ "$WITH_CODEX" = false ]; then rm -f "$PROMPTS_DIR/codex.md" fi + for deprecated_prompt in $DEPRECATED_PROMPTS; do + if [ -f "$PROMPTS_DIR/$deprecated_prompt" ]; then + rm -f "$PROMPTS_DIR/$deprecated_prompt" + echo " removed (deprecated): ${deprecated_prompt%.md}" + fi + done fi while IFS= read -r prompt_file; do diff --git a/plugins/ndf-kiro/prompts/merged.md b/plugins/ndf-kiro/prompts/merged.md index 8efb8651..f0a15833 100644 --- a/plugins/ndf-kiro/prompts/merged.md +++ b/plugins/ndf-kiro/prompts/merged.md @@ -1,3 +1,3 @@ -PRマージ後のクリーンアップを実行してください(main更新、ブランチ削除)。 +PRマージ後のクリーンアップ(main更新、worktree/ブランチ削除)、または作業中ブランチへの main 取り込みを実行してください。 -mergedスキルの手順に従って実行してください。引数があればそのまま使用します。 +mergedスキルの「用途の切り分け」で依頼の意図を判定し、該当する節の手順に従って実行してください。引数があればそのまま使用します。 diff --git a/plugins/ndf-kiro/skills/merged/SKILL.md b/plugins/ndf-kiro/skills/merged/SKILL.md index 17568379..70e7afcc 100644 --- a/plugins/ndf-kiro/skills/merged/SKILL.md +++ b/plugins/ndf-kiro/skills/merged/SKILL.md @@ -12,9 +12,18 @@ allowed-tools: PR マージ後の後始末をまとめて実行する。対象 PR のブランチ削除に加えて、残っているマージ済みブランチの整理と main の取り込みもこの Skill で扱う。 -## 手順 +## 用途の切り分け(最初に判定する) -1. **マージ確認**: 引数の(引数がなければ自身が作成した最新の)PR が main に merge されていることを github mcp で確認。merge されていなければ終了 +| 依頼の意図 | 実行する節 | +|---|---| +| PR マージ後のクリーンアップ / マージ済みブランチの整理 | 「クリーンアップの手順」→ 必要なら「マージ済みブランチの整理」 | +| 作業中ブランチへ最新 main を取り込む | 「main の取り込み」のみ(クリーンアップの手順は実行しない) | + +main 取り込みが目的の場合、対象 PR は未マージであるのが通常のため、「クリーンアップの手順」の手順 1 で終了してはならない。 + +## クリーンアップの手順 + +1. **マージ確認**: 引数の(引数がなければ自身が作成した最新の)PR が main に merge されていることを github mcp で確認。merge されていなければクリーンアップは実施せず終了 2. **作業ツリー退避**: `git status` を確認し、変更があれば `git stash` 3. **main 更新**: `git checkout main` → `git pull` 4. **worktree クリーンアップ**: `git worktree list` で当該 PR 番号に対応する worktree (`pr`) を探し、あれば `git worktree remove ` で削除(worktree 内の `.cross_review/` も一緒に消える) @@ -38,7 +47,7 @@ git push origin --delete # 3. リモートにも残っていれば削 ## main の取り込み -作業中のブランチへ最新のデフォルトブランチ (main/master) を取り込む場合はこちらを使う。 +作業中のブランチへ最新のデフォルトブランチ (main/master) を取り込む場合はこちらを使う。PR のマージ有無は前提条件にしない。 1. **ブランチ確認**: `git branch --show-current`。デフォルトブランチ自身なら `git pull` のみ実行して終了 2. **作業ツリー確認**: 未コミット変更があれば `git stash` で退避 diff --git a/plugins/ndf-shared/skills/merged/SKILL.md b/plugins/ndf-shared/skills/merged/SKILL.md index 17568379..70e7afcc 100644 --- a/plugins/ndf-shared/skills/merged/SKILL.md +++ b/plugins/ndf-shared/skills/merged/SKILL.md @@ -12,9 +12,18 @@ allowed-tools: PR マージ後の後始末をまとめて実行する。対象 PR のブランチ削除に加えて、残っているマージ済みブランチの整理と main の取り込みもこの Skill で扱う。 -## 手順 +## 用途の切り分け(最初に判定する) -1. **マージ確認**: 引数の(引数がなければ自身が作成した最新の)PR が main に merge されていることを github mcp で確認。merge されていなければ終了 +| 依頼の意図 | 実行する節 | +|---|---| +| PR マージ後のクリーンアップ / マージ済みブランチの整理 | 「クリーンアップの手順」→ 必要なら「マージ済みブランチの整理」 | +| 作業中ブランチへ最新 main を取り込む | 「main の取り込み」のみ(クリーンアップの手順は実行しない) | + +main 取り込みが目的の場合、対象 PR は未マージであるのが通常のため、「クリーンアップの手順」の手順 1 で終了してはならない。 + +## クリーンアップの手順 + +1. **マージ確認**: 引数の(引数がなければ自身が作成した最新の)PR が main に merge されていることを github mcp で確認。merge されていなければクリーンアップは実施せず終了 2. **作業ツリー退避**: `git status` を確認し、変更があれば `git stash` 3. **main 更新**: `git checkout main` → `git pull` 4. **worktree クリーンアップ**: `git worktree list` で当該 PR 番号に対応する worktree (`pr`) を探し、あれば `git worktree remove ` で削除(worktree 内の `.cross_review/` も一緒に消える) @@ -38,7 +47,7 @@ git push origin --delete # 3. リモートにも残っていれば削 ## main の取り込み -作業中のブランチへ最新のデフォルトブランチ (main/master) を取り込む場合はこちらを使う。 +作業中のブランチへ最新のデフォルトブランチ (main/master) を取り込む場合はこちらを使う。PR のマージ有無は前提条件にしない。 1. **ブランチ確認**: `git branch --show-current`。デフォルトブランチ自身なら `git pull` のみ実行して終了 2. **作業ツリー確認**: 未コミット変更があれば `git stash` で退避 From d6286b44256f07ce89a6d6d3310dec348ef8e0ff Mon Sep 17 00:00:00 2001 From: "takemi.ohama" Date: Sat, 8 Aug 2026 04:01:40 +0000 Subject: [PATCH 5/8] =?UTF-8?q?Docs:=20Task=200-7=20=E3=81=AB=E6=A0=B8?= =?UTF-8?q?=E5=BF=83=E3=83=AB=E3=83=BC=E3=83=AB=E3=81=AE=20ndf-policies=20?= =?UTF-8?q?=E7=A7=BB=E8=AD=B2=E3=82=92=E8=BF=BD=E8=A8=98=20(0-4)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 0-4 で `cherry-pick-pr` へ統合した `branch-fix-strategy` 由来の核心ルールは、 `disable-model-invocation: true` の Skill 内にあるため自然文の質問から参照できない。 Task 0-7 の変更内容に、常時読み込まれる `ndf-policies` への移譲を明記する。 Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_01AGejnYyYFuSkQjBhW2KQNy --- issues/ndf-development-skills/07-tasks.md | 1 + 1 file changed, 1 insertion(+) diff --git a/issues/ndf-development-skills/07-tasks.md b/issues/ndf-development-skills/07-tasks.md index a30a3371..41eff177 100644 --- a/issues/ndf-development-skills/07-tasks.md +++ b/issues/ndf-development-skills/07-tasks.md @@ -45,6 +45,7 @@ - **変更内容:** - `merged` / `pr` / `review` / `pr-tests` から `disable-model-invocation` を外し、`description` に発動条件を含める - `deploy` と `cherry-pick-pr` 相当の破壊的操作は明示指示専用を維持する + - 0-4 で `cherry-pick-pr` に統合した `branch-fix-strategy` 由来の核心ルール(環境ブランチへの適用原則、ブランチ汚染の回避)を、常時読み込まれる `ndf-policies` へ移す。明示指示専用の Skill に閉じ込めた知識が自然文の質問から参照できなくなる退行を防ぐ - 主要トリガは `description` に入れる。`when_to_use` は Claude Code 向けの追加トリガが要る Skill にだけ付与し、`description` で足りるものには付けない([03-runtime-conformance.md](03-runtime-conformance.md)) - `plan-to-spec` の長い `description` は要点を残して `when_to_use` へ移す。`cross-review` は逆に、`when_to_use` に置いた明示トリガの要点を `description` へ移す - 広すぎるトリガを具体化する From bc46bbc3913915bc5e3077cf1b269ad3cef77a8e Mon Sep 17 00:00:00 2001 From: "takemi.ohama" Date: Sat, 8 Aug 2026 04:13:55 +0000 Subject: [PATCH 6/8] =?UTF-8?q?Fix:=20merged=20Skill=20=E3=81=AB=E3=80=8C?= =?UTF-8?q?=E3=83=9E=E3=83=BC=E3=82=B8=E6=B8=88=E3=81=BF=E3=83=96=E3=83=A9?= =?UTF-8?q?=E3=83=B3=E3=83=81=E3=81=AE=E6=95=B4=E7=90=86=E3=81=AE=E3=81=BF?= =?UTF-8?q?=E3=80=8D=E3=81=AE=E5=88=86=E5=B2=90=E3=82=92=E8=BF=BD=E5=8A=A0?= =?UTF-8?q?=20(0-4)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit clean を merged へ統合した際、PR のマージ状態に依存せず単独実行できた 「マージ済みブランチの整理のみ」の導線が失われていた(機能の退行)。 - 用途の切り分け表に「マージ済みブランチの整理のみ」の行を追加 - 「マージ済みブランチの整理」節が単独で実行可能であり、 手順 1(PR のマージ確認)を前提にしないことを本文で明記 - build-runtime-plugins.sh で 3 ランタイムの生成物へ反映 Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_01AGejnYyYFuSkQjBhW2KQNy --- plugins/ndf-claude/skills/merged/SKILL.md | 11 +++++++++-- plugins/ndf-codex/skills/merged/SKILL.md | 11 +++++++++-- plugins/ndf-kiro/skills/merged/SKILL.md | 11 +++++++++-- plugins/ndf-shared/skills/merged/SKILL.md | 11 +++++++++-- 4 files changed, 36 insertions(+), 8 deletions(-) diff --git a/plugins/ndf-claude/skills/merged/SKILL.md b/plugins/ndf-claude/skills/merged/SKILL.md index 70e7afcc..343b428e 100644 --- a/plugins/ndf-claude/skills/merged/SKILL.md +++ b/plugins/ndf-claude/skills/merged/SKILL.md @@ -16,10 +16,13 @@ PR マージ後の後始末をまとめて実行する。対象 PR のブラン | 依頼の意図 | 実行する節 | |---|---| -| PR マージ後のクリーンアップ / マージ済みブランチの整理 | 「クリーンアップの手順」→ 必要なら「マージ済みブランチの整理」 | +| PR マージ後のクリーンアップ | 「クリーンアップの手順」→ 必要なら「マージ済みブランチの整理」 | +| マージ済みブランチの整理のみ | 「マージ済みブランチの整理」のみ(クリーンアップの手順は実行しない) | | 作業中ブランチへ最新 main を取り込む | 「main の取り込み」のみ(クリーンアップの手順は実行しない) | -main 取り込みが目的の場合、対象 PR は未マージであるのが通常のため、「クリーンアップの手順」の手順 1 で終了してはならない。 +「クリーンアップの手順」以外を目的とする場合、対象 PR は未マージであるのが通常のため、 +手順 1(PR のマージ確認)を前提条件にしてはならない。「マージ済みブランチの整理」と +「main の取り込み」はいずれも **単独で実行可能** で、PR のマージ状態に依存しない。 ## クリーンアップの手順 @@ -35,6 +38,10 @@ main 取り込みが目的の場合、対象 PR は未マージであるのが ## マージ済みブランチの整理 +残存するマージ済みブランチをまとめて削除する。**単独で実行可能**な節であり、 +「クリーンアップの手順」の手順 1(PR のマージ確認)を前提にしない。 +OPEN な PR が残っている状態でも、ブランチ整理だけを目的に実行してよい。 + ```bash git branch --merged main # 1. マージ済みブランチを列挙 git branch -d # 2. ローカル削除 diff --git a/plugins/ndf-codex/skills/merged/SKILL.md b/plugins/ndf-codex/skills/merged/SKILL.md index 70e7afcc..343b428e 100644 --- a/plugins/ndf-codex/skills/merged/SKILL.md +++ b/plugins/ndf-codex/skills/merged/SKILL.md @@ -16,10 +16,13 @@ PR マージ後の後始末をまとめて実行する。対象 PR のブラン | 依頼の意図 | 実行する節 | |---|---| -| PR マージ後のクリーンアップ / マージ済みブランチの整理 | 「クリーンアップの手順」→ 必要なら「マージ済みブランチの整理」 | +| PR マージ後のクリーンアップ | 「クリーンアップの手順」→ 必要なら「マージ済みブランチの整理」 | +| マージ済みブランチの整理のみ | 「マージ済みブランチの整理」のみ(クリーンアップの手順は実行しない) | | 作業中ブランチへ最新 main を取り込む | 「main の取り込み」のみ(クリーンアップの手順は実行しない) | -main 取り込みが目的の場合、対象 PR は未マージであるのが通常のため、「クリーンアップの手順」の手順 1 で終了してはならない。 +「クリーンアップの手順」以外を目的とする場合、対象 PR は未マージであるのが通常のため、 +手順 1(PR のマージ確認)を前提条件にしてはならない。「マージ済みブランチの整理」と +「main の取り込み」はいずれも **単独で実行可能** で、PR のマージ状態に依存しない。 ## クリーンアップの手順 @@ -35,6 +38,10 @@ main 取り込みが目的の場合、対象 PR は未マージであるのが ## マージ済みブランチの整理 +残存するマージ済みブランチをまとめて削除する。**単独で実行可能**な節であり、 +「クリーンアップの手順」の手順 1(PR のマージ確認)を前提にしない。 +OPEN な PR が残っている状態でも、ブランチ整理だけを目的に実行してよい。 + ```bash git branch --merged main # 1. マージ済みブランチを列挙 git branch -d # 2. ローカル削除 diff --git a/plugins/ndf-kiro/skills/merged/SKILL.md b/plugins/ndf-kiro/skills/merged/SKILL.md index 70e7afcc..343b428e 100644 --- a/plugins/ndf-kiro/skills/merged/SKILL.md +++ b/plugins/ndf-kiro/skills/merged/SKILL.md @@ -16,10 +16,13 @@ PR マージ後の後始末をまとめて実行する。対象 PR のブラン | 依頼の意図 | 実行する節 | |---|---| -| PR マージ後のクリーンアップ / マージ済みブランチの整理 | 「クリーンアップの手順」→ 必要なら「マージ済みブランチの整理」 | +| PR マージ後のクリーンアップ | 「クリーンアップの手順」→ 必要なら「マージ済みブランチの整理」 | +| マージ済みブランチの整理のみ | 「マージ済みブランチの整理」のみ(クリーンアップの手順は実行しない) | | 作業中ブランチへ最新 main を取り込む | 「main の取り込み」のみ(クリーンアップの手順は実行しない) | -main 取り込みが目的の場合、対象 PR は未マージであるのが通常のため、「クリーンアップの手順」の手順 1 で終了してはならない。 +「クリーンアップの手順」以外を目的とする場合、対象 PR は未マージであるのが通常のため、 +手順 1(PR のマージ確認)を前提条件にしてはならない。「マージ済みブランチの整理」と +「main の取り込み」はいずれも **単独で実行可能** で、PR のマージ状態に依存しない。 ## クリーンアップの手順 @@ -35,6 +38,10 @@ main 取り込みが目的の場合、対象 PR は未マージであるのが ## マージ済みブランチの整理 +残存するマージ済みブランチをまとめて削除する。**単独で実行可能**な節であり、 +「クリーンアップの手順」の手順 1(PR のマージ確認)を前提にしない。 +OPEN な PR が残っている状態でも、ブランチ整理だけを目的に実行してよい。 + ```bash git branch --merged main # 1. マージ済みブランチを列挙 git branch -d # 2. ローカル削除 diff --git a/plugins/ndf-shared/skills/merged/SKILL.md b/plugins/ndf-shared/skills/merged/SKILL.md index 70e7afcc..343b428e 100644 --- a/plugins/ndf-shared/skills/merged/SKILL.md +++ b/plugins/ndf-shared/skills/merged/SKILL.md @@ -16,10 +16,13 @@ PR マージ後の後始末をまとめて実行する。対象 PR のブラン | 依頼の意図 | 実行する節 | |---|---| -| PR マージ後のクリーンアップ / マージ済みブランチの整理 | 「クリーンアップの手順」→ 必要なら「マージ済みブランチの整理」 | +| PR マージ後のクリーンアップ | 「クリーンアップの手順」→ 必要なら「マージ済みブランチの整理」 | +| マージ済みブランチの整理のみ | 「マージ済みブランチの整理」のみ(クリーンアップの手順は実行しない) | | 作業中ブランチへ最新 main を取り込む | 「main の取り込み」のみ(クリーンアップの手順は実行しない) | -main 取り込みが目的の場合、対象 PR は未マージであるのが通常のため、「クリーンアップの手順」の手順 1 で終了してはならない。 +「クリーンアップの手順」以外を目的とする場合、対象 PR は未マージであるのが通常のため、 +手順 1(PR のマージ確認)を前提条件にしてはならない。「マージ済みブランチの整理」と +「main の取り込み」はいずれも **単独で実行可能** で、PR のマージ状態に依存しない。 ## クリーンアップの手順 @@ -35,6 +38,10 @@ main 取り込みが目的の場合、対象 PR は未マージであるのが ## マージ済みブランチの整理 +残存するマージ済みブランチをまとめて削除する。**単独で実行可能**な節であり、 +「クリーンアップの手順」の手順 1(PR のマージ確認)を前提にしない。 +OPEN な PR が残っている状態でも、ブランチ整理だけを目的に実行してよい。 + ```bash git branch --merged main # 1. マージ済みブランチを列挙 git branch -d # 2. ローカル削除 From 006ecff2daaa807f2ea8bd65be42f2ac7c226f96 Mon Sep 17 00:00:00 2001 From: "takemi.ohama" Date: Sat, 8 Aug 2026 04:26:08 +0000 Subject: [PATCH 7/8] =?UTF-8?q?Fix:=20stash=20=E5=BE=A9=E5=85=83=E5=85=88?= =?UTF-8?q?=E3=81=AE=E8=AA=A4=E3=82=8A=E3=82=92=E4=BF=AE=E6=AD=A3=E3=81=97?= =?UTF-8?q?=E3=83=96=E3=83=A9=E3=83=B3=E3=83=81=E9=81=8B=E7=94=A8=E3=81=AE?= =?UTF-8?q?=E5=8E=9F=E5=89=87=E3=82=92=20ndf-policies=20=E3=81=B8=E7=A7=BB?= =?UTF-8?q?=E8=AD=B2=20(0-4)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - merged Skill: main へ checkout したまま stash pop すると元ブランチの 未コミット変更が main に展開される問題を修正。退避元ブランチを記録し、 残っていれば checkout してから pop、削除済みなら pop せず報告する - branch-fix-strategy 由来の核心ルール(環境ブランチ適用の原則、 ブランチ汚染回避、revert の扱い)を ndf-policies へ移譲 - cherry-pick-pr は実行手順を残し、原則は ndf-policies を参照する形へ - 07-tasks.md: Task 0-7 の ndf-policies 移譲項目を削除し 0-4 の注意点へ移動 --- issues/ndf-development-skills/07-tasks.md | 3 +-- plugins/ndf-claude/skills/cherry-pick-pr/SKILL.md | 15 ++++++++++----- plugins/ndf-claude/skills/merged/SKILL.md | 7 +++++-- plugins/ndf-claude/skills/ndf-policies/SKILL.md | 13 +++++++++++-- plugins/ndf-codex/skills/cherry-pick-pr/SKILL.md | 15 ++++++++++----- plugins/ndf-codex/skills/merged/SKILL.md | 7 +++++-- plugins/ndf-codex/skills/ndf-policies/SKILL.md | 13 +++++++++++-- plugins/ndf-kiro/skills/cherry-pick-pr/SKILL.md | 15 ++++++++++----- plugins/ndf-kiro/skills/merged/SKILL.md | 7 +++++-- plugins/ndf-kiro/skills/ndf-policies/SKILL.md | 13 +++++++++++-- plugins/ndf-shared/skills/cherry-pick-pr/SKILL.md | 15 ++++++++++----- plugins/ndf-shared/skills/merged/SKILL.md | 7 +++++-- plugins/ndf-shared/skills/ndf-policies/SKILL.md | 13 +++++++++++-- 13 files changed, 105 insertions(+), 38 deletions(-) diff --git a/issues/ndf-development-skills/07-tasks.md b/issues/ndf-development-skills/07-tasks.md index 41eff177..4db937bb 100644 --- a/issues/ndf-development-skills/07-tasks.md +++ b/issues/ndf-development-skills/07-tasks.md @@ -35,7 +35,7 @@ | --- | --- | | 0-2 | `cross-review` が `fix` をループ内で呼ぶ。呼び出し規約を壊さない。`review` は `--branch` 引数でローカル差分レビューに切り替える | | 0-3 | 外部 AI 呼び出しの差分を `references/cli-codex.md` / `references/cli-gemini.md` に分離する。`cross-review` は両方を呼ぶため呼び出し箇所を更新する | -| 0-4 | 起動 247 回の `merged` を残し、`clean` を吸収する。改名しない。`cherry-pick-pr`(16 回) に `branch-fix-strategy`(4 回) を吸収し、実行コマンド側の名前を残す | +| 0-4 | 起動 247 回の `merged` を残し、`clean` を吸収する。改名しない。`cherry-pick-pr`(16 回) に `branch-fix-strategy`(4 回) を吸収し、実行コマンド側の名前を残す。`cherry-pick-pr` は明示指示専用のため、`branch-fix-strategy` 由来の核心ルール(環境ブランチへの適用原則、ブランチ汚染の回避)は常時読み込まれる `ndf-policies` へ移し、自然文の質問から参照できなくなる退行を防ぐ | | 0-5 | ブラウザ自動テストは [02-skill-inventory.md](02-skill-inventory.md) の対応表どおり 4 個へまとめる。`playwright-kit-ops` は実行環境ディレクトリとスクリプトを持つため単独で残し、`build-runtime-plugins.sh` の除外パターンが効く配置を保つ | | 0-6 | 削除対象は台帳で削除判定した 9 個に限り、判定は [02-skill-inventory.md](02-skill-inventory.md) の判断基準表に従う。うち `sync-main` は 0-4 で処理するため、この PR の対象は 8 個 | @@ -45,7 +45,6 @@ - **変更内容:** - `merged` / `pr` / `review` / `pr-tests` から `disable-model-invocation` を外し、`description` に発動条件を含める - `deploy` と `cherry-pick-pr` 相当の破壊的操作は明示指示専用を維持する - - 0-4 で `cherry-pick-pr` に統合した `branch-fix-strategy` 由来の核心ルール(環境ブランチへの適用原則、ブランチ汚染の回避)を、常時読み込まれる `ndf-policies` へ移す。明示指示専用の Skill に閉じ込めた知識が自然文の質問から参照できなくなる退行を防ぐ - 主要トリガは `description` に入れる。`when_to_use` は Claude Code 向けの追加トリガが要る Skill にだけ付与し、`description` で足りるものには付けない([03-runtime-conformance.md](03-runtime-conformance.md)) - `plan-to-spec` の長い `description` は要点を残して `when_to_use` へ移す。`cross-review` は逆に、`when_to_use` に置いた明示トリガの要点を `description` へ移す - 広すぎるトリガを具体化する diff --git a/plugins/ndf-claude/skills/cherry-pick-pr/SKILL.md b/plugins/ndf-claude/skills/cherry-pick-pr/SKILL.md index b44ff420..1de3823b 100644 --- a/plugins/ndf-claude/skills/cherry-pick-pr/SKILL.md +++ b/plugins/ndf-claude/skills/cherry-pick-pr/SKILL.md @@ -32,10 +32,14 @@ featureブランチに環境ブランチ(`qa/staging`等)を merge して confli ## 核心ルール -1. **修正は feature ブランチに先に commit し、cherry-pick で環境ブランチへ届ける。** 短命ブランチに先に commit して feature へ手作業で再実装すると、二重作業と不整合の原因になる -2. **環境ブランチを feature ブランチに merge しない。** conflict 解消目的でも禁止(main汚染の原因) -3. **短命ブランチを push する前に `origin/main` を必ず取り込む。** CI で最新 main 必須の Workflow があるため(処理フロー 5) -4. **マージ済みブランチには push しない。** 同名の短命ブランチに既存 PR がないか先に確認する(処理フロー 2) +原則は `ndf-policies`「ブランチ運用の原則」に定義されている。本 Skill の処理フローはその原則を手順へ落としたもので、対応は次のとおり。 + +| 原則 | 対応する処理フロー | +|------|------------------| +| feature に先に commit し cherry-pick で届ける | 3・6 | +| 環境ブランチを feature に merge しない | 「なぜ必要か」 | +| push 前に `origin/main` を取り込む | 5 | +| マージ済みブランチには push しない | 2 | ## 処理フロー @@ -121,10 +125,11 @@ git checkout - 短命ブランチは PR マージ後に削除してよい - `feature → main` の PR には影響しない -- revert の連鎖(revert → reapply → revert...)ではなく、**最終的なあるべき状態を直接コミット**する。履歴上の意図が明確になり、後の cherry-pick も簡単になる +- revert の扱いは `ndf-policies`「ブランチ運用の原則」5 に従う ## 関連 +- `ndf-policies` — 環境ブランチへの適用原則とブランチ汚染の回避(本 Skill の前提) - `/ndf:pr` — 通常のPR作成(base=main)。非 main ベースは本 Skill に誘導される - `/ndf:merged` — マージ後のブランチ整理と、現ブランチへの main 取り込み - `/ndf:deploy` — ブランチ全体を環境へデプロイ(cherry-pickとは別用途) diff --git a/plugins/ndf-claude/skills/merged/SKILL.md b/plugins/ndf-claude/skills/merged/SKILL.md index 343b428e..78891b9e 100644 --- a/plugins/ndf-claude/skills/merged/SKILL.md +++ b/plugins/ndf-claude/skills/merged/SKILL.md @@ -27,12 +27,14 @@ PR マージ後の後始末をまとめて実行する。対象 PR のブラン ## クリーンアップの手順 1. **マージ確認**: 引数の(引数がなければ自身が作成した最新の)PR が main に merge されていることを github mcp で確認。merge されていなければクリーンアップは実施せず終了 -2. **作業ツリー退避**: `git status` を確認し、変更があれば `git stash` +2. **作業ツリー退避**: `git branch --show-current` で**退避元のブランチ名を記録**し、`git status` を確認して変更があれば `git stash` 3. **main 更新**: `git checkout main` → `git pull` 4. **worktree クリーンアップ**: `git worktree list` で当該 PR 番号に対応する worktree (`pr`) を探し、あれば `git worktree remove ` で削除(worktree 内の `.cross_review/` も一緒に消える) 5. **ブランチ削除**: `git branch -d ` 6. **マージ済みブランチの整理**: 下記の手順で残存ブランチをまとめて削除 -7. **復元**: 手順 2 で stash していれば `git stash pop` +7. **復元**: 手順 2 で stash していれば、**退避元のブランチへ戻してから**復元する + - 退避元のブランチが残っている場合: `git checkout <退避元のブランチ>` → `git stash pop` + - 退避元のブランチを手順 5 / 6 で削除した場合: **`git stash pop` を実行しない**。手順 3 以降は main に居るため、そのまま pop すると無関係な変更が main の作業ツリーへ展開される。stash は残したまま `git stash list` の該当エントリを作業完了報告に記載し、復元先ブランチの作成か破棄かをユーザーに判断してもらう **注意**: 冪等性保証・エラー時中断・削除済み無視 @@ -67,6 +69,7 @@ git push origin --delete # 3. リモートにも残っていれば削 - 実行サマリー(PR タイトル、マージコミット、削除したブランチ、現在のブランチ) - main ブランチの状態 +- 復元していない stash が残っている場合はその旨と `git stash list` の該当エントリ - PR URL ## 関連 diff --git a/plugins/ndf-claude/skills/ndf-policies/SKILL.md b/plugins/ndf-claude/skills/ndf-policies/SKILL.md index eb25c338..ab8becf5 100644 --- a/plugins/ndf-claude/skills/ndf-policies/SKILL.md +++ b/plugins/ndf-claude/skills/ndf-policies/SKILL.md @@ -1,10 +1,19 @@ --- name: ndf-policies -description: "Apply core NDF project policies." +description: "Apply core NDF project policies, including the branch strategy for applying the same fix to environment branches (qa/staging/release) without contaminating feature branches." user-invocable: false --- # NDFポリシー このスキルはNDFプラグインの基本ポリシーを定義します。 -descriptionフィールドが常時コンテキストに注入されるため、本文の参照は不要です。 + +## ブランチ運用の原則 + +環境ブランチ(`qa/*`, `staging/*`, `release/*`)へ同じ修正を適用する場面全般に適用する。実行手順は `/ndf:cherry-pick-pr` にある。 + +1. **修正は feature ブランチに先に commit し、cherry-pick で環境ブランチへ届ける。** 短命ブランチに先に commit して feature へ再実装すると、二重作業と不整合の原因になる +2. **環境ブランチを feature ブランチに merge しない。** conflict 解消目的でも禁止。`feature → main` の PR へ環境固有コードが混入する(ブランチ汚染) +3. **短命ブランチを push する前に `origin/main` を取り込む。** CI に最新 main 必須の Workflow があるため +4. **マージ済みブランチには push しない。** 既存 PR の状態を確認し、マージ済みなら新ブランチ + 新 PR を作る(サフィックス `-v2`, `-v3`) +5. **revert を連鎖させない。** 最終的なあるべき状態を直接コミットする方が履歴上の意図が明確になり、後の cherry-pick も簡単になる diff --git a/plugins/ndf-codex/skills/cherry-pick-pr/SKILL.md b/plugins/ndf-codex/skills/cherry-pick-pr/SKILL.md index b44ff420..1de3823b 100644 --- a/plugins/ndf-codex/skills/cherry-pick-pr/SKILL.md +++ b/plugins/ndf-codex/skills/cherry-pick-pr/SKILL.md @@ -32,10 +32,14 @@ featureブランチに環境ブランチ(`qa/staging`等)を merge して confli ## 核心ルール -1. **修正は feature ブランチに先に commit し、cherry-pick で環境ブランチへ届ける。** 短命ブランチに先に commit して feature へ手作業で再実装すると、二重作業と不整合の原因になる -2. **環境ブランチを feature ブランチに merge しない。** conflict 解消目的でも禁止(main汚染の原因) -3. **短命ブランチを push する前に `origin/main` を必ず取り込む。** CI で最新 main 必須の Workflow があるため(処理フロー 5) -4. **マージ済みブランチには push しない。** 同名の短命ブランチに既存 PR がないか先に確認する(処理フロー 2) +原則は `ndf-policies`「ブランチ運用の原則」に定義されている。本 Skill の処理フローはその原則を手順へ落としたもので、対応は次のとおり。 + +| 原則 | 対応する処理フロー | +|------|------------------| +| feature に先に commit し cherry-pick で届ける | 3・6 | +| 環境ブランチを feature に merge しない | 「なぜ必要か」 | +| push 前に `origin/main` を取り込む | 5 | +| マージ済みブランチには push しない | 2 | ## 処理フロー @@ -121,10 +125,11 @@ git checkout - 短命ブランチは PR マージ後に削除してよい - `feature → main` の PR には影響しない -- revert の連鎖(revert → reapply → revert...)ではなく、**最終的なあるべき状態を直接コミット**する。履歴上の意図が明確になり、後の cherry-pick も簡単になる +- revert の扱いは `ndf-policies`「ブランチ運用の原則」5 に従う ## 関連 +- `ndf-policies` — 環境ブランチへの適用原則とブランチ汚染の回避(本 Skill の前提) - `/ndf:pr` — 通常のPR作成(base=main)。非 main ベースは本 Skill に誘導される - `/ndf:merged` — マージ後のブランチ整理と、現ブランチへの main 取り込み - `/ndf:deploy` — ブランチ全体を環境へデプロイ(cherry-pickとは別用途) diff --git a/plugins/ndf-codex/skills/merged/SKILL.md b/plugins/ndf-codex/skills/merged/SKILL.md index 343b428e..78891b9e 100644 --- a/plugins/ndf-codex/skills/merged/SKILL.md +++ b/plugins/ndf-codex/skills/merged/SKILL.md @@ -27,12 +27,14 @@ PR マージ後の後始末をまとめて実行する。対象 PR のブラン ## クリーンアップの手順 1. **マージ確認**: 引数の(引数がなければ自身が作成した最新の)PR が main に merge されていることを github mcp で確認。merge されていなければクリーンアップは実施せず終了 -2. **作業ツリー退避**: `git status` を確認し、変更があれば `git stash` +2. **作業ツリー退避**: `git branch --show-current` で**退避元のブランチ名を記録**し、`git status` を確認して変更があれば `git stash` 3. **main 更新**: `git checkout main` → `git pull` 4. **worktree クリーンアップ**: `git worktree list` で当該 PR 番号に対応する worktree (`pr`) を探し、あれば `git worktree remove ` で削除(worktree 内の `.cross_review/` も一緒に消える) 5. **ブランチ削除**: `git branch -d ` 6. **マージ済みブランチの整理**: 下記の手順で残存ブランチをまとめて削除 -7. **復元**: 手順 2 で stash していれば `git stash pop` +7. **復元**: 手順 2 で stash していれば、**退避元のブランチへ戻してから**復元する + - 退避元のブランチが残っている場合: `git checkout <退避元のブランチ>` → `git stash pop` + - 退避元のブランチを手順 5 / 6 で削除した場合: **`git stash pop` を実行しない**。手順 3 以降は main に居るため、そのまま pop すると無関係な変更が main の作業ツリーへ展開される。stash は残したまま `git stash list` の該当エントリを作業完了報告に記載し、復元先ブランチの作成か破棄かをユーザーに判断してもらう **注意**: 冪等性保証・エラー時中断・削除済み無視 @@ -67,6 +69,7 @@ git push origin --delete # 3. リモートにも残っていれば削 - 実行サマリー(PR タイトル、マージコミット、削除したブランチ、現在のブランチ) - main ブランチの状態 +- 復元していない stash が残っている場合はその旨と `git stash list` の該当エントリ - PR URL ## 関連 diff --git a/plugins/ndf-codex/skills/ndf-policies/SKILL.md b/plugins/ndf-codex/skills/ndf-policies/SKILL.md index eb25c338..ab8becf5 100644 --- a/plugins/ndf-codex/skills/ndf-policies/SKILL.md +++ b/plugins/ndf-codex/skills/ndf-policies/SKILL.md @@ -1,10 +1,19 @@ --- name: ndf-policies -description: "Apply core NDF project policies." +description: "Apply core NDF project policies, including the branch strategy for applying the same fix to environment branches (qa/staging/release) without contaminating feature branches." user-invocable: false --- # NDFポリシー このスキルはNDFプラグインの基本ポリシーを定義します。 -descriptionフィールドが常時コンテキストに注入されるため、本文の参照は不要です。 + +## ブランチ運用の原則 + +環境ブランチ(`qa/*`, `staging/*`, `release/*`)へ同じ修正を適用する場面全般に適用する。実行手順は `/ndf:cherry-pick-pr` にある。 + +1. **修正は feature ブランチに先に commit し、cherry-pick で環境ブランチへ届ける。** 短命ブランチに先に commit して feature へ再実装すると、二重作業と不整合の原因になる +2. **環境ブランチを feature ブランチに merge しない。** conflict 解消目的でも禁止。`feature → main` の PR へ環境固有コードが混入する(ブランチ汚染) +3. **短命ブランチを push する前に `origin/main` を取り込む。** CI に最新 main 必須の Workflow があるため +4. **マージ済みブランチには push しない。** 既存 PR の状態を確認し、マージ済みなら新ブランチ + 新 PR を作る(サフィックス `-v2`, `-v3`) +5. **revert を連鎖させない。** 最終的なあるべき状態を直接コミットする方が履歴上の意図が明確になり、後の cherry-pick も簡単になる diff --git a/plugins/ndf-kiro/skills/cherry-pick-pr/SKILL.md b/plugins/ndf-kiro/skills/cherry-pick-pr/SKILL.md index b44ff420..1de3823b 100644 --- a/plugins/ndf-kiro/skills/cherry-pick-pr/SKILL.md +++ b/plugins/ndf-kiro/skills/cherry-pick-pr/SKILL.md @@ -32,10 +32,14 @@ featureブランチに環境ブランチ(`qa/staging`等)を merge して confli ## 核心ルール -1. **修正は feature ブランチに先に commit し、cherry-pick で環境ブランチへ届ける。** 短命ブランチに先に commit して feature へ手作業で再実装すると、二重作業と不整合の原因になる -2. **環境ブランチを feature ブランチに merge しない。** conflict 解消目的でも禁止(main汚染の原因) -3. **短命ブランチを push する前に `origin/main` を必ず取り込む。** CI で最新 main 必須の Workflow があるため(処理フロー 5) -4. **マージ済みブランチには push しない。** 同名の短命ブランチに既存 PR がないか先に確認する(処理フロー 2) +原則は `ndf-policies`「ブランチ運用の原則」に定義されている。本 Skill の処理フローはその原則を手順へ落としたもので、対応は次のとおり。 + +| 原則 | 対応する処理フロー | +|------|------------------| +| feature に先に commit し cherry-pick で届ける | 3・6 | +| 環境ブランチを feature に merge しない | 「なぜ必要か」 | +| push 前に `origin/main` を取り込む | 5 | +| マージ済みブランチには push しない | 2 | ## 処理フロー @@ -121,10 +125,11 @@ git checkout - 短命ブランチは PR マージ後に削除してよい - `feature → main` の PR には影響しない -- revert の連鎖(revert → reapply → revert...)ではなく、**最終的なあるべき状態を直接コミット**する。履歴上の意図が明確になり、後の cherry-pick も簡単になる +- revert の扱いは `ndf-policies`「ブランチ運用の原則」5 に従う ## 関連 +- `ndf-policies` — 環境ブランチへの適用原則とブランチ汚染の回避(本 Skill の前提) - `/ndf:pr` — 通常のPR作成(base=main)。非 main ベースは本 Skill に誘導される - `/ndf:merged` — マージ後のブランチ整理と、現ブランチへの main 取り込み - `/ndf:deploy` — ブランチ全体を環境へデプロイ(cherry-pickとは別用途) diff --git a/plugins/ndf-kiro/skills/merged/SKILL.md b/plugins/ndf-kiro/skills/merged/SKILL.md index 343b428e..78891b9e 100644 --- a/plugins/ndf-kiro/skills/merged/SKILL.md +++ b/plugins/ndf-kiro/skills/merged/SKILL.md @@ -27,12 +27,14 @@ PR マージ後の後始末をまとめて実行する。対象 PR のブラン ## クリーンアップの手順 1. **マージ確認**: 引数の(引数がなければ自身が作成した最新の)PR が main に merge されていることを github mcp で確認。merge されていなければクリーンアップは実施せず終了 -2. **作業ツリー退避**: `git status` を確認し、変更があれば `git stash` +2. **作業ツリー退避**: `git branch --show-current` で**退避元のブランチ名を記録**し、`git status` を確認して変更があれば `git stash` 3. **main 更新**: `git checkout main` → `git pull` 4. **worktree クリーンアップ**: `git worktree list` で当該 PR 番号に対応する worktree (`pr`) を探し、あれば `git worktree remove ` で削除(worktree 内の `.cross_review/` も一緒に消える) 5. **ブランチ削除**: `git branch -d ` 6. **マージ済みブランチの整理**: 下記の手順で残存ブランチをまとめて削除 -7. **復元**: 手順 2 で stash していれば `git stash pop` +7. **復元**: 手順 2 で stash していれば、**退避元のブランチへ戻してから**復元する + - 退避元のブランチが残っている場合: `git checkout <退避元のブランチ>` → `git stash pop` + - 退避元のブランチを手順 5 / 6 で削除した場合: **`git stash pop` を実行しない**。手順 3 以降は main に居るため、そのまま pop すると無関係な変更が main の作業ツリーへ展開される。stash は残したまま `git stash list` の該当エントリを作業完了報告に記載し、復元先ブランチの作成か破棄かをユーザーに判断してもらう **注意**: 冪等性保証・エラー時中断・削除済み無視 @@ -67,6 +69,7 @@ git push origin --delete # 3. リモートにも残っていれば削 - 実行サマリー(PR タイトル、マージコミット、削除したブランチ、現在のブランチ) - main ブランチの状態 +- 復元していない stash が残っている場合はその旨と `git stash list` の該当エントリ - PR URL ## 関連 diff --git a/plugins/ndf-kiro/skills/ndf-policies/SKILL.md b/plugins/ndf-kiro/skills/ndf-policies/SKILL.md index eb25c338..ab8becf5 100644 --- a/plugins/ndf-kiro/skills/ndf-policies/SKILL.md +++ b/plugins/ndf-kiro/skills/ndf-policies/SKILL.md @@ -1,10 +1,19 @@ --- name: ndf-policies -description: "Apply core NDF project policies." +description: "Apply core NDF project policies, including the branch strategy for applying the same fix to environment branches (qa/staging/release) without contaminating feature branches." user-invocable: false --- # NDFポリシー このスキルはNDFプラグインの基本ポリシーを定義します。 -descriptionフィールドが常時コンテキストに注入されるため、本文の参照は不要です。 + +## ブランチ運用の原則 + +環境ブランチ(`qa/*`, `staging/*`, `release/*`)へ同じ修正を適用する場面全般に適用する。実行手順は `/ndf:cherry-pick-pr` にある。 + +1. **修正は feature ブランチに先に commit し、cherry-pick で環境ブランチへ届ける。** 短命ブランチに先に commit して feature へ再実装すると、二重作業と不整合の原因になる +2. **環境ブランチを feature ブランチに merge しない。** conflict 解消目的でも禁止。`feature → main` の PR へ環境固有コードが混入する(ブランチ汚染) +3. **短命ブランチを push する前に `origin/main` を取り込む。** CI に最新 main 必須の Workflow があるため +4. **マージ済みブランチには push しない。** 既存 PR の状態を確認し、マージ済みなら新ブランチ + 新 PR を作る(サフィックス `-v2`, `-v3`) +5. **revert を連鎖させない。** 最終的なあるべき状態を直接コミットする方が履歴上の意図が明確になり、後の cherry-pick も簡単になる diff --git a/plugins/ndf-shared/skills/cherry-pick-pr/SKILL.md b/plugins/ndf-shared/skills/cherry-pick-pr/SKILL.md index b44ff420..1de3823b 100644 --- a/plugins/ndf-shared/skills/cherry-pick-pr/SKILL.md +++ b/plugins/ndf-shared/skills/cherry-pick-pr/SKILL.md @@ -32,10 +32,14 @@ featureブランチに環境ブランチ(`qa/staging`等)を merge して confli ## 核心ルール -1. **修正は feature ブランチに先に commit し、cherry-pick で環境ブランチへ届ける。** 短命ブランチに先に commit して feature へ手作業で再実装すると、二重作業と不整合の原因になる -2. **環境ブランチを feature ブランチに merge しない。** conflict 解消目的でも禁止(main汚染の原因) -3. **短命ブランチを push する前に `origin/main` を必ず取り込む。** CI で最新 main 必須の Workflow があるため(処理フロー 5) -4. **マージ済みブランチには push しない。** 同名の短命ブランチに既存 PR がないか先に確認する(処理フロー 2) +原則は `ndf-policies`「ブランチ運用の原則」に定義されている。本 Skill の処理フローはその原則を手順へ落としたもので、対応は次のとおり。 + +| 原則 | 対応する処理フロー | +|------|------------------| +| feature に先に commit し cherry-pick で届ける | 3・6 | +| 環境ブランチを feature に merge しない | 「なぜ必要か」 | +| push 前に `origin/main` を取り込む | 5 | +| マージ済みブランチには push しない | 2 | ## 処理フロー @@ -121,10 +125,11 @@ git checkout - 短命ブランチは PR マージ後に削除してよい - `feature → main` の PR には影響しない -- revert の連鎖(revert → reapply → revert...)ではなく、**最終的なあるべき状態を直接コミット**する。履歴上の意図が明確になり、後の cherry-pick も簡単になる +- revert の扱いは `ndf-policies`「ブランチ運用の原則」5 に従う ## 関連 +- `ndf-policies` — 環境ブランチへの適用原則とブランチ汚染の回避(本 Skill の前提) - `/ndf:pr` — 通常のPR作成(base=main)。非 main ベースは本 Skill に誘導される - `/ndf:merged` — マージ後のブランチ整理と、現ブランチへの main 取り込み - `/ndf:deploy` — ブランチ全体を環境へデプロイ(cherry-pickとは別用途) diff --git a/plugins/ndf-shared/skills/merged/SKILL.md b/plugins/ndf-shared/skills/merged/SKILL.md index 343b428e..78891b9e 100644 --- a/plugins/ndf-shared/skills/merged/SKILL.md +++ b/plugins/ndf-shared/skills/merged/SKILL.md @@ -27,12 +27,14 @@ PR マージ後の後始末をまとめて実行する。対象 PR のブラン ## クリーンアップの手順 1. **マージ確認**: 引数の(引数がなければ自身が作成した最新の)PR が main に merge されていることを github mcp で確認。merge されていなければクリーンアップは実施せず終了 -2. **作業ツリー退避**: `git status` を確認し、変更があれば `git stash` +2. **作業ツリー退避**: `git branch --show-current` で**退避元のブランチ名を記録**し、`git status` を確認して変更があれば `git stash` 3. **main 更新**: `git checkout main` → `git pull` 4. **worktree クリーンアップ**: `git worktree list` で当該 PR 番号に対応する worktree (`pr`) を探し、あれば `git worktree remove ` で削除(worktree 内の `.cross_review/` も一緒に消える) 5. **ブランチ削除**: `git branch -d ` 6. **マージ済みブランチの整理**: 下記の手順で残存ブランチをまとめて削除 -7. **復元**: 手順 2 で stash していれば `git stash pop` +7. **復元**: 手順 2 で stash していれば、**退避元のブランチへ戻してから**復元する + - 退避元のブランチが残っている場合: `git checkout <退避元のブランチ>` → `git stash pop` + - 退避元のブランチを手順 5 / 6 で削除した場合: **`git stash pop` を実行しない**。手順 3 以降は main に居るため、そのまま pop すると無関係な変更が main の作業ツリーへ展開される。stash は残したまま `git stash list` の該当エントリを作業完了報告に記載し、復元先ブランチの作成か破棄かをユーザーに判断してもらう **注意**: 冪等性保証・エラー時中断・削除済み無視 @@ -67,6 +69,7 @@ git push origin --delete # 3. リモートにも残っていれば削 - 実行サマリー(PR タイトル、マージコミット、削除したブランチ、現在のブランチ) - main ブランチの状態 +- 復元していない stash が残っている場合はその旨と `git stash list` の該当エントリ - PR URL ## 関連 diff --git a/plugins/ndf-shared/skills/ndf-policies/SKILL.md b/plugins/ndf-shared/skills/ndf-policies/SKILL.md index eb25c338..ab8becf5 100644 --- a/plugins/ndf-shared/skills/ndf-policies/SKILL.md +++ b/plugins/ndf-shared/skills/ndf-policies/SKILL.md @@ -1,10 +1,19 @@ --- name: ndf-policies -description: "Apply core NDF project policies." +description: "Apply core NDF project policies, including the branch strategy for applying the same fix to environment branches (qa/staging/release) without contaminating feature branches." user-invocable: false --- # NDFポリシー このスキルはNDFプラグインの基本ポリシーを定義します。 -descriptionフィールドが常時コンテキストに注入されるため、本文の参照は不要です。 + +## ブランチ運用の原則 + +環境ブランチ(`qa/*`, `staging/*`, `release/*`)へ同じ修正を適用する場面全般に適用する。実行手順は `/ndf:cherry-pick-pr` にある。 + +1. **修正は feature ブランチに先に commit し、cherry-pick で環境ブランチへ届ける。** 短命ブランチに先に commit して feature へ再実装すると、二重作業と不整合の原因になる +2. **環境ブランチを feature ブランチに merge しない。** conflict 解消目的でも禁止。`feature → main` の PR へ環境固有コードが混入する(ブランチ汚染) +3. **短命ブランチを push する前に `origin/main` を取り込む。** CI に最新 main 必須の Workflow があるため +4. **マージ済みブランチには push しない。** 既存 PR の状態を確認し、マージ済みなら新ブランチ + 新 PR を作る(サフィックス `-v2`, `-v3`) +5. **revert を連鎖させない。** 最終的なあるべき状態を直接コミットする方が履歴上の意図が明確になり、後の cherry-pick も簡単になる From 5a4c481aef95b23bbaded259d9282ec624ae8901 Mon Sep 17 00:00:00 2001 From: "takemi.ohama" Date: Sat, 8 Aug 2026 04:40:52 +0000 Subject: [PATCH 8/8] =?UTF-8?q?Fix:=20README=20=E3=81=AE=E3=83=97=E3=83=A9?= =?UTF-8?q?=E3=82=B0=E3=82=A4=E3=83=B3=E4=B8=80=E8=A6=A7=E8=A1=A8=E3=81=AE?= =?UTF-8?q?=E5=85=AC=E9=96=8B=20Skill=20=E6=95=B0=E3=82=92=E5=AE=9F?= =?UTF-8?q?=E6=95=B0=E3=81=B8=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 冒頭 (L11) は 21/20/21 へ更新済みだったが、プラグイン一覧表 (L103) に 旧値 26/25/27 が残っており、同一ファイル内で異なる配布数を示していた。 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8a6c7483..8e839e30 100644 --- a/README.md +++ b/README.md @@ -100,7 +100,7 @@ kiro-cli chat | プラグイン名 | バージョン | 説明 | 詳細 | |------------|----------|------|------| -| **ndf** | 4.20.1 | Claude Code / Codex / Kiro CLI 向けに runtime 別配布物を提供する NDF プラグイン。8個の専門エージェント(Claude版)、公開Skills(Claude Code向け core 26個、Kiro向け core 25個、Codex向け core 27個)、Claude SessionStart/Stopフック、Codex/Kiro向け通知・実行補助を提供。v4.0.0 で Codex MCP サーバを廃止し、`/ndf:codex` skill + `corder` エージェント経由の CLI 直接実行に一本化。 | [Claude](./plugins/ndf-claude/README.md) / [Codex](./plugins/ndf-codex/README.md) / [Kiro](./plugins/ndf-kiro/README.md) | +| **ndf** | 4.20.1 | Claude Code / Codex / Kiro CLI 向けに runtime 別配布物を提供する NDF プラグイン。8個の専門エージェント(Claude版)、公開Skills(Claude Code向け core 21個、Kiro向け core 20個、Codex向け core 21個)、Claude SessionStart/Stopフック、Codex/Kiro向け通知・実行補助を提供。v4.0.0 で Codex MCP サーバを廃止し、`/ndf:codex` skill + `corder` エージェント経由の CLI 直接実行に一本化。 | [Claude](./plugins/ndf-claude/README.md) / [Codex](./plugins/ndf-codex/README.md) / [Kiro](./plugins/ndf-kiro/README.md) | ### NDF v4.20.1 の主な変更