/git-and-pr:cleanup-worktreesfrom git-and-pr
Safely scans all git worktrees, checks merge status and PR state, categorizes them (Merged/PR Closed/Remote Deleted/Active), presents a report, and deletes with user approval. Never deletes the current worktree. Invoke when asked to "clean up worktrees", "remove merged worktrees", or "prune worktrees".
Ships in git-and-pr. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Intelligent git worktree cleanup. Discovers all worktrees, checks their status, categorizes them, and removes stale ones safely.
List all worktrees:
git worktree list --porcelain
Parse the output to collect:
HEAD in output)Skip automatically:
~/.claude/worktrees/ (Claude Code internal worktrees — managed separately)Also run a basic sanity check:
git worktree list
If any worktree paths are missing from disk (unlocked but directory gone), note them as "orphaned" — they should be pruned first:
git worktree prune
For each remaining worktree branch, check in this order:
2a. Is the branch merged into main?
git branch --merged main | grep "<branch-name>"
If it appears: category = Merged.
2b. Is there an open or closed PR?
gh pr list --head "<branch-name>" --state all --json number,state,title,mergedAt
state: MERGED: category = PR Merged (if not already caught by 2a)state: CLOSED (not merged): category = PR Closed (Abandoned)state: OPEN: category = Active (has open PR — do not delete)2c. Does the remote branch still exist?
git ls-remote --heads origin "<branch-name>"
2d. Does the worktree have uncommitted changes?
git -C "<worktree-path>" status --porcelain
If there are uncommitted changes, mark as Dirty regardless of other categories. Never auto-delete dirty worktrees.
Display the results in a clear table:
## Worktree Status Report
### Safe to Delete
| Branch | Path | Reason | PR |
|--------|------|--------|----|
| train-123-my-feature | ~/workspace/... | Merged | #45 (merged) |
| train-456-old-thing | ~/workspace/... | Remote deleted | None |
### Active (keeping)
| Branch | Path | Status |
|--------|------|--------|
| train-789-current | ~/workspace/... | Open PR #67 |
### Dirty (manual review needed)
| Branch | Path | Changes |
|--------|------|---------|
| train-999-wip | ~/workspace/... | 3 modified files |
### Skipped
| Path | Reason |
|------|--------|
| ~/.claude/worktrees/... | Claude Code internal worktree |
| (main worktree) | Primary checkout |
If there is nothing to delete, say so clearly and stop.
Present the "Safe to Delete" list and ask:
"Ready to remove N worktrees listed above. Proceed? (This removes the worktree directories and their local branch refs.)"
Wait for explicit user confirmation before deleting anything.
If confirmed, for each worktree in the "Safe to Delete" list:
git worktree remove "<worktree-path>" --force
git branch -d "<branch-name>"
Notes on --force: Only use it for worktrees where the branch is confirmed merged or remote-deleted. If git worktree remove without --force fails for an unexpected reason, stop and report — do not blindly retry with --force.
For dirty worktrees: never delete. Tell the user to commit, stash, or discard changes manually first.
After deletion, run:
git worktree list
Report:
git worktree prune was run to clean up any remaining administrative filesgit worktree remove fails unexpectedly, stop and report rather than escalating with destructive flags.What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub arosenkranz/agent-config --plugin git-and-pr6 skills in this plugin
/address-pr-feedbackSystematic 5-phase workflow for handling PR review comments. Fetches review threads via gh api (not gh pr view), triages by priority, executes fixes via sub-agent, posts inline GitHub replies, and commits. Invoke when asked to "address PR feedback", "respond to review comments", or "handle PR review"./pin-actionsPin GitHub Actions from mutable tags (e.g., @v4) to immutable commit SHAs to prevent supply chain attacks. Use when editing .github/workflows files, hardening CI security, looking up action SHAs, pinning actions to specific commits, or replacing "uses: owner/repo@tag" references with SHA-pinned equivalents.
/refineIterative visual/UI refinement mode. Make one change at a time, describe it, wait for feedback. Use when tuning visual effects, layouts, or styling. Invoke with /refine.