Skip to the lesson
CivOps AI Academy · F13Your First Workflow, End to End: Paper to Screen, Review, Record and Chart
0%

Chapter 1 · Session 14

From a paper form to a field list

A paper form is a specification someone wrote years ago. You watch it being used, bring three filled-in sheets back, and Claude Code turns every box into a decision you can check: captured, typed, worked out by the server, or dropped. The person who fills in the form signs the list off before anything is built.

30 min3 stepsNo code yetAbout 3 hours hands-on in all, plus a week beside the paper

By the end of this chapter you can

  • Say why one form is carried all the way through before any second one is started.
  • Have Claude Code turn every box on a paper form into a field list in docs/workflow-1-fields.md.
  • Check the list with the person who fills in the form and their supervisor, and record their sign-off.

One form, all the way through

Sessions 1 to 13 each built one part of the platform. This session joins them for one real paper form, so that what the person on the floor writes today becomes a record on a screen, is reviewed by their supervisor, appears on the lot's record and is counted on a chart the manager reads. Doing one form completely teaches more than starting five: every later form follows the same path, and the problems you meet here, you meet once.

One form, five stopsFive stops left to right: the setter's screen, the die_changes table, the review queue, the die_change_reviews table, and the lot's record page with the manager's chart. One die change, five stops, every one checked by a testSetter's screenrecords the die changedie_changesone row, id from deviceReview queueverify, or returndie_change_reviewsone row per decisionRecord and chartlot page, manager viewWhat people see and what the database holds must both be right at each stop.
One form, five stops. The die change sheet as it travels from the setter's screen to the manager's chart. A test checks what people see and what the database holds at every stop.

The course follows the stamping plant. Its intent says the quality lead decides at each die change whether to hold or release the new lot, so the paper form that starts every one of those decisions is the die change sheet the setter fills in at the press. Use the form your own intent points to: a start-up checklist, a torque record, a sanitation sign-off. The steps are the same.

Step 1

Watch the form in use, and bring three sheets back

45 minutes on the floor

Why

The form on paper is not the form in use. On the floor you see the box nobody fills, the column used for something else and the note in the margin because there was no box for it. If you skip this, Claude Code copies the paper faithfully, mistakes included, and the setter rejects the screen on the first day. Three real sheets are also the best test data you will ever have.

Do this

Ask the area supervisor first, so nobody is surprised to see you watching. Send this:

Message to send (fill in the <...> parts)
To: <the area supervisor>
Subject: Watching one die change on <press> this week

As part of the Acme Bottling platform (Cleveland), we are replacing the paper die change sheet with a screen, one form at a time. Before anything is built I would like to watch one die change on a normal shift, without helping or interrupting, and take copies of three recent filled-in sheets with the names covered.

Could I do that on <day and shift>? The setter will be asked to check the screen before it replaces the paper, and the paper stays in use until you and the quality lead agree to retire it.

On the floor, stand where you can see the sheet. Note for every box: who writes it, when, from where (a gauge, a clock, memory), and whether anyone reads it afterwards. Note anything written outside the boxes. Wear the plant's required safety equipment.

Back at your desk, type the sheet's boxes as a plain list, in order, with what you saw beside each. Keep the three sheets (names covered) as photographs: you will need them in Step 2 and again in Step 11.

You will see recreated screen

Paper: die change sheet, Press 3 (photographed, names covered)
DIE CHANGE SHEET · PRESS SHOP
BoxWhat you saw
Date / ShiftWritten at the end, from memory
Press no. / Die no. / Part no. / Lot no.Copied from the job card
Time off / Time onTime off often missing1
Shut height (mm)Read from the press display
Clamps torqued · Die protection tested · Scrap chute clear · Guards in placeTicked all at once
First piece to QCAlways ticked
Setter / Supervisor sign-offSupervisor signs at end of shift2
Die rack locationBlank on every sheet
Written in the margin"Die 7 needs shims, 0.5 mm"3
The stamping plant's die change sheet, recreated. Your notes from the floor matter more than the printed boxes.
  1. A box often left blank is a box people find hard to fill at the moment it happens. The screen can capture it instead.
  2. A sign-off hours later is not a check. The review in Brief 3 makes it a real one.
  3. A note with no box is a field the form is missing. Ask about it in Step 3.

Check it worked

You have a typed list of every box with what you saw beside each, three photographed sheets with names covered, and the margin notes written down.

Fastest path

Watch the start of a shift: die changes cluster there, so you can see two or three in an hour instead of waiting all day for one.

If it goes wrong

The supervisor does not want you on the floor

Ask what would make it acceptable: a different shift, the supervisor standing with you, or a walk-through at the press with the setter between jobs. Do not design the screen from the blank form alone.

The sheets have personal details on them

Cover names, signatures and badge numbers before you photograph them. The photographs are used for made-up test data, and real plant data never goes into the development project or a test (Session 6).

Four questions for every box

Every box on the form ends up in exactly one of four places. Asking these questions in order is what turns a copy of the paper into a screen people will use. The answers become the field list, the input to every brief in Chapter 2: with it, Claude Code has almost nothing to guess.

Ask, in orderIf yesStamping plant examples
Does any decision use it?If no: drop it, and write down whyDie rack location: nobody reads it; the die store has its own list
Can the platform know it without asking?Capture it: the time, the signed-in person, the press the screen is open atSetter, date, time off and time on, press
Is it worked out from other values?Decide it on the server, never in the browserSetup minutes; part number (from the lot); the shift
OtherwiseThe person types it, with the right keypad, unit and limitsDie number, shut height in mm, the four safety checks, a note
From paper to fieldsThe paper die change sheet with fourteen boxes on the left; on the right its fields in four groups: captured automatically, typed by the setter, worked out on the server, and dropped with a reason. DIE CHANGE SHEET · PRESS SHOPDateShiftPress no.Die no.Part no.Lot no.Time offTime onShut height (mm)Safety checks (4 ticks)First piece to QCSetter initialsSupervisor sign-offDie rack locationCaptured: nobody writes it againstarted_at, finished_at: device clock at the tapequipment_id: the press the screen is atrecorded_by: who is signed inTyped by the setterdie_id, lot_id: picked from short listsshut_height_mm: number pad, 100 to 900four safety checks: Yes or Nonote: needed when a check is NoWorked out on the serversetup_min: finished minus startedpart and shift: from the lot and the timecomplete: all Yes, or a noteDropped, with the reason written downfirst piece to QC: the inspection records itdie rack location: nobody reads itsupervisor sign-off: becomes the review
From paper to fields. Fourteen boxes become four kinds of field. Nobody writes the date, the press or their initials again.
Step 2

