The #1 Reason AI Code Gets Reworked Isn't the Model. It's Missing Context.
Engineers told us what is most often wrong with AI-generated code. Most of it starts before the first prompt.
What engineers end up fixing
We asked engineers in one organization a simple open question: "What is most often wrong with AI-generated code in your work?" We got about 82 distinct comments.
The top two causes were: AI not knowing the wider context (27 answers) and AI writing too much, too complicated code (26). Plain bugs came much further down.

One engineer summed up the pattern better than any chart:
"In my view, AI itself rarely generates buggy code. Errors come from wrong assumptions or from imprecision in the task description or the prompt, so on the human side." – engineer
Context lives outside the repository
The context AI is missing is rarely in the code it can read. It sits in the systems around it: integrations, data, other products, infrastructure and business rules.
"Lack of broader context, specifically no information about the systems that integrate with ours, for example current public documentation, an API catalog, data structure schemas, contracts, etc." – engineer
"AI often does not look at a wider context. Proposes changes that are ok for one product but have a negative impact on other products." – engineer
Worse, a model that lacks context rarely says so:
"If it lacks context, it won't let me know about it and hallucinates." – engineer
Tasks are written for humans
A ticket written for a colleague assumes a reader who knows the business and will ask when something is unclear. An agent doesn't ask. It guesses.
"Tasks are written for a person who understands the business and can answer extra implementation details on their own along the way." – engineer
"AI depends on complete, clear and unequivocal system requirements. Most of the time we don't have them defined on required level :)" – engineer
There is a new twist. Requirements themselves are increasingly written with AI, and they inherit the same problems:
"Requirements are getting longer, but that's because LLMs are used to write them, and they have exactly the same problems as generated code. If code is generated from generated requirements, the result isn't hard to predict." – engineer
Another engineer noticed a second-order effect: since AI made coding faster, more tasks get planned, and the quality of task descriptions "got noticeably worse in the process".

Too much code is a context problem too
The second-largest theme looks like a model habit, but it has the same root. An agent that doesn't know what already exists builds it again.
"Changes that are too big. Something that can be done in three lines, AI turns into a whole litany: a new class, a service, etc. It doesn't reuse code." – engineer
"AI usually generates more code than I expect. It often creates new functions instead of reusing existing ones, resulting in messy code that looks good at first glance but is poorly structured and difficult to maintain." – engineer
This is also where review time goes. Every unneeded class and comment is something a human has to read before merging.
Instructions are not enforcement
Many teams already give AI their coding guidelines. Engineers report that it helps, but doesn't hold:
"In the first iteration, despite clear instructions, LLMs spit out AI slop." – engineer
"Edge cases, following rules about 'DON'T CHANGE ANYTHING IN THIS LOGIC', AI seems to miss some of these and I end up with code rewritten without one crucial IF statement." – engineer
A rule in a prompt is advice. A rule that must always hold belongs where it is checked every time: in linters, tests, CI and hooks.
Tests are a special case. Five answers describe AI-written tests that "pretend to test something, or return a correct result but rest on wrong assumptions". Tests that come from the same agent as the code are not independent proof that the code works.
What to fix, in order
- Write down what the agent can't see. A short context file in each repository with conventions, commands and recurring mistakes. Next to it, an API catalog, contracts and data schemas in a form an agent can read.
- Fix the input. A definition of ready for AI-assisted work: the expected outcome, constraints, edge cases and decisions already made, written by people and kept short.
- Plan before code. For larger tasks, ask for a plan first. A wrong assumption is cheap to fix in a plan and expensive to fix in 800 lines of code.
- Enforce what must hold. Move must-follow rules into automated checks, and turn every review comment that comes back a second time into a rule.
Better models will hallucinate less. They still can't know what nobody wrote down. The cheapest rework to avoid is the one decided before the first prompt.
