Training an AI like a junior: my Lean standard, built mistake after mistake

An AI agent fixes a bug in seconds, but often next to its cause, and the CI turns red again a bit further down the line. In this article, I tell, commits in hand, how its repeated mistakes on a personal project became a Lean standard. You will find the method, the real figures, and a standard you can reuse.

TL;DR

  • Every time the AI agent fails, I ask myself what was missing in my instructions, and I add it.
  • At first, I let the agent fill an instructions file with its learnings: too long for it, unreadable for me. My Lean training brought me back to the standard: an intention, typical mistakes, checkable key points.
  • My commits show it: 9 fixes in a row for a first deployment, and the same fix to redo 6 minutes later in other files.
  • An AI agent is a beginner fresh out of school: advanced technical knowledge, but no field experience. Training it is testing your own ability to pass on what you know.

The agent fixes fast, but next to the cause

In a previous article, I tested GitHub Copilot to build a JS web app: a map of the hiking paths around my town, for the members of my association. It was a personal project, to assess what AI could do and to grow my own skills. I held all the roles at once, lead dev, PM and end client, with one question: can we reduce lead time without losing quality?

I had already drawn a few lessons from it. By default, Copilot proposed neither tests nor documentation, and I was the one who asked for them. Once in place, it kept proposing them for every change: I concluded that it learned from my practices. In this article, I go further, on how to teach an AI agent to work with my standards.

Letting the agent propose new features and fixes, I saw the same scenario come back. The agent sees an error message, finds the file at fault, fixes it. Then something breaks elsewhere.

The agent has all the knowledge of the world in its training, and access to all the code of the project. I expected it to propose lasting fixes: dependencies between files, tests, documentation. That was my misconception. These practices, which are the bare minimum of development for me, had to be taught.

What my commits tell

“Without data, you’re just another person with an opinion,” said W. Edwards Deming. It is my motto: I was a researcher, then a data scientist, and I prefer to decide on facts. So I read the git history of the project again, which is public.

  • On 9 December 2024, the first deployment takes 9 “Fix…” commits in two hours. Each one fixes the next CI error: a missing module, the webpack configuration, a permission, the Node version.
  • The Node version goes from 14 to 16 to accept a single operator (??=), then to 18 four days later, then to 22 a year later, when the required version is finally declared in package.json. Three patches before treating the cause.
  • On 10 August 2025, a googleapis update breaks the CI. The agent’s first proposal: go back to the old version. I had to ask “Isn’t it safer to update now to the newer version?”, then twice whether other files or steps needed the same fix: “Do I need to change any other actions files for this same problem?”, “Aren’t there any other steps that would need this flag too?”. The fix came in two commits, at 19:02 then at 19:08.

None of these fixes is wrong. They treat the visible symptom, one at a time.

Twenty minutes from my questions to a guide

Five minutes after that last commit, at 19:13, I asked Copilot: “How can I give you pre-chat instructions that you would need to apply each time I interact with you? Like: Have you verified that other files have the same problem? You added some code, is it tested? You added a new step in the procedure, is it documented?”

In twenty minutes and seven requests, the guide grew from 172 to 970 words. Two requests came straight from repeated mistakes:

  • “In this project, we always forget to run the command to update the dependencies before commit.”
  • “After a series of questions and corrections, sometimes, like here, you do not propose to clean the repository.”

The last one said everything about my intention: I wanted “Please follow our Copilot Workflow Guide when responding” to be the only sentence to type, and the agent to do the rest.

Deep down, I was telling the agent: “fill this file with your learnings”. Each mistake added a paragraph, and the guide filled up with ideas in a jumble.

A beginner does not learn from a 200-page guide

After a while, I saw it was not efficient, for two reasons. With a file that is too long, the agent loses part of it along the way: even with ever-larger context windows, it no longer takes everything into account over time. And a file filled by the agent is unreadable for a human: nobody reviews it, so nobody fixes it.

It was Régis Médina’s video, “9 lies about AI”, that reminded me. Régis explains how to train an AI with a Lean standard written in natural language, so that its proposals include the good practices you already have. At work, I have this reflex: observe the field, write down the good practice, close the continuous improvement loop. On my personal project, I had forgotten it, and my Lean training came back.

You do not make a beginner read a 200-page guide and hope they take it all in, let alone grow their skills. What works is a Lean standard: simple, visual, giving the intention rather than the “how”, with several reading levels depending on experience. The titles are enough. The examples help when in doubt, before calling for help.

