ln-626-dead-code-auditor
Scannednpx machina-cli add skill levnikolaevich/claude-code-skills/ln-626-dead-code-auditor --openclawPaths: File paths (
shared/,references/,../ln-*) are relative to skills repo root. If not found at CWD, locate this SKILL.md directory and go up one level for repo root.
Dead Code Auditor (L3 Worker)
Specialized worker auditing unused and unreachable code.
Purpose & Scope
- Worker in ln-620 coordinator pipeline
- Audit dead code (Category 9: Low Priority)
- Find unused imports, variables, functions, commented-out code
- Calculate compliance score (X/10)
Inputs (from Coordinator)
Receives contextStore with tech stack, codebase root, output_dir.
Workflow
- Parse context + output_dir
- Run dead code detection (linters, grep)
- Collect findings
- Calculate score
- Write Report: Build full markdown report in memory per
shared/templates/audit_worker_report_template.md, write to{output_dir}/626-dead-code.mdin single Write call - Return Summary: Return minimal summary to coordinator
Audit Rules
MANDATORY READ: Load shared/references/clean_code_checklist.md for universal dead code patterns and severity definitions.
1. Unreachable Code
Detection:
- Linter rules:
no-unreachable(ESLint) - Check code after
return,throw,break
Severity: MEDIUM
2. Unused Imports/Variables/Functions
Detection:
- ESLint:
no-unused-vars - TypeScript:
noUnusedLocals,noUnusedParameters - Python:
flake8withF401,F841
Severity:
- MEDIUM: Unused functions (dead weight)
- LOW: Unused imports (cleanup needed)
3. Commented-Out Code
Detection:
- Grep for
//.*{or/*.*functionpatterns - Large comment blocks (>10 lines) with code syntax
Severity: LOW
Recommendation: Delete (git preserves history)
4. Legacy Code & Backward Compatibility
What: Backward compatibility shims, deprecated patterns, old code that should be removed
Detection:
- Renamed variables/functions with old aliases:
- Pattern:
const oldName = newNameorexport { newModule as oldModule } - Pattern:
function oldFunc() { return newFunc(); }(wrapper for backward compatibility)
- Pattern:
- Deprecated exports/re-exports:
- Grep for
// DEPRECATED,@deprecatedJSDoc tags - Pattern:
export.*as.*old.*orexport.*legacy.*
- Grep for
- Conditional code for old versions:
- Pattern:
if.*legacy.*orif.*old.*version.*orisOldVersion ? oldFunc() : newFunc()
- Pattern:
- Migration shims and adapters:
- Pattern:
migrate.*,Legacy.*Adapter,.*Shim,.*Compat
- Pattern:
- Comment markers:
- Grep for
// backward compatibility,// legacy support,// TODO: remove in v - Grep for
// old implementation,// deprecated,// kept for backward
- Grep for
Severity:
- HIGH: Backward compatibility shims in critical paths (auth, payment, core features)
- MEDIUM: Deprecated exports still in use, migration code from >6 months ago
- LOW: Recent migration code (<3 months), planned deprecation with clear removal timeline
Recommendation:
- Remove backward compatibility shims - breaking changes are acceptable when properly versioned
- Delete old implementations - keep only the correct/new version
- Remove deprecated exports - update consumers to use new API
- Delete migration code after grace period (3-6 months)
- Clean legacy support comments - git history preserves old implementations
Effort:
- S: Remove simple aliases, delete deprecated exports
- M: Refactor code using old APIs to new APIs
- L: Remove complex backward compatibility layer affecting multiple modules
Scoring Algorithm
MANDATORY READ: Load shared/references/audit_scoring.md for unified scoring formula.
Output Format
MANDATORY READ: Load shared/templates/audit_worker_report_template.md for file format.
Write report to {output_dir}/626-dead-code.md with category: "Dead Code" and checks: unreachable_code, unused_exports, commented_code, legacy_shims.
Return summary to coordinator:
Report written: docs/project/.audit/ln-620/{YYYY-MM-DD}/626-dead-code.md
Score: X.X/10 | Issues: N (C:N H:N M:N L:N)
Reference Files
- Worker report template:
shared/templates/audit_worker_report_template.md - Clean code checklist:
shared/references/clean_code_checklist.md - Audit scoring formula:
shared/references/audit_scoring.md - Audit output schema:
shared/references/audit_output_schema.md
Critical Rules
- Do not auto-fix: Report only, never delete code
- Age-aware severity: Legacy shims >6 months = MEDIUM, <3 months = LOW
- Effort realism: S = <1h, M = 1-4h, L = >4h
- Exclusions: Skip generated code, vendor, migrations, test fixtures
- Git-aware: Recommend deletion confidently -- git history preserves old code
Definition of Done
- contextStore parsed (including output_dir)
- All 4 checks completed (unreachable code, unused imports/vars/functions, commented-out code, legacy shims)
- Clean code checklist loaded from
shared/references/clean_code_checklist.md - Findings collected with severity, location, effort, recommendation
- Score calculated per
shared/references/audit_scoring.md - Report written to
{output_dir}/626-dead-code.md(atomic single Write call) - Summary returned to coordinator
Version: 3.0.0 Last Updated: 2025-12-23
Source
git clone https://github.com/levnikolaevich/claude-code-skills/blob/master/ln-626-dead-code-auditor/SKILL.mdView on GitHub Overview
Dead Code Auditor is an L3 worker in the ln-620 coordinator pipeline that scans for unreachable code, unused imports, variables, and functions, and detects commented-out blocks. It also flags backward compatibility shims and deprecated patterns, producing a findings report and a compliance score to guide cleanup.
How This Skill Works
It reads the contextStore to obtain the codebase root and output_dir, runs dead code detection using linters and grep, aggregates findings, computes a score, and writes the full markdown report to output_dir/626-dead-code.md in a single write call. It then returns a brief summary to the coordinator.
When to Use It
- After a major refactor to identify dead or unused code paths
- Before a release to ensure codebase hygiene and reduce risk
- When migrating legacy code and evaluating backward compatibility shims
- During codebase health checks for unused imports, variables, and functions
- When cleaning up deprecated patterns and preparing deprecation plans
Quick Start
- Step 1: Parse contextStore to obtain codebase root and output_dir
- Step 2: Run dead code detection with linters/grep and collect findings
- Step 3: Write the report to output_dir/626-dead-code.md and return a summary
Best Practices
- Load universal dead code patterns from shared/references/clean_code_checklist.md before auditing
- Use language specific rules (ESLint no-unreachable / no-unused-vars, flake8 F401/F841 in Python, etc.)
- Run the audit in CI or pre-merge to catch issues early
- Review findings by severity and fix high-priority items first
- Store the generated 626-dead-code.md report in the repo for traceability
Example Use Cases
- TypeScript project flags noUnusedLocals and noUnusedParameters across modules
- Python project surfaces F401 unused imports and F841 unused variables
- Commented-out blocks detected indicating potential dead code retirement
- Backward compatibility wrappers identified as legacy shims
- Migration code flagged for removal after validating current API usage