/yskills:stale-checkfrom yskills
Diagnoses whether a git branch, repo, or worktree is stale by checking behind-target, merged status, post-merge commits, abandonment, unpushed work, and rebase conflict risk. Read-only; never modifies branches.
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.
Read when SKILL.md points to them; scripts run unread.
One question: is this repo/branch still a valid place to keep working, or has the world moved on? Run the probe, map the numbers to a verdict, give the user a one-screen answer in their language. Never rebase, merge, reset, delete, or checkout — diagnose only.
bash <this-skill-dir>/scripts/stale_check.sh [repo-path] [--target <branch>] [--no-fetch] [--all-worktrees]
--all-worktrees when the question is "which worktrees can go" or the repo has several
worktrees (the script lists each with ahead/behind/merged/dirty/age and flags).--no-fetch only if offline or the user says not to touch the network.--target → $STALE_CHECK_TARGET → the worktree manager's own record (super.engineering's
sc worktree status, used automatically inside such a session) → origin/HEAD → main/master. If the
user or the tool that created the worktree says the base is something else (develop, a release
branch), pass --target; don't re-derive it from the branch name.The first block is KEY=VALUE; the rest is supporting evidence (commit lists, post-merge commits, what
the branch is for, dirty files, other worktrees). Read the whole thing before judging.
| Verdict | Signals | Meaning |
|---|---|---|
| LEFTOVER — PR 合了但后面还有提交 / merged, then kept going | PR=MERGED and POST_MERGE_COMMITS > 0 | The PR landed, then more commits went on the branch. Those commits are on no branch the target knows about. Deleting now loses them. |
| DEAD — 已合并,可清 / merged, safe to retire | MERGED_INTO_TARGET=yes_* and DIRTY_TRACKED=0 | The branch's work already lives on target. Only untracked leftovers may still matter. |
| REUSED — 合过的分支上又开了新活 / new work on a merged branch | MERGED=yes_*, DIRTY_TRACKED>0, and (AHEAD>0 or PR=MERGED) | The branch is finished, but uncommitted changes sit on top. They belong on a fresh branch off target. |
| DEAD — PR 已关闭未合 / closed unmerged | PR=CLOSED and MERGED_INTO_TARGET=no | Abandoned by decision. Ask before treating leftovers as valuable. |
| CONFLICTING — 过期且会打架 / stale and will conflict | MERGED=no, REBASE_CONFLICT=yes | Rebase needed and will conflict in the listed files. Cost of continuing rises daily. |
| STALE — 明显落后 / clearly behind | BEHIND ≥ 30 or MERGE_BASE_AGE_DAYS ≥ 14 or BRANCH_TIP_AGE_DAYS ≥ 14, none of the above | Needs a rebase before any new commit; check OVERLAP_FILES — overlap without conflict is still risk. |
| DRIFTING — 稍微落后 / a little behind | BEHIND > 0, none of the above | Fine to keep working; rebase before pushing / opening a PR. |
| FRESH — 没过期 / up to date | BEHIND=0 (or on the target branch itself with LOCAL_TARGET_BEHIND_REMOTE=0) | Up to date. |
MERGED_INTO_TARGET values, strongest evidence first: yes_ancestor (fast-forward / merge commit, or the
branch has no commits of its own), yes_patch_equivalent (rebase-merge or cherry-pick), yes_squash
(the branch's whole diff equals one target commit), yes_pr_head (GitHub merged a PR whose head is exactly
this commit), yes_tree_identical. n/a means you are on the target branch itself.
Secondary flags to always surface when non-zero, regardless of verdict:
UPSTREAM=none with AHEAD>0 → never pushed; every branch commit exists only on this machine.
unpushed=? there means "no upstream to compare with", not zero.UPSTREAM state=gone → remote branch deleted (usually post-merge). Corroborates DEAD.unpushed>0, DIRTY_TRACKED>0, UNTRACKED>0 → work that would be lost if the worktree were dropped.
List the files — the user decides.AHEAD=0 → the branch has no commits of its own (yes_ancestor is then trivially true). With dirty
files and no PR, it's an unstarted branch whose whole feature is still uncommitted — judge it by
BEHIND and say plainly that nothing is committed yet.STASHES is repo-wide (all worktrees share it); this_branch counts stashes made on this branch.
Removing a worktree does not drop stashes.LOCAL_TARGET_BEHIND_REMOTE>0 when on the target branch itself → the local main is what's stale.FETCH=failed → every remote-derived number may be old; say so.POST_MERGE_COMMITS=rewritten → the branch was rebased/reset after its PR merged; compare the two
commit lists by hand. unknown → the PR head isn't fetched locally.Thresholds are heuristics for a repo where the target moves several commits a day. On a slow repo a
20-behind branch can be FRESH-ish; a 5-behind branch touching the same file as target can be hot. Lean on
OVERLAP_FILES and REBASE_CONFLICT over raw counts.
Keep it to one screen:
【DEAD / STALE / …】<branch> vs <target>, with the 2–3 numbers that drove it.
Right under it, one line on what the branch is for, from the ## purpose block (PR title, first
commit, diff size, top touched folders, notes that name the branch). After a verdict, people usually
ask next what the branch was for, so answer it up front. If only commit messages back it, say it's a
guess.budget-form.tsx". Do not execute it. If the user then asks to rebase/delete/clean,
that's a new request, handled under the repo's own rules and its worktree tool's own commands.With --all-worktrees, add a compact table of the other worktrees (branch, ahead/behind, merged, dirty,
tip age, flags) and mark the DEAD ones. The table runs cheap checks plus one gh call for recently
merged PRs:
merged=yes / yes_patch / yes_pr_head — the work is on target (yes_pr_head: a merged PR's head
is exactly this branch tip, which is how squash merges show up).merged=pr_merged_tip_moved — a PR from this branch merged, but the tip has moved since: commits after
the merge, or a rewrite. Probe it on its own; it is often LEFTOVER.merged=no — not proven merged. Squash merges without a PR record land here too.temp_dir = the tree lives 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 (prunable,
dirty=?).Probe any borderline row on its own (stale_check.sh <its path>) before calling it DEAD. If the user then
asks to clean up, hand off to the worktree-cleanup skill.
Worked examples from real runs (names and paths changed) — LEFTOVER, a squash-merged DEAD, CONFLICTING, DRIFTING, REUSED, and a worktree sweep — are in references/examples.md. Read them when unsure how a verdict should sound.
PR=MERGED alone is not "safe to delete": check POST_MERGE_COMMITS. People keep committing on a
branch after the PR lands, and those commits never reach target.AHEAD>0 forever. Trust yes_squash / yes_pr_head over the count;
git branch --merged and most worktree sidebars report these branches as unmerged.PR=none only means no PR from this branch name; the work may have been re-pushed under another name
or committed straight to target. If MERGED=yes_* with PR=none, say "content already on target, no
PR record".PR=n/a means gh is missing, unauthenticated, or the remote isn't on GitHub. Merge detection still
works from git alone, except yes_pr_head and POST_MERGE_COMMITS.DIRTY_TRACKED / UNTRACKED for what would be lost.next dev) can
write its cache back and leave an empty shell directory. Worth a line in the recommendation.main; a stale local
main shows up as LOCAL_TARGET_BEHIND_REMOTE.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
git-branch, worktree-cleanup, stale-branch, branch-status, git-diagnosis
5 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.npx claudepluginhub lycfyi/yskills --plugin yskillsOther plugins' skills for the same job