plugins/git-workflow/skills/post-merge-cleanup/SKILL.md
Cleans up git assets (worktrees, branches) and updates task status after PR merge. Supports both filesystem (STATUS.md) and Linear issue tracking. Safe defaults with dry-run preview mode.
npx skillsauth add talent-factory/claude-plugins post-merge-cleanupInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
This skill automates the cleanup process after a PR has been merged:
/git-workflow:post-merge-cleanup task-013 # Auto-detect source
/git-workflow:post-merge-cleanup PROJ-123 # Linear issue (auto-detected)
/git-workflow:post-merge-cleanup task-013 --dry-run # Preview only
| Parameter | Required | Description |
|-----------|----------|-------------|
| task_id | Yes | Task identifier (e.g., task-013, PROJ-123) |
| --linear | No | Force Linear as task source |
| --file | No | Force filesystem (STATUS.md) as source |
| --dry-run | No | Preview changes without executing |
| --no-status-update | No | Skip task status update, only cleanup git |
| --keep-local | No | Keep local branch (only delete remote) |
--dry-run, --linear, --file, --no-status-update, --keep-localLinear Detection (if task_id matches [A-Z]+-\d+ pattern OR --linear flag):
Call: mcp__plugin_linear_linear__get_issue(id: <task_id>)
Store: issue title, current state, project info
Filesystem Detection (default for task-NNN pattern):
# Search for STATUS.md files
glob ".plans/**/STATUS.md"
# Parse markdown table for task row matching task_id
# Store: file path, current status, line location
If neither source found: Display error with suggestions.
Find all git assets associated with the task:
# 1. Check for worktrees
git worktree list | grep -i "<task_id>"
# 2. Check local branches
git branch | grep -iE "(feature/)?(task-)?<task_id>"
# 3. Check remote branches
git branch -r | grep -iE "(feature/)?(task-)?<task_id>"
Display summary to user:
Found git assets for <task_id>:
Worktree: .worktrees/task-013
Local branch: feature/task-013-admin-dashboard
Remote branch: origin/feature/task-013-admin-dashboard
If --dry-run: Display what would be cleaned up and exit.
# Check if PR was merged
gh pr list --search "<task_id>" --state merged --limit 5
If no merged PR found:
If merged PR found:
Execute in order (skip if asset not found):
4.1 Remove Worktree:
git worktree remove .worktrees/<task_id> --force
4.2 Delete Local Branch (unless --keep-local):
git branch -d <branch_name>
-D4.3 Delete Remote Branch:
git push origin --delete <branch_name>
4.4 Prune Stale References:
git fetch --prune
--no-status-update)For Linear Issues:
Call: mcp__plugin_linear_linear__update_issue(
id: <task_id>,
state: "Done" # Or equivalent completed state for the project
)
mcp__plugin_linear_linear__list_issue_statuses to find correct "completed" stateFor Filesystem (STATUS.md):
Read current file content
Find task row in markdown table:
| <task_id> | or | NNN | (where NNN matches task number)Update status in row:
pending / ⬜ / todo → ✅ completedin_progress / 🔄 / doing → ✅ completedRecalculate progress (if present):
| **Total** | ... | XX% |)Update "Next Steps" section (if present):
If STATUS.md was modified:
# Stage changes
git add <status_file_path>
# Commit with conventional message
git commit -m "✅ chore: Mark <task_id> as completed"
# Push to remote
git push
Successful cleanup:
Post-Merge Cleanup for task-013
================================
Task Source: Filesystem (.plans/subscribeflow-mvp/STATUS.md)
PR Status: #15 merged on 2026-02-03
Git Cleanup:
✓ Worktree removed: .worktrees/task-013
✓ Local branch deleted: feature/task-013-admin-dashboard
✓ Remote branch deleted: origin/feature/task-013-admin-dashboard
✓ Stale references pruned
Status Update:
✓ Task status: in_progress → completed
✓ Progress updated: 80% → 89% (78/88 SP)
✓ Changes committed and pushed
Cleanup complete!
Dry-run output:
Post-Merge Cleanup for task-013 (DRY RUN)
==========================================
Would perform the following actions:
Git Cleanup:
• Remove worktree: .worktrees/task-013
• Delete local branch: feature/task-013-admin-dashboard
• Delete remote branch: origin/feature/task-013-admin-dashboard
Status Update:
• Update .plans/subscribeflow-mvp/STATUS.md
• Change task-013 status: in_progress → completed
• Recalculate progress: 80% → 89%
Run without --dry-run to execute.
Worktree has uncommitted changes:
Warning: Worktree .worktrees/task-013 has uncommitted changes.
Modified: src/components/Dashboard.tsx
Options:
1. Commit changes first
2. Discard changes and remove (--force)
3. Abort cleanup
Choice [1/2/3]:
Branch not fully merged:
Warning: Branch feature/task-013-foo is not fully merged.
This may indicate the PR was not merged, or was squash-merged.
Options:
1. Force delete anyway (-D)
2. Keep branch and continue
3. Abort cleanup
Choice [1/2/3]:
Linear API error:
Error: Could not update Linear issue PROJ-123
Reason: Insufficient permissions
Status update skipped. Git cleanup completed successfully.
Please update the issue manually in Linear.
| ID | Task | Status |
|-----|----------------|----------------|
| 013 | Admin Dashboard| 🔄 in_progress |
| Task | Status |
|-----------|-----------|
| task-013 | pending |
| Status Type | Recognized Values |
|-------------|-------------------|
| Pending | pending, ⬜, todo, open, backlog |
| In Progress | in_progress, 🔄, doing, active, started |
| Completed | completed, ✅, done, closed, finished |
documentation
Creates comprehensive handoff documentation before a /compact operation, enabling a new agent with fresh context to seamlessly continue the work. Activate when the user says "prepare a handoff", "document before compact", "context is getting too large", "I need to hand this off", "create a handoff document", "end of session notes", or "document the current state for tomorrow". Supports --output and --linear-issue options.
documentation
Collects completed tasks, GitHub activity, calendar meetings, wiki learnings, and Linear progress for the past week, then writes a structured retrospective to the Obsidian vault. Activate when the user runs "/weekly-review", asks "what did I accomplish this week", "weekly retrospective", "summarise my week", or "prepare weekly review". Works from any directory.
development
Produces a prioritised daily briefing by aggregating tasks from Obsidian TaskNotes, Google Calendar, Gmail, Linear, and GitHub, then writes the result to today's daily note in the Obsidian vault. Activate when the user runs "/today", asks "what's on my plate today", "give me my daily briefing", "what do I need to do today", or "morning briefing". Works from any directory without requiring Obsidian to be running.
tools
Provides a quick status snapshot of all GitHub repositories in a configured organisation — active, dormant, stalled — plus open pull requests and issues. Terminal output only, optimised for speed. Activate when the user runs "/project-pulse", asks "what is the status of my GitHub projects", "show me my repos", "which projects are active", "project overview", "GitHub pulse", or "what is happening in [org]". Works from any directory.