Claude Code works in a loop. It gathers context from your repository, uses tools to inspect or change files, and checks the result. A useful mental model is a developer who can read the project and run tests, with permissions that control which actions are allowed. Anthropic describes this process in its public guide to how Claude Code works.
Follow a bug fix through the loop
Suppose an empty quantity in a shopping-cart form is saved as zero. The product requirement says a quantity is a whole number greater than zero. Before opening Claude Code, put three cases in your notes: blank is rejected, zero is rejected, and one is saved. This gives the agent a concrete result to check.
- Gather context. Ask Claude Code to find where raw form input becomes a number and identify the existing validation tests. Read through the files it names before approving edits.
- Make the change. Request a failing regression test and a small validation change. Decide whether the fix belongs at the form boundary, the API boundary, or both. If the same parser handles imports, check that behavior separately.
- Verify the result. Run the targeted tests and review the diff. Check that the implementation distinguishes empty input from an explicit zero and leaves valid quantities intact.
The loop can repeat within a task. A failing test may send the agent back to inspect a second parser. Treat a summary such as “fixed validation” as a pointer to the diff and test output.
What the model gets from tools
A read tool returns file content. A shell tool can return test output. Those results become context for the next model turn. Repository instructions such as CLAUDE.md can describe where tests live and which checks maintainers expect. Short instructions with an actual test command and scope tend to be easier to apply during a fix.
Keep credentials, production data and private customer records out of the evaluation checkout. Review Anthropic’s security documentation to understand how tool approvals and sandboxing apply to your setup.
A prompt you can use on a small bug
Inspect the quantity validation and identify the parser and its tests.
Explain the smallest change before editing. After agreement, add a test
for empty input, zero, and one. Run the relevant test command.
Report the changed files, test result, and any cases left untested.Run the experiment in a disposable checkout. Give the agent the minimum permissions needed for the current step and review any proposed command you would hesitate to run yourself. Keep deployment and publishing for after review.
How to compare two coding agents
Give each tool the same commit, task and permission boundaries in separate checkouts. Record whether the change passed existing tests, whether it added a useful regression test, the size of the diff and how often a human had to intervene. Save an example of a misleading success message if you encounter one. That example can make a better team training case than an average time score.
For a fuller evaluation template, see our coding-model evaluation guide.



