Skip to the lesson
CivOps AI Academy · F16AI Fleet: The Overnight Build and the Morning Review
0%

Chapter 1 · Session 17

The evening: plan the night and set the guard rails

An overnight build is decided at five in the afternoon, not at three in the morning. Before you leave, every worker has a brief on main, a spending cap, an exact list of what it may do, and a reason to stop. A one-dollar dry run proves it all before the real night starts.

40 min4 stepsAbout 40 minutes before you leave

By the end of this chapter you can

  • Write tonight's plan in docs/nights/ and merge it with its briefs before any worker starts.
  • Say what an unattended worker may and may not do, and which guard rail enforces each.
  • Prove the guard rails with a one-dollar dry run, then start bounded workers a few minutes apart.

Why overnight, and what it costs

A fleet working while the plant team sleeps turns fourteen idle hours into build time, and your working day goes on what only you can do: deciding, reviewing and talking to the floor. The price is that nobody is watching. So the night produces proposals and nothing else: no merge, no deploy, no database change. The morning decides.

An overnight buildFrom 17:00 to 18:00 the brief and dry run, workers start staggered by 18:30 and build until about 06:00, then morning review and merging until 09:00. One overnight build, plant time (to scale)17:0019:0021:0023:0001:0003:0005:0007:0009:00Brief,dry runWorkers build, test, commit and push in small stepsLastpushesMorning reviewand mergestaggered startNothing deploys and nothing merges while nobody is watching17:00 you write09:00 you decide
One night, drawn to scale. About forty minutes of preparation, workers started a few minutes apart, the build overnight, and the review in the morning. Nothing merges or deploys while nobody is watching.

What an unattended worker may and may not do

A worker mayA worker may notWhat stops it
Read the repository and edit files in its brief's foldersChange migrations, packages, .github/, CLAUDE.md or .claude/Deny rules on those paths, given on the command line
Run npm ci, the tests, lint and the type checkInstall a new package, reach other websites, read .env filesdontAsk mode: anything not on the allowlist is refused, not asked
Commit and push its own branch; merge main into itPush to main, force push, rebaseSession 1's deny rules and main's ruleset
Open a pull request, or a draft when it stopsMerge, deploy, or touch the live or development databaseNot on the allowlist; and its worktree has no keys at all
Spend up to its capSpend past the account's limit--max-budget-usd and --max-turns; the spend limit from Session 16

Claude Code's dontAsk mode is made for this: it runs only what you have pre-approved and refuses everything else instead of waiting for an answer nobody will give [1]. Deny rules apply in every mode. The mode that skips all checks is meant only for isolated containers and virtual machines; never use it on a computer that holds company files or keys [1].

Guardrails for an unattended fleetFour nested layers around a worker: spend caps, branch protection, its own worktree, permissions. Spend capsaccount limit · --max-budget-usd · --max-turnsBranch protectionpull requests only · checks required · no force-pushWorktreeits own folder and branch · no keys in itPermissionsdontAsk mode · an exact allowlist · deny rulesOne worker, in its own worktree, on its own branchEach layer stops a different failure; a night needs all four
Four layers, each stopping a different failure. If a worker gets past the innermost layer, the next one holds. The worst a worker can do is open a bad pull request, which you close in the morning.
Step 1

Write tonight's plan, and merge it with its briefs

15 minutes

Why

Each worker starts from main as it is on GitHub, so a brief that is not merged is a brief it cannot read. Writing the night on one dated page also means anyone can see in the morning exactly what was asked, with which caps, and compare it with what came back. Most failures trace back to the brief, so this page is where the night is won or lost.

Do this

Terminal or PowerShell
cd ~/code/acme-platform && git switch main && git pull && claude
Paste into Claude Code
Read docs/waves.md, docs/fleet-ledger.md and docs/briefs/TEMPLATE.md. Tonight the fleet runs the next wave of docs/waves.md unattended.

On a new branch night/plan, write docs/nights/ with today's date as the file name (YYYY-MM-DD.md), with these sections:
- Goal: what the night should deliver, in one sentence.
- Workers: one line each, numbered Worker 1, Worker 2, Worker 3 (no more than the wave has, and no more than 3): its brief file, the folders it owns, its worktree name (night-1, night-2, night-3).
- Caps: $8 and 80 turns per worker, and the night's maximum, which is the sum. Say that the budget is an estimate and spend can pass it slightly.
- Stop rules: two identical failures; a folder the brief does not own; any refused action. On stopping: push, then a draft pull request titled STOPPED: with what was finished, what was tried last and the exact error.
- Never tonight: merge, deploy, push to main, force push, rebase, install packages, change migrations, .github/, CLAUDE.md or .claude/, edit an existing test, read .env files.
- Morning: who reviews (pat@acme.com, then sam@acme.com approves), in the order of the workers, by 10:00.

If a worker's task has no brief yet, write it from the template as in Session 16: its own folders, a Do not touch list, acceptance checks written first, and the two-failure limit. Each brief must be clear enough that nobody needs to answer a question. Open a pull request titled "Night plan" with today's date, wait for the checks and show me the link.

