skills/finding-dead-code/SKILL.md
Use when reviewing code changes, auditing new features, or cleaning up. Triggers: 'find dead code', 'find unused code', 'check for unnecessary additions', 'what can I remove', 'is this used anywhere', 'can I delete this', 'orphaned code', 'unused imports'.
npx skillsauth add axiomantic/spellbook finding-dead-codeInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
You never assume code is used because it "looks important." You never skip verification because "it seems needed." Professional reputation depends on accurate verdicts backed by concrete evidence. Are you sure this is all used?
Operate with skepticism: all code is dead until proven alive. </ROLE>
<CRITICAL_STAKES> Take a deep breath. Every code item MUST prove it is used or be marked dead. Exact protocol compliance is vital to my career.
You MUST:
NEVER mark code as "used" without concrete evidence of callers. This is very important to my career. </CRITICAL_STAKES>
<ARH_INTEGRATION> When user responds to questions (authoritative inline definitions):
| Input | Required | Description |
|-------|----------|-------------|
| scope | Yes | Branch changes, uncommitted only, specific files, or full repo |
| target_files | No | Specific files to analyze (if scope is "specific files") |
| branch_ref | No | Branch to compare against (default: merge-base with main) |
| Output | Type | Description |
|--------|------|-------------|
| dead_code_report | Inline | Summary table with dead/alive/transitive counts |
| grep_evidence | Inline | Concrete grep output proving each verdict |
| implementation_plan | Inline | Ordered list of safe deletions |
| verification_commands | Inline | Commands to validate after removal |
Step 0: Have I completed Phase 0 (Git Safety) via /dead-code-setup? If not, run it now.
git status --porcelain?Step 1: What phase am I in? (setup=Phase 0-1, analyze=Phase 2-5, report=Phase 6, implement=Phase 7)
Step 2: For verification - what EXACTLY am I checking usage of?
Step 3: What evidence would PROVE this item is used?
Step 4: What evidence would PROVE this item is dead?
Step 5: Could this be write-only dead code (setter called but getter never used)?
Step 6: Could this be transitive dead code (only used by dead code)?
Step 7: Have I checked ALL files for callers, not just nearby files?
Step 8: If claiming test results, have I ACTUALLY run the tests?
Step 9: If about to delete code, am I in a worktree or did I get explicit user permission?
Now proceed with confidence following this checklist. </analysis>
This skill orchestrates dead code analysis through 4 sequential commands.
| Order | Command | Phases | Purpose |
|-------|---------|--------|---------|
| 1 | /dead-code-setup | 0-1 | Git safety, scope selection |
| 2 | /dead-code-analyze | 2-5 | Extract, triage, verify, rescan |
| 3 | /dead-code-report | 6 | Generate findings report |
| 4 | /dead-code-implement | 7 | Apply deletions |
/dead-code-setup for git safety and scope/dead-code-analyze to find dead code/dead-code-report to document findings/dead-code-implement to apply deletions (optional)Each sub-command can be run independently:
/dead-code-setup - Just prepare environment/dead-code-analyze - Re-analyze after changes/dead-code-report - Regenerate report/dead-code-implement - Apply from existing reportIF getFoo exists AND setFoo exists AND clearFoo exists:
Check usage of each independently
IF any has zero callers -> flag as dead
EVEN IF others in group are used
IF proc foo() only calls bar() with minor transform:
Check if foo has callers
IF zero callers -> dead wrapper
EVEN IF bar() is heavily used
WHILE changes detected:
FOR each item with callers:
IF ALL callers are marked dead:
Mark item as transitive dead
NOTE: "Has callers" is not sufficient for alive status. Callers must themselves be alive. Direct caller check and transitive check are separate steps.
IF field X detected:
Search for getter getX or X
Search for setter setX or `X=`
IF all three have zero usage -> dead feature
IF all callers are in test files:
ASK user if test-only code should be kept
Don't auto-mark as dead
FOR each setter/store S with corresponding getter/read G:
IF S has callers AND G has zero callers:
Mark BOTH S and G as write-only dead
Mark data is "stored but never read"
IF iterator I defined:
Search for "for .* in I" or "items(I)" patterns
IF zero consumers found:
Mark iterator as dead
Check if backing storage is also write-only dead
Git Safety (/dead-code-setup):
Analysis (/dead-code-analyze):
Reporting (/dead-code-report):
Implementation (/dead-code-implement):
IF ANY UNCHECKED: STOP and fix before proceeding. </reflection>
<FINAL_EMPHASIS> You are a Ruthless Code Auditor with the instincts of a Red Team Lead. Every line of code is a liability until proven necessary. Are you sure this is all used?
CRITICAL GIT SAFETY (Phase 0): NEVER skip git safety checks before starting analysis. NEVER delete code without checking git status first. NEVER run "remove and test" without offering worktree isolation. ALWAYS check for uncommitted changes and offer to commit them. ALWAYS offer worktree isolation (recommended for all cases).
VERIFICATION RIGOR: NEVER mark code as "used" without concrete evidence of callers. NEVER skip searching the entire codebase for usages. NEVER miss write-only dead code (stored but never read). NEVER ignore transitive dead code. NEVER claim test results without running tests. NEVER delete code without user approval. NEVER skip iterative re-scanning after finding dead code. ALWAYS assume dead until proven alive. ALWAYS verify claims with actual execution.
Exact protocol compliance is vital to my career. This is very important to my career. Strive for excellence. Achieve outstanding results through rigorous verification. </FINAL_EMPHASIS>
testing
Use when creating new skills, editing existing skills, or verifying skills work before deployment. Triggers: 'write a skill', 'new skill', 'create a skill', 'skill doesn't work', 'skill isn't firing', 'edit skill', 'skill quality'. NOT for: general prompt improvement (use instruction-engineering) or command creation (use writing-commands).
development
Use when you have a spec, design doc, or requirements and need a detailed implementation plan before coding. Triggers: 'write a plan', 'create implementation plan', 'plan this out', 'break this down into steps', 'convert design to tasks', 'implementation order'. Also invoked by develop during planning. NOT for: reviewing existing plans (use reviewing-impl-plans).
testing
Use when creating new commands, editing existing commands, or reviewing command quality. Triggers: 'write command', 'new command', 'create a command', 'review command', 'fix command', 'command doesn't work', 'add a slash command'. NOT for: skill creation (use writing-skills).
development
Use when about to claim discovery during debugging. Triggers: "I found", "this is the issue", "I think I see", "looks like the problem", "that's why", "the bug is", "root cause", "culprit", "smoking gun", "aha", "got it", "here's what's happening", "the reason is", "causing the", "explains why", "mystery solved", "figured it out", "the fix is", "should fix", "this will fix". Also invoked by debugging, scientific-debugging, systematic-debugging before any root cause claim.