/dev10x-coding:git-worktree-prunefrom dev10x-coding
Safely removes git worktree checkouts whose branches have already merged. Handles squash merges, dirty checkouts, generated files, and in-use workspaces with a single approval.
Ships in dev10x-coding. 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.
Read when SKILL.md points to them.
Announce: "Using dev10x-coding:git-worktree-prune to classify worktrees and remove the ones whose work has already merged."
This skill follows references/task-orchestration.md patterns.
REQUIRED: Create a task at invocation. Execute at startup:
TaskCreate(subject="Prune merged worktrees", activeForm="Pruning worktrees")Mark completed when done: TaskUpdate(taskId, status="completed")
Leave an open task (GH-149). Before completing it, check TaskList.
When no Verify AC task exists and the list would otherwise be empty,
create one first — TaskCreate(subject="Verify AC and close session", description="<removed, skipped and kept paths>", activeForm="Verifying AC") — and never complete it yourself
(.claude/rules/essentials.md § Task List Invariant).
dev10x-coding:git-worktree only creates checkouts, and git worktree prune
drops admin entries for paths that are already gone. Nothing removes a
live checkout whose branch merged, so they accumulate. A hand sweep is
slow and gets the hard cases wrong:
[gone] upstreams miss them;
merge state comes from the PR..agents/ / .codex/ make
git worktree remove refuse without --force.open_workspace_id for a
checkout in use.The worktree_prune_candidates MCP tool settles all of these in one
read-only call; this skill turns its answer into one approval and a
careful removal loop.
mcp__plugin_dev10x_cli__detect_base_branch and use its
base_branch throughout — never hardcode develop.git fetch --prune origin so the unpushed-commit count and the
base ref are current.mcp__plugin_dev10x_cli__worktree_prune_candidates(base=<base>, cwd=<absolute path of this checkout>). Always pass cwd — the MCP
server is long-lived and its own directory may be another repo or a
removed worktree. Branch on an error key: report it and stop.path in worktrees with its
branch and head. Steps 3 and 4 act only on paths in this set.The tool groups every worktree:
| Class | Meaning |
|---|---|
remove | Clean or mirrors-only, nothing on no remote, not open in herdr, merged PR (head matches, or HEAD is on base) |
ask | Clean and pushed, but its PR closed unmerged, or it has no PR |
keep | Main or current checkout, dirty, holding ignored files outside known caches, unpushed, open, locked, open PR, moved past its merged PR, missing, or any state it could not read |
Ignored files (a local .env, settings) are deleted by git worktree remove even without --force, so any ignored_paths entry keeps the
checkout. Only .venv/, node_modules/, __pycache__/,
.pytest_cache/, .ruff_cache/ and .mypy_cache/ are disregarded.
The response's herdr field says how open workspaces were read. When
herdr is not on the server's PATH but ~/.herdr exists or HERDR_ENV
is set, the state is unknown and every otherwise-removable checkout is
kept. Herdr items lacking path or open_workspace_id are unknown too.
When remove and ask are both empty, print the keep table and skip
to Step 4.
Otherwise present, before the question:
remove and ask paths with branch, PR, last_commit_at and
reason, as code blocks;keep paths with their reason, so nothing is hidden;herdr value as a line herdr: <value>, so a missing
herdr (herdr: absent) is visible instead of reading as "nothing open".REQUIRED: Call AskUserQuestion (do NOT use plain text). This blocks
every removal until the user answers. Options — mark exactly one
(Recommended) and list it first, computed from the survey: "Remove
safe" leads when remove is non-empty, "Remove nothing" leads when it
is empty:
remove setask pathThe user may answer "Other" with an explicit path list; accept only paths from the surveyed set and drop anything else with a note.
For each approved path, one at a time:
Call mcp__plugin_dev10x_cli__worktree_prune_candidates(base=<base>, paths=[<path>], cwd=<same checkout as Step 1>) — a fresh read,
never the survey's.
Remove it only when all of these hold — otherwise skip it and
report the fresh reason (or the error):
error key and the path is not in not_found;worktrees list — read its
fresh class and force_required from that entry;branch and head equal the surveyed ones — a path
removed and recreated by a parallel session is a different
checkout, so skip it on any difference;class is one the answer approved: remove for Remove
safe; remove or ask for Remove safe + ask or an explicit
"Other" path list.So under Remove safe a path whose class drifted from remove to
ask (its PR closed after the survey) is skipped, and a fresh keep
is skipped under every answer.
Remove it:
force_required: false → git worktree remove <path>force_required: true → git worktree remove --force <path>.
The tool sets this only when the untracked set is a subset of the
generated mirrors and nothing else is dirty.Record a failure and continue with the next path — one refusal must not abort the batch.
git worktree prune to clear admin entries of missing paths.dev10x-coding:git-branch-prune to remove merged ones."git worktree remove and git worktree prune stay out of every
base_permissions catalog on purpose: they delete files, so each call
prompts (GH-1942, supervisor decision). Do not seed them.
dev10x-coding:git-branch-prune owns that.--force unless the fresh read says force_required: true.keep wins.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub dev10x-guru/dev10x-claude --plugin dev10x-coding40 skills in this plugin
/ci-reviewdev10x-coding:ci-reviewUse when a change to a Claude CI review prompt, args file, reviewer agent or CLI pin needs checking before it merges — so you read what the CI code review and PR hygiene check would post on a real PR, with nothing reaching GitHub unless you choose, after reading the report, to share it as one marked replica comment. TRIGGER when: "what would the CI review say", replaying the Claude CI review locally, verifying a review prompt or model change on a PR. DO NOT TRIGGER when: self-reviewing a branch with no PR (use dev10x-coding:review), or reviewing someone's PR and posting (use dev10x-coding:gh-pr-review).
/fanoutdev10x-coding:fanoutProcess multiple independent work items as a worktree-isolated swarm — each item runs the full dev10x-coding:work-on lifecycle inside its own background Agent with isolation="worktree" (under Herdr, its own Herdr workspace and agent). Honors dependencies, minimizes conflicts, auto-advances by default. TRIGGER when: 2+ independent work items need parallel processing (PRs, issues, tickets). DO NOT TRIGGER when: single task or sequential dependency chain (use dev10x-coding:work-on); already running as a swarm child (see recursive-fanout guard).