Read the plan and each brief once more as if you were the worker with nobody to ask. Owner two approves; merge it before you go on.

You will see recreated screen

claude — acme-platform
⏺ Write(docs/nights/2026-10-21.md)
+## Workers
+Worker 1: docs/briefs/10-holds-per-press-widget.md · app/manager/widgets/holds/ · night-1
+Worker 2: docs/briefs/11-phone-layout-fixes.md · app/operator/layout/ · night-2
+## Caps
+$8 and 80 turns per worker. Night maximum: $16 (an estimate; allow a little over).
+## Never tonight
+merge, deploy, push to main, force push, rebase, install packages, migrations, .github/, edit an existing test, .env
1
⏺ Pull request #53 adds tonight's plan for 2 workers (wave 3 has two tasks), with a night maximum of $16. Both briefs existed; I tightened brief 11's acceptance checks so they say which screens, at 360 and 390 px. Checks are green.2
The plan is one page. The Workers section is what each night worker will look up.
  1. Each worker's brief, folders and worktree name, on one line.
  2. Two workers, because the wave has two tasks. More agents than tasks only adds waiting and collisions.

Check it worked

docs/nights/ on main has today's plan with Workers, Caps, Stop rules, Never tonight and Morning, and every brief it names is on main.

Fastest path

Merge before you do anything else this evening. The dry run in Step 3 reads the plan from main, so it also proves the merge happened.

If it goes wrong

A brief says "ask me if unsure"

Nobody can answer at night. Say: Replace every "ask me" in tonight's briefs with the decision itself, or with: choose the safest reading and write it down.

The wave needs a migration or a new package

That part is not for tonight. Do it by day as the lead (Session 16, Step 2), merge it, and plan the night around what is left.

Step 2

Check the guard rails you are relying on

5 minutes

Why

The night is safe because of settings made weeks ago: main refuses changes without a pull request and green checks, and the account has a spend limit. A setting someone relaxed for a quick fix last week and forgot to restore turns a bad pull request into a bad main. Five minutes of looking is cheap insurance for an unwatched night.

Do this

Open

https://github.com/acme-ops/acme-platform/settings/rules

Rulesets: protect main is Active; pull request and approval required; required status checks on (Session 10); force pushes blocked; only owner one may bypass.

Open

https://claude.ai/admin-settings/usage

Usage: the spend limit you set in Session 16 is still there.

Then make sure the computer stays awake all night: plugged in, and sleep set to Never when plugged in (Windows: Settings, System, Power). On a Mac, put caffeinate -i in front of each command in Step 4.

You will see recreated screen

github.com/acme-ops/acme-platform/settings/rules
GeneralCollaborators and teamsRulesActionsSecrets and variables
protect main
Enforcement statusActive ▾1
Require a pull request before merging (1 approval)
Require status checks to pass2
Block force pushes
Bypass listpat@acme.com only3
The ruleset on main, as it should be before any unattended night.
  1. Active, not Evaluate or Disabled.
  2. On since Session 10, with your checks listed by name.
  3. Nobody else, and no app or agent account, on the bypass list.

Check it worked

The ruleset is Active with the four settings shown, and a spend limit is set where the fleet's usage is billed.

If it goes wrong

Require status checks is off, or the bypass list has more names

Put it back now (Session 10). Without it, a red pull request can merge, by a tired person in the morning or by anyone on the bypass list.

The computer is a laptop that goes home with you

Use a desktop that stays in the office, or wait until you have one. A run stopped by a lid closing loses only work since its last push, but the night is wasted.

Step 3

The one-dollar dry run

10 minutes

Why

Problems found at five o'clock cost a dollar; found at seven the next morning they cost a night. The dry run starts one worker exactly as the real ones will start, with a one-dollar cap, and asks it to try the things it must not be able to do. If any of them works, a guard rail is missing and the night does not start.

Do this

Terminal or PowerShell, in your repository folder
mkdir ../night-logs
Terminal or PowerShell, in your repository folder
claude -p "Dry run, do not change any code. Read CLAUDE.md and the newest night plan in docs/nights/. Then try each of these and report each one with the exact command and whether it was allowed or refused: 1. read .env.local; 2. git push origin main; 3. npm install left-pad; 4. edit .github/workflows/ci.yml; 5. npm ci then npm test. Finish with one line per worker in the plan: its brief file and whether you could read it." --worktree night-dryrun --permission-mode dontAsk --max-budget-usd 1 --max-turns 15 --allowedTools "Read" "Edit" "Write" "Bash(npm ci)" "Bash(npm test)" "Bash(npm test *)" "Bash(npm run lint *)" "Bash(npx tsc --noEmit)" "Bash(git status *)" "Bash(git diff *)" "Bash(git log *)" "Bash(git add *)" "Bash(git commit *)" "Bash(git fetch *)" "Bash(git merge origin/main)" "Bash(git push -u origin HEAD)" "Bash(gh pr create *)" "Bash(gh pr list *)" "Bash(gh pr view *)" "Bash(gh pr checks *)" "Bash(gh run view *)" --disallowedTools "Edit(.github/**)" "Edit(.claude/**)" "Edit(supabase/**)" "Edit(package.json)" "Edit(package-lock.json)" "Edit(CLAUDE.md)"

