skills/dead-code-sweep/SKILL.md
This skill should be used when cleaning up codebases that have accumulated dead code, redundant implementations, and orphaned artifacts — especially codebases maintained by coding agents. Triggers on "find dead code", "clean up unused code", "remove redundant code", "prune this codebase", "dead code sweep", "code cleanup", or when a codebase has gone through multiple agent-driven refactors and likely contains overlooked remnants. Systematically identifies cruft, categorizes findings, and removes confirmed dead code with user approval.
npx skillsauth add petekp/claude-skills dead-code-sweepInstall 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.
Systematic identification and removal of dead code, redundant implementations, and orphaned artifacts in codebases — particularly those maintained by coding agents with limited context windows.
Coding agents operate within narrow context windows. When refactoring, they often:
This cruft compounds. Each orphaned artifact misleads the next agent (or human), who wastes context budget reading code that does nothing.
Determine the analysis boundary.
If the user provides a scope (directory, file pattern, module), constrain all analysis to that scope.
If no scope is provided, analyze the full codebase. Start by reading the project structure:
Produce a brief inventory:
Language(s): TypeScript, Python
Entry points: src/index.ts, src/cli.ts
Build: esbuild via package.json scripts
Packages: 1 (single package)
Estimated LOC: ~4,200
Launch parallel sub-agents to scan for different categories of dead code. Read references/cruft-patterns.md for the full catalog of detection patterns.
Organize detection into these parallel tracks:
| Track | What It Finds | |-------|--------------| | Orphaned files | Files not imported, required, or referenced by any other file | | Unused exports | Exported symbols (functions, classes, types, constants) never imported elsewhere | | Redundant implementations | Multiple functions/classes doing the same thing under different names | | Stale compatibility code | Shims, adapters, wrappers, and re-exports that bridge interfaces that no longer differ | | Dead branches | Conditional paths that can never execute (always-true/false guards, unreachable returns) | | Orphaned tests | Test files testing functions or modules that no longer exist | | Orphaned dependencies | Packages in dependency manifests not imported anywhere in source |
For each track, the sub-agent should:
references/cruft-patterns.md for detection strategies specific to that trackrg <filename> -- scripts/ tests/ .github/. Files consumed
as ratchet-check arguments or Bats test fixtures are NOT dead even if
zero source files import them.Verification is critical. Common false positives to watch for:
bin fieldscheck_file_contains "name" "path/to/file" in scripts/ci/, or
cat "$PROJECT_ROOT/path/to/file" in tests/**/*.bats. These are string
arguments, not imports, so import-tracing tools miss them entirely.When uncertain, mark as "needs review" rather than "confirmed dead."
Consolidate all findings into a structured report at .claude/dead-code-report.md.
Organize findings by confidence level, then by category:
# Dead Code Sweep Report
**Scope:** [full codebase | specific path]
**Date:** [date]
**Estimated removable lines:** [count]
## Confirmed Dead (high confidence)
### Orphaned Files
- `src/utils/old-parser.ts` — Not imported anywhere. Superseded by `src/parser/index.ts`.
- ...
### Unused Exports
- `formatDate()` in `src/helpers.ts:42-58` — Exported but zero imports across codebase.
- ...
[...other categories...]
## Needs Review (uncertain)
### Possibly Dynamic
- `handleLegacyEvent()` in `src/events.ts:91` — No static imports, but may be registered dynamically.
- ...
For each finding, include:
Present the report summary to the user and ask for approval before removing anything.
Use AskUserQuestion to present findings by category:
Found 12 confirmed dead items and 3 needing review.
Confirmed dead by category:
- 3 orphaned files (~280 lines)
- 5 unused exports (~120 lines)
- 2 redundant implementations (~90 lines)
- 2 orphaned dependencies
Which categories should I clean up?
Options: Remove all confirmed / Select categories / Review each item / Skip cleanup
For each approved category:
If any removal causes a build or type error, immediately revert that specific removal and move the item to "needs review."
After cleanup, update the report with what was removed and what was kept.
Start from known entry points and trace what's reachable, rather than starting from a suspect symbol and trying to prove it's used. The reachability approach has fewer false negatives.
A symbol exported from a package's public API may be consumed by external code not visible in this repository. When analyzing libraries or packages with external consumers, only flag internal (non-public-API) dead code as "confirmed." Flag public API dead code as "needs review."
Agent-generated cruft tends to cluster. When one dead function is found, examine its neighbors — the agent likely abandoned the entire section during a refactor. A dead file often has sibling dead files created in the same commit.
When available, check when suspect code was last meaningfully modified. Code untouched across several refactor commits is more likely dead. Use git log --follow to trace renames and detect superseded files.
Files may have zero source-code references but be consumed by CI scripts (scripts/ci/, .github/workflows/), shell test fixtures (tests/**/*.bats), or verification tooling (.verifier/). These references appear as string arguments to shell functions — invisible to import tracing. Always run rg <filename> -- scripts/ tests/ .github/ before classifying a file as orphaned.
tools
Comprehensively manually test the Circuit plugin's user-facing surface in either Claude Code or Codex. Use this skill whenever the user asks to "manually test Circuit", "QA the Circuit plugin", "exercise the Circuit surface", "run the Circuit checklist", "smoke test Circuit", "find regressions in Circuit", "test the Claude Circuit plugin", "test the Codex Circuit plugin", or when preparing a Circuit release for marketplace publication. Argument is the host package to test — `claude` or `codex`. Produces a Markdown report with per-command pass/fail, exploratory findings ranked by severity, run-folder evidence links, and a concise terminal summary. Use even if the user does not say the word "test" — phrases like "go through every Circuit command" or "make sure Circuit still works end-to-end" should also trigger.
development
Turn the prompt supplied with this skill into a concise, auditable Codex Goal or explain why a Goal is not the right fit. Use when the user asks to draft, formulate, rewrite, tighten, or create a `/goal` from a plain-language task, especially for multi-step work that needs a durable objective, evidence-based completion, constraints, iteration policy, and a default adversarial review loop.
development
Give the human a fast, plain-English catch-up on what changed in the project: what the agents did, why, and what decisions need their input. Use this whenever the user asks to "catch me up", "what changed", "where are we", "recap", "brief me", "give me the rundown", "what did you do", "summarize the session", "fill me in", or otherwise signals they have been away and want to get back up to speed quickly. Built for someone steering several agent-driven projects at once who does not read the code closely but needs to grasp the core ideas, the choices made, and the open decisions well enough to steer. Trigger even if they do not use these exact words: any request to get oriented on recent progress should use this skill.
tools
Expert Unix and macOS systems engineer for shell scripting, system administration, command-line tools, launchd, Homebrew, networking, and low-level system tasks. Use when the user asks about Unix commands, shell scripts, macOS system configuration, process management, or troubleshooting system issues.