What Is Behind /simplify - Fighting Over-Engineering in AI Code
Fighting Over-Engineering in AI-Generated Code
You ask the AI for a function that reads a file and returns its contents. You get a FileReaderFactory with a configurable BufferStrategy, an abstract FileSource interface, dependency injection, and a retry mechanism with exponential backoff. For reading a file.
Why AI Over-Engineers
LLMs are trained on codebases that include enterprise software, framework code, and library code. These codebases use abstractions, patterns, and indirection because they serve thousands of use cases. The model learns that "good code" has factories, interfaces, and configuration layers.
But your code serves one use case. You do not need a factory because you will never swap the implementation. You do not need an interface because there is only one concrete type. The AI does not know this - it defaults to the most "professional-looking" solution it has seen in training data.
The /simplify Habit
Reviewing AI-generated code for over-engineering should be a standard step. Ask yourself:
- How many layers of indirection exist? If you need to trace through three files to understand what happens when a function is called, there are too many layers.
- Are there abstractions with only one implementation? An interface with a single concrete class is not an abstraction. It is ceremony.
- Could this be a function instead of a class? AI loves classes. Most logic is better expressed as functions.
- Does the error handling match the stakes? Retry with exponential backoff is great for payment processing. It is overkill for reading a config file at startup.
Practical Countermeasures
Add constraints to your prompts and project instructions:
- "Prefer functions over classes"
- "No abstractions unless there are at least two concrete implementations"
- "Use the simplest approach that works"
- "Avoid design patterns unless the problem specifically calls for one"
In a CLAUDE.md or similar config file, these constraints reduce over-engineering significantly. The model responds well to explicit simplicity requirements.
The Deeper Problem
Over-engineered code is not just verbose - it is harder to debug, harder to modify, and harder for the next agent to understand. Every unnecessary abstraction increases the context window needed to comprehend the system. In multi-agent workflows, this compounds fast.
Simple code is agent-friendly code.
- AI Coding Produces Mass Bad Code
- Claude Code Over-Engineering System Prompt Workaround
- Architecture Problem, Not a Claude Code Problem
Fazm is an open source macOS AI agent. Open source on GitHub.