When it has reported, remove the dry run's worktree and branch (a message that it is not locked is fine):

Terminal or PowerShell, in your repository folder
git worktree unlock .claude/worktrees/night-dryrun
git worktree remove --force .claude/worktrees/night-dryrun
git branch -D worktree-night-dryrun

You will see recreated screen

Terminal
$ claude -p "Dry run, do not change any code. …" --worktree night-dryrun --permission-mode dontAsk --max-budget-usd 1 …
1. Read(.env.local): refused (denied by project settings)1
2. git push origin main: refused (not allowed in this mode)
3. npm install left-pad: refused (not allowed in this mode)
4. Edit(.github/workflows/ci.yml): refused (denied)
5. npm ci, npm test: exit code 0, 214 passed2
Worker 1: docs/briefs/10-holds-per-press-widget.md, readable. Worker 2: docs/briefs/11-phone-layout-fixes.md, readable.3
The dry run's report. Four refusals and one green test run is the result you want.
  1. Every forbidden action refused. If any one says allowed, stop: fix the setting before the night.
  2. The tests run in a fresh worktree, without keys.
  3. Proof that the plan and briefs are on main where the workers will look.

Check it worked

Items 1 to 4 were refused, the tests ran with exit code 0, every worker's brief was readable, and git worktree list no longer shows night-dryrun.

If it goes wrong

Item 1, 2 or 4 says allowed

A deny rule is missing or was loosened. Do not start the night. Compare .claude/settings.json with Session 1 (Step 10), and check the command was pasted in full, including the --disallowedTools part.

It cannot find the night plan

The Night plan pull request is not merged, or the worktree started from an old copy of main. Merge it, then run the dry run again.

The tests fail in the worktree but pass in your main folder

Something the tests need is not in the repository, often a key in .env.local. Tests must run without real keys; fix that by day before running a night.

Step 4

Start the night, workers a few minutes apart

5 minutes

Why

Each worker is one command in its own terminal window: its own worktree, the exact allowlist, a dollar cap and a turn cap, and a log file you will read in the morning. Starting them a few minutes apart spreads their large first requests over the same usage window, and lets you see each one begin before you leave.

Do this

Start only as many workers as tonight's plan names. In a terminal in ~/code/acme-platform:

Terminal 1, in your repository folder
claude -p "You are night worker 1, unattended: nobody can answer questions tonight. Read CLAUDE.md, then the newest night plan in docs/nights/, and carry out the brief for Worker 1. Where the brief is unclear, choose the safest reading and write down what you chose. Stop when: two identical failures, the work needs a folder your brief does not own, or an action is refused. Then commit what you have, push, and open a DRAFT pull request titled STOPPED: and the brief name, saying what you finished, what you tried last and the exact error. When the work is done: push, open the pull request, wait for every check on the latest commit and fix anything red inside your own folders." --worktree night-1 --permission-mode dontAsk --max-budget-usd 8 --max-turns 80 --output-format json --allowedTools "Read" "Edit" "Write" "Bash(npm ci)" "Bash(npm test)" "Bash(npm test *)" "Bash(npm run lint *)" "Bash(npx tsc --noEmit)" "Bash(git status *)" "Bash(git diff *)" "Bash(git log *)" "Bash(git add *)" "Bash(git commit *)" "Bash(git fetch *)" "Bash(git merge origin/main)" "Bash(git push -u origin HEAD)" "Bash(gh pr create *)" "Bash(gh pr list *)" "Bash(gh pr view *)" "Bash(gh pr checks *)" "Bash(gh run view *)" --disallowedTools "Edit(.github/**)" "Edit(.claude/**)" "Edit(supabase/**)" "Edit(package.json)" "Edit(package-lock.json)" "Edit(CLAUDE.md)" > ../night-logs/night-1.json

Wait until a pull request or a first push appears for night-1, or three minutes have passed. Then, in a second terminal:

Terminal 2, in your repository folder
claude -p "You are night worker 2, unattended: nobody can answer questions tonight. Read CLAUDE.md, then the newest night plan in docs/nights/, and carry out the brief for Worker 2. Where the brief is unclear, choose the safest reading and write down what you chose. Stop when: two identical failures, the work needs a folder your brief does not own, or an action is refused. Then commit what you have, push, and open a DRAFT pull request titled STOPPED: and the brief name, saying what you finished, what you tried last and the exact error. When the work is done: push, open the pull request, wait for every check on the latest commit and fix anything red inside your own folders." --worktree night-2 --permission-mode dontAsk --max-budget-usd 8 --max-turns 80 --output-format json --allowedTools "Read" "Edit" "Write" "Bash(npm ci)" "Bash(npm test)" "Bash(npm test *)" "Bash(npm run lint *)" "Bash(npx tsc --noEmit)" "Bash(git status *)" "Bash(git diff *)" "Bash(git log *)" "Bash(git add *)" "Bash(git commit *)" "Bash(git fetch *)" "Bash(git merge origin/main)" "Bash(git push -u origin HEAD)" "Bash(gh pr create *)" "Bash(gh pr list *)" "Bash(gh pr view *)" "Bash(gh pr checks *)" "Bash(gh run view *)" --disallowedTools "Edit(.github/**)" "Edit(.claude/**)" "Edit(supabase/**)" "Edit(package.json)" "Edit(package-lock.json)" "Edit(CLAUDE.md)" > ../night-logs/night-2.json

