Clean up after a PR is merged - delete branches and confirm issue closure
/plugin marketplace add builtby-win/skills/plugin install done@builtby-win-skillsThis skill inherits all available tools. When active, it can use any tool Claude has access to.
Clean up local and remote branches after a PR is merged.
/donegit branch --show-current
If on an issue branch (pattern: {PROJECT_PREFIX}/issue-{N}-*), proceed with cleanup.
Note: PROJECT_PREFIX should be configured in your project's CLAUDE.md. Examples: myproject, builtby-win-web, etc.
gh pr view --json state,mergedAt
Verify the PR was merged. If not merged, warn user.
Check if a worktree exists for this issue and delete it:
# Extract issue number from branch name
ISSUE_NUM=$(git branch --show-current | grep -oP 'issue-\K[0-9]+')
# Try to delete worktree using the global CLI
# This will fail gracefully if no worktree exists
npx @builtby.win/worktree delete ${ISSUE_NUM} 2>/dev/null && WORKTREE_DELETED=1
Alternatively with globally installed CLI:
worktree delete ${ISSUE_NUM} 2>/dev/null && WORKTREE_DELETED=1
If worktree was deleted, it will:
.worktrees/issue-{N}-{slug}/ directory.worktree-metadata.jsongit checkout main
git pull origin main
git branch -d {PROJECT_PREFIX}/issue-{N}-{slug}
Use -D (force) if needed, but prefer -d to catch unmerged commits.
git push origin --delete {PROJECT_PREFIX}/issue-{N}-{slug}
gh issue view {N} --json state
The issue should be closed automatically by the Closes #N in the PR body.
Output:
PR #{PR_NUM} merged!
Cleanup complete:
- Switched to main
- Deleted local branch: {PROJECT_PREFIX}/issue-{N}-{slug}
- Deleted remote branch
- Issue #{N} is now closed
Ready for next task. Run /work to see what's available.
If worktree was deleted, also include:
- Deleted worktree: .worktrees/issue-{N}-{slug}
- Stopped dev server (port {PORT} now available)
- Removed {N} database snapshot(s)
Claude should detect when a PR is merged by:
gh pr view --json stateWhen detected, automatically run cleanup.
In your project's CLAUDE.md, set:
## GitHub Workflow Configuration
PROJECT_PREFIX=your-project-name
Example configurations:
PROJECT_PREFIX=areyougo.ing (for areyougo.ing project)PROJECT_PREFIX=builtby-win-web (for builtby.win/web)PROJECT_PREFIX=myapp (for any custom project)This skill should be used when the user asks to "create a hookify rule", "write a hook rule", "configure hookify", "add a hookify rule", or needs guidance on hookify rule syntax and patterns.
Create distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.