The Andrej Karpathy Skills project identifies over-engineering as one of the most common and expensive LLM coding failures. Models tend to add abstractions, invent configuration options, handle impossible edge cases, and write speculative features for requirements that were never asked for. This principle — Simplicity First — holds the line: write only the minimum code that solves the stated problem.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/multica-ai/andrej-karpathy-skills/llms.txt
Use this file to discover all available pages before exploring further.
The core problem
From Andrej Karpathy’s observation:“They really like to overcomplicate code and APIs, bloat abstractions, don’t clean up dead code… implement a bloated construction over 1000 lines when 100 would do.”Over-engineering isn’t always obviously wrong. Strategy patterns, configuration layers, and caching systems are legitimate tools — the problem is timing. Adding them before they’re needed creates code that’s harder to read, harder to test, harder to change, and more likely to contain bugs.
The five rules
- No features beyond what was asked. If the request is “add a discount function,” write a discount function. Not a discount system.
- No abstractions for single-use code. Interfaces, base classes, and protocol layers add value when there are multiple implementations. One implementation doesn’t justify the overhead.
- No “flexibility” or “configurability” that wasn’t requested. Optional parameters, strategy injection, and plugin systems are speculative — they solve problems the user may never have.
- No error handling for impossible scenarios. Handle the errors that can actually occur. Don’t guard against inputs that the call site can never produce.
- If you write 200 lines and it could be 50, rewrite it. Length is a signal. If a solution is long, review it before shipping it.
The senior engineer test
Ask yourself: “Would a senior engineer say this is overcomplicated?” A senior engineer reviewing a discount calculation function doesn’t want to see an abstract base class, a strategy pattern, a dataclass config object, and a calculator wrapper. They want to see a function that takes an amount and a percentage and returns a number. The elaborate version signals that the author solved a problem they invented, not the problem they were given. If the answer to the test is yes — simplify before submitting.Examples from real requests
Over-abstraction: “Add a function to calculate discount”
The request says “a function.” The over-engineered response creates five classes.Bad example — strategy pattern for a single use case
Good example — one function that does the job
When to add complexity
Add the strategy pattern only when you actually need multiple discount types. If that requirement arrives later, refactor then — with real requirements to guide the design, not imagined ones. Code written for actual needs is almost always simpler and more correct than code written for hypothetical needs.Speculative features: “Save user preferences to database”
The request asks for one operation: save preferences. The over-engineered version adds caching, validation, merging, and a notification system that nobody requested.Bad example — solves problems that don't exist yet
Good example — exactly what was asked for
The right direction for complexity
Simplicity First doesn’t mean “write bad code.” It means complexity should be earned, not anticipated.| Add it now | Add it later |
|---|---|
| Error handling for inputs that can actually occur | Error handling for inputs the call site can never produce |
| The one implementation that’s needed | An abstraction layer for multiple implementations that don’t exist |
| Clear variable names and a short docstring | Configuration systems, registries, and plugin architectures |
| Tests for real behavior | Tests for behavior no one has asked for |
Related principles
Think Before Coding
Agree on what to build before writing any code. Simpler starts with a clear scope.
Surgical Changes
When editing existing code, don’t add complexity beyond the change requested.