AI models are trained on people writing code, not deleting it, so left alone they default to addition even when subtraction is the better move.
The Details:
Dead code leaves fingerprints once you know where to look: a try/except catching an error the function cannot raise, a helper with exactly one caller, a feature flag stuck at true for two years, a comment marked "temporary" sitting over something that has clearly become permanent. Spotting the pattern is easy. Knowing whether it is safe to remove requires institutional memory an AI does not have.
The fix is to separate judgment from action. Ask the model to argue for a deletion and trace every caller before anything gets touched, then let a human decide, then cut. Vague requests like "clean this up" produce cosmetic renames; a sharper prompt like "what would break if this function vanished" forces the model to build a real case with evidence.
Kept code is not free. Every unnecessary line becomes a small permanent tax: every future reader has to parse it, wonder if it matters, and decide whether it is safe to touch. That overhead multiplies across files and across every engineer who joins the project, which is why codebases that are never pruned get harder to work in even when nothing is technically broken.
AI has a real edge here precisely because it lacks the human liabilities: no boredom reading a long file, no ego about a clever abstraction someone wrote years ago, no sunk-cost attachment to work it did not personally write. That detachment only pays off if someone actually points the tool at deletion instead of only ever asking it to add.
Bottom Line: The AI tools that make codebases better long term are not measured by lines generated. They are measured by how much unnecessary code they helped someone remove.
Enjoy this article?
Listen to the Claude Code Conversations radio show or join the community.