branch-sync-and-cleanup
Standardizes Git branch sync and cleanup workflows for developers.
Install
mkdir -p .claude/skills/branch-sync-and-cleanup && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/12924" && unzip -o skill.zip -d .claude/skills/branch-sync-and-cleanup && rm skill.zipInstalls to .claude/skills/branch-sync-and-cleanup
Activation
This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.
Sync main before starting Issue work and clean up merged local branches after PR merge. Use when picking up a new Issue, or right after a PR is merged. Applies the same flow to CodeX and Claude.Key capabilities
- →Sync main before starting Issue work
- →Clean up merged local branches after PR merge
- →Confirm no uncommitted changes before main operations
- →Switch to default branch and pull latest changes
- →Create a new work branch following naming conventions
- →Identify merged local branches using `git branch --merged main`
How it works
The skill provides a standardized procedure to synchronize the main branch before starting new work and to clean up merged local branches after a PR merge, ensuring a clean and up-to-date workspace.
Inputs & outputs
When to use branch-sync-and-cleanup
- →Syncing main branch
- →Cleaning up merged local branches
- →Preparing workspace for new issue
About this skill
Branch Sync And Cleanup
What This Skill Produces
- Issue 着手前にデフォルトブランチを最新化してから作業ブランチを切る手順
- PR マージ後にローカルのマージ済みブランチを安全に削除する手順
- CodeX / Claude で同一に運用するための共通チェックリスト
When to Use
- Issue を起点に新しい実装やバグ修正に取りかかるとき
- PR がマージされたあと、ローカルが古いブランチで散らかってきたとき
- どのエージェントを使っても同じフローで進めたいとき
Decision Points
-
これから作業を始めるか / マージ後の片付けか
- 着手前なら A. の手順、マージ後なら B. の手順に従う
- 両方やる場合は A.(作業ブランチを切る前)または B.(次の作業に入る前)として個別に実行する
-
現在のブランチと未コミット差分の有無
- 未コミット差分があるなら、退避(stash / 別ブランチへ移動)するか確認してから main 操作を行う
- 差分を意図せず破棄しないことを最優先にする
-
ローカルブランチが本当にマージ済みか
git branch --merged mainの結果と GitHub 側の PR 状態を突き合わせて判定する- squash merge の場合はローカルから見るとマージ済みに見えないことがあるため、PR 番号でも確認する
Procedure
A. Issue 着手前の main 最新化
git statusで未コミット差分が残っていないことを確認する。残っているなら退避するか、ユーザーに確認する。git switch mainでデフォルトブランチに切り替える。git pull --ff-onlyで最新化する。fast-forward できない場合は無理に進めず原因を確認する。git switch -c <branch>で作業ブランチを作成する。ブランチ名はfeature/<task-name>またはfix/<task-name>規約に従う。- 必要なら
git statusでクリーンな状態から始まっていることを再確認する。
B. PR マージ後のローカル整理
git switch main && git pull --ff-onlyで main を最新化する。git fetch --pruneでリモート追跡の死んだ枝を整理する。git branch --merged mainでローカルのマージ済みブランチ一覧を確認する。- 不要なブランチを
git branch -d <branch>で 1 本ずつ削除する。 - 強制削除
-Dはユーザー明示の許可がない限り使わない。 - 仕上げに
git branchで残ったブランチを確認し、想定外のものが残っていないか点検する。
Quality Checks
- 作業開始時、必ず最新の main から枝分かれしている
- マージ後、ローカルに古い作業ブランチが残っていない
- 削除対象が本当にマージ済みであることを確認したうえで削除している
- 未コミット差分を巻き込んだまま main を操作していない
Guardrails
-Dによる強制削除はユーザー許可が必要- 未マージブランチを誤削除しない
- 未コミット差分を勝手に破棄しない(必要ならまず stash や確認)
- main 上で直接実装を始めない
git push --forceやgit reset --hardなどの destructive 操作はユーザー明示の許可がない限り使わない
Output Format
返答には必要に応じて以下を含める。
- Mode: 着手前 (sync) かマージ後 (cleanup) か
- Current branch / status: 現在の状態
- Actions taken: 実行したコマンドと結果
- Remaining branches: 削除後の
git branch一覧(cleanup 時)
Example Prompts
/branch-sync-and-cleanup Issue #999 に着手するので main を最新化して作業ブランチを切って/branch-sync-and-cleanup PR がマージされたのでローカルのマージ済みブランチを整理して/branch-sync-and-cleanup 新しいタスクに入る前に main を最新化して、ついでに古いブランチも片付けて
When not to use it
- →Do not use `-D` for forced deletion without explicit user permission
- →Do not delete unmerged branches by mistake
- →Do not discard uncommitted changes without confirmation
Limitations
- →強制削除 `-D` はユーザー明示の許可がない限り使わない
- →未マージブランチを誤削除しない
- →未コミット差分を勝手に破棄しない(必要ならまず stash や確認)
How it compares
This workflow offers a structured, agent-agnostic checklist for git branch synchronization and cleanup, preventing accidental data loss and maintaining a clean repository, unlike manual, ad-hoc git operations.
Compared to similar skills
branch-sync-and-cleanup side by side with the closest alternatives in the catalog.
| Skill | Installs | Updated | Safety | Difficulty |
|---|---|---|---|---|
| branch-sync-and-cleanup (this skill) | 0 | 2mo | No flags | Beginner |
| tmux | 20 | 2mo | Review | Intermediate |
| jira | 11 | 6mo | No flags | Beginner |
| triaging-issues | 5 | 2mo | Review | Intermediate |
Try saying
Example prompts that trigger this skill in your AI assistant.
You might also like
tmux
openclaw
Remote-control tmux sessions for interactive CLIs by sending keystrokes and scraping pane output.
jira
davila7
Use when the user mentions Jira issues (e.g., "PROJ-123"), asks about tickets, wants to create/view/update issues, check sprint status, or manage their Jira workflow. Triggers on keywords like "jira", "issue", "ticket", "sprint", "backlog", or issue key patterns.
triaging-issues
pytorch
Triages GitHub issues by routing to oncall teams, applying labels, and closing questions. Use when processing new PyTorch issues or when asked to triage an issue.
file-manager
Xxiii8322766509
文件管理技能。用于创建、移动、复制、删除文件和文件夹,整理目录结构。当用户需要管理文件、整理文件夹或批量处理文件时使用。
openspec-archive-change
studyzy
归档实验性工作流中已完成的变更。当用户想要在实现完成后最终确定并归档变更时使用。
slash-commands
parcadei
Create and use Claude Code slash commands - quick prompts, bash execution, file references