Claude Code and Codex: how to reduce repeated mistakes
Use CLAUDE.md, AGENTS.md and regression tests to reduce repeated mistakes in Claude Code and Codex. Practical examples and reusable instructions.
To reduce repeated mistakes in Claude Code and Codex, combine persistent instructions, bounded tasks, and tests that detect the failure. Recording a correction helps future sessions, but does not guarantee compliance. Improvement becomes measurable when you can verify what changed and preserve that criterion in the project.
Have you explained the same correction three times? Before switching models, inspect the process. The instruction may be buried in chat, conflict with another rule, or never have been tested. Our teaching example is a contact form that accepts submissions without an email. It is not a customer case study.
Where should instructions live: CLAUDE.md or AGENTS.md?
In Claude Code, use CLAUDE.md for project guidance; in Codex, use AGENTS.md. Inside their terminal interfaces, /init can generate a starting point. Review the proposed paths, commands, and constraints against your repository. This is an interactive command inside the tool, not a shell command.
/initA useful rule says when to act, what to do, and how to check it. For the form: “When email is missing, block submission and show a message”. Record the actual test command used by your project as well. Keep instructions brief and remove outdated or conflicting guidance.
Persistence is not a guarantee: Instructions provide context; they do not retrain the model or replace application validation. Claude Code also has automatic memory. Review what it retains instead of assuming that every correction was saved.
How to split a task without losing the goal
Ask for three verifiable deliverables: understand, fix, then demonstrate. This order helps expose a wrong diagnosis before changes accumulate. You do not need three separate conversations; request these stages within the same session and keep the acceptance criterion explicit.
- Diagnosis: “Reproduce submission without an email and explain where validation is missing”.
- Change: “Fix that behavior without changing the design or unrelated features”.
- Verification: “Test empty and valid email inputs; show the result of each case”.
When delegating to multiple agents, assign distinct owners and files. One can investigate while another reviews tests, but agree on who integrates the changes. If two contributors edit the same area without coordination, the obstacle becomes work organization rather than model capability.

What to request after fixing a bug
Request a regression test: a check designed to detect that same bug if it returns. It should fail against a version without the fix and pass afterward. Make that comparison in a test environment; it does not require undoing production changes. Try this instruction:
Add a test for submission without an email.
Check that it catches the bug and passes with the fix.
Also test a valid email.
Record the brief rule and exact test command
in the project instruction file.In some Node projects, npm test runs the test script in package.json. Check that the script exists and understand its scope first. A successful exit does not prove the form was tested. Ask for the case name, its outcome, and anything that remains unverified.
What if the mistake happens again?
Check whether the agent read the rule, whether another instruction contradicts it, and whether the test covers the real scenario. In the next session, ask it to identify applicable instructions before editing files. If the requirement changes, update the test too: preserving an incorrect rule can perpetuate a problem.
Which mistake would you like to stop explaining? Pick one and try this sequence. MAMBO helps teams review processes and implement AI with verifiable criteria. The useful question is what evidence you need before trusting the next run.
Explore the approach and apply it with your team:
AI implementation with MAMBO
The first model to change is our own
Sources and scope
Based on official documentation consulted on September 21, 2026. Commands depend on the tool version and project; the examples are illustrative.
Memoria e instrucciones de Claude Code
AGENTS.md en Codex
Comandos de Codex CLI