Rename references

From melodic-software/claude-code-plugins · View interactive version

Rename references is an AI agent skill from the GitHub repository melodic-software/claude-code-plugins. Sweep stale references after a rename, including forms token-only grep misses (slash-tokens, paths, chain prose, table rows, frontmatter globs). Use when: 'rename X to Y', 'I renamed X', 'audit rename', 'find stale refs', 'check for stragglers', 'after git mv', 'sweep references', 'rename impact pre

How to use this skill

Skill file

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)

Repository context. Gather first

<!-- BEGIN GENERATED: gather-block. Edit docs/conventions/gather-block/block.md, then run scripts/sync-gather-block.py -->

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).

<!-- END GENERATED: gather-block -->

Purpose

After 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.

Adapting to your environment

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.

Action router

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.

Override flags (audit modes)

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 CODE2 and CODE3 "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.

Auto-memory location

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.

Blocklist action

/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.

Smart default (no arguments)

Detect rename pairs in this priority order:

  1. Explicit args (highest precedence, never overridden)
  2. Recent conversation. Scan last 20 turns for prose like "I renamed X to Y", "rename X → Y", "git mv X Y", or assistant edits replacing identifier X with Y across multiple files
  3. Git rename detection. git diff --name-status -M HEAD and git diff --cached --name-status -M; R<score> lines map old path → new path
  4. Paired D <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."

Natural-language parser

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).

Workflow phases (apply mode)

  1. Detect. Gather rename pair (args / conversation / git per Smart default)
  2. Survey. Run all patterns from 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")
  3. Triage. Classify each match into 3 buckets per context/triage.md:
  1. Confirm. Present the bucket-count report, gate proceed/abort via AskUserQuestion, then per bucket:
  1. Apply, Edit each accepted match. Idempotent, running twice is safe.
  2. Re-sweep. Re-run Phase 2; exit when the actionable count is 0 (the survey after 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.
  3. Hand off. Suggest running the consuming repository's verification workflow (build + test + lint) to confirm no semantic regression in the rename target.

Audit mode runs phases 1-3 only and reports, no Edit calls. Preview mode runs 1-4 and reports planned edits, no Edit.

Auto-exclusions

Paths skipped from sweeps automatically:

Composition

| 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) |

Edge cases

Glossary-driven renames

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:

string literals are swept here like any other form; declarations of types, functions, variables

and enum members, and the call sites a symbol rename reaches, are listed for a language-aware

refactor tool, per "What this skill does NOT do".

so a hit in an ADR's file name, or in a path or link naming that file, is kept, never edited.

only. Each hit is listed with 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.

seed or fixture, a message schema, a public API field): never edited. The report names each as a

decision, a phased migration or a mapping that keeps the stored name, recorded as an ADR through

/architecture:adr (if enabled).

What this skill does NOT do

Next

/docs-naming:audit-file-names.

Related

Gotchas

2 and nothing else; chain prose, comma-lists, numbered rows, and frontmatter forms each need their

own pattern, and each surfaces only when that pattern runs. Run the whole library, or invoke

/docs-hygiene:rename-references audit.

Integration with workflow

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 |

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.