codex/skills/find-dead-code/SKILL.md
Find dead code using parallel sub-agent analysis and optional CLI tools, treating code only referenced from tests as dead. Use when the user asks to "find dead code", "find unused code", "find unused exports", "find unreferenced functions", "clean up dead code", or "what code is unused". Analysis-only — does not modify or delete code.
npx skillsauth add tobihagemann/turbo find-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.
Identify dead code in a codebase. Core rule: code only used in tests is still dead code. Only production usage counts.
In an incomplete or abandoned implementation, a declared-but-unused symbol may be intended-but-not-yet-used. When git history shows it was added as a deliberate part of an unfinished stack, recommend investigate rather than delete.
Determine the project structure:
package.json, tsconfig.json, pyproject.toml, setup.py, Package.swift, .xcodeproj, Cargo.toml, go.mod, pom.xml, build.gradle**/*.ts, **/*.py, **/*.swift, **/*.go, **/*.rs, **/*.javasrc/, lib/, Sources/)src/auth/, src/api/, src/utils/, lib/models/). Each directory becomes one sub-agent's scope in Step 3.If the user specified a scope, restrict analysis to that scope.
Establish which files are test files. Code referenced ONLY from these locations is dead.
| Language | Test file patterns |
|----------|-------------------|
| TS/JS | *.test.{ts,tsx,js,jsx}, *.spec.{ts,tsx,js,jsx}, __tests__/**, __mocks__/**, *.stories.{ts,tsx,js,jsx} |
| Python | test_*.py, *_test.py, tests/**, test/**, conftest.py |
| Swift | *Tests.swift, *Test.swift, Tests/**, *UITests.swift, XCTestCase subclasses |
| Go | *_test.go, testdata/** |
| Rust | tests/**, benches/**, #[cfg(test)] modules (inline test modules within source files) |
| Java/Kotlin | src/test/**, *Test.java, *Tests.java, *Spec.java, *Test.kt |
| General | fixtures/**, __fixtures__/**, mocks/**, testutils/**, testhelpers/**, spec/** |
Also exclude: test runner configs (jest.config.*, vitest.config.*, pytest.ini), storybook files, benchmark files.
If a CLI tool is installed, run it as a fast first pass for zero-reference dead code.
| Language | Tool | Check | Run |
|----------|------|-------|-----|
| TS/JS | knip | npx knip --version | npx knip --no-exit-code |
| Python | vulture | vulture --version | vulture <src_dirs> --min-confidence 80 |
| Swift | periphery | which periphery | periphery scan --skip-build |
| Go | deadcode | which deadcode | deadcode ./... |
| Rust | compiler warnings | — | cargo build 2>&1 \| grep "dead_code" |
Important limitation: CLI tools count test imports as real usage. They cannot detect code that is only used in tests. They only find symbols with literally zero references anywhere. Step 3 is required for test-only detection.
If no CLI tool is installed, skip to Step 3. Do not ask the user to install anything.
Before dispatching, read the project's test configuration and CI workflow to identify any test tier that resets a shared external resource between tests, such as a database, a fixed port, or a cache. Such tiers have no cross-process interlock, so sub-agents running them concurrently wipe each other's state and return failures that look like real defects. Name any such tier to every sub-agent as off-limits.
This is the primary analysis. Launch one sub-agent per top-level source directory from Step 1 with spawn_agent / wait_agent using inherited model defaults so they run concurrently. State the count explicitly when emitting the calls. Each sub-agent's prompt directs it to treat the shared working tree and its git index as read-only — any empirical check runs in an isolated git worktree created under $TMPDIR and discarded afterward. Give that worktree its own dependency install rather than reaching the shared tree's install by any route: removing a worktree deletes through symlinks, and a redirected suite writes into the shared install. When its own install is not possible, the check is left unrun and reported as such. Afterward the sub-agent verifies that git worktree list no longer shows the worktree, that git status --short is clean, and that the shared tree's dependency directory still resolves (a destroyed install leaves git status clean, since it is gitignored). Damage the sub-agent cannot repair is reported with the exact repair command in place of findings.
Each sub-agent receives:
Each sub-agent performs these steps on its assigned directory:
a) Find exported/public symbols:
| Language | Exported symbol patterns |
|----------|--------------------------|
| TS/JS | export function, export const, export let, export var, export class, export interface, export type, export enum, export default, module.exports |
| Python | Top-level def and class in non-_-prefixed modules, module-level constants (FOO = ...), symbols in __all__, public functions (no _ prefix) |
| Swift | public func, public var, public let, public class, public struct, public enum, public protocol, open class, open func, open var |
| Go | Capitalized identifiers: func FooBar, type FooBar struct, var FooBar, const FooBar (Go uses capitalization for public visibility) |
| Rust | pub fn, pub struct, pub enum, pub trait, pub const, pub static, pub type, pub mod |
| Java/Kotlin | public class, public static, public void, public fields, val/var properties, fun (top-level), @Bean, @Component, @Service annotated classes |
b) For each symbol, grep across the entire codebase for references, excluding:
node_modules/, dist/, build/, vendor/, __pycache__/, .tox/, .build/, DerivedData/, target/)c) Classify each reference as test or production based on the test file patterns.
CRITICAL — same-module references count as production usage. A symbol called by another production file within the same module/package is alive. Do not report symbols as "dead" when they have zero external callers but are used internally. Only report symbols with zero production references from any file. "Unnecessarily public" (could be internal/unexported) is a visibility issue, not dead code — do not include it.
d) Report structured results for each symbol:
dead (zero prod refs anywhere), test-only (only test refs), alive (has prod refs)After all sub-agents complete, collect and merge their results. Deduplicate any symbols that appear in multiple reports (e.g., re-exports).
Apply these filters to the merged results from Steps 2 and 3:
init() and main() functions, Go interface implementations, Rust main(), Rust trait implementations, #[derive(...)] generated code, CLI handlers registered in main, magic/lifecycle methods (__init__, __repr__), serialization methods (to_json, from_dict), interface/protocol implementationsindex.ts, __init__.py) before declaring a symbol dead. A symbol re-exported through a barrel may have indirect consumers.getattr, importlib, reflect package in Go, proc_macro in Rust), string-based lookups, or decorator/attribute registration as "likely dead" rather than "definite".turbo/specs/, ROADMAP.md, TODO.md), cross-reference test-only findings against them. Test-only APIs may be planned features awaiting integration — flag as investigate rather than deleteClassify each finding:
Run the $evaluate-findings skill on the classified results to verify each finding against the actual code and weed out false positives. Read the full definition file for each finding — not just the flagged symbol. The surrounding code may reveal that the feature is already implemented differently (e.g., a public ping() method may be test-only while a private keepalive loop in handleConnect() does the real work).
Proceed with the evaluation results in the next section.
For each surviving finding, assign a recommendation:
| Signal | Recommendation | |--------|---------------| | No tests, no production usage | delete | | Has tests but no production usage, and no spec/roadmap reference | delete (method + test assertions) | | Has tests but no production usage, referenced in spec/roadmap/TODO | investigate (planned feature, not dead) | | Partially wired up, unclear intent, or needs domain context | investigate |
For findings marked investigate, run the $investigate skill to determine whether the code is a planned feature, an unwired integration, or truly dead.
Watch for these high-yield patterns that tools and simple grep often miss:
isEnabled, count, currentItems). The module's production consumers use behavior (events, callbacks, side effects) — only tests peek at the internal state. When removing these, the corresponding test assertions must also be removed or rewritten to use behavior-based verification.While scanning for dead code, note (but do not act on) these related issues for the user:
Group results by confidence level:
| File | Symbol | Type | Line Range | Recommendation | |------|--------|------|------------|----------------|
| File | Symbol | Type | Test files referencing it | Recommendation | |------|--------|------|--------------------------|----------------|
| File | Symbol | Type | Reason for uncertainty | Recommendation | |------|--------|------|------------------------|----------------|
Include:
development
Apply a UX lens to a user-facing change: whether it serves the user's real goal and whether the path through it holds together, using the Understanding, Bridging, and Flowing contexts. Use when scoping, planning, or assessing any change that affects what a user sees or does. Loaded as a lens during planning and assessment.
development
Apply a UX lens to a user-facing change: whether it serves the user's real goal and whether the path through it holds together, using the Understanding, Bridging, and Flowing contexts. Use when scoping, planning, or assessing any change that affects what a user sees or does. Loaded as a lens during planning and assessment.
development
Assess project-wide structural technical debt: complexity hotspots, deprecated API usage, duplication clusters, and architecture rot. Ranks findings by impact and refactor effort into a report at .turbo/technical-debt.md. Use when the user asks to "assess technical debt", "find technical debt", "review technical debt", "what should we refactor", "find refactoring candidates", "where is the code rot", or "what's our worst code". Analysis-only — does not modify code.
development
Run a multi-agent review of code comments and markdown documentation for unnecessary content, then fix the issues. Covers what-restating comments, name-mirroring doc comments, status-update prose, and other documentation noise. Use when the user asks to "simplify docs", "simplify documentation", "clean up comments", "clean up docs", "review documentation", "strip unnecessary comments", "reduce doc noise", or "run simplify-docs".