/yskills:worktree-cleanupfrom yskills
Removes finished git worktrees and their branches after proving they are merged (including squash merges) and clean. Stops dev servers, prunes dead registrations, and reports what was kept.
Ships in yskills. 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.
stale-check says what is dead; this skill removes it without losing anyone's work. Answer in the user's language.
git worktree list). If it sits on a
merged feature branch, offer to switch it back to the target branch, and only if it is clean.reset --hard, checkout -- . or clean -fd to make a tree "clean". Dirty means stop.bash <stale-check-dir>/scripts/stale_check.sh <repo> --all-worktrees
Without stale-check, use git -C <repo> worktree list --porcelain and do step 2 by hand for
each entry. For several repos, loop over the ones the user named, or over the folder where
they keep their repos. Flags from the script: temp_dir (a tree under /tmp, $TMPDIR or an
agent scratchpad, usually made by another agent session that may be gone), missing_dir
(registered, but the folder is gone), and the dirty count.
Run git fetch --prune first, so <remote>/<target> is current. Sidebars and
git branch --merged are not evidence: both miss squash merges, and some sidebars show
"0 unpushed" for a branch that never had a remote.
Merged means one of:
git merge-base --is-ancestor <branch> <remote>/<target> (merge commit or fast-forward);git cherry <remote>/<target> <branch> prints no + lines (rebase-merge, cherry-pick);gh pr list --head <branch> --state merged --json number,headRefOid returns a PR and
the branch tip equals headRefOid (a squash merge, with nothing committed after it);MERGED_INTO_TARGET=yes_* with
POST_MERGE_COMMITS at 0 or n/a.Clean means git -C <wt> status --porcelain --untracked-files=all prints nothing, and no stash
was made on the branch (git stash list --format=%gs | grep -E "^(WIP on|On) <branch>:").
Ignored build output (node_modules, .next, dist) does not count. List untracked leftovers
(scripts, CSVs, notes, .env* files) to the user with their paths; don't remove them silently.
lsof -nP -d cwd 2>/dev/null | grep -F "<wt-path>" # shells, servers, agents started there
pgrep -fl "next dev|next-server|vite|webpack|tsx watch|nodemon" | grep -F "<wt-path>"
Stop dev servers first (kill <pid>). A running dev server keeps writing its cache and
recreates the folder as an empty shell right after removal. A shell or an agent session whose
working directory is inside the tree means someone may still be using it: ask.
git -C <main-checkout> worktree remove "<wt-path>"
git -C <main-checkout> branch -d <branch> # plain merges
git -C <main-checkout> branch -D <branch> # squash or patch merges, only after step 2
worktree remove refuses when the tree has modified or untracked files. Don't add --force
to get past it: step 2 missed something, so go back.locked in git worktree list --porcelain) was locked on purpose. Ask.branch -d refuses squash-merged branches as "not fully merged". Use -D only with a proof
from step 2, and say which proof.git push <remote> --delete <branch> changes the shared remote, so confirm first.missing_dir registrations: git worktree prune --dry-run -v, then git worktree prune..git file, only build output (.next,
node_modules, .turbo). Show the user the list with what is inside each, check again that
nothing else is there, then rm -rf each one.branch -D.Three short lists: removed (repo · branch · how the merge was proven), kept with the reason, and needs the user's decision with the one fact they need ("3 unpushed commits, no PR ever opened"). End with how many worktrees each repo has left.
rm -rf instead of git worktree remove leaves its
registration behind. git worktree prune clears it.What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub lycfyi/yskills --plugin yskills5 skills in this plugin
/cold-readCold-read user-facing words the way a first-time, lazy, hurried reader would, using fresh-context reader subagents that never saw the conversation that produced them: UI copy (a strings-file diff, screenshots, or a who/where/text list), landing pages, profile bios, decks and charts, plans, emails, notifications, application answers, and the options an agent is about to show a human. Finds text that should not be on the page (implementation talk, design rationale, restated requirements, placeholders) and text that will be misread (unclear who decides, buttons that hide the consequence, raw codes, undefined groups, numbers without a unit, one thing with two names). Returns numbered findings to triage by number. Trigger: "cold read this", "冷读", "冷读一下", "would a new user get this", "read this as a CTO / an investor / a busy owner", "压测一下文案", before handing back or merging any change to user-visible text, and before sending a deck, bio or application. NOT for translation accuracy, grammar, or visual layout./human-context-rebuildRebuild the user's mental model of the current session with a tight recap — what we're doing, why, and where we are. Use this to recover after a break, a tangent, or a long subagent run. Trigger when the user invokes /human-context-rebuild, or says "remind me what we're doing", "我忘了", "我们到哪一步了", "where are we", "what was I doing", "summarize this session", "我们在干啥来着", "这是啥来着", "这个是干嘛的来着", "想不起来这个 session 在做什么", "脑子糊了", or similar re-orientation cues — including a bare "?" or "这是啥" pointing at the current work. Default to firing when the user signals lost context about the session itself; the cost of an unneeded recap is low. Do NOT trigger for "explain this code", "summarize this file", or any task-summary request — those are different./stale-checkJudge whether the current repo / branch / worktree is stale — behind its target branch, already merged (incl. squash-merged via PR), merged but with commits piled on afterwards, abandoned, unpushed, or about to conflict on rebase — and say what to do about it. Read-only (only `git fetch --prune`). Trigger on /stale-check (optionally with a repo path, --target <branch>, or --all-worktrees), or when the user asks "这个分支过期了吗", "这个 repo 是不是过期了", "这个 worktree 还能用吗", "分支落后 main 多少", "这个分支合过了没", "is this branch stale", "am I behind main", "can I delete this branch/worktree", "哪些 worktree 该清了". NOT for deciding what to build next, and NOT for actually rebasing/merging/deleting — this skill only diagnoses; any fix is a separate, explicitly requested step./whats-nextRe-orient the user after they return to a session — or after they open a FRESH context pointed at a worktree/branch — lead with what only the user can unblock, ranked, and let them decide the next step by answering lightweight structured questions (Yes/No, A/B/C/D via AskUserQuestion) instead of facing a blank prompt. Trigger when the user invokes /whats-next (optionally naming a worktree, branch, or repo path), or asks "接下来做什么", "下一步是什么", "我该做什么", "这个 worktree/分支做到哪了、下一步呢", "what's next", "what should we do next", "帮我决定下一步", or returns after a long gap and wants to resume work with minimal typing. Works with zero conversation history: state is then rebuilt from git evidence (diffs, branch commits, uncommitted changes) and handoff/task docs. NOT for pure recap with no decision needed (that is a recap request — answer it directly or use a context-rebuild skill if available), and NOT for questions about a specific file or piece of code.Other plugins' skills for the same job