If the plan has a third worker, a few minutes later in a third terminal:

Terminal 3, in your repository folder
claude -p "You are night worker 3, unattended: nobody can answer questions tonight. Read CLAUDE.md, then the newest night plan in docs/nights/, and carry out the brief for Worker 3. Where the brief is unclear, choose the safest reading and write down what you chose. Stop when: two identical failures, the work needs a folder your brief does not own, or an action is refused. Then commit what you have, push, and open a DRAFT pull request titled STOPPED: and the brief name, saying what you finished, what you tried last and the exact error. When the work is done: push, open the pull request, wait for every check on the latest commit and fix anything red inside your own folders." --worktree night-3 --permission-mode dontAsk --max-budget-usd 8 --max-turns 80 --output-format json --allowedTools "Read" "Edit" "Write" "Bash(npm ci)" "Bash(npm test)" "Bash(npm test *)" "Bash(npm run lint *)" "Bash(npx tsc --noEmit)" "Bash(git status *)" "Bash(git diff *)" "Bash(git log *)" "Bash(git add *)" "Bash(git commit *)" "Bash(git fetch *)" "Bash(git merge origin/main)" "Bash(git push -u origin HEAD)" "Bash(gh pr create *)" "Bash(gh pr list *)" "Bash(gh pr view *)" "Bash(gh pr checks *)" "Bash(gh run view *)" --disallowedTools "Edit(.github/**)" "Edit(.claude/**)" "Edit(supabase/**)" "Edit(package.json)" "Edit(package-lock.json)" "Edit(CLAUDE.md)" > ../night-logs/night-3.json

Leave the windows open and the computer awake. Note the time each worker started, for the Morning section tomorrow.

You will see recreated screen

Terminal
$ claude -p "You are night worker 1, unattended: …" --worktree night-1 --permission-mode dontAsk --max-budget-usd 8 --max-turns 80 --output-format json --allowedTools … > ../night-logs/night-1.json1
$ git worktree list
~/code/acme-platform a91c2e0 [main]
~/code/acme-platform/.claude/worktrees/night-1 a91c2e0 [worktree-night-1]2
A worker running unattended prints nothing until it finishes. Silence is normal.
  1. The whole result, with cost, turns and how it ended, goes to the log file in the morning.
  2. Its own folder and branch, starting from main.

Check it worked

Each worker in the plan has a worktree (git worktree list), and within a few minutes its branch has a first push or its terminal is still running.

Fastest path

Start worker 1, and while it gets going, re-read worker 2's brief one last time. You lose nothing by starting it three minutes later.

If it goes wrong

A command ends at once with an error about an option

It was not pasted in full: a long command can be cut off at a line break. Copy it again with the Copy button and paste it as one piece.

PowerShell says the path ../night-logs does not exist

Run mkdir ../night-logs from Step 3 in ~/code/acme-platform first.

You hit the plan's usage limit as the workers start

Three workers draw on one usage window. Stop the last one (Ctrl+C), and run two workers until the ledger shows how much a night uses.

Knowledge check

Which permission setup fits an unattended worker on a computer that also holds company files?

Knowledge check

Two workers each run with --max-budget-usd 8. Roughly the most the night's model use can cost is:

References

  1. Claude Code docs: Choose a permission mode (dontAsk, bypassPermissions). https://code.claude.com/docs/en/permission-modes
  2. Claude Code docs: CLI reference (-p, --worktree, --max-budget-usd, --max-turns, --allowedTools). https://code.claude.com/docs/en/cli-reference
  3. Claude Code docs: Run Claude Code programmatically (headless). https://code.claude.com/docs/en/headless
  4. GitHub Docs: About rulesets. https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/managing-rulesets/about-rulesets

Chapter 2 · Session 17

Through the night: what workers do, and how they stop

During the night each worker loops: change, test, commit, push. It ends in one of two ways: a pull request because its checks pass, or a draft pull request that says why it stopped. Nobody needs to be woken, because nothing a worker can do overnight is irreversible.

20 min1 stepNo 3 a.m. phone calls

By the end of this chapter you can

  • Describe how a worker's night ends, and why there is no state in which it merges or deploys.
  • Say which stop rules end a run and what enforces each.
  • Read the heartbeat (pushes) without disturbing the workers, and tell a quiet worker from a stuck one.
Worker states overnightQueued, then working in a test-fix-commit-push loop, ending in a pull request or a stop with its reason in a draft pull request. QueuedWorkingPull requestStoppedDone: waits for morningStopped: draft PR with a notetest · fix · commit · pushStop rules: budget or turn cap reached · two identical failures ·a folder outside its brief needed · an action refused
A worker's night. It ends in a pull request or a stop with its reason written down. No state merges or deploys: those wait for a person.

Stop rules, not hope

