Working with AI Coding Agents: A Disciplined Loop
Tell a coding agent to make the failing tests pass. It can fix the code, or it can weaken the tests. Both turn the checks green. Only one fixes anything.
Guess first
Your coding agent reads a notes file about your project. Its paths and commands are months out of date. How does that compare with no file at all?
Out-of-date context is worse than none, because the agent follows it confidently. A stale path or command gets used as if it were still true.
· Committing first, even to a wrong guess, makes the answer stick.
At a glance · about 1 min
The Loop for One Change
- Outcome and checksWrite behaviour and acceptance checks before prompting.
- Context fileMost agents read a plain file in the repository.
- Plan firstCorrect the plan, not the code.
- Smallest changeOne feature or fix per session.
- Review diffExplain the important lines yourself.
- VerifyRun checks; break something once to see it fail.
- CommitSave a known-good state with a clear message.
In brief
An agent can write a hundred lines while you read ten, so you risk shipping code you cannot explain. Seven steps take one change from your own acceptance checks to a known-good commit. Close the chat and explain the diff aloud, line by line: only code you can explain counts as reviewed.
Key ideas
- The useful unit of progress is a change you can defend: what it does, how you checked it, and how to undo it, not code you merely accepted.
- Write acceptance checks before prompting, get a plan before any edit, review the diff, break the code once to prove the check can fail, and commit known-good states.
- Label agent-written code honestly as reviewed or accepted, and keep accepted code away from places where failure would be expensive.
Check yourself 5 cards answer from memory, then open each
Retrieval, not rereading, makes learning last (see the weekly loop). Grade yourself honestly and the study dashboard brings each card back on a spaced schedule that supports retention.
-
recall
What is the difference between "reviewed" and "accepted" agent-written code?
Show answer
Reviewed code is code you read and can explain, including what it assumes. Accepted code simply ran and you moved on. Only reviewed code counts as evidence of your skill, and accepted code should stay away from expensive-failure areas.
-
recall
What five things does the page say belong in a short, current context file for an agent?
Show answer
Purpose, in two sentences; structure, meaning where important files live; commands to run, test and build; conventions such as naming, style and error handling; and a never-touch list covering generated files, secrets and vendored code.
-
explain
Why does the loop tell you to break something on purpose once and confirm that the check fails?
Show answer
A check that cannot fail proves nothing. Deliberately breaking the code and watching the check fail shows that it really tests what you think it tests, so a later pass actually means something.
-
apply
After three prompts in a row ending in "still broken," an agent finally makes your tests pass, but you notice it changed the tests' expected values. What does the page recommend?
Show answer
Both are signs of slipping into vibe-coding: three "still broken" prompts, and the agent fixing the test instead of the code, since "make the checks pass" can be satisfied by weakening them. Stop, revert to the last good commit, shrink the task, and restate the failure from evidence.
-
connect
This page points to "Deliberate Practice: Choose Targets You Can Observe" for the wider habit behind "predict, check, correct." What does that habit ask you to do with an agent, and where does the learning happen?
Show answer
Before the agent answers, write down what you expect, such as which files will change and what the output will be. Then compare. The gap between prediction and result is where you learn; skipping the prediction leaves only the outcome.
A responsible workflow for using coding agents: spec first, plan first, review every diff, verify, and commit known-good states.
After this page You can run a coding agent through a seven-step loop and ship only changes you can explain and undo.
Read the full pageHide the full page · 6 min
A coding agent can write a hundred lines in the time it takes you to read ten. That speed is useful only if you can still say what the code does and why you trust it. This page describes a loop for using agents so that you ship changes you can explain, not code you merely accepted.
The method is a working recommendation, not a law of nature. Agents and their commands change quickly, so check the current documentation for whatever tool you use. Provisional
The goal: explainable change
The useful unit of progress is a change you could defend to a colleague: what it does, how you checked it, and how to undo it. If the agent wrote it and you cannot explain it, you have borrowed code, and the debt arrives later as a bug you cannot localise.
Andrej Karpathy introduced the term "vibe coding" in a post of February 2025. It names the style of accepting whatever the model produces and pasting error messages back until it runs. He called it "not too bad for throwaway weekend projects". The loop below is for work you intend to keep. Established as to the term's origin; the judgment about when each style is appropriate is Provisional.
The loop for one change
- Write the outcome and acceptance checks first. One sentence of behaviour, plus how you will know it works, including at least one failure case. You write these, before prompting.
- Give the agent a context file. Most agents read a plain file in the repository (Claude Code reads
CLAUDE.md; other tools use similar files). - Ask for a plan before any edit. Correct the plan, not the code. A wrong plan is cheap to fix; a wrong diff is not.
- Request the smallest coherent change. One feature or fix per session.
- Review the diff. Explain the important lines yourself. Ask the agent, "What could this break?" and treat the answer as a lead to check, not as a verdict.
- Verify. Run the checks yourself. Once, break something on purpose and confirm the check fails; a check that cannot fail proves nothing.
- Commit a known-good state with a message you will understand in six months.
What belongs in the context file
Keep it short and current. A reader, human or machine, should find:
- Purpose: what the project is for, in two sentences.
- Structure: where the important directories and files live.
- Commands: how to run, test and build it.
- Conventions: naming, style, how errors are handled.
- Never-touch list: generated files, secrets, vendored code, anything the agent must not edit.
Out-of-date context is worse than none, because the agent will follow it confidently.
Guardrails
| Guardrail | Why it matters |
|---|---|
| One repository, one task, one known-good commit | Gives you a place to return to; Pro Git shows how to inspect and restore earlier revisions. |
| Secrets never in the repository or in prompts | Keys committed to history are hard to retract, and prompts may be logged. OWASP names sensitive information disclosure as a risk for LLM applications. |
| Synthetic data before real data | You can predict the right answer for data you made up, so you can tell when the output is wrong. |
| Local checks first, automated checks after | Automate only what you have already seen work by hand. |
| Frameworks only when coordination pain is real | Each added layer is something else you must understand and review. |
Signs you have slipped into vibe-coding
- You cannot say, in a sentence, what changed.
- You accepted a fix without first reproducing the bug.
- The agent "fixed" the test instead of the code. This is a recognisable failure shape: the goal "make the checks pass" can be satisfied by weakening the checks. Anthropic's system card for Claude 3.7 Sonnet (2025) reports the model occasionally modifying tests to match its code's output.
- Three prompts in a row ended in "still broken."
The response is the same in every case: stop, revert to the last good commit, shrink the task, and restate the failure from evidence.
Reviewed versus accepted
Keep an honest label on every piece of agent-written code.
- Reviewed: you read it and can explain what it does and what it assumes.
- Accepted: it ran, and you moved on.
Only reviewed code counts as your evidence of skill. Accepted code is not forbidden, but keep it away from the parts of a system where a failure would be expensive.
A habit that helps is predict, check, correct. Before the agent answers, write down what you expect: which files will change, what the output will be. Then compare. The gap between prediction and result is where you learn; skipping the prediction removes the learning and leaves only the outcome. For the wider habit, see The Weekly Loop and Deliberate Practice.
A prompt template
Goal: [one useful behaviour]
Environment/versions: [observed facts]
Relevant files: [paths]
My attempt / current failure: [evidence]
Acceptance checks: [normal result + important failure behaviour]
Constraints: [scope, data boundary, cost/time]
Inspect first and propose a plan before editing.
Make the smallest coherent change and show how to verify it.
Separate verified behaviour from assumptions.
Then ask me to explain one important part before we move on.
The last line matters most. It turns the agent from author into examiner, which keeps you in the loop.
A bounded tutor prompt and a stop rule
When you use an agent to learn rather than to build, bound the exchange:
Topic and remaining time: [one topic, minutes]
Source and version: [specific section]
My explanation or attempt: [my own words]
Find the first important mistake or unsupported assumption.
Ask one question at a time and wait for my answer.
Give the smallest useful hint, then change one condition.
Check version-sensitive claims against the official source.
Separate fact, inference, and unknown.
Stop rule: when you can explain the mechanism, solve a changed case, and name the remaining limit, record the next action and end the session. More tools and tabs are optional until the next real question needs them. This is the stance of Technology, AI and Human Judgment: use the machine to sharpen the struggle, not replace it.
Why the discipline is also reasoning
Each step has a counterpart in careful thinking. Acceptance checks are predictions committed before the result; reviewing the diff is checking premises; breaking a test on purpose is looking for a counterexample, as described in Proof and Precise Reasoning. An articulate agent explanation is exactly the kind of answer that Technical Writing as Reasoning teaches you to separate into observation, inference and assumption. When you are ready for agents that call tools on their own, read Building Bounded Agents.
Try this
- Choose a small script you own. Write three acceptance checks, including one failure case, then ask an agent for a plan only. Mark where the plan is wrong before it edits anything.
- After any agent-made change, close the chat and explain the diff aloud, line by line. Note each line you could not explain, and either learn it or remove it.
- Take a passing test, change the code so it should fail, and confirm that it does. If it still passes, the check was not testing what you thought.
Further reading
- Anthropic, Building effective agents (2024): workflows versus agents, and keeping designs simple.
- Anthropic, Claude Code documentation: memory files, plan mode and permissions (check the current version).
- Chacon and Straub, Pro Git, 2nd ed.: viewing diffs and restoring a known revision.
- Beck, Test-Driven Development: By Example (2002): writing the check first.
- OWASP, Top 10 for Large Language Model Applications: prompt injection and information disclosure.
Sources 7
- Karpathy, A. (2025). Post introducing the term 'vibe coding', X (formerly Twitter), 2 February 2025. x.com/karpathy/status/1886192184808149383.
- Anthropic. Claude Code documentation, 'Memory' (CLAUDE.md) and 'Common workflows' (plan mode). Anthropic official documentation, current version.
- Chacon, S. and Straub, B. (2014). Pro Git, 2nd ed., Apress. Chapters 2 (Git Basics) and 7 (Git Tools).
- Beck, K. (2002). Test-Driven Development: By Example. Addison-Wesley.
- Anthropic (2024). Building effective agents. anthropic.com/engineering/building-effective-agents.
- OWASP. Top 10 for Large Language Model Applications (Prompt Injection; Sensitive Information Disclosure).
- Anthropic (2025). Claude 3.7 Sonnet System Card, section 6, 'Excessive Focus on Passing Tests'. anthropic.com/claude-3-7-sonnet-system-card.