Have Claude Code turn the form into a field list

15 minutes

Why

A field list is where a wrong decision costs a sentence to fix. Asking Claude Code to sort every box with the four questions, in plain English, against your existing tables, matrix and naming standard, gives you a page you and the setter can check in ten minutes. It also stops it inventing new places to keep data that the schema already has.

Do this

Paste into Claude Code
Read docs/INTENT.md, docs/SCHEMA-PLAN.md, docs/naming-standard.md, docs/matrix.json and the files in supabase/migrations/ so you know the tables, roles and names we already have. Do not write any SQL or code.

Here is our paper die change sheet, box by box, with what I saw on the floor:
<paste your typed list of boxes and notes>

On a new branch workflow-1/fields, write docs/workflow-1-fields.md for someone who does not write code:
1. A table with one row per box on the paper: the box, and what happens to it: dropped (with the reason), captured (from where), worked out on the server (from what), or typed by the person (with keypad, unit and limits).
2. The field list: one row per field that survives, with its name (naming standard; units in the name, such as shut_height_mm), its type, its unit and limits, where it comes from, whether it can be empty, and which roles in docs/matrix.json write it and read it.
3. Which existing tables each field points to (presses and dies are rows in equipment; the lot is a row in lots). Do not add a table for anything we already have.
4. Rules: the record and the supervisor's review are never changed or deleted (a correction is a new row that says why); the time it happened comes from the device at the tap, and the time it arrived from the server; anything worked out from other values is decided on the server; the person is taken from the sign-in, never typed.
5. "Questions for the setter and the supervisor": every margin note and anything the paper does not settle.

Open a pull request titled "Workflow 1: field list" and show me the link.

You will see recreated screen

claude — acme-platform
⏺ Read(docs/matrix.json)
⎿ Read 112 lines
⏺ Read(supabase/migrations/20261016091500_create_first_tables.sql)
⎿ Read 96 lines
1
⏺ Write(docs/workflow-1-fields.md)
+| Die rack location | Dropped: nobody reads it; the die store keeps locations |
+| Time off / Time on | Captured: device clock when the setter taps Start and Finish |
+| Setup minutes | Server: finished_at minus started_at |
+| Supervisor sign-off | Becomes the review (die_change_reviews), not a box |
2
⏺ Write(docs/workflow-1-fields.md)
+## Questions for the setter and the supervisor
+1. 'Die 7 needs shims, 0.5 mm': should shims used be a field, or a note?
+2. If one safety check is No, may the setter still finish the record?
3
⏺ Pull request #31 adds docs/workflow-1-fields.md: 14 boxes: 3 dropped, 5 captured, 2 worked out on the server, 4 typed by the setter, plus a note field for what the margin held. It uses equipment, lots and memberships as they are and proposes two new tables: die_changes (event) and die_change_reviews (decision). Two questions need the floor.
Claude Code reads what exists before it sorts the boxes, and ends with questions only the floor can answer.
  1. It reads your existing tables first, so it reuses equipment and lots instead of inventing a presses table.
  2. Every box is accounted for, including the ones that disappear.
  3. Margin notes become questions, not guesses.

Check it worked

The pull request has one new file. Every box on the paper appears in the first table with one of the four outcomes; every field has a name, type, unit, source and the roles that write and read it; there is a Questions section.

If it goes wrong

It added a Pass or Complete button for the setter to press

Say: Anything worked out from other values is decided on the server. Make complete a server rule: all four checks Yes, or a note saying why not. A judgement the browser sends can be changed in transit.

It proposes new tables for presses, dies or users

Say: Presses and dies are rows in equipment, people are in memberships. Use what exists; list anything else under Not now with the reason.

It made setter initials a typed field

Say: The person comes from the sign-in, never from the page. We found a platform where every record said it was created by the founder, whoever was signed in, because the page sent the name and the server believed it.

Step 3

Check the field list with the setter and the supervisor

20 minutes

Why

The setter knows things no document says: that time off is the last good part, not when the press stopped; that shims matter. Each of those is a field or a rule. Finding them now costs a conversation; finding them after go-live costs a migration, a data fix and a retest. Their sign-off is also what lets you retire the paper later.

Do this

Sit with the setter who fills in the sheet most often, and their supervisor. Read docs/workflow-1-fields.md on GitHub together, one row at a time. Ask: Is this what you write? Is anything you write missing? Is the rule right? Answer the questions at the end. Then:

Paste into Claude Code, after replacing the <...> parts
The setter and the supervisor read docs/workflow-1-fields.md:
1. <paste their answer to question 1>
2. <paste their answer to question 2>
They also changed: <paste anything else, in their words>.

Update the file to match, add "Checked with the setter and the area supervisor on <today's date>" at the top, and push to the same pull request.

When it is right, owner two approves and the pull request merges.

You will see recreated screen

github.com/acme-ops/acme-platform/blob/main/docs/workflow-1-fields.md
docs/workflow-1-fields.md
Checked with the setter and the area supervisor on 2026-11-021
2
FieldType and unitSourceWrites / reads
started_attime with zoneDevice clock at StartOperator / plant roles
shut_height_mmdecimal, 0.01 mm, 100–900Typed (number pad)Operator / plant roles
shims_mmdecimal, 0.1 mm, 0–5Typed, optionalOperator / plant roles
setup_minwhole minutesServerNobody / plant roles
recorded_bypersonSign-inServer / supervisor, quality lead
The field list on GitHub as the setter reads it: plain words, no code.
  1. The sign-off: who checked it and when. You will point back to it before retiring the paper.
  2. shims_mm came from the margin note. The conversation added a field the paper never had.

