Chapter 1 · Session 3
Briefs, and the rules Claude Code works by
From now on Claude Code writes the code. Your job is to say what to build, decide before it starts how you will know it is right, and read what comes back. This chapter sets up what makes that job routine: a brief template, standing rules for how Claude Code proves its work and when it must stop, and the right answers to its permission questions.
30 min2 stepsOne pull request
By the end of this chapter you can
- Name the five parts of a brief and say why the acceptance checks are written first.
- Add the brief template and the working rules (proof, stopping, never weakening a check) in one pull request.
- Answer permission prompts safely: which commands may be allowed for good, and which never.
A new job
Claude Code can write in an hour what took a week, and it will happily write the wrong thing in an hour too. It does not know your plant, it remembers nothing from last week unless it is written in the repository, and it will say it is done when it believes it is done. None of that is a reason not to use it. It is a reason to direct it well: a clear brief, checks written first, proof instead of summaries, and a person reading every change before it merges.
What a brief says
Anthropic's guidance for Claude Code puts it plainly: the more specific the instructions, the better the first attempt and the fewer corrections later [1]. Specific does not mean long. It means Claude Code can answer, from the brief alone: what outcome do you want, where are the edges, how will we both know it is done, and what proof should I bring back.
| Part | Says | Example: brief 01, the status page |
|---|---|---|
| Goal | The outcome in plant words, and why it matters to the intent | A /status page showing which version is live and when it was built, so anyone can tell after a deploy whether a change is live |
| Context | What to read first; rules that stand | docs/INTENT.md, CLAUDE.md, the template, the home page (which already shows a build time) |
| Acceptance checks (written first) | Numbered given, when, then lines. Each becomes a test that fails before the work and passes after it | Given the app is built, when I open /status, then I see the version from package.json |
| Out of scope | What must not be touched or added | No sign-in, no database, no new packages, no change to existing tests or checks |
| How to show it works | The proof you want back: commands, exit codes, check results, an address to open | npm test with its exit code; CI green on the latest commit; the preview address of /status |
Standing rules go in CLAUDE.md
Rules that apply to every brief go in CLAUDE.md once, not in every prompt [2]. The ones this session adds come straight from what went wrong while we built our own platform: an agent reporting "all tests pass" when they had not run, an agent retrying the same refused step for a day, and an agent going around a check it had been refused. Each rule below exists because of one of those.
One prompt: the brief template and the working rules
15 minutesWhy
A template means every brief has the same five parts, so nothing important is left for Claude Code to guess. The working rules in CLAUDE.md then apply to every task without you repeating them: how to prove something works, when to stop, and that checks are never weakened. An allow list for read-only commands removes most of the permission questions, while Session 1's deny list still refuses the dangerous ones. One pull request does all three.
Do this
cd ~/code/acme-platform && git switch main && git pull && claudeOn a new branch setup/briefs, do three things and nothing else.
1. Create docs/briefs/TEMPLATE.md, a brief template with these headings and one line under each saying what goes there:
- Goal: the outcome in plant words, and why it matters to the decision in docs/INTENT.md.
- Context: the files to read first, and any rule that stands.
- Acceptance checks (written first): numbered lines "Given ..., when ..., then ...". Each becomes a test that must fail before the work and pass after it.
- Out of scope: what must not be touched or added.
- How to show it works: the proof I want back (commands, exit codes, check results, an address to open).
End it with: "One brief, one pull request. If the checks do not fit on one screen, split the brief."
2. Add a section "Working rules" to CLAUDE.md, keeping everything already there:
- Before you say something works, show the exact command, its exit code and the last 20 lines of its output. Never pipe a test command into another command when reporting its result. If something could not run, say "could not run", not "passed".
- A change is done when the checks on its pull request are green on its latest commit. Wait for them with gh pr checks --watch before reporting.
- After two identical failures, stop. Tell me what failed (quote the error), what you tried, whether the cause is in our code or outside it, and what you need from me.
- Never edit, skip, loosen or delete a test, a check, a limit or a CI step to make something pass, and never use a different command to do something you were refused. If you think a check is wrong, stop and explain; I decide.
- Every new test must be shown failing before the change that makes it pass.
- If anything you told me earlier turns out to be wrong, say so first.
- To show what a branch changed, compare with git diff origin/main...HEAD (three dots).
3. In .claude/settings.json, keep every deny rule exactly as it is and add an allow list for these read-only and checking commands only: npm test, npm run lint, npm run typecheck, npm run build, npx tsc --noEmit, git status, git diff, git log, gh pr view, gh pr checks, gh pr diff.
Commit, push, open a pull request titled "Brief template and working rules", and show me the link.You will see recreated screen
- Added below the Session 2 line, which stays.
- Only additions. Every deny line keeps a space in the margin: unchanged.
- It tells you how to check its claim. From now on, every report should.
Check it worked
Pull request #6 (your number may differ) changes three files: docs/briefs/TEMPLATE.md (new), CLAUDE.md and .claude/settings.json. In Files changed, settings.json has no red (removed) lines. Owner two approves and you merge.
Fastest path
After the merge, paste The pull request is merged. Switch to main and pull. Claude Code reads CLAUDE.md again at the start of every session, so the working rules apply from your next prompt in a new session.
If it goes wrong
The settings.json change removes or rewrites a deny rule
Say: Restore every deny rule exactly as it is on main. Only add the allow list. The deny rules are your guard rails from Session 1; adding an allow list never needs them changed.
CLAUDE.md is rewritten from the top, or grows long
Say: Keep everything that was in CLAUDE.md and only add the Working rules section. Keep it to rules; where a fact lives in a file, point to the file. We found six of ten areas listed in our own CLAUDE.md naming nothing that existed, because copied facts had drifted.
The allow list includes git push, rm, supabase or vercel
Say: Remove everything from the allow list except the commands I listed. Those commands change things; you want to be asked.
Permission prompts: what to answer
Claude Code asks before it runs a command that is not on the allow list, and before it edits files, unless you tell it otherwise [3]. It offers three answers. The deny list from Session 1 refuses the dangerous commands whatever you answer, but it cannot list everything, so the answer you choose still matters.
| Answer | Choose it for | Examples |
|---|---|---|
| 1. Yes | Anything you are not sure of, and the first time you see a command | A command you do not recognise; an install |
| 2. Yes, and don't ask again | Commands that only read or check, or that only change your branch, which a pull request will show you | npm test, npm run lint, npx tsc --noEmit, gh pr checks, gh pr create, git add, git commit |
| 3. No, and tell Claude what to do differently | Anything that deletes, rewrites history, touches main, the live database or keys, or installs something you did not ask for | rm -rf, git reset --hard, git push --force, supabase db push or reset, vercel --prod, reading .env, npm install of an unknown package |
See your permission rules, and answer prompts the safe way
5 minutesWhy
Answering every prompt by hand is slow, and the temptation is to allow everything, which is unsafe. The safe middle is the allow list from Step 1, plus a few "don't ask again" answers for commands that cannot do harm, with the deny list refusing the rest. Seeing your rules once, and answering one real prompt, sets the habit.
Do this
Start a new session so it reads the merged rules, then type the command below. It lists the Allow and Deny rules; check the deny rules from Session 1 are all there, then press Esc.
git switch main && git pull && claude/permissionsThen give it a harmless task that needs a command not yet on the allow list:
List the open pull requests in this repository with gh pr list, and tell me in one line each what they change.You will see recreated screen
- Commands it may run without asking: the list from Step 1.
- Commands it may never run, whatever you answer. All of Session 1's rules should be here.
- Option 2 here: it only reads. Answer 3 for anything that deletes, pushes to main, or touches the database or keys.
Check it worked
/permissions shows your allow list and every deny rule from Session 1, and you answered the gh pr list prompt with option 2.
Fastest path
Shift+Tab switches Claude Code to accepting file edits without asking. That is reasonable on a branch, because every edit reaches main only through a pull request you read; commands still ask. Press Shift+Tab again to switch back.
If it goes wrong
You chose "don't ask again" for something you should not have
Type /permissions, find the rule under Allow, and remove it. "Don't ask again" answers are saved for this project on your computer only, so nobody else is affected.
Claude Code asks to run something that would delete files, reset git or touch the live database
Choose 3 and say: Do not run that. Tell me what you are trying to achieve and the safest way to do it. If it was supabase db push or vercel --prod, the deny list should have refused it: check /permissions.
Claude Code is refused a command and tries another way to do the same thing
We hit this: an agent refused permission to open pull requests opened one through a different command. Choose 3 and say: You were refused that. Stop and ask me; never use a different command to do something you were refused. The working rule from Step 1 says the same.
Knowledge check
Which part of a brief is written before any code, and must fail first?
Knowledge check
Claude Code asks permission to run a command. Which is safe to answer "Yes, and don't ask again"?
References
- Anthropic: Claude Code best practices. https://www.anthropic.com/engineering/claude-code-best-practices
- Claude Code docs: Memory and CLAUDE.md. https://code.claude.com/docs/en/memory
- Claude Code docs: Settings and permission rules. https://code.claude.com/docs/en/settings
Chapter 2 · Session 3
Checks first: tests and CI on every pull request
A check that fails before a change and passes after it is the only proof that the change did what you asked. This chapter gives the platform a test runner and a GitHub check that runs lint, the type check and the tests on every pull request, proves the check can fail, and teaches you to read a change before you approve it.
30 min2 stepsOne pull request
By the end of this chapter you can
- Add Vitest, npm test and .github/workflows/ci.yml in one pull request, and see the check go red, then green.
- Ask for proof (commands, exit codes, check results), never a summary.
- Read a change: Claude Code explains it against fixed questions; you confirm in the Files changed tab.
Why checks first
If a test is written after the code, it tends to describe what the code does rather than what you needed. Written first, it is your definition of done, fixed before anyone is tempted to bend it. This is test-driven development: write a failing test, make it pass, then tidy up [1]. With an agent it matters even more, because Claude Code can run the test, read the failure and try again many times on its own [2].
Three checks on every change
| Check | What it catches | Tool |
|---|---|---|
| Lint | Code patterns known to cause bugs, and code that is never used | ESLint (npm run lint) |
| Type check | A value used as the wrong kind (a number where text was expected), a missing field, a misspelt name | TypeScript (npm run typecheck, which runs tsc --noEmit) |
| Tests | The behaviour you asked for: what a person sees, what is stored | Vitest (npm test) [3] |
All three run on GitHub, on every pull request, where nobody can skip them [4]. The type check runs on its own as well as in the build because we learnt the hard way: our platform's live build was set to ignore type errors while CI checked them, twenty-one errors piled up, and CI failed on every push for weeks until everyone ignored the emails. Until Session 10 makes the check required, GitHub will still let a red pull request merge: owner two's rule is simple, never approve red.
One prompt: a test runner, npm test, and the CI check
15 minutesWhy
Tests only protect you if they run on every change, on GitHub. Adding the runner and the check now, while the app is one page, takes minutes; adding them after there are twenty screens takes days. The prompt also makes Claude Code prove the check can fail, because a check that can never go red protects nothing, and we had checks like that.
Do this
Read node_modules/next/dist/docs/ first, in particular the guide on testing with Vitest: this version of Next.js differs from older guides.
On a new branch setup/tests-and-ci:
1. Set up Vitest as that guide describes, with an npm script "test" that runs every test once and exits (not watch mode). Add a first test, tests/home.test.tsx, that renders the home page and checks it shows "Acme Bottling platform".
2. Make sure package.json has a "lint" script (ESLint) and a "typecheck" script (tsc --noEmit), and that both pass. Fix any errors without using any, @ts-ignore, @ts-nocheck or eslint-disable; if you think one is needed, stop and ask me.
3. Add .github/workflows/ci.yml, named CI, with one job called checks that runs on every pull request and every push to main, on ubuntu-latest with Node 22: npm ci, then npm run lint, npm run typecheck and npm test as three separate steps, so a failure names which one.
4. Prove the check can fail. Push the branch and open a pull request titled "Tests and CI". Then push one commit that changes the test to expect "THIS SHOULD FAIL", wait with gh pr checks --watch, and show me it is red. Then revert that commit, push, wait, and show me it is green.
Report: the links to the red run and the green run, and the exact command, exit code and last 20 lines of npm test on your machine.You will see recreated screen
- It read the docs shipped with your version of Next.js before writing any setup.
- Three separate steps, so a red check names lint, typecheck or tests.
- Red on purpose: proof the check runs your tests and can fail.
- Proof, not a summary: two run links and an exit code you can check.
Check it worked
Pull request Tests and CI shows a green CI check on its latest commit, and its Checks tab history has one red run before it. Claude Code's report has the exit code of npm test (0) and its last lines.
Fastest path
Asking for the red run in the same prompt saves a round trip later: you never have to wonder whether the check really runs your tests.
If it goes wrong
Claude Code says all tests pass, but the check on GitHub is red
Trust GitHub. Say: The CI check is red. Run gh pr checks, read the failed step's log, fix the cause, and wait for green before you report. Show me the exit code, not a summary. We recorded a run that printed npm: not found and, minutes later, a report of 1,326 tests passing.
The output looked green, but the exit code was not 0
A command piped into another (npm test | tail) reports whether the second command worked, not the tests. Our main branch went red this way. Say: Run npm test without piping it, and tell me its own exit code.
Typecheck fails on files you did not touch
Fix them now, in this pull request. Say: Fix every type error without any, ts-ignore or ts-nocheck. If one needs a decision, list it and stop. Never set the build to ignore type errors: that is how our CI stayed red for weeks.
The test still passed when it expected "THIS SHOULD FAIL"
The test is not testing the page: it may only check that a word appears in a file, or not be run at all. Say: The test passed when it should have failed. Find out why, fix it, and show me it red, then green. Our own guard tests once checked that a word was present, not that anything worked.
npm ci fails in CI with a lock file error
package-lock.json was not committed, or is out of date. Say: Run npm install, commit package-lock.json, push, and wait for the check.
Reading a change
Green means the checks passed. It does not mean the change is what you asked for, or only what you asked for. You do not need to read code line by line: read in a fixed order, riskiest first, and let Claude Code explain each file against fixed questions, then confirm its answers in GitHub's Files changed tab [5]. Google's published guidance for its own reviewers says the same: first whether the change does what was needed, then the details [6].
- The summary against the brief. Did it do what you asked, all of it and nothing else? Anything it says it could not do is the most important line.
- The list of files changed. Every file should be one the brief allows. Compare only what the branch changed since it left main (three dots), or you will see everything main gained too.
- Tests and checks. Anything removed, skipped or loosened is the first thing to stop on.
- Workflow, settings and packages. CI steps, .claude/settings.json and new dependencies change only if the brief said so.
- The code, explained by Claude Code, and then the preview: the change, running, on your phone.
Read the change before you approve it
10 minutesWhy
This is the routine every later pull request goes through, done once on a change that is easy to understand. Claude Code answers fixed questions with the file and line for each; you check its answers against GitHub's own list of files. Two views that agree are worth more than one, and owner two reviews the same way before approving.
Do this
Explain pull request "Tests and CI" to me file by file, in plain English. Compare only what this branch changed since it left main (git diff origin/main...HEAD, three dots). Then answer each question Yes or No, with the file and line that shows it:
1. Is every changed file one I asked for? List any that are not.
2. Does ci.yml run lint, typecheck and tests as separate steps, on every pull request?
3. Does anything make a failing step pass anyway (|| true, continue-on-error, a skipped test, a test that only checks a word is in a file)?
4. Which new packages were added, who publishes each, and are they only used for testing?
5. Was any deny rule in .claude/settings.json changed?
6. Is anything you told me earlier in this session wrong? Say so first.
Do not change anything.https://github.com/acme-ops/acme-platform/pulls
Open the pull request, then Files changed. Check the file list matches answer 1, and open ci.yml to see the three steps.
You will see recreated screen
- Question 3 is the one that matters most: a check that cannot fail is worse than none, because it looks like protection.
You will see recreated screen
| File | Change |
|---|---|
| .github/workflows/ci.yml | +18 |
| package.json | +9 −1 |
| package-lock.json | +1,214 −2 |
| tests/home.test.tsx | +11 |
| tsconfig.json | +1 −1 |
| vitest.config.mts | +10 |
- Six files, as Claude Code said. package-lock.json is long because it records every installed package exactly: read package.json instead.
- Green on the latest commit. Check the time: it should be after the revert.
Check it worked
Question 3 and question 5 are No, and the Files changed list matches answer 1. Owner two reads the same and approves; you merge.
If it goes wrong
The pull request seems to change hundreds of files you never asked about
You are probably comparing with today's main using two dots, which shows everything main gained too. Use the Files changed tab, or say: Show me only what this branch changed, with git diff origin/main...HEAD (three dots).
Question 3 finds || true, continue-on-error or a skipped test
Stop. Say: Remove it. A check that cannot fail protects nothing. If a step fails, fix the cause or tell me why.
A red check seems to have nothing to do with the change
It may have run on an old commit. Say: Which commit did this check run on, and is it behind main? If so, merge origin/main into the branch (no rebase, no force push), push, and wait for the new run. We had agents chase old red checks for hours.
Claude Code calls a warning a false positive and offers to silence it
Say: Check that warning on its own and show me the evidence. On our platform, a whole group of security warnings dismissed as false positives hid routes that returned customer staff details to anyone.
Knowledge check
A new test passes before any change has been made. What does that tell you?
Knowledge check
Claude Code reports "all tests pass". What do you ask for?
References
- Martin Fowler: Test Driven Development. https://martinfowler.com/bliki/TestDrivenDevelopment.html
- Anthropic: Claude Code best practices. https://www.anthropic.com/engineering/claude-code-best-practices
- Next.js Docs: Setting up Vitest with Next.js. https://nextjs.org/docs/app/guides/testing/vitest
- GitHub Docs: Workflow syntax for GitHub Actions. https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions
- GitHub Docs: Reviewing proposed changes in a pull request. https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/reviewing-proposed-changes-in-a-pull-request
- Google Engineering Practices: How to do a code review. https://google.github.io/eng-practices/review/reviewer/
Chapter 3 · Session 3
One brief, end to end: the status page
Now the whole routine on a small, real change: a /status page that shows which version is live and when it was built. You commit the brief, Claude Code writes the tests and shows them failing, then builds until they pass and brings proof, and you read the change and open it on your phone before it merges.
40 min4 stepsEnds with a gate
By the end of this chapter you can
- Commit a brief before any code, using the template.
- Have the acceptance checks written as tests and shown failing, then passing, without the tests changing.
- Stop an agent going in circles, refuse a weakened check, and read the change and the preview before merging.
Why a status page? After every deploy, someone will ask whether their change is live. A page that shows the version, the commit and the build time answers in five seconds. From Session 11, when deploys and rollbacks become routine, it is the first page you open. And it is small enough that every part of the routine is easy to see.
Write brief 01 and commit it before any code
10 minutesWhy
The brief is your definition of done, written before anyone is tempted to bend it. Committing it first means the pull request will show the brief, then the failing tests, then the code, in that order, so anyone reading it later can see what was asked and whether it was delivered. The brief is written for you here; read each part, and change anything that is not right for your plant.
Do this
On a new branch brief/01-status-page, create docs/briefs/01-status-page.md with exactly the text below, commit it, and stop. Do not write any code or tests yet.
# Brief 01: status page
## Goal
A page at /status that shows which version of the platform is live and when it was built, so that after any deploy anyone at Acme Bottling can tell in five seconds whether a change is live.
## Context
Read docs/INTENT.md, CLAUDE.md, docs/briefs/TEMPLATE.md and the home page (app/page.tsx), which already shows a build time.
## Acceptance checks (written first)
1. Given the app is built, when I open /status, then I see the version number from package.json.
2. Given the app was built on Vercel, when I open /status, then I see the first 7 characters of the commit it was built from; built anywhere else, it says "local".
3. Given the app was built at a certain time, when I open /status twice a minute apart, then both show the same build time, in UTC, as YYYY-MM-DD HH:MM UTC.
4. Given a secret environment variable is set, when I open /status, then its value appears nowhere on the page.
## Out of scope
No sign-in, no database, no new packages, no change to the home page or to any existing test or check.
## How to show it works
- Each acceptance check is a test in tests/status.test.tsx, shown failing before the page exists.
- npm test: the exact command, its exit code and the last 20 lines.
- The CI check green on the pull request's latest commit.
- The Vercel preview address of /status.You will see recreated screen
- Your text, saved as it is. If Claude Code "improves" it, ask it to save exactly what you gave.
- It stops. The next step is the tests, not the page.
Check it worked
The branch has one commit with one file, docs/briefs/01-status-page.md, and Claude Code says it wrote no code or tests.
Fastest path
For your own briefs later, write a paragraph in plain words and ask: Fill docs/briefs/TEMPLATE.md from this as docs/briefs/NN-name.md and show me; do not write code. Then rewrite the acceptance checks in your own words: they are the part that must be yours.
If it goes wrong
Claude Code starts writing the page as well
Say: Stop. Undo everything except the brief. Tests come next, then code. On a branch nothing is lost.
You are not sure an acceptance check can be tested
Ask: For each acceptance check in brief 01, tell me how a test would prove it, and whether any check cannot be tested as written. Do not write the tests yet. Rewrite any check it says cannot be tested.
Checks first: the tests, shown failing
10 minutesWhy
Tests shown failing before the page exists prove two things: the tests really run, and they really look for the page. Only then does "passing" later mean something. One of our own checks reported "present" for every page for weeks, real or not, because nobody had ever seen it say "absent". A test that has never failed has never been tested.
Do this
Read docs/briefs/01-status-page.md. Write its four acceptance checks as tests in tests/status.test.tsx, one test per check, each named after its check. Test what a person would see on the page, not whether a word appears in a source file. For check 4, set a made-up variable such as SUPABASE_SERVICE_ROLE_KEY=made-up-value-must-not-show inside the test, and check the page does not contain it. Do not create the page or change anything else.
Run npm test and show me the exact command, its exit code and the last 20 lines. All four new tests must fail because /status does not exist yet, and the home page test must still pass. Then commit the tests, push the branch, open a draft pull request titled "Brief 01: status page", wait for the CI check (it should be red), and show me the link.You will see recreated screen
- The reason is the missing page, nothing else. A typo or a missing package would be the wrong red.
- Exit code 1: failure, stated plainly, with the command.
- Red on GitHub too, at the tests step, not lint or typecheck.
Check it worked
The draft pull request is red, the failing step is npm test, and Claude Code showed exit code 1 with four failing tests named after your four checks.
If it goes wrong
A new test passes before the page exists
It is not testing the page. Say: Test N passes without the page. Rewrite it so it can only pass when /status shows what the brief asks, and show me it failing.
The tests fail for the wrong reason (a typo, a missing package, a configuration error)
A test must fail because the feature is missing, nothing else. Say: Show me the first error of each failing test. Fix any failure that is not caused by the missing page, then show me again.
Claude Code says the page cannot be tested because it is an async Server Component
Next.js's own Vitest guide says Vitest does not yet support async Server Components. Say: Keep the page a synchronous component that reads a small build-information module, and test the page through it. Do not change the brief's checks.
Claude Code asks you for a real key to test check 4
Never give one. Say: Use a made-up value inside the test. No real key is ever needed in a test.
Let Claude Code build it, and ask for proof
10 minutesWhy
Now Claude Code has a target it can check itself against, as many times as it needs, without you. The prompt forbids touching the tests, tells it to read this version's Next.js docs before writing a page, and asks for proof against the brief's "How to show it works". When it reports, you have evidence, not a claim.
Do this
Now make the tests in tests/status.test.tsx pass by building the /status page as brief 01 describes. Do not change any test, check or CI step; if you think a test is wrong, stop and tell me why.
Before you write the page, read node_modules/next/dist/docs/ on how this version of Next.js renders pages at build time and reads environment variables, so the build time is fixed when the app is built, not when the page is opened.
Then run npm run lint, npm run typecheck and npm test, and show me each command's exit code. Mark the pull request ready for review, wait for the CI check with gh pr checks --watch, and give me the Vercel preview address of /status. Report against each line of "How to show it works" in the brief.You will see recreated screen
- Reads the docs for your version before writing the page.
- An exit code with the result, for every command.
- Proof line by line against the brief, including that the tests did not change.
Check it worked
CI is green on the latest commit, Claude Code gave an exit code for each command, and it says the test file is unchanged since the red commit (Step 8 checks that for yourself).
Fastest path
For anything bigger than this, start in plan mode (Shift+Tab until it says plan mode): Claude Code reads and writes a plan, then waits for your yes. Two minutes reading a plan catches a misunderstanding before it is two hundred lines of code.
If it goes wrong
The same error, the same "let me try again", three times or more
Press Esc to interrupt, then paste: Stop. Do not try again yet. Tell me what exactly failed (quote the error), what you have already tried, whether the cause is in our code or outside it (a service, a permission, another change), and what you need from me. Repeating a step and not knowing when to stop are the commonest agent failures; our own agents once spent a day rebuilding the same refused commit.
CI is green, but the change includes the test file
Stop. Say: You changed tests/status.test.tsx. Restore it exactly as it was in the red commit and make the page pass the original tests. If you believe a test is wrong, explain why and wait. Changing the check to reach green is how an agent "finishes" work it has not done.
Claude Code says it is done, with no exit codes or check result
Say: Show me the exact commands, their exit codes and the last 20 lines, and the result of gh pr checks on the latest commit. If something could not run, say could not run.
The build time changes every time you reload the preview
The page is being drawn on every visit, so it shows the time of the visit. Check 3 should have caught this, so the test is too weak. Say: Check 3 passed, but the preview shows a new time on every reload. Make the test catch this, show it failing, then fix the page.
You will see recreated screen
- The second identical failure: the working rule says stop here. If it does not, you stop it.
- A diagnosis, not another attempt. Now you can decide.
Read the change, try it on your phone, merge
10 minutesWhy
Green means the tests passed; it does not mean the tests are the ones you approved, or that the page works where people will use it. Checking the test file is byte for byte the one that was red, and opening the preview on a phone, take five minutes and close the two ways a green change can still be wrong.
Do this
Review pull request "Brief 01: status page" for me. Compare only what this branch changed since it left main (git diff origin/main...HEAD). Answer Yes or No, with the file and line:
1. Does each acceptance check in the brief have a test, and does each test check what a person sees on the page?
2. Is tests/status.test.tsx exactly the same now as in the commit where the tests were red? Show me git diff between that commit and HEAD for that file.
3. Is every changed file covered by the brief? List any that are not.
4. Is anything outside the brief's scope added: sign-in, a database, new packages, changes to the home page or to CI?
5. Could the page ever show the value of a secret, and which test proves it cannot?
Do not change anything.https://github.com/acme-ops/acme-platform/pulls
Open the pull request. In Files changed, check the list matches answer 3. Then open the Vercel bot's preview link on your phone and add /status to the address.
Reload the preview after a minute: the build time must not change. The commit shown must match the latest commit on the pull request. Then owner two approves, you merge, and when Vercel has deployed main, open the live page:
https://acme-platform.vercel.app/status
Your live status page. The commit should match the merge commit on main.
You will see recreated screen
- From package.json.
- The first 7 characters of the commit this preview was built from: compare with the pull request.
- The build time in UTC. If it changes on reload, the page is not doing what check 3 asks.
You will see recreated screen
| Commit | Message | CI |
|---|---|---|
| a41b7c2 | Brief 01: status page | – |
| 3e5a1f0 | Acceptance tests for brief 01 (failing) | ✗ |
| 9f8e7d6 | Status page: version, commit, build time | ✓ |
- The record of the routine: brief, then red, then green. Anyone can read what was asked and see it delivered.
- Owner two approved after reading the same answers and the preview.
Check it worked
https://acme-platform.vercel.app/status shows the version, the commit of the merge on main, and a build time that does not change when you reload.
If it goes wrong
Answer 2 shows the test file changed after it was red
Do not merge. Go back to Step 7's second fix: restore the test, then make the page pass it. If the test really was wrong because the brief was wrong, change the brief first, in its own commit, so the record shows why.
The live page still shows the old commit after the merge
Vercel may still be building, or a newer merge replaced the deploy (it shows Canceled, which is not a failure). Wait for Ready at https://vercel.com/acme-ops/acme-platform, then reload. Comparing the commit on /status with main is exactly what the page is for.
The preview asks you to sign in to Vercel
That is Vercel's Deployment Protection, on by default for previews (Session 1). Sign in with your company Vercel account. A 401 from a preview is Vercel's protection, not a fault in your page.
Knowledge check
CI turned green and the diff shows a test assertion was loosened. What do you do?
Knowledge check
Claude Code has failed the same way twice and says "let me try again". What is the best next step?
References
- OWASP Gen AI Security Project: Top 10 for LLM Applications. https://genai.owasp.org/llm-top-10/
- Vercel Docs: Environments and preview deployments. https://vercel.com/docs/deployments/environments
- Vercel Docs: System environment variables. https://vercel.com/docs/environment-variables/system-environment-variables
- Claude Code docs: Common workflows. https://code.claude.com/docs/en/common-workflows
Chapter 4 · 12 questions · 80% passes
Final assessment
Twelve questions across the session. Score 80% (10 of 12) to pass. Your LMS records your score and each answer; you can review the chapters and try again.
15 min12 questions≈ 15 minutesRetake allowed
Your result
CivOps AI Academy
Directing an AI Agent: Briefs, Checks First, and Reading the Change
Element F12 complete · Learner
Your LMS records this completion. For the CivOps Foundation certificate, finish the Foundation Course at https://civops.io/learn.