What is an AI code smell?
Recurring defects in LLM and agent written code: it passes the demo, but maintenance costs more than expected.
An AI code smell is a recurring, recognizable defect in code written by a language model or a coding agent: not an error that breaks the build, but a pattern that compiles, passes the tests, and still costs money when someone has to maintain it. They read as the machine's signature: overbroad exception handling, oversized functions, dead code, magic numbers, imports of nonexistent libraries hidden in never-executed branches. These are not new defects: they are the classic smells from Fowler's catalog, showing up at a different rate. A study across four models finds generated code carries 63.34 percent more of them than a human baseline (Ghosh Paul et al., 2025), and a survey of generated code finds at least one defect in 60.9 percent of units, with the overlong method at 40 percent (Sousa et al., ENIAC 2025). The point of spotting them is to price the cleanup before accepting the code, because the bill comes due either way.
See also: Technical debtTechnical debt is the potential future cost of expedient software decisions that can make later changes more difficult, expensive, or even impossible.
The patterns that keep coming back
The classic catalog comes back: overbroad exception handling; dead code and branches that never run; magic numbers where named constants belong; oversized functions doing ten jobs. Generation adds its own defects: imports of libraries that do not exist, hidden in never-executed branches and invented to make the snippet work, and the Modular Mirage, neatly separated files with no logical cohesion, with a 0.94 correlation between generated lines and architectural smells (Zhu, Tsantalis and Rigby, 2026). The numbers agree: on two widely used models, ten of thirteen classic defects cross detection thresholds (CodeSmellEval, Velasco et al., 2024), and a static analyzer detects twenty-two machine learning specific smells across 890 Python systems (SpecDetect4ML, Mahmoudi et al., 2025). The CodeSmellEval group then uses that metric for a causal analysis: generation strategy, model size, model architecture and prompt wording all matter, with prompt and architecture decisive (Velasco et al., 2025). Vendor numbers agree, taken as vendor numbers: Veracode and Apiiro see more defects in generated code, CodeRabbit, across 470 pull requests, counts about 1.7 times as many flagged issues in AI-assisted ones as in human-only ones.
An enterprise example
A manufacturing SME asks for an estimate to rescue a twenty-thousand-line internal application, partly written by an agent on the previous vendor's instructions. The demo worked. The analysis finds the typical picture: three functions past five hundred lines, exceptions caught overbroadly and ignored in the modules, a connector importing a nonexistent library and neutralized with a dead branch, thresholds written as magic numbers and credentials hardcoded in source code. The estimate separates two lines: what is kept and covered with tests, and what is rewritten because changing it would cost more than rewriting it. That is what this entry adds to a quote: without names for the patterns, cleanup stays a generic line item the customer reads as padding.
Why it matters for decision makers
Anyone evaluating a rescue or an acquisition has to price the cleanup, or the cost surfaces after signing. These defects sit inside technical debt, which remains the broader category, but they are concentrated and measurable: a static analyzer catches what shows up in the code's form, they can be counted and dated to the commit that introduced them; attribution requires the declaration policy described below. So the defense is not banning assistants but governing them: a generated contribution policy states what enters the repository and with what declaration, pipeline checks catch them before the merge, and human review stays on architecture, where the model fails most. The rest of the neighborhood needs separating too: vibe coding is having code written through conversation, AI slop is mediocre output in general, analysis tools remain a means, not the diagnosis.
Related terms
- Technical debtTechnical debt is the potential future cost of expedient software decisions that can make later changes more difficult, expensive, or even impossible.
- AI slopAI slop is low-quality digital content generated with artificial intelligence, often in large quantities, that looks polished but offers little real value.
- Vibe codingVibe coding is building software by describing an outcome to AI and accepting the generated code without reading or reviewing it; risk depends on the use case.
- AI code contribution policyThe rule by which a project decides whether to accept AI-written code, under what conditions and with what declaration.
- LintingStatic analysis that flags likely errors, suspicious constructs and style violations without running the code.
If it is a technical decision you keep postponing, that is the decision I help you make.
See custom tools, governance and operations