< Back to articles

AI agent keeps making the same mistakes? Fix the system, not the output

AI agent keeps making the same mistakes? Fix the system, not the output

The AI agent put business logic into a view model again, deleted code that was supposed to be there, and wrote fifty lines instead of ten. Fixing it by hand only helps until the next task. Rostislav Babáček, mobile team lead and head of AI adoption at Ackee, went through the most common AI agent mistakes developers run into in Claude Code. For each one he shows which part of the system to fix so the mistake stops coming back.

📋 TL;DR

  • A repeated AI agent mistake isn't bad luck, it's knowledge missing from the system. Fixed code doesn't pass it on. Fixed rules, a glossary, ADRs or a workflow do.
  • Business logic in a view model went away once the agent learned the Tell, Don't Ask principle in .claude/rules. A glossary helped with invented naming, and architecture decision records (ADRs) helped with the deletion of "unnecessary" logic.
  • When developers don't know in what order to run skills, you're missing an orchestration workflow. One prompt starts the whole chain, and nobody minds that the commit skill takes two minutes.
  • A misunderstood assignment is handled by an interview-me phase, where the agent confronts the assignment with the codebase and asks questions. But a human answers, and the agent can't be blamed for a wrong answer.
  • Losing discipline on a large task is context rot. A multi-phase plan helps, where each phase runs in a clean context window as one vertical slice, so the app builds after every phase.
  • Against AI slop, a deslop phase runs after each implementation phase. Against ignored rules, adversarial review by two clean subagents runs over the git diff.
  • A commit after every phase replaces one unreadable giant commit with a series of runnable steps.
  • The main rule: don't fix the output, fix the system.

🩺 Diagnosing AI agent mistakes: symptom, cause, fix

Ackee started rolling out agentic development in March 2026 across 29 developers and more than fifteen codebases, from a streaming platform through a banking app to logistics with tens of millions of parcels a year. Reality didn't look like the LinkedIn posts claiming AI writes 90% of production code elsewhere. It looked like a list of complaints. The agent didn't understand the assignment. It skipped the tests in the morning and forgot the lint in the afternoon. It left a pile of pointless comments in the code.

Babáček turned those complaints into a working method. Every frustration with the agent is information the agent doesn't have. It doesn't know it's doing something wrong and can't find out by itself. But you can write it into the system the agent works in: the rules, the project context, the workflow or the review. A manual fix solves one merge request, a system fix solves all the following ones.

Diagram: fixing the output by hand leads to the same mistake repeating, while writing the knowledge into rules, a glossary, ADRs or a workflow removes the mistake for good

According to Babáček, five layers shape output quality: the model, the built-in harness tools, project setup, the assignment and the developer's skills. You get the first two with the tool and can't do much about them. The team fully controls the other three, and that's where all the fixes below live. The whole model is described in detail in the article AI agent output quality is not a given. This one is a practical overview of symptoms.

SymptomWhere to fix itFix
Business logic in a view model.claude/rulesThe Tell, Don't Ask principle with an example
Invented class namesProject contextA glossary with alternative names
Deletes logic it considers unnecessaryProject contextADR
Nobody knows in what order to run skillsWorkflowAn orchestration skill
Forgets tests and lintWorkflowA verify step in the feedback loop
Implemented something differentAnalysis phaseInterview-me
Mixes up terms from the assignmentAnalysis phaseLoading and updating context
Loses discipline after a whilePlanA multi-phase plan
App doesn't build after a phasePlanVertical slices
One giant commitImplementationA commit after every phase
Pointless comments and bloated codeImplementationDeslop
Ignores the rulesImplementationAdversarial review

🧩 The agent doesn't respect the architecture or the project

The first three symptoms have one thing in common: the agent lacks knowledge about the project. Project setup solves them, meaning CLAUDE.md, .claude/rules and the project context.

Business logic ended up in a view model

The team repeatedly told the agent not to put business logic in the view model. It didn't help. What helped was a colleague who knew the Tell, Don't Ask principle from Martin Fowler. If the principle works in classic development, why not teach it to the agent? A rule with an example was added to .claude/rules, and the problem disappeared.

The general lesson: a prohibition ("don't do X") works worse than a named principle with an example. The agent then knows what to do instead.

The agent invents class names

On one project the agent didn't follow the established naming and made up names that made no sense in the context of the app. The fix was a glossary, a dictionary of terms in the project context. Each term has three parts:

  • the main, preferred name,
  • a description,
  • alternative names.

When the agent runs into an alternative name, the glossary points it to the primary one, and the agent uses that in class names too.

The agent deletes logic it considers unnecessary

Babáček fought this one himself. The app contained logic for a special metric that the BI team wanted. The agent kept flagging it as a bug and deleting it. He couldn't talk it out of it.

💡
Why a code comment isn't enough

An explanatory comment right in the code looks like the quickest fix. At the next refactoring it's easily lost, and the reason the code exists goes with it. An architecture decision in a separate file survives refactoring.

