From polishkit
Scan the codebase for dead code — unused exports, unreachable branches, dead variables, and obsolete imports — and remove it after confirmation. Use when the user asks to find dead code, remove unused code, or clean up unused exports/imports/variables.
How this skill is triggered — by the user, by Claude, or both
Slash command
/polishkit:dead-codeThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Scan for dead code — unused exports, unreachable branches, dead variables, and obsolete imports — and remove it after confirmation.
Scan for dead code — unused exports, unreachable branches, dead variables, and obsolete imports — and remove it after confirmation.
Focus area (if provided): $ARGUMENTS If no focus area is provided, scan the entire codebase.
Identify the primary language(s) in the repo and check for available static analysis tools:
TypeScript / JavaScript
# Check for TypeScript
ls tsconfig.json 2>/dev/null && echo "TypeScript project"
# Check for ESLint with unused-vars rule
ls .eslintrc* eslint.config* 2>/dev/null
Python
# Check for pyflakes, vulture, or ruff
which pyflakes vulture ruff 2>/dev/null
Go
# Check for staticcheck
which staticcheck 2>/dev/null
Run all applicable checks in parallel:
Unused exports (TypeScript)
# ts-prune or grep-based analysis
npx ts-prune 2>/dev/null || \
grep -rn "^export " --include="*.ts" --include="*.tsx" | \
grep -v "node_modules" | head -100
Unused imports
tsc --noEmit often surfaces these; or ESLint no-unused-varspyflakes . or ruff check --select F401 .Dead variables / unreachable branches
tsc --noEmit for noUnusedLocals, noUnusedParametersvulture . for dead code detectionstaticcheck ./...Unreachable code patterns (language-agnostic grep)
# Code after return/throw at same indentation level
grep -rn "return\b" --include="*.ts" --include="*.tsx" --include="*.js" .
Commented-out code blocks
# Large commented blocks (3+ consecutive comment lines)
grep -rn "^[[:space:]]*//" --include="*.ts" --include="*.tsx" | \
awk -F: '{print $1 ":" $2}' | uniq -c | awk '$1 >= 3 {print}'
Group findings by category:
| Category | Count | Severity |
|---|---|---|
| Unused exports | N | Medium |
| Unused imports | N | Low |
| Dead variables | N | Low |
| Unreachable branches | N | High |
| Commented-out code | N | Low |
For each finding, show:
Skip findings in:
node_modules/, dist/, build/, .next/*.generated.ts, *.d.ts)Use AskUserQuestion to group findings into batches of at most 4 questions. For each batch:
Wait for all confirmations before proceeding.
For each confirmed removal:
tsc --noEmit or language equivalent if available)After all removals:
# Verify nothing broke
tsc --noEmit 2>/dev/null || echo "No TypeScript to check"
Commit with: chore: remove dead code and open a PR targeting develop.
Provides a checklist for code reviews covering functionality, security, performance, maintainability, tests, and quality. Use for pull requests, audits, team standards, and developer training.
npx claudepluginhub smallorbit/smallorbit-plugins --plugin polishkit