My guide was only a list of questions: what the AI had to do, never what went wrong. A standard says both, so that you know whether a piece of work is OK or not OK. So it changed shape:

  • August 2025: a list of questions to ask yourself;
  • March 2026: a step-by-step procedure to analyse a defect;
  • April 2026: two standards, defect analysis and code changes, with an intention, typical mistakes and key points;
  • November 2026: each key point is checkable, with its why and ✅ / ❌ examples.

Here is a key point as it stands today:

Standard key point

✅ The files that call the modified code are listed, and their compatibility is checked

A local fix can break another module that depended on the old behaviour.

  • ✅ “getUser() is called in profile.js and admin.js: both handle the new null return.”
  • ❌ The CI fails after the fix because another module depended on the modified code.

The reading levels are there: the bold title is enough for someone who already knows the move, the italic why helps apply it to a new case, and the examples settle it when in doubt.

The standard also lives from its own mistakes. In May 2026, the rule “always run npm update before committing” moved unrelated dependencies, when there was only one vulnerability to fix. The guide now says to use npm install --package-lock-only in that case. The rule was not erased: it was refined, and the change is dated.

The AI behaves like a junior, and that speaks about my team

That same evening, the freshly written guide asked to document any new procedure. The agent did not propose to mention the guide in the README. At 19:47, I asked it why. Its answer: “I missed following the Copilot Workflow Guide despite it being available in the repository, which is exactly the type of situation the guide was created to prevent.” And it did not think the guide needed updating. It was not the last time: “It was written that I had to do this, but I just didn’t follow the standard this time.”

Funny, it is the same with humans. You can have a great good-practice guide, not everyone always follows it. And there, as a manager or a coach, the right question is not “why did you get it wrong?” but “why didn’t you follow the standard?”. We think we already know it, it is too complicated, it is not in the right place, we don’t have time… Each reason is a lead to improve the standard, not a reproach.

If even a machine programmed to follow instructions is tempted to go too fast, imagine a human! If my standard is not clear, accessible and easy to take in, my AI agent will fail, and so will my colleagues.

I had no team on this project, but all this reminded me of what I lived with teams on real projects. An AI agent is a beginner fresh out of school, with advanced technical knowledge but no field experience. What it lacks, I can pass on, thanks to my Lean principles. Developer, production manager, then PM, I kept one conviction: technology only holds value through its impact on users and colleagues, and the energy must go to people.

Writing for the AI forced me to dig into my head to put on paper what I know I do well when I develop. I was discovering JavaScript, but not the approach: I had learned root cause analysis with R. Testing the standard on an agent was testing my ability to pass it on. It is also what allowed me to propose, in my current job, a more mature way of working with AI agents: that will be the topic of a next article.

What has changed with today’s agents

In 2025, I had to remind the agent to read the guide before each answer. Today, agents read an instructions file at the root of the project on their own (AGENTS.md, CLAUDE.md). All the more reason to keep it short and readable: it is loaded at every session. A pre-commit hook can block what must not go through. The repository of this blog has one, which refuses any change to an old article.

They still do not look for the cause on their own. From June to September 2026, the CI of the map kept breaking. From 20 July to 26 September, no weekly release came out, for 68 days, while 25 dependency updates had been merged. Digging with Claude Code, I found two causes. The security audit blocked the deployment because of vulnerabilities in development dependencies, which never reach production. And the automatic merge could go through without waiting for the CI. The lasting fix was not to ignore the audit, but to block only serious vulnerabilities in production dependencies, and to make every merge wait for a green CI.

From that session, all I have left is a memory file written by the agent. It has the shape of a standard key point: the decision, its why, and how to apply it: “don’t reintroduce a blocking full audit, nor merges that bypass checks”.

The standard no longer serves to teach the agent to read its instructions. It serves to pass on a way of looking: mine, which looks for the cause before fixing.

The standard, ready to reuse

My two standards are available on my GitHub repository blog_tips: technical defect analysis and code changes, in English and in French. They are written for humans as well as for AI agents.

To start your own, no need to write everything at once:

  1. Pick a move you repeat often: analysing a bug, reviewing a change.
  2. Write its intention and three key points that can be checked with a yes or a no.
  3. At each mistake, from the agent or from a colleague, ask two questions: “what was missing in the standard?” and “what would have shown it earlier?”.

And you, which instruction do you repeat most often, to an AI or to a colleague? It might be the first key point of your standard. Tell me in the comments!