Check it worked

docs/workflow-1-fields.md is merged on main, signed off with the setter's and supervisor's roles and the date, with no open questions.

Fastest path

Take the photographed sheets with you and fill in one of them on the field list together, row by row. Gaps show up in minutes.

If it goes wrong

The setter wants the screen to look exactly like the paper

Show them the four captured fields: "you will never write the date, press or your initials again". Keep the order of the typed fields the same as the order they measure in; that is the part of the paper worth copying.

They want a field for everything 'just in case'

Ask which decision uses it. A field nobody decides with is a box nobody fills on the screen either. Put it under Not now with the reason.

Knowledge check

The paper sheet has a box for the setter's initials. What does the screen do with it?

Knowledge check

An entry is made offline at 06:10 and reaches the server at 07:05. Which time do reports use for when the die change happened?

References

  1. Lean Enterprise Institute: Gemba (Lean Lexicon). https://www.lean.org/lexicon-terms/gemba/
  2. ASQ: What is a check sheet?. https://asq.org/quality-resources/check-sheet
  3. ISO 9001:2015 Quality management systems: Requirements. https://www.iso.org/standard/62085.html

Chapter 2 · Session 14

Four briefs, one agent, in order

The workflow is too big for one change and too connected for several agents at once. You write four briefs and one end-to-end test before any code exists, then run the briefs with one Claude Code, one after another, each merged and deployed before the next starts.

45 min5 steps4 pull requests1 end-to-end test, written first

By the end of this chapter you can

  • Split a workflow into briefs that each make one reviewable pull request, in the order the layers depend on each other.
  • Write the acceptance checks and the end-to-end test before any code, and see the test fail.
  • Run each brief with one agent, read the change, merge it and let the Session 11 pipeline deploy it.

Why four briefs, and why in this order

Each layer stands on the one below. The screen cannot be built well until the table, its access rules and some made-up data exist; the review cannot be built until there are records to review; the chart cannot count verified die changes until verifications exist. So each brief is merged before the next one starts, and each is small enough to read in one sitting, using the brief template and the reading order from Session 3 [1].

Four briefs, one workflowAn end-to-end test written first, then Brief 1 the record, Brief 2 the operator screen, Brief 3 the review and Brief 4 the record page and chart, each with its acceptance check, in order. End-to-end test, written first: marked test.fail() until Brief 4 makes it passBrief 1 · The recorddie_changes, die_change_reviews, matrix rowscheck: allowed and refused test per matrix cellBrief 2 · The operator screenSession 12 parts, outbox, phone sizecheck: offline records arrive exactly onceBrief 3 · The reviewverify, or return with a reasoncheck: self-review refused by the databaseBrief 4 · Record and chartlot page; verified minutes per presscheck: no data says so; e2e test passesOne agent, one brief at a time: each is merged and deployed before the next starts.
Four briefs, one workflow. Each is one pull request through the ten clamps, with its acceptance checks written first. The end-to-end test is written before all of them.
BriefBuildsAcceptance checks, written firstStands on
1 The recordA new migration for die_changes and die_change_reviews, the matrix rows, the generated access rules, made-up seed rowsEach role reads and writes exactly what the matrix says; another site sees nothing; bad rows refused; history unchangeableSessions 5–8
2 The operator screenThe die change screen, built from the Session 12 parts, with the outboxAt phone size: a good record is saved once; offline records arrive once; the person comes from the sign-inBrief 1, Session 12
3 The supervisor's reviewVerify or return with a reason, in the Session 13 queueA return needs a reason; reviewing your own record is refused by the server; a correction points at the returned recordBrief 2, Session 13
4 The record and the chartThe lot's record page, and a chart of verified die change minutes on the manager viewA verified record appears in both; a returned one is not counted; with no data the chart says soBrief 3

The end-to-end test, written first