So the project got an architecture decision record (ADR). When the agent loads context for a file at the start of its work, it also finds the relevant ADR and learns the logic has a purpose. Since then it leaves the logic alone.

🔁 The agent doesn't follow the process: from skills to workflows

Ackee splits feature development into three phases: analysis, implementation and finalization (review on GitLab). Each phase is a sequence of skills. And that brought new complaints.

Three phases of feature development: a workflow as an orchestration skill brings discipline and efficiency, and plugins are grouped into marketplaces

Nobody knows in what order to run skills

Developers asked in what order to run the skills, whether anything happens if they skip one, and whether they can move one elsewhere. The order has a reason. The answer is a workflow: a plugin with an orchestration skill that runs from a handful to dozens of other skills in the right order. The agent then keeps the discipline itself, and nobody has to be taught what follows what. And you need one prompt instead of five.

"The commit skill takes two minutes, I'll do it by hand"

A manual commit takes about 20 seconds, the commit skill two minutes. As long as the developer runs skills by hand and waits for them, the complaint is fair. Once the commit skill runs inside an autonomous workflow, the extra two minutes stop mattering. The developer isn't waiting for them.

The same skill gets written on two projects

On one project the team wrote a build and test skill, and on another, colleagues wrote almost the same one. Wasted work. So Ackee groups plugins into marketplaces in three layers: one shared by all development teams, platform ones (backend, frontend, mobile) and project ones. Skills aren't copied around repositories but versioned like any other dependency. How sharing know-how through plugins works in practice is covered in the article From prompts to collective know-how.

The agent forgets tests and lint

The instruction "run the tests, build and lint" was in CLAUDE.md. But CLAUDE.md is a recommendation, not enforcement. The agent sometimes followed it and sometimes didn't. The reliable fix is a verify step right in the implementation loop: the app is built, tested and linted, the findings go back to the agent, it works them in, and the whole step runs again. Until it passes, the phase isn't done.


🔍 The agent didn't understand the assignment

According to Babáček, the analysis phase is the most important one. It starts with the agent getting a link to the ticket and pulling the content from Redmine, Azure DevOps or Jira itself. The goal is an assignment that someone who has never seen the project could implement without mistakes. You have to treat the agent as a colleague who lacks context, and supply that context.

It implemented something completely different

The agent put the assignment together, got to work, and the result was completely off. So an interview-me phase was added to the analysis workflow. The agent studies the assignment, does a deep exploration of the codebase and starts confronting the proposed solution with what is actually in the code. It looks for holes in the assignment and asks questions.

The interview-me phase in the analysis workflow: understanding the problem and confronting it with the codebase, human in the loop, and loading project context such as ADRs, glossary, API spec and DB schema

This phase is largely human in the loop. The agent asks about the things it's unsure of, and the developer answers. If they answer wrong, they're defining a wrong assignment. And then they can't be angry at the agent that the implementation doesn't fit.

The client uses several names for one thing

A client's assignment sometimes calls the same thing by three different terms. The agent then doesn't know what is meant and makes mistakes. The fix: the analysis phase loads and updates the project context. Besides the glossary and ADRs, it holds the current API specification (the team refreshes it every sprint), the database schema and links to Figma.

Book a consultation

🍰 The agent loses discipline on large tasks

After a while, the implementation drifts

The agent got an assignment, made a plan and started implementing a large feature in a single context window. It hit the window's limits, context rot set in, and sometimes compaction, which is lossy. Information gets lost along the way.

The fix is a skill that creates a multi-phase plan. A large problem is chopped into subproblems, and each is solved in its own clean context window. The agent never reaches the limits of the window, and the output is better.

The app doesn't even build after a phase

Babáček was implementing a feature where, after three of five phases, he needed to test a database migration. He had the agent stop after the third phase, but the app wouldn't build. The agent had split the multi-layer architecture by layers: in the first phases it changed only the repository, but not the layers that depend on it.

The fix is vertical slices, known as tracer bullets from the book The Pragmatic Programmer. Each phase of the plan goes through all the affected layers at once, just as a thin slice. In the first phase, for example, you get a button and the whole path to the data, only instead of writing to the database it prints "hello" to the log for now. Every phase can be built and tested.

Horizontal versus vertical plan splitting: when split by app layers, the app won't build between phases, while with vertical slices every phase is runnable
⚠️
Vertical slices aren't for everything

This pattern doesn't suit larger refactorings. It's ideal for ordinary features, where something is added to the repository and, say, a button in the UI builds on it.


⚙️ The code works, but you don't like it

At Ackee, the implementation phase runs as a loop over the individual phases of the plan: TDD, deslop, adversarial review, verify, commit. Mostly AFK, meaning without a human at the keyboard. A human steps in only when needed.

The agent did it all in one go

The plan had ten phases. The agent implemented them one by one but delivered everything in a single giant commit. The result was a one-shot implementation that nobody could make sense of, and when something needed debugging, the only option was to revert everything.

