/docs-hygiene:rename-references [audit|preview|blocklist] [<old> [to <new>]] [--container|--identifier…] [--repo <repo> ...]from docs-hygiene
Sweeps stale references after renaming skills, files, or identifiers across 7+ syntactic forms including chain prose, table rows, frontmatter, and glob patterns. Use after 'rename X to Y' or 'git mv'.
Ships in docs-hygiene. 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.
Arguments. [audit|preview|blocklist] [<old> [to <new>]] [--container|--identifier…] [--repo <repo> ...]. Full form: [audit [blast|half-rename|orphans]|preview|blocklist] [<old> [to <new>]] [--include-historical|--include-memory|--include-plan-docs|--include-bare-token|--container|--identifier] [--repo <repo> ...|--repos-from <file|->|--owner <owner>|--fleet] [--skip <entry> ...] (e.g., /rename-references audit, /rename-references audit blast /verify to /verify-changes, /rename-references audit half-rename /a to /b, /rename-references audit orphans /a to /b, /rename-references blocklist)
Run each command below as its own Bash call, all sent together in one message (worktree isolation).
Keep any bound in the command's own pipe (output limits).
Unless this section says otherwise, treat a failure (not a repository, git unavailable) as an unknown value and carry on. Keep these as body calls, never ## Pre-computed context lines (gather-block convention).
git status --porcelain | head -20git diff --name-status -M HEAD | grep '^R' | head -15git diff --cached --name-status -M | grep '^R' | head -15git branch --show-currentAfter renaming a skill, file, or identifier, references survive in 7+ syntactic forms. Token-only grep (/old) catches the obvious ones; the rest hide in chain prose (→ old →), comma-lists (Test, Old, Retro), numbered table rows (| 7. Old |), frontmatter chain strings (description: "...→ old → retro process."), frontmatter globs ({a,b,old,c}), cross-skill mode references, and content-file paths (context/old.md style).
This skill makes "find every reference" one invocation instead of 4 manual sweep passes: it runs the full pattern library, triages matches into 3 buckets, and surfaces ambiguity (English-verb collisions like confirm/test/review) for user confirmation rather than auto-applying.
The pattern library, triage classifier, and audit modes need only git and the Grep tool. An adjacent capability named in prose (a verification workflow, an issue tracker, a codebase-audit routine) is optional: invoke it if present, otherwise proceed without. Consumer conventions (work-notes locations, commit policy, naming rules) come from the consuming repository's CLAUDE.md and rules; read them, never assume them.
Parse $ARGUMENTS first token to determine action. Subsequent tokens are the rename pair (with to/→/->/into separator) or single token for reverse-mode.
| Argument shape | Action | Read |
|---|---|---|
| (empty) | Smart default | inline below. Detect rename pair from conversation/git/staged |
audit | Audit (read-only sweep. Alias for audit blast) | context/audit.md + audit-modes.md |
audit <old> or audit <old> to <new> | Audit with explicit pair | context/audit.md |
audit blast [<old> [to <new>]] | Audit Blast. Pre-rename impact (counts + per-file + bucket distribution; inline-only) | audit-modes.md |
audit half-rename <old> to <new> | Audit Half-Rename. Files mentioning both old and new (incomplete-rename hygiene) | audit-modes.md |
audit orphans <old> to <new> | Audit Orphans. Refs at old name or vanished path after rename (requires pair) | audit-modes.md |
<old> to <new> | Apply full rename | context/apply.md |
preview <old> to <new> | Preview dry-run | context/apply.md (skip Edit phase) |
<old> (single token, no separator) | Reverse. Find refs, ask what to replace with | context/audit.md |
blocklist | Print English-verb blocklist (read-only introspection of triage-bucket safety mechanism) | inline below |
Every sweep runs off the pattern library, the full form registry in context/patterns.md; read it before any sweep. A sweep runs through the Grep tool with the patterns.md regexes over the tracked tree, covering every form the action sweeps (every form in patterns.md for apply, preview, audit and Blast; the forms Audit Orphans names for Orphans). One Grep may combine forms in an alternation as long as every form's regex is in it; never let one token grep stand in for them. Attribute each hit to its form, and a form whose regex no call ran is a form the sweep missed. Reading files one by one is not a sweep; use Read only to confirm a Grep hit in its surrounding context before classifying or editing it. Triage logic is in context/triage.md. Audit sub-mode detail (Blast / Half-rename / Orphans) is in context/audit-modes.md.
A small tree, or a bare-token search that already shows every hit, excuses no form: run each form's regex as patterns.md writes it, the numbered-row and frontmatter forms included, and name the forms run in the report.
Six flags. Four widen the sweep; two override the rename-mode resolution. Defaults preserve safety (rename-documenting plan docs / frozen historical notes / memory entries excluded). Long-form only, position-agnostic.
| Flag | Effect | Apply mode? |
|---|---|---|
--include-historical | Sweep archived/completed work notes and frozen records of past work | OK |
--include-memory | Sweep Claude Code auto-memory files and MEMORY.md indices in the auto-memory directory (resolution: Auto-memory location) | OK |
--include-plan-docs | Sweep the active plan/work-notes documents that document this rename | audit-mode only, apply mode rejects with explicit error (the plan doc documents the rename, both names appear by design) |
--include-bare-token | Surface the bare-token residue that container-rename mode suppresses (patterns.md "Phase 0b"). Always Ambiguous, never Certain. Not applicable to audit orphans, which sweeps no bare-token form | audit-mode only |
--container | Force container-rename mode, skipping the evidence ladder (patterns.md "Phase 0b") | OK |
--identifier | Force identifier-rename mode | OK |
Multiple flags compose. Unknown flags raise an error. Detail in audit-modes.md "Override flags" section.
Several repositories. A target form (--repo <repo> and the others) is accepted by every action except blocklist, and sweeps the one rename pair in each repository, per ${CLAUDE_PLUGIN_ROOT}/reference/target-scope.md and ../../context/clean-tree-fallback.md "Several repositories": one subagent per repository runs Phases 2-3, the Grep sweep with its path set to that repository's root and the triage, and hits are reported per repository. The pair comes from the arguments, or from the Smart default run in the session's own repository. The main session runs Phase 4 over the merged report, so every confirmation is asked there. Apply edits the session's own repository in place, as without a target form, and each other repository in its own worktree with its own pull request; Phase 6's re-sweep runs per repository.
Memory exclusion and --include-memory act on the auto-memory directory the session actually uses.
Settings and environment can move it away from the default under ~/.claude/projects/, so resolve
the configured location before sweeping or excluding, and fall back to the default only when nothing
overrides it.
/docs-hygiene:rename-references blocklist prints the English-verb blocklist literal from context/triage.md. Read-only: no edits, no sweeps. To extend, edit triage.md directly.
Detect rename pairs in this priority order:
git diff --name-status -M HEAD and git diff --cached --name-status -M; R<score> lines map old path → new pathD <path> + ?? <similar-path> in git status --porcelain (heuristic. Levenshtein-similar basenames within same dir)If multiple candidates surface, present via AskUserQuestion. User picks which pair to audit.
If zero candidates: report "No rename detected in conversation or git state. Provide /docs-hygiene:rename-references <old> to <new> or /docs-hygiene:rename-references audit <old> to invoke explicitly."
The argument string after the action keyword can be:
| Form | Example | Parses to |
|---|---|---|
<old> to <new> | /verify to /verify-changes | old=/verify, new=/verify-changes |
<old> to <new> (mode) | /verify to /verify-changes outcome | old=/verify outcome, new=/verify-changes outcome |
<old> → <new> | test live → test e2e | old=test live, new=test e2e |
<old> -> <new> | foo -> bar | old=foo, new=bar |
<old> into <new> | legacy into modern | old=legacy, new=modern |
<path/old.md> to <path/new.md> | confirm/SKILL.md to verify/SKILL.md | path rename. Skill applies extra path-form patterns |
Multi-word old/new is fine. Separator is the only delimiter. Quote characters ("foo bar") optional. Old/new taken verbatim. Leading slashes preserved (/confirm stays /confirm, not confirm).
context/patterns.md in parallel as Grep tool calls against tracked text files; aggregate per-file hit counts. For a skill/identifier rename, first enumerate coupled-sibling renames (dot-form behavior point-IDs, internal mode names, content-file basenames that changed in lockstep) and queue each as its own rename pair. They carry no primary token, so the primary sweep never reaches them (see Gotchas "coupled-rename")context/triage.md:
confirm/test/review/fix/clean/build/lint/verify/plan/etc.)AskUserQuestion, then per bucket:
context/patterns.md "Phase 0" span-precedence and "Phase 0b" container-rename mode, minus the matches the user confirmed skipping in Phase 4: neither the mode's residue nor a deliberate skip ever counts, or the loop cannot terminate). If non-zero, new form not in pattern library. Report to user, add to context/patterns.md, re-iterate.Audit mode runs phases 1-3 only and reports, no Edit calls. Preview mode runs 1-4 and reports planned edits, no Edit.
Paths skipped from sweeps automatically:
--include-historical is passed, report them only as "Kept as history" (triage.md "Frozen historical records"), never as a choice for the user..git/, node_modules/, bin/, obj/, .venv/, dist/, build/| Stage | How | Why |
|---|---|---|
| Pre-rename impact analysis | /docs-hygiene:rename-references audit <old> | Read-only sweep, see blast radius before changing anything |
| Rename execution | /docs-hygiene:rename-references <old> to <new> | Sweep → triage → edit → re-sweep |
| Post-rename verification | the consuming repository's build/test/lint workflow | Confirm no semantic regression |
| Cleanup near rename sites | a separate simplification/refactor pass | Opportunistic refactor (separate concern) |
confirm, test, review, clean, fix, build, lint, plan, run, view, start, stop, merge, split, sort, filter, group, head, body, link, list, work, log, watch, monitor. Triage forces these into ambiguous bucket regardless of regex hit position. User confirms each.confirm inside confirmation must not match. All bare-token patterns use \b./confirm should match but not /confirmation, /confirm-changes, or path/confirm. Use \B/<old>([^\w-]|$) (non-word-boundary before the slash; a consumed terminator after that excludes a hyphen). A trailing \b is not enough: it treats a hyphen as a boundary, so it matches inside kebab-case sibling commands, and Form 1 is Certain, so that auto-applies. The consumed character is not part of the reference.multiline: true on the Grep tool.test → test e2e is a substring expansion. Apply most-specific match first, mark already-edited regions to prevent double-edit.When the pair comes from a domain glossary change (a term renamed, a word moved to the entry's
Avoid: line, or a verb moved into the parentheses of an entity's Actions: line, usually handed
over by /domain-driven-design:ubiquitous-language (if enabled)), code names
follow the glossary too, and the sweep runs as its own reviewed change, never folded into the
glossary edit. When the domain-driven-design plugin is enabled, the
sweep also matches the term inside identifiers the way that skill's glossary contract counts a
term ("Counting a term"), so addLearner is found for learner; when it is not, the report says the identifier-part pass
did not run. Ordinary renames keep the \b anchor ("Word-boundary trap"). The report groups hits
by layer:
file:line and the glossary term; none is edited, because users'
words may rightly differ from the model's. A hit matching the entry's Shown to users as:
wording is intended, not drift./architecture:adr (if enabled).git branch -m.docs-naming is enabled, /docs-naming:audit-file-names (if enabled) does. Without it, list the tree with git ls-files, compare each name against the rule by hand, and run audit here once per pair you decide to rename.audit orphans is strictly pair-driven (post-rename hygiene only). For repo-wide dead-link / dead-reference checks unrelated to a specific rename, use a codebase-audit workflow or documentation link checker if your environment provides one./docs-naming:audit-file-names./toolchain:check./docs-hygiene:rename-references audit.context/patterns.md, add an eval case, and re-iterate. Do not silently apply.git mv changes directory depth, relative refs inside the moved files (source ../../lib.sh, # shellcheck source=../../../../tests/..., relative markdown links) silently break. They carry no renamed token, so every token-keyed pattern returns clean while the moved file itself is broken. After any depth-changing move: run the Grep tool with pattern \.\./ over the moved files, then re-run the moved code from its new location (tests, --help).verify.runtime-affecting-paths, Form 12), internal mode names (quality mode), content-file basenames (context/quality.md style paths). A phase-scoped, skill-only grep on the primary token (/verify) leaves these external refs, in skill bodies, config files, and other skills' dispatch tables, unverified. A slash-anchored token sweep can return "clean" while <old>.id / <old-mode> / <old>.md-path refs survive elsewhere. Before declaring a rename complete: enumerate the coupled identifiers (Survey phase) and run a sweep per pair.Invoke /docs-hygiene:rename-references whenever a rename happens: during implementation, or before final verification to confirm no stragglers.
Skill chaining:
| Condition | Action |
|---|---|
| User says "I renamed X to Y" mid-implementation | Invoke /docs-hygiene:rename-references <X> to <Y> to sweep before continuing |
git mv just executed | Invoke /docs-hygiene:rename-references audit to surface stragglers |
| Pre-PR: working tree contains R-status files | Suggest /docs-hygiene:rename-references audit before final verification |
/docs-hygiene:rename-references finds 0 matches | Proceed to verification (or done if already past it) |
/docs-hygiene:rename-references finds new form not in pattern library | Update context/patterns.md, add eval case, re-iterate |
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
rename, refactoring, stale-references, code-sweep, pre-pr-check
npx claudepluginhub melodic-software/claude-code-plugins --plugin docs-hygiene10 skills in this plugin
/audit-derivabilityAudit derivabilityRead-only audit of whether a doc earns its existence or an agent can re-derive it from code, config, and structure: verdict per file (delete, convert-to-pointer, keep-as-derivation-cache, keep-owns-facts). Use when: 'is this doc worth keeping', 'audit doc value', 'prune redundant docs', or derivability. Not for noise: /docs-hygiene:audit-noise. Load it before judging whether a doc should stay or go./audit-encapsulationAudit encapsulationAudit skill encapsulation and boundary leak where external citation reaches private skill surface (.claude/skills/X/, plugins/*/skills/X/) beyond slash invocation; read-only, explicit fix FILE:LINE. Use when 'audit encapsulation', 'find skill leaks', 'check skill boundaries', skill boundary violation, reaching into SKILL, API drift, refactor skill. Load it to ask what depends on another plugin's internals. Load it too before publishing plugins as separate installs./audit-noiseAudit noiseRead-only audit of tracked markdown (rule/skill/convention doc) for nine noise shapes: stale historical citation, ghost ref, preamble, tracker back-ref, negation without positive, conversational residue. Use when 'audit markdown noise', 'find ghost refs', 'declutter', sweep for noise. Not for code comments: /code-tidying:remove-comments. Load it before listing a doc's leftover lines to cut before sharing it.Other plugins' skills for the same job