Each brief has its own checks. One more test proves the four work together: it signs in as a setter and a supervisor in two separate browser contexts (Playwright's way of having two people in one test [2]), sends one die change through the whole path including a return and a correction, and reads the database at every stop. It is written now, before any code, and marked as expected to fail with Playwright's test.fail() [3], so the checks stay green while it fails as it should. Brief 4 removes the mark. If the test ever passes before then, Playwright reports it, which tells you the test is not testing anything.

Step 4

Write the four briefs and the end-to-end test

15 minutes

Why

Writing every acceptance check before any code means done is decided by you, not by whatever the agent produces. Writing all four briefs at once, while the field list is fresh, also shows gaps between them (who sets the lot? which page shows the review?) before they become rework. One prompt replaces four rounds of back and forth.

Do this

Paste into Claude Code
Read docs/briefs/TEMPLATE.md, docs/workflow-1-fields.md, docs/matrix.json, and the Playwright tests and sign-in helpers the Session 12 and 13 screens already use. Do not write any application code or SQL.

On a new branch workflow-1/briefs:

1. Write four briefs from the template, in docs/briefs/:
   w1-1-record.md: a NEW migration creating die_changes (event) and die_change_reviews (decision) from the field list; rows added to docs/matrix.json for both tables and for the new screens; access rules regenerated with scripts/gen-policies.mjs; made-up seed rows in supabase/seed.sql.
   w1-2-operator-screen.md: the die change screen for the operator role, built from the Session 12 components and outbox.
   w1-3-review.md: verify or return with a reason, in the Session 13 review queue.
   w1-4-record-and-chart.md: the lot's record page, and a chart of verified die change minutes per press on the manager view.
   Each brief puts its acceptance checks FIRST, by test file name, each one observable (what the person sees, or what the database holds). Each says what it must not change: no applied migration, no existing test, no workflow file.

2. Write tests/e2e/workflow-1.spec.ts with Playwright: a setter and a supervisor in two browser contexts. The setter records a die change with one safety check No and a note; the supervisor returns it with a reason; the setter records a correction pointing at it; the supervisor verifies the correction. After every step, read the database and check the rows (one row, right person, right times, reason kept, nothing changed). At the end, the lot's record page shows both records and both reviews, and the chart counts one verified die change. Mark the test with test.fail() and a comment: "Remove in Brief 4".

3. Run the test and show me it fails for the right reason (the screen does not exist yet), not because of a typo.

Open a pull request titled "Workflow 1: briefs and the end-to-end test", wait for every check to finish, and tell me the result in plain words.

You will see recreated screen

claude — acme-platform
⏺ Write(docs/briefs/w1-3-review.md)
+## Acceptance checks (written first)
+1. tests/e2e/review.spec.ts: Return without a reason is refused; the message says why.
+2. supabase/tests/workflow-1.test.sql: a review by the person who recorded it is refused.
+3. A correction's corrects_id points at the returned record; the returned record is unchanged.
1
⏺ Write(tests/e2e/workflow-1.spec.ts)
+test.fail(); // Remove in Brief 4: the workflow does not exist yet
+const setter = await signedIn(browser, 'operator');
+const supervisor = await signedIn(browser, 'supervisor');
+expect(await rows('die_changes', { lot })).toHaveLength(1);
2
⏺ Bash(npx playwright test tests/e2e/workflow-1.spec.ts)
⎿ 1 expected to fail · page /die-change returned 404 (not built yet)
3
⏺ Bash(gh pr checks --watch)
⎿ ci pass · schema pass · clamps pass · e2e pass
⏺ Pull request #32 adds four briefs and the end-to-end test. The test fails as expected because /die-change does not exist; Playwright counts that as expected. All checks are green.
Four briefs, then the test, then proof that it fails for the right reason, before anything else exists.
  1. Checks first, each naming the file that proves it.
  2. test.fail() keeps the checks green while the workflow does not exist. Brief 4 removes it.
  3. It fails for the right reason: the page is missing, not a typo in the test.

Check it worked

Pull request Workflow 1: briefs and the end-to-end test is green, has four files in docs/briefs/ and one in tests/e2e/, and Claude Code showed the test failing because the screen does not exist yet. Owner two approves; merge it.

Fastest path

Read only the acceptance checks of each brief before approving. If the checks are right, the rest of the brief can be fixed cheaply later; if they are wrong, everything built to them is wrong.

If it goes wrong

The test fails because of a typo or a missing helper, not because the screen is missing

Say: The test must fail only because the workflow does not exist. Fix the test until the first failure is the missing /die-change page, then show me. A test that fails for the wrong reason will pass for the wrong reason too.

A check in a brief only looks for a word in a file

Say: Rewrite that check to call the page or the database and check the result, not the code. On our platform three such checks passed one night while the feature they guarded was broken.

The agent says the test cannot fail, or passes it straight away

Stop. A test that passes before the code exists proves nothing. Say: Show me the test failing with the feature missing, then explain what it actually checks.

Step 5

Brief 1: the record, its access rules and its tests

20 minutes

Why

Everything else stands on these two tables. Writing them as a new migration, with access rules generated from the matrix rather than written by hand, means the rules match what you and the decision-maker agreed in Session 7. Merging it lets the Session 11 pipeline apply it to the live database, so nobody types db push by hand any more.

Do this

Paste into Claude Code
Carry out docs/briefs/w1-1-record.md on a new branch workflow-1/record. Before you start, list the open pull requests and the files each touches; if this brief needs any of them, stop and tell me.

- Create the migration with npx supabase migration new workflow_1_die_changes. Never edit an existing migration.
- Follow the Session 5 rules: site_id on both tables, append-only trigger, corrects_id and correction_reason, timestamptz, numeric with the unit in the name, security_invoker on any view, row-level security on.
- Add the rows for die_changes, die_change_reviews and the new screens to docs/matrix.json, then run scripts/gen-policies.mjs to generate the access rules migration. Do not write a policy by hand.
- Tests: the generated allowed-and-refused test per matrix cell, the cross-site test, and pgTAP tests that every rule in docs/workflow-1-fields.md refuses a bad row.
- Seed: a few made-up die changes and reviews relative to today, marked as made up like the rest of supabase/seed.sql.

Push, open a pull request titled "Workflow 1: the record", wait for every check, and fix any failure before you report. Then explain the migration to me against these questions, each Yes or No with the line that shows it: every field from the field list and nothing else; every reference a foreign key; history unchangeable; a review by the person who recorded the die change refused; policies generated, none by hand; nothing dropped or renamed.

Read the answers and the Files changed tab in the Session 3 order. Owner two approves; merge. Then watch the deploy:

Open

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

Open the run of the deploy workflow for your merge. The migrations step must list the two new files.

You will see recreated screen

claude — acme-platform
⏺ Bash(npx supabase migration new workflow_1_die_changes)
⎿ Created supabase/migrations/20261103101200_workflow_1_die_changes.sql
1
⏺ Bash(node scripts/gen-policies.mjs)
⎿ Wrote supabase/migrations/20261103101500_policies_workflow_1.sql · 11 policies from 11 matrix cells
2
⏺ Bash(gh pr checks --watch)
⎿ ci pass · schema pass (64 tests) · access pass (38 tests) · clamps pass
⏺ Pull request #33 is green. 1 Yes: 12 fields, all from the field list. 2 Yes: 6 foreign keys. 3 Yes: append-only trigger on both tables (lines 58, 74). 4 Yes: trigger refuses reviewed_by = recorded_by (line 81). 5 Yes: 11 policies, all generated. 6 Yes: nothing dropped or renamed.3
The migration comes from a new file, the access rules come from the generator, and the answers come with line numbers.
  1. A new file with a later time. Nothing applied is edited.
  2. Rules from the matrix, by the generator. The count of policies matches the cells you filled.
  3. The review questions, answered with the line that proves each one.

You will see recreated screen

github.com/acme-ops/acme-platform/actions
deploy · Merge pull request #33 from workflow-1/record
1
StepResult
Apply migrations✓ 20261103101200_workflow_1_die_changes, 20261103101500_policies_workflow_1
Deploy to Vercel (production)✓ Ready
Smoke check✓ signed-out request refused
After the merge: the deploy workflow applies the migrations before the new code goes live.
  1. The two new files, applied by the pipeline. Nobody typed db push.

Check it worked

Pull request Workflow 1: the record is merged, the deploy run is green with both migrations applied, and the Security Advisor for acme-platform-prod shows no errors.

Fastest path

"Wait for every check and fix any failure before you report" saves a round trip: Claude Code reads the red log and fixes it while you do something else.

If it goes wrong

A check fails with "new row violates row-level security policy", or an insert works but returns nothing

In Postgres an insert that returns its new row also needs the right to read it. Say: The operator can insert into die_changes but not read the row back. Add the read right to docs/matrix.json for the operator's own site, regenerate the policies, and add a test that the inserted row really is in the table.

A check named for a generated list fails, though the code looks fine

The list of routes or policies was not regenerated after the matrix changed, and the check names the check, not the list. Say: Open the failed check's log, tell me which generated file it compares, regenerate it with the command the log prints, and show me what changed.

After merging main into the branch, a column or test you added is gone

Someone undid a batch on main and the undo took yours with it, with no conflict reported. We hit this. Say: List every schema change 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.

The deploy run fails at Apply migrations

Nothing new went live: the pipeline stops before the code. Open the step's log and paste the last 30 lines into Claude Code with: The production migration failed with this. Explain the cause without touching production, and propose a new migration that fixes it. Never edit the applied file. Follow docs/runbook.md if the site is affected.

Step 6

Brief 2: the operator screen

20 minutes

Why

The setter's screen is where the record starts, so it must be quicker than paper with gloves on, keep working when the network drops, and never record the wrong person. Building it from the Session 12 parts means it inherits touch targets, the outbox and the phone tests instead of reinventing them.

Do this

Paste into Claude Code
Carry out docs/briefs/w1-2-operator-screen.md on a new branch workflow-1/operator-screen.

This version of Next.js differs from older guides: read the relevant guide in node_modules/next/dist/docs/ before writing any page or route code. Route protection lives in proxy.ts.

- Build /die-change from the Session 12 components: touch first, 44 px targets, number pad for shut_height_mm, the four checks as large Yes/No buttons in the order the setter works.
- Start and Finish record the device time at the tap. The record gets its id on the device and goes through the Session 12 outbox, so a retry never makes a second row.
- The server takes the person from the session and ignores any person the page sends. It decides setup_min and refuses the record if a check is No and the note is empty.
- The screen is already in docs/matrix.json from Brief 1: regenerate lib/access/routes.ts from it. Do not open the route any other way.
- Run the brief's acceptance checks at 360 and 390 px, including offline: record two die changes with the network off, turn it on, and check exactly two rows arrive.

Push, open a pull request titled "Workflow 1: operator screen", wait for every check and the Vercel preview, and fix any failure before you report. Give me the preview address.

Open the preview on your phone, sign in as a test operator, and record one die change with the phone in flight mode, then turn flight mode off.

You will see recreated screen

acme-platform-git-workflow-1-operator-screen-acme-ops.vercel.app/die-change
Die change · Press 3
Setteryou (from sign-in)1
Start die change · 06:10
DieD-07 ▾
Shut height (mm)412.50
Clamps torqued: Yes
Die protection: Yes
Scrap chute: Yes
Guards: No
Note (needed when a check is No)Rear guard latch loose, reported to maintenance2
Finish · 06:52
The die change screen on a phone, recreated. Big targets, the time captured by a tap, nothing typed that the platform already knows.
  1. Taken from the sign-in on the server. There is no box for it.
  2. A No needs a note: the server refuses the record without one, whatever the page does.
  3. The outbox from Session 12: honest about what has and has not reached the server.

Check it worked

The pull request is green, the screen works on your phone at the preview address, and after flight mode the record appears once in the development project's die_changes table with your test operator as recorded_by. Merge it; the pipeline deploys it. Nobody is told to use it yet.

If it goes wrong

Every record says it was made by the same person

The page is sending the person and the server believes it. Say: Take the user from the signed-in session on the server for every insert and ignore any user the page sends. Add a test that signs in as two different operators and checks each record's recorded_by.

Two rows arrive for one die change after the network comes back

The id is being made on the server, so a retry looks like a new record. Say: The id must be made on the device and the insert must ignore a repeat of the same id. Add a test that sends the same record twice and expects one row.

The check is red for something this pull request did not touch

It may have run on an old commit before a fix landed on main. Say: Tell me which commit this check ran on and how far behind main it is. If it is behind, merge origin/main into the branch (no rebase, no force push), push, and diagnose only what is still red.

The route test fails: /die-change answers without sign-in, or refuses the operator

That is the default-deny from Session 9 doing its job. Say: Regenerate lib/access/routes.ts from docs/matrix.json and run the route tests. Do not add an exception by hand.

Step 7

Brief 3: the supervisor's review

15 minutes

Why

A signature at the end of the shift is not a check; a review of each record, with the reason kept when it is returned, is. The rule that nobody verifies their own record must live in the database, so it holds even when someone resends the request by hand. A returned record stays as it was, and the correction points at it, so the history is complete.

Do this

Paste into Claude Code
Carry out docs/briefs/w1-3-review.md on a new branch workflow-1/review.

- Add die changes to the Session 13 review queue: oldest first, showing press, die, setup minutes, any No check and its note.
- Verify or Return. Return needs a reason; the server refuses an empty one. The review is a new row in die_change_reviews; nothing is updated.
- A review by the person who recorded the die change is refused by the database (Brief 1's trigger), and the screen says so plainly. Add a test that sends that request directly, without the screen, and expects the refusal.
- A returned record shows on the setter's screen with the reason. The setter's correction is a new die_changes row with corrects_id pointing at it and a correction_reason.
- After each action, check in the database that the row really changed; a success message alone is not a pass.

Push, open a pull request titled "Workflow 1: review", wait for every check and the preview, fix any failure, and report.

You will see recreated screen

acme-platform-git-workflow-1-review-acme-ops.vercel.app/supervisor/review
First piecesDie changes
Press 3 · Die D-07 · 42 min · recorded 06:52Guards: No. "Rear guard latch loose, reported to maintenance"1
Reason (needed to return)Guard must be fixed before running. Re-record after maintenance signs off.
Return2
Verify
The supervisor's queue with the die change added. A return needs a reason; the setter sees it.
  1. What the paper sign-off never showed: the No and its note, at the moment it matters.
  2. Returning keeps the record and adds a review with the reason. Nothing is deleted.
  3. The database refuses self-review; the screen only explains it.

Check it worked

The pull request is green. On the preview: a return without a reason is refused; a return with one appears on the setter's screen; the correction points at the returned record, which is unchanged; your own record cannot be reviewed. Merge it; the pipeline deploys it.

If it goes wrong

Verify says Saved but the queue still shows the record

In Postgres an insert or update only sees rows the role may read, so a missing read right makes it do nothing quietly. Say: After Verify, check in the database whether a die_change_reviews row exists. If not, find which read right is missing in docs/matrix.json, regenerate, and add a test that checks the row really exists.

A supervisor can verify their own record when the request is resent from the browser's tools

The rule is only in the screen. Say: Self-review must be refused by the database trigger from Brief 1. Show me the test that sends the request directly and expects the refusal. Rights are decided by what the action does, not by which button is shown.

The return button claims success but the setter never sees the reason

A stand-in or a missing step is pretending. Say: Trace a return from the button to the setter's screen and show me each row it writes and reads. Any step that reports success without a row is a defect.

Step 8

Brief 4: the record and the chart

20 minutes

Why

The record page is where a quality lead answers "what happened on this lot?" in one place: the die change, its review, the first pieces and the hold or release. The chart is where the manager sees setup time by press. Both must count only what was verified, and both must say plainly when there is nothing to show, never a made-up number.

Do this

Paste into Claude Code
Carry out docs/briefs/w1-4-record-and-chart.md on a new branch workflow-1/record-and-chart. Read node_modules/next/dist/docs/ before writing page or route code.

- The lot's record page: the die change records (with corrections linked), their reviews with reasons, the first-piece results, and the hold or release decisions, in time order, each with who and when. Every value comes from the database.
- On the manager view: a chart of median die change minutes per press for the last 14 days, counting verified die changes only, from a view created with security_invoker = true. Under the chart: the source (the view and its tables), the number of die changes counted, and the time of the newest one.
- With no verified die changes in the period, the chart says "No verified die changes in the last 14 days", never 0 and never sample points.
- Remove test.fail() from tests/e2e/workflow-1.spec.ts. It must now pass.

Push, open a pull request titled "Workflow 1: record and chart", wait for every check and the preview, fix any failure, and report. Do not merge.

You will see recreated screen

claude — acme-platform
⏺ Write(tests/e2e/workflow-1.spec.ts)
-test.fail(); // Remove in Brief 4: the workflow does not exist yet
1
⏺ Bash(npx playwright test tests/e2e/workflow-1.spec.ts)
⎿ 1 passed (41s): recorded, returned with reason, corrected, verified; 2 records, 2 reviews, chart counts 1
⏺ Bash(gh pr checks --watch)
⎿ ci pass · schema pass · access pass · clamps pass · e2e pass
⏺ Pull request #36 is green. The end-to-end test now passes without the expected-to-fail mark. The chart reads die_change_minutes (security_invoker = true) from die_changes and die_change_reviews; with no data it shows the No verified die changes message. Preview: https://acme-platform-git-workflow-1-record-and-chart-acme-ops.vercel.app2
The end-to-end test passes for the first time, with the expected-to-fail mark removed.
  1. The mark comes off, and the same test now passes: done is what you wrote in Step 4.
  2. Where every number comes from, in its summary and under the chart.

You will see recreated screen

acme-platform-git-workflow-1-record-and-chart-acme-ops.vercel.app/manager
Die change minutes, median per press, last 14 days
1
PressMedian minutesDie changes
P-01389
P-034711
P-05No verified die changes0
Source: die_change_minutes (die_changes, die_change_reviews) · verified only · newest 06:52 today2
The chart on the manager view, recreated. Source, count and freshness are part of the chart.
  1. A press with nothing to count says so, in words.
  2. Every number names where it came from and how fresh it is. Session 15 makes this the rule for every widget.

Check it worked

The pull request is green, the end-to-end test passes with no test.fail() left, and the preview shows the record page and the chart. Do not merge yet: walk the data trail first (Step 9).

If it goes wrong

The chart shows smooth sample numbers, or 0 for a press with no data

That is an invented number, and we shipped them: a chart that drew twelve hard-coded points and called them "In control" on 87 screens. Say: Every value on this chart must come from die_change_minutes. Remove any sample, default or zero used for no data, show the No verified die changes message instead, and add a test that renders the chart with no rows and expects that message.

Links on the record page open a 404

A link that compiles is not a link that works. Say: Start the build, sign in as each role, open the record page for a seeded lot and follow every link. Report every 404 or error and fix them.

Claude Code reports all tests pass but the check on GitHub is red

Trust the check, not the summary. Say: The e2e check is red. Show me the exact command, its exit code and the last 20 lines of its log, then fix the cause.

Knowledge check

Why are the four briefs run by one agent, one after another, rather than four agents at once?

Knowledge check

Why is the end-to-end test marked with test.fail() until Brief 4?

References

  1. Anthropic: Claude Code best practices. https://www.anthropic.com/engineering/claude-code-best-practices
  2. Playwright documentation: Isolation and browser contexts. https://playwright.dev/docs/browser-contexts
  3. Playwright documentation: Test annotations (test.fail). https://playwright.dev/docs/test-annotations
  4. Supabase Docs: Row Level Security. https://supabase.com/docs/guides/database/postgres/row-level-security

Chapter 3 · Session 14

Follow the data, ship it, and give it to the floor

A green test proves the workflow works in a test. You prove it by hand once, on a preview with made-up data, watching every row arrive. Then the pipeline ships it, and the setter who used the paper uses the screen beside it for a week before anyone retires the paper.

30 min3 stepsEnds with a gate1 parallel week

By the end of this chapter you can

  • Follow the data trail by hand: check the database, not just the screen, after every step.
  • Ship the last brief through the Session 11 pipeline and check production is current.
  • Run the screen beside the paper with the setter, and record a dated go or no-go decision.

Follow the data trail

A screen can say Saved while the database holds nothing, two rows, or the right row with the wrong person. The end-to-end test reads the database after every step, and so should you, once, by hand, before the workflow ships. Do it on the preview of Brief 4, which uses the development project and its made-up data, so nothing you make up ever reaches production.

The data trailFive steps on the left, from the setter recording to the supervisor verifying, each with the database facts to check on the right. After each step, read the database, not just the screenSetter records1 row in die_changes · recorded_by = setter · setup_min set by serverNetwork drops, retrystill 1 row: the same id from the deviceSupervisor returns1 row in die_change_reviews · reason not empty · reviewer is not the setterSetter correctsnew die_changes row · corrects_id = the first · the first unchangedSupervisor verifiesa second review row · the chart counts 1 · the record page shows both
The data trail. Each step leaves exact facts in the database. The test checks them; you watch them arrive in the Table Editor.
Step 9

Walk the data trail yourself, on the preview

15 minutes

Why

Running the whole path once with your own hands, watching the table beside the screen, catches what tests were not written for: a time in the wrong zone, a note cut short, a review shown to the wrong person. It is also the walk you will repeat for the setter, so you will know what they should see.

Do this

Open

https://supabase.com/dashboard/project/tsrqponmlkjihgfedcba/editor

The development project's Table Editor. Open die_changes in one tab and die_change_reviews in another, beside the preview.

On Brief 4's preview, signed in as a test operator in one browser and a test supervisor in a private window: record a die change with one check No and a note; return it with a reason; record the correction; verify it. After each action, refresh the table and compare it with the diagram above. Then open the lot's record page and the chart. If anything differs, give Claude Code what you saw:

Paste into Claude Code only if something differed
On the preview of "Workflow 1: record and chart" I walked the data trail by hand. After <the step>, the screen showed <what you saw> but die_changes / die_change_reviews held <what you saw>. Find the cause, add a test that catches it, fix it, and push to the same pull request. Wait for every check before you report.

You will see recreated screen

supabase.com/dashboard/project/tsrqponmlkjihgfedcba/editor
die_change_reviewsdie_changesequipmentholdsinspectionslots
1
idequipmentguards_in_placesetup_minrecorded_bycorrects_idcorrection_reason
4102P-03false42operator.test
4107P-03true51operator.test4102Guard latch replaced by maintenance
The development project's die_changes table after the correction: two rows, the second pointing at the first, both kept.
  1. The returned record is unchanged; the correction points at it and says why.
  2. The access rules generated in Brief 1, on the tables the screens use.

Check it worked

Every step left exactly the rows the data trail says: one row per record, the right person, the reason kept, the correction linked, nothing changed. The record page and the chart agree with the tables.

If it goes wrong

The preview shows production data, or the Table Editor of acme-platform-prod shows your test records

Stop. Made-up records must never enter production. Check which project the preview uses in Vercel's environment variables for Preview; it must be acme-platform-dev. Tell owner two, and remove the test rows only by a reviewed correction, never by deleting history by hand.

The chart on the preview says No verified die changes, though you just verified one

Look at the newest row's time: the made-up seed may have aged, so "last 14 days" holds only your one record, or none. That is the chart being honest. Session 15 covers keeping the development data current.

Step 10

Merge, and let the pipeline ship it

10 minutes

Why

Since Session 11 a merge is a deploy: the pipeline applies any migrations, then the new code goes live, with a smoke check. Checking the run, the live site and production's migration list, rather than assuming, is how you know production is the main you just merged and not something older.

Do this

Owner two approves Workflow 1: record and chart; merge it. Then:

Open

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

The deploy run for this merge must be green. Then choose the daily production-freshness check from Session 11 and Run workflow on main.

Open

https://supabase.com/dashboard/project/abcdefghijklmnopqrst/advisors/security

The Security Advisor for the live project: Rerun linter. No errors.

Open

https://acme-platform.vercel.app/die-change

The live screen, on your phone, signed in as yourself. Look; do not record a made-up die change in production.

You will see recreated screen

github.com/acme-ops/acme-platform/actions
production-freshness · run by pat@acme.com
Newest migrationsOn mainIn production
20261103101200_workflow_1_die_changes✓✓
20261103101500_policies_workflow_1✓✓
The production-freshness check, run by hand: every migration on main is applied to production.
  1. The answer you want after every merge that changes the database. Anything missing means production is behind main.

Check it worked

The deploy run is green, the freshness check finds nothing missing, the Security Advisor shows no errors, and https://acme-platform.vercel.app/die-change opens on your phone.

If it goes wrong

A page works on the preview but fails on the live site with "column does not exist"

Production is behind main. Our live database once fell nine migrations behind, the oldest seven weeks old. Read the deploy run's Apply migrations step: if it failed, nothing new should have gone live; follow docs/runbook.md. Never apply a migration by hand to make it match.

The production deploy in Vercel shows Canceled

A newer merge replaced it within a minute. A canceled deploy that a newer ready deploy replaced is not a failure. Check that the newest production deployment is Ready and came from git.

Claude Code offers to deploy to fix it

Say no. Production comes only from main through GitHub; a deploy from a laptop once sent local settings to our live site and broke three pages. The deny rule from Session 1 should stop it anyway.

Put it in front of the floor

Tests find what you thought of. The setter finds the rest: a label that reads differently on a dirty screen, an order that does not match how they work, a button a glove misses. Then the screen runs beside the paper for a week. Every difference has a cause: a defect, a training gap, or a paper error the screen has just caught. Software guidance in regulated industries makes the same point: confirm a system works for its intended use, where it is used, before relying on it [1]. If your form is a controlled record under ISO 9001, or a record FDA rules require, check with your quality lead what moving it to a screen requires [2].

Parallel weekBars for five days comparing die changes recorded on paper and on the screen; Tue differs. Die changes recorded per day in the parallel week: paper (grey) and screen (cyan)99Mon1110Tue88Wed1010Thu99Fri
A parallel week. Die changes recorded per day on paper and on the screen. On Tuesday the screen has one fewer: find out why before going live.
DifferenceLikely causeWhat to do
Screen has fewer than paperA record still in a device's outbox, or the screen skippedCheck the outbox on that tablet; check the shift knew
Screen has more than paperA duplicate from a retry, or the paper skippedSame id twice means the outbox insert is broken: a defect for Claude Code
Same count, different valueA typing error on one of themThe review shows which; the paper is not automatically right
Different setup minutesPaper times written from memory at the end of the shiftUsually the screen is right: that is part of why you built it
Cutting over from paperFive steps: first use by the setter, a parallel week, a daily comparison, a dated go or no-go by two people, and retiring the paper on one press; a difference sends you back to another week. First usesetter, one pressParallel weekpaper and screenCompare dailycount and valuesGo or nottwo people, datedRetire paperon that press onlya difference: find the cause, fix it, run another week
Cutting over from paper, one press at a time. The paper goes only after a week that matches and a dated decision, and a difference sends you back for another week.
Step 11

The setter uses it, beside the paper, for a week

20 minutes a day for a week

Why

The person who filled in the paper is the only one who can say the screen does the job. A week side by side, compared every day, turns "it seems fine" into numbers, and every difference into a cause and a fix. Retiring the paper is then a decision two named people make on evidence, written down where an auditor can find it.

Do this

Make sure the setter and their supervisor have accounts with the operator and supervisor roles (invited as in Session 9). Watch the setter's first real die change on the screen without helping, and note every hesitation. Fix what they find through a brief, as in Chapter 2. Then, for five shifts on that press, they fill in both. At the end of each shift compare count, die, times and checks. At the end of the week:

Paste into Claude Code at the end of the week (fill in the <...> parts)
On a new branch workflow-1/go-live, add a section "In use: the parallel week and the decision" at the end of docs/workflow-1-fields.md with:
- the press and the dates of the parallel week;
- a table per day: die changes on paper, on the screen, and whether every value matched;
- every difference, its cause and its fix (with the pull request link if there was one);
- the decision: <go / another week>, made by <the area supervisor> and <the quality lead> on <date>;
- what happens to the paper on that press, and which press is next.
Open a pull request titled "Workflow 1: parallel week and decision".

You will see recreated screen

github.com/acme-ops/acme-platform/blob/main/docs/workflow-1-fields.md
In use: the parallel week and the decision
1
DayPaperScreenValues match
Mon99Yes
Tue1110No: one record still in the tablet's outbox (Wi-Fi dead spot by Press 3)
Wed88Yes
Thu1010Yes
Fri99Yes
Decision: go on Press 3, 2026-11-14Area supervisor and quality lead. Paper retired on Press 3 only; Press 5 next.2
The decision, on GitHub, beside the field list it started from.
  1. Every difference has a cause. Tuesday's was a dead spot, fixed by a Wi-Fi access point, not by code.
  2. Two named people, a date, one press. The other presses follow one at a time.

Check it worked

The section is merged on main with a day-by-day comparison, a cause for every difference, and a dated go or another-week decision by two named people. The paper is retired only on that press, only after a go.

If it goes wrong

The setter stops using the screen after a day

Ask what made them stop, at the press, the same day. It is usually one thing (a slow step, a target too small for a glove). Fix it through a brief and restart the week. Do not count the week if the screen was skipped.

Someone wants to go live on every press at once

One press first, with a decision and a way back. A defect found on one press costs a fix; found on six, it costs a week of records to reconcile. Session 23 does the same for the whole platform.

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

Knowledge check

The screen says Saved. Why does the data trail still look at the table?

Knowledge check

During the parallel week the screen shows one more die change than the paper. What do you check first?

References

  1. U.S. FDA: General Principles of Software Validation. https://www.fda.gov/regulatory-information/search-fda-guidance-documents/general-principles-software-validation
  2. eCFR: 21 CFR Part 11, Electronic Records; Electronic Signatures. https://www.ecfr.gov/current/title-21/chapter-I/subchapter-A/part-11
  3. Supabase Docs: Tables and data (Table Editor). https://supabase.com/docs/guides/database/tables
  4. Vercel Docs: Deployments. https://vercel.com/docs/deployments

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

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

1. What do you do before anyone designs the screen for a paper form?
2. A box on the sheet has been blank on every sheet for a year and no decision uses it. What happens to it?
3. Where is setup minutes (finish time minus start time) worked out?
4. A record is made offline at 06:10 and reaches the server at 07:05. What does the record keep?
5. In what order do the four briefs run?
6. Why is the end-to-end test written before Brief 1 and marked with test.fail()?
7. Brief 1 needs access rules for the two new tables. Where do they come from?
8. After Brief 1 merges, how does the new migration reach the live database?
9. A supervisor resends a Verify request for their own die change from the browser's tools. What should happen?
10. With no verified die changes in the last 14 days, what does the chart show?
11. Where do you walk the data trail by hand, and why there?
12. When is the paper sheet retired on a press?