Stop whenEnforced byWhy
The dollar cap is reached--max-budget-usd: the run ends whatever the agent thinks [1]A task that turned out bigger than planned costs no more than its cap
The turn cap is reached--max-turns: the run exits with an error [1]Ends a loop that is not converging. Its work up to the last push is kept, without a pull request
Two identical failuresThe brief and CLAUDE.md (Session 16)Retrying something refused for a reason outside the code never succeeds
A folder it does not ownThe brief; deny rules on the shared foldersScope creep collides with the other workers
Any refused actiondontAsk refuses it; CLAUDE.md says stop, never find another wayIn our build, an agent refused one command opened a pull request with a different one

Agents going round in circles and not knowing when to stop are the two most common agent failures, and our own fleet hit both: a day of retries rebuilding the same refused commit. The two-failure rule and the caps end that. The draft pull request is the escalation: it puts the question in front of you in the morning, in one place, instead of an answer guessed at 3 a.m.

A heartbeat you can read

Each push to a worker's branch is a heartbeat, and it makes a restart cheap: everything up to the last push is safe on GitHub. Judge a worker by whether its branch is moving, not by whether its terminal prints anything. In our build a watchdog stopped working agents as "dead" because they had been quiet; long thinking is silent.

Pushes per hour as a heartbeatThree workers' commits per hour; two push steadily then finish, one stops after two hours. Commits pushed per hour, an example night (each square is one hour from 18:00)night-1342321night-223323221night-331night-3 stopped at 20:00 after two identical failures; its draft pull request says whythe others stop pushing when their work is done, then open their pull requests
Commits pushed per hour on an example night. Two workers push steadily and then finish; one stops early, and its draft pull request says why.

Who gets woken up? Nobody. Site reliability engineers alert a person only for something that needs a person now [2]. A guarded night cannot touch production, cannot merge and cannot spend past its caps, so a worker that stops simply waits for the morning. If you find yourself wanting an alarm, a guard rail is missing: add it instead. And keep the whole conversation, not just the last answer: Claude Code keeps each run's full session on your computer, and the log file names it, so in the morning you can open it and see every step [3].

When a worker stopsFour reasons a worker stops overnight, what each usually means, and what to do in the morning. A worker stoppedBudget or turn capTask too big or brief unclearsplit it or rewrite the briefTwo identical failuresRead its draft pull requestfix the brief (or a wrong test)Needed a folder outside its briefThe task was cut wronglyre-cut it in the wave planComputer slept or restartedWork is safe up to the last pushstart a fresh run from it
When a worker stops. Its draft pull request or log says why; most fixes are a better brief, made in the morning.
Step 5

Read the heartbeat before bed, without touching the workers

2 minutes

Why

A worker that never really started is the one problem worth catching tonight, because it is cheap to fix now and costs the whole night if found in the morning. Looking at pushes and pull requests tells you everything you need without interrupting a worker, which would waste its context and its turns.

Do this

Terminal or PowerShell, in your repository folder
gh pr list --state open
Terminal or PowerShell, in your repository folder
git -C .claude/worktrees/night-1 log --oneline -5

You will see recreated screen

Terminal
$ gh pr list --state open
#54 Brief 10: holds-per-press widget worktree-night-1 OPEN1
$ git -C .claude/worktrees/night-1 log --oneline -5
6f1d2a0 Widget shows holds per press for the last 7 days
c3e98b1 Tests for brief 10 acceptance checks (failing first)2
Thirty minutes in. Worker 1 has pushed and opened its pull request early; worker 2 is still committing.
  1. Its pull request is open: the checks will run on it overnight.
  2. Recent commits: the worker is alive. No new commit for an hour is normal while it is waiting for checks or thinking.

Check it worked

Each worker has at least one commit on its branch, or is still running in its terminal. You have not typed anything into a worker's window.

If it goes wrong

A worker's terminal has already returned, with no commit and no pull request

Read its log: ../night-logs/night-2.json. The last result line says how it ended. If it could not start (a typo, a missing brief), fix that and run its command again. If it stopped on a rule, leave it for the morning.

A worker has been silent for an hour

Silence is not death. If its branch has commits or its pull request's checks are running, leave it. Do not stop a worker by name (pkill, Task Manager's End task on every node): stop only that terminal with Ctrl+C, and only if you are sure.

Knowledge check

A worker has failed the same test twice with the same error at 01:00. What should happen?

Knowledge check

Why judge a worker by its pushes rather than by what its terminal prints?

References

  1. Claude Code docs: CLI reference (--max-budget-usd, --max-turns). https://code.claude.com/docs/en/cli-reference
  2. Google: Site Reliability Engineering, Monitoring Distributed Systems. https://sre.google/sre-book/monitoring-distributed-systems/
  3. Claude Code docs: Run Claude Code programmatically (JSON output and sessions). https://code.claude.com/docs/en/headless

Chapter 3 · Session 17

The morning review

The night's output is a set of proposals. The morning decides which become part of the plant's platform: collect the night in one table, send back what fails a cheap check, read what is left, and merge one pull request at a time, each green on its latest commit.

45 min4 stepsEnds with a gate

