I priced my own dead code and got a $775 bill
Description and use
The author built GhostCode, an AST‑based dead‑code analyzer that quantified maintenance cost at $775.49 per year. Removing unused files reduced the repo size and the tool now runs in CI.
Problem
Dead code incurs ongoing maintenance costs that are hard to quantify.
Outcome
GhostCode identified 10 unused files and 21 unused symbols, revealing $775.49 of annual maintenance cost. Deleting a helper module reduced the repo size and kept tests green.
Workflow
- 1. Parse Python and JS/TS files with tree-sitter to obtain ASTs.
- 2. Convert ASTs into a NetworkX graph of files, functions, classes, and imports.
- 3. Identify ghost nodes as those with zero incoming edges.
- 4. Apply three scorers: dead-code confidence, debt (complexity), and cost (LOC × $0.50 × complexity).
- 5. Present results on a Next.js dashboard backed by a FastAPI API.
- 6. Use PyGithub to create deletion pull requests automatically.
- 7. Run the analyzer in CI to maintain the graveyard size.
Evidence
GhostCode, a dead-code analyzer that reads your AST instead of guessing from text
The scan found 10 ghost files and 21 ghost symbols. Three circular import chains I didn't know about. Total: $775.49 of annual maintenance burn
A helper module I was "keeping in case I need it later" turned out to have zero incoming edges from day one. It was never needed. Deleting it took one PR and the tests stayed green, 91 out of 91.
- Record date: 2026-10-18T08:56:06.538Z