From git-workflow
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.
How this skill is triggered — by the user, by Claude, or both
Slash command
/git-workflow:post-merge-cleanupThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
This skill automates the cleanup process after a PR has been merged:
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 |
npx claudepluginhub talent-factory/claude-plugins --plugin git-workflowResolves merged PR workflows to completed state: verifies merge, backfills metadata, cleans up branches/worktrees. Use after PRs are merged.
Merges an open PR for the current branch via GitHub CLI. Checks for uncommitted changes, consolidates plan files, and cleans up stale worktrees from prior sessions.
Merges all open PRs in dependency order, closes linked issues, deletes feature branches, and cleans up local/remote refs. Use when completing features or finalizing a release cycle.