By the end of this chapter you can

  • Collect every worker's result, cost and checks on its latest commit in one table.
  • Send back what fails a cheap check before spending reading time on it.
  • Read each remaining change against the platform's rules, then merge in order, updating from main each time.
  • Close the night: the ledger, one rewritten brief, and the worktrees removed.

Cheapest check first

Do not start by reading the biggest pull request. Take every pull request through the checks in order of cost, automatic first, your careful reading last. A pull request that fails an early check goes back without you reading a line.

Morning triageEight pull requests: one has red checks, one changed an existing test, leaving six that pass every check. Eight pull requests through the morning checks, cheapest check first (example night)1Checks green on its latest commit?7 of 8 pass2Only the folders in its brief?7 of 7 pass3No existing test changed?6 of 7 pass4Diff readable (under ≈ 400 lines)?6 of 6 pass5Works on the phone preview?6 of 6 passGreen: carry on to the next check. Red: stop there and send it back with a rewritten brief. Six reach a careful read and merge.
Eight pull requests through the morning checks, on an example night. Two fail before anyone reads them; six reach a careful read.
CheckHowIf it fails
1. Checks green on its latest commitThe pull request's checks on GitHub, for the commit it shows now [1]If behind main, update and re-judge; if still red, back with the failure
2. Only its brief's foldersFiles changed, against the briefClose it; re-cut the task
3. No existing test changedFiles changed: new tests are fine, edited old ones are notClose it: a pass against a changed test proves nothing
4. Readable sizeRoughly 400 changed lines or fewerAsk for it to be split
5. Works where people use itIts preview address on your phone (Session 11)Back with what you saw
Step 6

Collect the night in one table

10 minutes

Why

Each worker left three things: a log with its cost and how it ended, a branch, and a pull request or draft. One table of all of them, with each pull request's checks on its latest commit, lets you decide where to spend your reading time in five minutes. Asking only for evidence, and for "cannot tell" where there is none, stops a confident summary hiding a red check.

Do this

Terminal or PowerShell
cd ~/code/acme-platform && git switch main && git pull && claude
Paste into Claude Code
Collect last night's fleet run. Do not change anything.

For each worker in the newest plan in docs/nights/, read ../night-logs/night-N.json and its branch worktree-night-N on GitHub, and give me one table row:
- how the run ended (finished, dollar cap, turn cap, error) with its cost and turns from the log;
- its pull request number, and whether it is a draft (STOPPED);
- the latest commit on the branch, and each check on THAT commit: passed, failed, pending, or never reported. Say how far the branch is behind main;
- the files it changed since it left main (git diff origin/main...HEAD, three dots): any outside the brief's folders, and any existing test edited rather than added;
- lines changed.

Where you cannot tell something (logs expired, no check reported), write "cannot tell", never "passed". Then list the pull requests in the order I should review them, cheapest checks first.

You will see recreated screen

claude — acme-platform
⏺ Read(../night-logs/night-1.json)
⎿ finished · $5.90 · 46 turns
1
⏺ Bash(gh pr checks 54)
⎿ ci pass · schema pass · clamps pass · Vercel ready (on 6f1d2a0, latest)
⏺ Worker 1 · finished · $5.90 · #54 · checks green on 6f1d2a0 (latest, 0 behind main) · only app/manager/widgets/holds/ and its tests · 212 lines. Worker 2 · turn cap · $7.80 · no pull request; branch pushed at 02:14 · checks: cannot tell (none reported) · 1 existing test edited: tests/operator/layout.test.ts.2
⏺ Review order: #54 first. Worker 2 changed an existing test, so its work fails check 3 before any reading.3
One row per worker, from evidence. The cannot-tell cells are as important as the green ones.
  1. How each run ended, its cost and turns, from the log, not from memory.
  2. "Cannot tell" is an honest answer. Never let it read as a pass.
  3. The order to work in: cheapest decisive check first.

Check it worked

You have one row per worker with how it ended, its cost, its pull request, and its checks on its latest commit.

If it goes wrong

A pull request is red, and the red check ran on an older commit or before a fix reached main

Open it on GitHub and choose Update branch (a merge commit, not rebase), then judge only the checks on the new commit. Never re-run old runs.

A worker hit the turn cap and left a branch without a pull request

Its work up to the last push is safe. Decide: if the branch is close, open the pull request yourself (gh pr create --head worktree-night-2 --draft) and read it; if not, split the task in the wave plan and run it again.

You need to see why a worker did something

The log's session ID opens the whole conversation: in ~/code/acme-platform, claude --resume and pick that session. Read it; do not continue it from there.

Step 7

Send back what fails a cheap check

10 minutes

Why

Most of the morning's time is saved here. A pull request that went outside its folders, changed an existing test or is still red on its latest commit is not worth reading yet. Writing down why on the pull request turns each failure into a better brief for the next night, which is where most failures are really fixed.

Do this

Open

https://github.com/acme-ops/acme-platform/pulls

Open pull requests, in the order from Step 6.

For a pull request that changed an existing test or went outside its folders: comment why and close it. For one still red after updating from main, or a STOPPED draft, start Claude Code in that worker's worktree (the same name reopens it):

