post-merge-cleanup
Skill0 starsChanged 6 months agoApache-2.0View on GitHub
PR が merge された後の局所的なクリーンアップを一発で済ませる skill。merge 確認 → main fast-forward → worktree remove → branch -D まで、必要なら dispatcher の dashboard 更新 + 元 author worker への ack も。並列 worker / worktree で開発している環境で merge ごとに繰り返す定型手順を機械化する。「merge した」「PR merged」「PR #N を入れた後」のタイミングで使う。
5 other projects use a version of this.
Adopted by
Most recently taken up by
- alex-macra/claude-codex-skills-assemblytheir own version, first seen Nov 1, 2026
- dolanmiu/docxtheir own version, first seen Oct 8, 2026
- hannasdev/skillstheir own version, first seen Jun 28, 2026
- yasunori0418/skillstheir own version, first seen Jun 27, 2026
- dcolclazier/skillstheir own version, first seen May 18, 2026
Other versions5 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 5
- dolanmiu/docx★ 6ksame name
- yasunori0418/skills★ 9same name
- alex-macra/claude-codex-skills-assembly★ 1same name
- dcolclazier/skills★ 1same name
- hannasdev/skills★ 1same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository33 other files it gives its agents.
- add-mesh-peerSkill
- adrSkill
- analyze-logsSkill
- codex-consultSkill
- codex-reviewSkill
- config-analyzerSkill
- cross-reviewSkill
- drawioSkill
- empirical-prompt-tuningSkill
- git-historySkill
- github-writingSkill
- hard-task-playbookSkill
- inherit-wipSkill
- interviewSkill
- ja-natural-reviewSkill
- mcp-smoke-via-claude-pSkill
- meeting-minutesSkill
- memoSkill
- nerfstudio-trainerSkill
- obsidian-work-loggerSkill
- plan-with-qaSkill
- poll-sonnet-workersSkill
- release-applySkill
- ros2-inspectorSkill
- ros2-launch-debugSkill
- ros-analyzeSkill
- safe-pathspec-commitSkill
- setup-claude-localSkill
- split-advisorSkill
- surveySkill
- work-logSkill
- write-specSkill
- zenn-interviewSkill
The file
Files
並列 worker + 専用 worktree で複数 PR を回している環境で、merge 後に必ず踏む 定型手順を 1 コマンドにまとめる skill。
なぜ必要か
worktree 分離(<repo>-wt-<key> パターン)で並列開発していると、PR が merge
されるたび同じ 5-6 ステップを踏む:
- merge 確認: 本当に MERGED 状態か(gh pr view で state)
- main 同期:
git fetch --prune && git checkout main && git pull --ff-only - worktree remove:
git worktree remove <path>(残骸防止) - branch -D: squash & merge 後の branch は
git branch -dだと「not fully merged」で失敗するので-D強制削除が必要 - (任意)dashboard 更新: dispatcher の
dashboards/<project>.md上の Worker 状態行 + アクティブタスク表を編集 - (任意)worker ack: tmux で元 author の pane に「merged at
<time>」を送信
ステップは機械的だが、手で打つと枝刈り漏れや「-d で失敗 → 諦め → 後で git branch
-a で気付く」が起きる。2026-05-21 の Wave 3 で 1 日 5 回繰り返したため skill 化。
使うタイミング
- ユーザーが「merge した」「PR merged」「入れた」「マージしといて」と言ったとき
gh pr mergeを実行した直後- 並列 worker 環境(tmux-multi-agents 等)で、特定の worktree を使い切ったとき
- 単独開発でも
git worktree addで作業した branch を merge した後 - 複数 PR を順次 merge していて、一括で後処理したいとき
- main の
git statusに残った変更やgit worktree listの枝刈りミスに気付いたとき
前提
- リポジトリは GitHub(
ghコマンドが使える、認証済み) - 作業ディレクトリは PR 元 repo の main worktree
- ユーザーが merge 番号(PR 番号)と、対応する worktree path / branch 名を伝えられる
- (Dispatcher 環境のみ)
/home/gisen/work/tmux-multi-agents/dashboards/<project>.mdが存在
必要な情報
skill 起動時、以下を ユーザー or 会話文脈から特定 する。曖昧なら AskUserQuestion で確認:
| 必須 | 情報 | 例 |
| ✓ | PR 番号 | 103 |
| ✓ | repo | h-wata/mesh-mem(main worktree の cwd の origin remote から自動取得可) |
| ✓ | worktree path | /home/gisen/work/mesh-mem-wt-issue51 |
| ✓ | branch 名 | feat/issue-51-mcp-proactive-save |
| 元 author worker pane | ros-agents:0.1(dispatcher 環境) | |
| project 名(dashboard 更新時) | mesh-mem |
複数 PR を一括処理する場合、(PR, worktree, branch) のセットを並べる。
手順
Step 1: merge 確認
gh pr view <PR> --repo <owner>/<repo> --json state,mergedAt
# → {"state":"MERGED","mergedAt":"2026-05-21T..."} を確認state が MERGED でなければ そこで止める。OPEN や CLOSED なら原因を確認:
- OPEN: まだ merge されていない → merge 待ち or ユーザー実行依頼
- CLOSED + mergedAt=null: closed without merge → cleanup の意図を再確認
Step 2: main 同期
main worktree(PR 元 repo の主 working tree)で:
cd <main-worktree-path>
git fetch origin --prune
git checkout main
git pull --ff-only origin mainfetch --prune で remote 側で消えた branch ref も同時に枝刈りされる。
--ff-only で local commit が混ざっている場合は止まる(安全)。
Step 3: worktree remove
git worktree remove <worktree-path>worktree に dirty な変更が残っていれば失敗する。その場合:
- 残っている変更が必要か確認(cherry-pick が必要なら拾う)
- 不要なら
git worktree remove --force <worktree-path>
Step 4: branch 削除
git branch -d <branch-name> 2>&1 || git branch -D <branch-name>squash & merge 後の branch は -d で「not fully merged」エラーが出る
(merge commit が無いため)。-D 強制削除が必要。先に -d を試して、
失敗時のみ -D にすれば、本当に merged 済かを git 経由で確認できて安全。
remote 側 branch は GitHub の --delete-branch フラグで削除されているはず
だが、念のため git fetch --prune 後に git branch -a で remote tracking
の残骸を確認するとよい。
Step 5: 状態確認
git worktree list
git branch期待: 削除したはずの worktree / branch が両方消えていること、main は
origin/main と一致(## main だけ表示)。
Step 6: (任意)dashboard 更新
Dispatcher 環境 (/home/gisen/work/tmux-multi-agents/) の場合:
DASHBOARD="/home/gisen/work/tmux-multi-agents/dashboards/<project>.md"
INDEX="/home/gisen/work/tmux-multi-agents/dashboard.md"更新対象:
- 該当 Worker の状態列を「実装中」「待機 (merge 待ち)」→ 「待機 (merge 済)」 または「待機中」に
- 「Wave X 残タスク」表で当該 PR を「✅ MERGED: …」に書き換え
- 「Codex cross-review 履歴」表に最終 verdict 追加(あれば)
- 必要なら index 側の Worker ステータス表も同期
これは Edit ツールで行単位置換するのが楽。複数 PR を一括処理する場合は
1 ファイル開いて連続 Edit する。
Step 7: (任意)元 worker への ack
Dispatcher 環境で tmux session に worker pane がある場合:
tmux send-keys -t <session>:0.<pane> "[merge 完了] PR #<N> (<title>) merged at <HH:MM>。お疲れさまでした。引き続き待機していてください。"
sleep 0.5
tmux send-keys -t <session>:0.<pane> Enter重要: メッセージと Enter は別コマンドで sleep を挟む。同一 send-keys
"text" Enter だと Enter が届かず次メッセージと連結するバグあり
(tmux-multi-agents 運用知見)。
Step 8: 複数 PR の場合
(PR_A, wt_A, br_A) と (PR_B, wt_B, br_B) を順次処理するときは、Step 1-4 を各セットでループ、Step 5-7 は最後に一括でやると効率的。
main 同期 (Step 2) は最初の 1 回だけでよい(merge は GitHub 側で順序付き、 fetch --prune で最新化される)。
エラーパターンと対処
git worktree remove が失敗
- 「contains modified or untracked files」: 残った dirty 変更を確認。
必要なものは cherry-pick で拾い、不要なら
--forceで削除 - 「is a main working tree」: main worktree を削除しようとしている。 worktree path を再確認(誤って main を指定していないか)
git pull --ff-only が失敗
- local main に commit が積まれている → ユーザー判断を仰ぐ
- rebase してから pull するか
- local commit を別 branch に退避するか
- ネットワーク / 認証エラー →
gh auth statusで確認
branch 削除が -d も -D も失敗
- branch が checked out のままになっている可能性 → 別 worktree が使ってないか
git worktree listで確認 - ref が壊れている →
git reflog show <branch>で状態確認
アンチパターン
git add -A的な雑な後始末をしない: 削除対象を明示。worktree / branch 名を会話文脈から特定できない場合は AskUserQuestion で確認する- main worktree を
worktree removeしない: skill の Step 3 は 作業 worktree のみ が対象。誤って main を指定すると repo が使えなくなる - dashboard 更新を skip しない(Dispatcher 環境のみ): 後でユーザーが状況を 見たときに「これもう merge 済?」と聞き直す手間が発生するため、必ず反映する
- Step 1 (merge 確認) を飛ばさない: 「merge した」と聞いたら本当に MERGED か 必ず確認。OPEN のまま cleanup すると WIP を失う
例: 単一 PR の最小フロー
# Step 1
gh pr view 103 --repo h-wata/mesh-mem --json state,mergedAt
# → MERGED
# Step 2-5
cd /home/gisen/work/mesh-mem
git fetch origin --prune
git checkout main
git pull --ff-only origin main
git worktree remove /home/gisen/work/mesh-mem-wt-issue51
git branch -d feat/issue-51-mcp-proactive-save || git branch -D feat/issue-51-mcp-proactive-save
git worktree list
git branchここまでが skill の 必須範囲。Step 6-7 は dispatcher / 並列 worker 環境 のみ。
例: 並列 2 PR を一括 cleanup(Dispatcher 環境)
# Step 1 (両方)
gh pr view 102 --repo h-wata/mesh-mem --json state,mergedAt # MERGED
gh pr view 103 --repo h-wata/mesh-mem --json state,mergedAt # MERGED
# Step 2 (1 回だけ)
cd /home/gisen/work/mesh-mem
git fetch origin --prune
git checkout main
git pull --ff-only origin main
# Step 3-4 (各 PR)
git worktree remove /home/gisen/work/mesh-mem-wt-issue75
git worktree remove /home/gisen/work/mesh-mem-wt-issue51
git branch -D fix/issue-75-forward-compat-extras feat/issue-51-mcp-proactive-save
# Step 5
git worktree list
git branch
# Step 6: dashboard.md / dashboards/<project>.md を Edit
# Step 7: tmux で W1, W2 に ack 送信出力サマリ
skill 完了時、以下をユーザーに 3-5 行で報告:
- merge した PR 番号と時刻
- main の新しい HEAD(短 SHA)
- 削除した worktree / branch
- dashboard を更新したかどうか
- 残っている worktree がある場合、その path(残置の意図確認のため)
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