The fix: a commit after every phase of the plan, enriched with context. Combined with vertical slices, every commit is a runnable app. You can click through between them, follow how the agent progressed and debug a specific step.

Pointless comments and fifty lines instead of ten

TDD has a red-green-refactor phase with an instruction to implement the minimum, and the agent still didn't follow it. So a deslop phase was added to the loop, aimed at the typical symptoms of AI slop. It goes through the newly generated code, removes pointless comments, deals with needless nesting and runs simplify, which simplifies the implementation.

The deslop phase in the implementation loop: removing pointless comments and needless nesting, and simplifying the code

The rules exist, but the agent ignores them

Even .claude/rules aren't a guarantee. In a large context the agent pushes some things aside and prioritizes what it sees fit. So the loop includes an adversarial review by two clean subagents. They don't know why the code was written the way it was, so they don't have the implementer's bias. They get only the git diff. The first subagent validates it against .claude/rules, the second against the plan phase, meaning the assignment.

Since introducing this check, Babáček says he hasn't seen code on a merge request that violated the defined rules. The whole loop runs in the background, and the team doesn't touch the implementation in roughly 95% of cases. The freed-up time goes into the analysis and verification phases, where a human is really needed.

🎓 When the problem isn't the agent but the team

Some of the complaints weren't aimed at the agent but at how the team works with it.

  • "Why doesn't the setup work for me in Cursor?" When everyone uses a different tool, the project setup fragments. So Ackee picked a single platform, Claude, partly because it extends into back office and other teams.
  • "I use --dangerously-skip-permissions, is that a problem?" and "I'll replace the lint script with a skill." There's no point in swapping a deterministic linter for a skill, and bypassing the permission system is not a minor thing. At Ackee, these questions are answered by a twelve-level educational framework for developers. It starts from the absolute basics (the permission system, sandboxing, dev containers, progressive disclosure in skills, why not to have 50 MCP servers enabled) and the team goes through it together, so nobody runs far ahead and the rest don't get left behind. How permissions work in Claude Code is covered in the article Claude Code permissions: who decides what an AI agent may do.
  • A borrowed skill set is a black box. According to Babáček, ready-made sets like superpowers are hundreds of lines of text where you don't know why each pattern is there. Your own skills fitted to specific use cases get by with dozens of lines, work more reliably and use fewer tokens.

🔧 Don't fix the output, fix the system

The most common mistake doesn't arise in the agent but on the merge request. A reviewer writes that a line needs wrapping, the author fixes it by hand and moves on. But nothing is added to .claude/rules, so the same comment shows up on the next merge request, and then again.

“Please, don't fix the output. If you fix the system, the mistake won't happen to you again in the future. If you don't, it will keep happening over and over.”

Rostislav Babáček, Team Leader and Lead Implementer of Agentic Development at Ackee

It also follows that the team has to build the harness itself and be involved in it. If you don't know what is in the system and why, you won't trust it. And it doesn't work without time for training. Developers who don't know the harness mostly just complain about it. Once they understand why the individual steps are there, they start extending it themselves.

Frequently asked questions

CLAUDE.md is a recommendation for the agent, not an enforced rule. In a large context the agent pushes some instructions aside on its own. Whatever must always happen (tests, build, lint) belongs in a workflow step with a feedback loop. Compliance with the rules in .claude/rules is then checked by a separate subagent's review over the git diff.
Write down why the logic exists in an architecture decision record (ADR) in the project context. The agent loads the relevant ADR when it works with the file and understands that the code has a purpose. A code comment is weaker because it's easily lost during refactoring.
Add a separate deslop phase to the implementation loop. It goes through the newly generated code, removes pointless comments and nesting and simplifies the implementation. The instruction to implement the minimum in TDD alone wasn't enough.
It works in a single context window, hits its limits, and context rot or lossy compaction sets in. A multi-phase plan helps, where each phase runs in a clean context window, along with splitting phases into vertical slices so the app builds after every phase.
Only partly. The model and the built-in harness are two of the five layers that affect output quality. The team fully controls project setup, a good assignment and developer skills, and most of the fixes in this article live there.

🎯 Key takeaways

  • Every repeated agent mistake is knowledge missing from the system. Write it down where it belongs: rules, a glossary, ADRs, a workflow or review.
  • A named principle with an example works better than a prohibition.
  • Whatever must always happen doesn't belong in CLAUDE.md but in a workflow with a feedback loop.
  • Split large tasks into phases as vertical slices, each in a clean context and with its own commit.
  • If you fix the output and not the system, you fix the same mistake again. And if you don't share, you slow yourself down too.

Subscribe to the newsletter

More notes like this from Ackee are in our newsletter. Subscribe and the next one lands straight in your inbox.

Rostislav Babáček
Rostislav Babáček
Team Leader, Indigo Mobile Development team

Are you interested in working together? Let’s discuss it in person!