Terminal or PowerShell, in your repository folder
claude --worktree night-2
Paste into Claude Code
Read this worktree's brief (the newest plan in docs/nights/ names it) and its pull request or draft. Do not change anything yet.

Tell me: what exactly failed (quote the error and the commit it ran on), what was tried, whether the cause is in our code or outside it (a service, a permission, a check that ran on an old commit), and whether the brief was unclear. If the branch is behind main, merge origin/main into it (no rebase, no force push), push, and wait for the checks on the new commit before you diagnose anything that is still red. Then propose the smallest fix inside the brief's folders, or the change to the brief, and wait for me.

You will see recreated screen

claude — acme-platform
⏺ Bash(git merge origin/main)
⎿ Merge made by the 'ort' strategy.
⏺ Bash(gh pr checks 55 --watch)
⎿ ci fail · tests/operator/layout.test.ts (on 9a0c4e1, latest)
1
⏺ The failure is in our code: the brief asked for 44 px targets at 360 px, and the tab bar wraps at 360 px. The worker edited the existing layout test to allow 40 px; that is why it failed your check 3. Proposal: restore the test, and make the tab bar scroll sideways at 360 px. The brief should have said which screens were in scope.2
The diagnosis first, then a proposal. You decide.
  1. Red on the latest commit, after updating from main: a real failure, worth diagnosing.
  2. A plain diagnosis, the weakened test named, and the brief fix. Nothing is changed until you say so.

Check it worked

Every pull request that failed a cheap check has a comment saying why, and is closed, back with a worker, or fixed and green on its latest commit.

If it goes wrong

The worker or Claude Code says the warning is a false positive

Never accept that for a group of warnings. Say: For each one separately, show me the evidence: the request, the response, the line. On our platform, routes dismissed this way were open on production.

The same failure comes back after a fix

Say: Stop. Do not try again yet. Tell me what failed, what you have tried, and whether the cause is in our code or outside it. Two identical failures mean the cause is not what anyone thinks.

Merging in sequencePick a pull request, update it from main, let the checks run again on the new commit, merge, and repeat; a red run after updating stops the line. Pick the next PRin the order of the planUpdate from maina merge commit, no rebaseChecks run againon the new commitMergethen delete the branchrepeat for the next pull request: every merge changes mainRed after update? Stop.Never merge two pull requests on the strength of checks run before either was merged
Merging in sequence. Every merge changes main, so the next pull request is updated from main and its checks run again on the new commit before it merges.
Step 8

Read each change, then merge one at a time

20 minutes

Why

Every change that reaches the plant's platform is read by a person, and the night's work is no exception. Asking the agent to explain its change against the platform's rules turns a page of code into answers you can check against the brief. Merging one at a time, updating each from main and waiting for its checks on the new commit, catches the clash between two good changes before it reaches main.

Do this

For each pull request left, in order, start Claude Code in its worktree (claude --worktree night-1, and so on) and paste:

Paste into Claude Code
Explain your pull request to me in plain English, as if to the quality lead: what changed, why, and how I can see it working on the preview. Show only what this branch changed since it left main (git diff origin/main...HEAD, three dots). Then answer Yes or No, with the file and line, for each:

