What it teaches your agent
| Rule | Why |
|---|
| Confirm the merge from the remote, never from memory or the user's word | Deleting an unmerged branch loses work |
| Diff the branch's files against the default branch | A squash merge never shows up in git branch --merged |
| Stop on anything untracked or ignored in the worktree | A worktree can hold files that exist nowhere else |
| Remove the worktree and branch, revert churn, fast-forward default | The main checkout ends where the remote is |
| Retire notes that still call the work open, keeping only what the repo does not record | Stale notes mislead the next session |
| Four short lists as the report, plus what was assumed | You see what went, and what was not checked |
Merges are confirmed on GitHub through gh and on GitLab through glab; the rest is plain git.
How it works
flowchart TD
fetch[git fetch --prune] --> merged{Gone on the remote and content on default?}
merged -- no --> stopCommits[Name the commits and stop]
merged -- yes --> clean{Worktree clean?}
clean -- no --> stopFiles[Name the files and stop]
clean -- yes --> confirm[List what goes, wait for your word]
confirm --> remove[Remove worktree and branch]
remove --> pull[git pull --ff-only]
pull --> notes[Retire stale notes]
notes --> report[Report]
Example
The report the skill ends with:
Removed
- Worktree
../app-login-redirect and branch fix/login-redirect
- Churn in
package-lock.json in the main checkout, reverted
notes/fix-login-redirect.md
main moved from a1b2c3d to e4f5a6b
Folded
- The auth mock resets between tests, into
notes/testing.md
Dropped
- "Add a redirect test", already on
main at test/login.test.ts:12
Seen, not touched
notes/deploy.md still names the old staging host
Assumed rather than read: nothing.
Install
| Agent | Command |
|---|
| ![Claude Code][badge-claude-code] | /plugin marketplace add ArefMozafari/post-merge-cleanup
/plugin install post-merge-cleanup@post-merge-cleanup |
| ![Gemini CLI][badge-gemini-cli] | gemini extensions install https://github.com/ArefMozafari/post-merge-cleanup |
| ![GitHub Copilot CLI][badge-github-copilot-cli] | copilot plugin marketplace add ArefMozafari/post-merge-cleanup
copilot plugin install post-merge-cleanup@post-merge-cleanup |
| ![Cursor][badge-cursor] | agent plugin marketplace add https://github.com/ArefMozafari/post-merge-cleanup then /plugins in agent and install post-merge-cleanup |
| ![Codex][badge-codex] ![Cursor][badge-cursor] ![Windsurf][badge-windsurf] ![Cline][badge-cline] and more | npx skills add ArefMozafari/post-merge-cleanup |
| ![GitHub CLI][badge-github-cli] for Copilot and other agents | gh skill install ArefMozafari/post-merge-cleanup |
Manual install
Copy the skills/post-merge-cleanup folder into your agent's skills directory: