TL;DR — AI coding assistants are structurally biased toward adding code: addition is locally checkable, while deletion needs runtime and organizational knowledge that isn't in the context window. Left alone, that bias grows the codebase faster than anyone can understand it. The fix is to treat deletion as an evidence-gathering task, measure net change, and use the assistant to build the case for removal instead of making the call.
Ask a coding assistant to fix a bug, and it will almost always hand you a patch that adds lines. A guard clause here, a fallback there, a new helper because the existing one didn't quite fit. Ask it to remove a module and it gets timid, or worse, confidently wrong.
This is not a quirk of one tool. It is a structural property of how these systems work, and it matters more than most of the autocomplete-quality debates. Assistants make addition cheap and leave deletion exactly as expensive as before. Over a year, that asymmetry reshapes a codebase.
Addition is locally verifiable. Deletion isn't.
Think about what an assistant can check from inside its context window. If it writes a new function, it can see the signature, the types, the call site it was asked to serve. The claim "this code does the thing" is mostly checkable against what is on screen. A compiler or a type checker backs it up quickly.
Now take the claim "this code is unused." That is a universal statement about the whole system, including parts that were never loaded into the context:
Callers reached through reflection, dynamic dispatch, string-keyed registries, or config-driven plugin loading.
Consumers outside the repository: other services, scheduled jobs, notebooks, a customer's integration.
Code paths that fire once a quarter, or only under a feature flag that is off in the environment you are looking at.
Behavior that exists because of an incident nobody wrote down.
None of this is in the file. A model reading the file sees a function with no visible callers and has two options: guess, or leave it alone. The safe, reward-shaped behavior is to leave it alone and add something next to it. That is how you get the third near-duplicate date-parsing helper in a repo.
The gradient points one way
There are a few forces stacking up here, and they compound.
The task framing is additive. "Implement X," "fix Y," "add a test for Z." Almost no one prompts "make this change and leave the repo smaller." The assistant optimizes for the request, and the request describes a delta of new behavior.
Local coherence beats global economy. The model is excellent at producing code that is consistent with the neighboring files. It is much weaker at noticing that the neighboring files already contain what it is about to write. Retrieval helps, but retrieval finds similar code by text and meaning, and "similar" is a weaker signal than "this is the same responsibility."
Defensive code is always a plausible completion. Extra null checks, broad try/catch blocks, redundant validation, a compatibility shim for a caller that may not exist. Each one is individually reasonable, and each is hard to criticize in review. Collectively they bury the actual logic. In a TypeScript codebase you see it as optional chaining on values the type system already guarantees, and casts that silence a problem instead of fixing the type.
Review is the only brake, and review is the scarce resource. If generation gets cheaper and review stays human-speed, the review queue sets the real throughput. Reviewers skim large additive diffs, because a diff that only adds is easier to approve than a diff that removes something, which demands proof.
Why this is a maintenance problem, not a style problem
Code you didn't need still costs you. It has to be compiled, tested, scanned, patched, and understood by the next person. It widens the attack surface, which matters when the dead code includes an old auth path nobody remembers. It also pollutes the context the next assistant session retrieves, so stale patterns get copied forward as if they were conventions.
That last point is the feedback loop worth fearing. An assistant treats your repository as its ground truth for "how we do things here." If a third of the examples it retrieves are redundant or deprecated, it reproduces them. Dead code stops being inert. It becomes training signal for the tool you use every day.
A senior engineer's value in maintenance work is largely subtractive: noticing that two services do the same job, that a flag has been on for two years, that an abstraction serves one caller. The tools are weakest exactly where that judgment lives.
What actually helps
I don't think the answer is "use assistants less." The answer is to stop asking them to make the deletion decision, and start using them to assemble the evidence for it.
Turn deletion into an evidence task
The question "is this safe to delete?" is unanswerable from source alone. The question "gather everything that bears on whether this is safe to delete" is a good agent task. Have it list static references, search for string-built names, check config and deployment manifests, and summarize what it could not rule out. Then pair that with runtime evidence a human or a pipeline supplies: production call counts, trace data, flag states. The assistant writes the case. The owner signs it.
Feed it the signals that aren't in the file
Most failures here are missing-context failures. If your tooling can expose coverage from production traffic, last-invoked timestamps, and ownership metadata, the assistant stops guessing. An agent with access to "this function has had zero invocations across the window we care about" behaves very differently from one reading text alone.
Measure net change, not just green checks
Track lines and public surface area added per feature, and make it visible in review. A reviewer should see "this change adds a new helper, and an equivalent one exists at this path" flagged automatically. Even a crude duplicate-detection step in CI shifts behavior, because it turns "the assistant was creative" into "the assistant was redundant."
Prompt for the smallest change, and mean it
Instructions like "prefer modifying existing code over adding new abstractions; justify any new file" measurably change what comes back, in my experience. Pair it with a standing rule: any assistant-authored change that adds a compatibility shim must name the caller it protects. If it can't, the shim goes.
Schedule subtraction like you schedule features
If deletion only happens when someone feels brave, it won't happen. Put recurring, scoped removal work on the board: one flag, one module, one dependency at a time. Use the assistant for the mechanical parts, such as removing call sites, updating tests, and fixing types after the removal, while the decision and the rollout plan stay with a person.
The thesis in one line
Coding assistants are generators in a job that is half pruning. They lower the cost of writing code toward zero, and the cost of knowing which code should exist does not move. If you don't deliberately spend your saved time on the second problem, the first one eats it.
The teams that get long-term value won't be the ones who generate the most. They'll be the ones whose codebases are still legible in two years, because someone made the tool prove a line was needed before it stayed.
Top comments (1)
Before an assistant writes a new helper or fallback, do you require it to name the existing module it extends so duplicate implementations are caught before review?