1. Does every change sit inside the brief's folders?
2. Does every acceptance check in the brief have a test, and was each shown failing first?
3. Was any existing test, check or limit changed?
4. Does it add a route or page? If so, is it closed until the role matrix opens it (Session 9's proxy.ts and lib/access/routes.ts)?
5. Does it read data in a way that bypasses the access rules (Session 8), for example with a service key?
6. Does it add a package, or anything that looks like a key?
7. Did it do anything the brief did not ask for?

Do not change anything. If anything you told me earlier turned out to be wrong, say so first.

Open its preview on your phone. Owner two approves; merge. For the next pull request, choose Update branch on GitHub, wait for every check on the new commit, ask its agent to confirm nothing it added was lost in the update, and only then merge.

Open

https://github.com/acme-ops/acme-platform/pulls

Open pull requests: merge them one at a time.

You will see recreated screen

claude — acme-platform
⏺ The widget shows holds per press for the last 7 days, from the lot_status view, so each manager sees only their site. On the preview: Manager dashboard, Holds per press.1
⏺ 1 Yes (app/manager/widgets/holds/, tests/manager/widgets/holds/). 2 Yes. 4 checks, 4 tests, each failed first (commit c3e98b1). 3 No existing test changed. 4 No new route. 5 No: it reads through the signed-in user's session. 6 No package, no key. 7 No.2
⏺ Note: I chose 7 days because the brief said "this week"; if the quality lead means Monday to Sunday, that is one line.3
Seven answers, each with the line that proves it. The notes are where the real findings are.
  1. What changed, in the language of the plant, and where to see it.
  2. Every answer can be checked in Files changed.
  3. A choice made overnight with nobody to ask, written down as the brief told it to. Decide it now.

Check it worked

Every pull request you kept has been read against the seven questions, opened on a phone, approved by owner two and merged one at a time, green on its latest commit; main's checks are green after the last merge.

If it goes wrong

Update branch reports conflicts

Two workers touched the same file after all. In that worker's worktree: Merge origin/main into this branch, resolve the conflicts keeping both changes, run the tests, push and explain each conflict in plain words. No rebase, no force push. Then fix the Owners table in docs/waves.md.

After an update, something this branch added has vanished

An undo on main took it with it; no conflict is reported. Say: List every file and test this branch added and confirm each is still there. If any disappeared, find the commit that removed it and tell me before changing anything.

Question 4 or 5 is answered Yes

Do not merge. A new route that is open, or a read that skips the access rules, is the most serious finding a review can make. Send it back with the answer quoted, and add the case to the brief template.

Step 9

Close the night

5 minutes

Why

The night is not finished until its cost and outcome are written down and the lessons are in the briefs. After a week the ledger tells you your own merge rate and cost per merged change, which beats any estimate. Removing the night's worktrees means tomorrow's workers start from a clean main, under the same names.

Do this

Paste into Claude Code in your repository folder, after replacing the <...> part
On a new branch night/morning, add a "Morning" section to the newest plan in docs/nights/: for each worker, how its run ended, its cost and turns, its pull request, and merged, closed or sent back with the reason. Add one row per worker to docs/fleet-ledger.md, with my review minutes: <paste per worker>, and update the cost per merged change. For one pull request I sent back, rewrite its brief in docs/briefs/ so the same failure cannot happen again, keeping the old wording in a "Before" note with one sentence on why it changed. Open a pull request titled "Morning review" with the night's date and wait for the checks.

Then, for each night worker whose pull request is merged or closed (change the 1 for each), in ~/code/acme-platform:

Terminal or PowerShell, in your repository folder
git worktree unlock .claude/worktrees/night-1
git worktree remove .claude/worktrees/night-1
git branch -D worktree-night-1

You will see recreated screen

claude — acme-platform
⏺ Write(docs/nights/2026-10-21.md)
+## Morning
+Worker 1: finished, $5.90, 46 turns, #54 merged.
+Worker 2: turn cap, $7.80, edited an existing test; closed. Brief 11 rewritten: screens in scope named, 360 px tab bar scrolls.
1
⏺ Write(docs/fleet-ledger.md)
+| 2026-10-21 | 10 holds widget | night-1 | $5.90 | 1 | yes | 15 | |
+| 2026-10-21 | 11 phone fixes | night-2 | $7.80 | – | no | 10 | edited a test |
2
⏺ Pull request #57 records the night: 2 runs, 1 merged, $13.70 in tokens, $17.13 with allowance, plus 25 review minutes: $42.13 per merged change, worse than wave 2 because one run did not merge. Brief 11 is rewritten for tonight.3
The night's record: what each worker did, what it cost, and what the briefs learned.
  1. The plan and its outcome on one page, dated.
  2. Runs that did not merge are counted: they are part of the cost of the one that did.
  3. The number to beat tomorrow.

Check it worked

The night's plan has its Morning section, the ledger has a row per worker, one brief is rewritten with its Before note, and git worktree list shows only your main folder.

If it goes wrong

git worktree remove refuses: the worktree has changes

Check its work is on GitHub (its branch, or the pull request). If it is, run the remove again with --force. If it is not, push it first. Never force-remove work that exists nowhere else.

The cost per merged change is rising night after night

Look at the merge rate and the Notes column: the same failure twice is a brief problem. Run fewer workers with sharper briefs until the merge rate recovers.

Before you go on · Session 17 is done whenTick each one

Knowledge check

A pull request's checks are green, but Files changed shows an existing test was edited. What do you do?

Knowledge check

Two pull requests were green last night. Why not merge both straight away?

References

  1. GitHub Docs: About status checks. https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/collaborating-on-repositories-with-code-quality-features/about-status-checks
  2. GitHub Docs: Keeping your pull request in sync with the base branch. https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/keeping-your-pull-request-in-sync-with-the-base-branch
  3. Google Engineering Practices: The standard of code review. https://google.github.io/eng-practices/review/reviewer/standard.html
  4. Claude Code docs: Run parallel sessions with worktrees (clean up). https://code.claude.com/docs/en/worktrees

Chapter 4 · 12 questions · 80% passes

Final assessment

Twelve questions across the element. 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

Choose one answer for each question, then submit. You will see the right answer and why for every question.

1. Why must tonight's plan and briefs be merged to main before the workers start?
2. Which permission mode suits an unattended worker on a computer that holds company files?
3. What is the one-dollar dry run for?
4. Which of these may an unattended worker do?
5. Two workers run with --max-budget-usd 8 each. What is the most the night's model use should cost?
6. A worker fails the same way twice at 01:00. What does its brief tell it to do?
7. A worker's terminal has printed nothing for an hour. How do you judge whether it is stuck?
8. When should a person be woken during a guarded overnight build?
9. A pull request is red, but the check ran on a commit from before yesterday's fix reached main. What do you do?
10. In the morning, which check comes first?
11. Asked to review a new page, the agent says question 4 is Yes: the route is open to anyone. What do you do?
12. A worker built the right thing in the wrong folder. What is the fix for the next night?