# Verifying agent work

> Code you did not write needs a different kind of reading. This topic covers reviewing an agent's diff against the specification rather than for plausibility, observing the system as it runs, narrowing a fault systematically, turning checks into loops the agent can run itself within limits you set, relying on deterministic gates over model opinions, and attacking your own agent before someone else does.

Page: https://schubergphilis.github.io/ai-training/topics/coding-with-agents/verification/
License: CC BY-SA 4.0, https://creativecommons.org/licenses/by-sa/4.0/

*Coding with agents* · topic `coding-with-agents/verification`

Code you did not write needs a different kind of reading. This topic covers reviewing an agent's diff against the specification rather than for plausibility, observing the system as it runs, narrowing a fault systematically, turning checks into loops the agent can run itself within limits you set, relying on deterministic gates over model opinions, and attacking your own agent before someone else does.

## Concepts

- **Reviewing code you did not write**: Reading an agent's diff as a reviewer, not an author: you have no memory of why each line exists, so every line has to justify itself. Look for changes outside the brief, silent behavior changes, deleted tests, copied patterns applied wrongly and comments that describe intent rather than what the code does. Read the code, not the agent's summary of it. [glossary](https://schubergphilis.github.io/ai-training/glossary/#reviewing-code-you-did-not-write)
- **Verifying against the specification**: Checking the result against the success criteria written before the work, item by item, instead of judging whether the change looks reasonable. This catches the plausible-but-wrong result, the criterion quietly dropped and the edge case skipped. If a criterion cannot be checked, either the spec or the verification design needs fixing before the change is accepted. [glossary](https://schubergphilis.github.io/ai-training/glossary/#verifying-against-the-specification)
- **Observing a running system**: Running the changed software and watching what it actually does: the logs it writes, the requests it makes, the state it leaves behind, the screen it renders. Tests prove what they cover; observation catches what nobody thought to test. For agent work, running it yourself is also the check that the agent's report of "tests pass" is true. [glossary](https://schubergphilis.github.io/ai-training/glossary/#observing-a-running-system)
- **Isolating a fault**: Narrowing a failure to its cause by systematic steps: reproduce it, shrink the input, bisect the change, add observation at the boundary, confirm the hypothesis before fixing. Agents can help at each step but will also guess fixes; insisting on a reproduced, explained cause before any patch is what keeps the fix from becoming a new bug. [glossary](https://schubergphilis.github.io/ai-training/glossary/#isolating-a-fault)
- **Bounded self-checking loops**: Giving the agent a check it can run itself, such as a test suite, a linter or a build, and letting it iterate until the check passes, with a limit on attempts and a rule for what it may change. The bound matters: an unbounded loop will eventually satisfy the check by weakening it. The human verifies the check is still honest at the end. [glossary](https://schubergphilis.github.io/ai-training/glossary/#bounded-self-checking-loops)
- **Deterministic gates**: Checks whose outcome does not depend on a model's judgment: tests, type checks, linters, builds and schema validation. They give the same answer for the same input, so they can block a merge. A review by another model adds a second opinion and finds things a gate cannot, but it can be wrong or be persuaded in the same way as the first model, so it never replaces the gate. [glossary](https://schubergphilis.github.io/ai-training/glossary/#deterministic-gates)
- **Red-teaming your own agent**: Deliberately trying to make your own agent misbehave before relying on it: feeding it a file with hidden instructions, pasting it a web page you did not read, asking for something its permissions should stop, giving it an ambiguous brief and seeing how far it runs. The aim is to learn what it does under pressure, in a sandbox where nothing real can be damaged. What you find becomes a permission change, an instruction or a gate. [glossary](https://schubergphilis.github.io/ai-training/glossary/#red-teaming-your-own-agent)
- **Fresh-context review**: A review by an agent session that did not write the change. It gets the diff, the specification and the criteria to check, and none of the reasoning that produced the change, so it judges the result on its own terms. A reviewer asked for gaps finds some even in sound work, so it is told to report only what affects correctness or the stated requirements. Its findings are advice a person weighs, next to the deterministic gates that decide whether a change merges. [glossary](https://schubergphilis.github.io/ai-training/glossary/#fresh-context-review)

## Links

- **Builds on:** [Plan, implement, verify](https://schubergphilis.github.io/ai-training/topics/coding-with-agents/workflow/), [Verifying outputs](https://schubergphilis.github.io/ai-training/topics/safety/verification/)
- **Leads to:** [Evaluation and testing](https://schubergphilis.github.io/ai-training/topics/building-agents/evaluation/), [Quality with agents](https://schubergphilis.github.io/ai-training/topics/coding-with-agents/quality/)
- **Competencies drawing on it:** [Verifies agent-written code before trusting it](https://schubergphilis.github.io/ai-training/competencies/coding-with-agents/verifies-agent-work/)

## Lessons

- [Reproducing a fault before the agent fixes it](https://schubergphilis.github.io/ai-training/coding-with-agents/observing-and-debugging/) (tutorial)
- [Attacking your own agent before someone else does](https://schubergphilis.github.io/ai-training/coding-with-agents/red-teaming-your-agent/) (tutorial)
- [A review from a fresh session](https://schubergphilis.github.io/ai-training/coding-with-agents/review-in-a-fresh-session/) (tutorial)
- [Reviewing a diff you did not write, against the spec](https://schubergphilis.github.io/ai-training/coding-with-agents/reviewing-the-diff/) (tutorial)
- [Giving the agent a check it can run, with a limit](https://schubergphilis.github.io/ai-training/coding-with-agents/self-checking-loops/) (tutorial)

## Sources

- `Brilliant VER` Verification, Brilliant, Coding with AI skills map (reference)
- `Academy ai-fluency-for-builders` [AI Fluency for builders](https://academy.claude.com/courses/ai-fluency-for-builders), Claude Academy (course)
- `Academy claude-code-in-action` [Claude Code in action](https://academy.claude.com/courses/claude-code-in-action), Claude Academy (course)
- `Claude Code best practices` [Best practices for Claude Code](https://code.claude.com/docs/en/best-practices), Claude Code documentation (reference)
- `OpenAI Academy get-started-with-codex-jkhsq` [Get Started with Codex](https://academy.openai.com/public/courses/get-started-with-codex-jkhsq), OpenAI Academy (course)
- `OpenAI Academy scale-codex-across-teams-and-systems-jr83a` [Scale Codex Across Teams and Systems](https://academy.openai.com/public/courses/scale-codex-across-teams-and-systems-jr83a), OpenAI Academy (course)
