Skip to the lesson
CivOps AI Academy · F10The Operator Surface: Touch First, Readable, and Working Offline
0%

Chapter 1 · Session 12

Design the screen with the operator

The operator surface is where the plant's data is born. Before any code, Claude Code writes the screen out in plain words from your intent, schema and role matrix, and you check it with an operator at the press, on paper, in gloves.

30 min2 stepsNo code yetAbout 3 hours hands-on in all

By the end of this chapter you can

  • Say why the operator screen decides the quality of every number above it.
  • Apply the floor rules: 44 px targets, 64 px for gloves, text sized for the distance, calm until abnormal, blank is never 0.
  • Have Claude Code write a plain-English screen plan, and check it with an operator at the press.

Where data is born

Every chart the manager reads and every hold the quality lead decides starts with an operator typing a number at a press. On paper, a smudged number is caught later, if at all. On a screen, a mis-tap is never caught, unless the screen is designed so the mis-tap cannot happen. That is why the operator screen comes first: the supervisor review and the manager view (Session 13) can only be as good as what this screen records.

The course example is the stamping plant's first-piece entry: after a die change, the operator measures the first part off the press against the part's characteristics and enters the results for the new lot. Each result becomes one row in inspections, which you made in Session 5. Use your own plant's first task in its place.

Conditions on the floorSix conditions around an operator, each with its design answer: gloves, arm's length, glare, noise, interruptions and a shared tablet. The operatorstanding, mid-taskGlovestargets 64 px or moreArm's lengthlarger text, few wordsGlare and dusthigh contrast, no thin greyNoisenothing relies on soundInterruptionsone task, saved as you goShared tabletwho is signed in, always shown
The floor is not a desk. Each condition at the press has a design answer. The plan in Step 1 must answer all six.

The floor rules

These rules come from published guidance, adjusted for the floor. Apple asks for tap targets of at least 44 by 44 points [1]. The web's accessibility standard, WCAG 2.2, sets 24 by 24 CSS pixels as the minimum and 44 by 44 as the enhanced level [2] [3]. Gloves make the contact patch bigger and less precise, so the course rule is higher still for the main action.

Tap target sizesFour squares drawn to scale: 24, 44, 48 and 64 pixels, labelled with the guideline each comes from. Tap targets drawn at their real relative size (1 px = 2 drawing units)24 pxWCAG 2.5.8 minimum (AA)44 pxApple HIG; WCAG 2.5.5 (AAA)48 dpAndroid guidance64 pxgloved stations (our rule)Bigger targets with space between them cut mis-taps; on a phone, 44 px is about 7 mm.
Tap targets to scale. The course rule: 44 px for everything, 64 px for the main action on any screen used with gloves.
RuleWhyHow it is checked
Every target at least 44 by 44 px, with 8 px between targetsA finger is wider than a mouse pointer; a wide contact must not hit two buttonsA screen test measures every control at 360 and 390 px wide (Step 7)
The main action (Save) at least 64 px high, full width, at the bottomGloves, and the thumb is already at the bottomThe same test, plus ten entries in gloves (Step 5)
Fields at 16 px or larger, with the decimal keypad (inputmode="decimal")Phones zoom into smaller fields and the page jumps; the keypad has big keys and no letters [4]Screen test, and tapping a field on the phone
Capital letters at least the viewing distance divided by 156Readability depends on the angle a letter fills at the eye, not on pixelsA ruler at the press (Step 5)
Calm until abnormal: grey while values are inside limits; a value outside is the only thing in colour, with wordsWhen colour is rare it always means something; about 1 in 12 men cannot tell red from green [5]Enter a value outside its limits and read the words
Context always on top: site, press, part, lot, shift, who is signed inA shared tablet must never record under the wrong person or pressLook at the top of the screen
A blank field means not measured, and is saved as no value, never 0Zero is a real reading. We once showed an unreadable sensor as 0, and a screen full of invented values as finishedA screen test saves a blank field and reads the row
Anatomy of an operator screenA phone-width screen with five regions from top to bottom: context, task, fields, submit button and sync status. Press 03 · part 7741 · Shift Bwho and where, always shownFirst-piece check: lot L-0412one task, named in plain wordsHole position · flange height · burrlarge fields, number keypadSavefull width, thumb reach2 waiting to sendsync status
Anatomy of the operator screen at phone width. Context at the top, one task, large fields, a full-width action within thumb reach, and the waiting count always visible.
Character height by distanceBar chart: about 2.2 mm at 0.35 m, 4.5 mm at 0.7 m, 9.6 mm at 1.5 m, 19 mm at 3 m and 38 mm at 6 m. Capital-letter height for comfortable reading at 22 minutes of arc (millimetres)0.35 mphone in the hand2.2 mm0.7 mtablet at arm's length4.5 mm1.5 mscreen on the machine guard9.6 mm3 mscreen across the aisle19.2 mm6 mboard across the room38.4 mm
Letter height by distance, drawn to scale. A tablet on a stand at arm's length needs letters about twice as tall as a phone in the hand.
Step 1

Ask Claude Code for a screen plan, not a screen

10 minutes

Why

Asking for a screen straight away gets you something that looks finished and that you cannot check. A plan in plain words, written from your intent, schema and role matrix, can be read by an operator in ten minutes and corrected for the cost of a sentence. It also makes Claude Code read the rules the screen must keep before it writes any of it.

Do this

Terminal or PowerShell
cd ~/code/acme-platform && git switch main && git pull && claude
Paste into Claude Code
Read docs/INTENT.md, docs/SCHEMA-PLAN.md, docs/matrix.json and docs/naming-standard.md. Do not write any code.

On a new branch ui/operator-first-piece-plan, write docs/screens/operator-first-piece.md: the operator's first-piece entry screen, in plain English, for someone who does not write code. It covers one task only: after a die change, the operator records the first-piece results for the new lot on one press.

Give:
1. Who uses it (the operator role in docs/matrix.json), where (standing at the press, phone or tablet, gloves on), and how often.
2. What the top of the screen always shows: site, press, part, lot, shift and who is signed in.
3. Every field, in order: which characteristic, its unit, its limits as stored in the characteristics table, and the keypad it needs. Nothing the operator does not record on paper today.
4. What the screen decides and what it leaves to others: it shows whether each value is inside its limits; it never holds or releases a lot (the quality lead does).
5. The floor rules: every target at least 44 px with 8 px between targets, Save at least 64 px high and full width at the bottom, fields at 16 px or larger, capital letters at least the viewing distance divided by 156, status in words as well as colour, nothing that needs hover, and a blank field means "not measured" and is never shown or saved as 0.
6. What happens with no network: the entry is kept on the device, the screen says how many entries are waiting, and each is sent exactly once when the network returns.
7. Everything the database or the access rules can refuse for this entry, and the plain sentence the operator sees for each.
8. A text sketch of the screen at phone width, top to bottom.
9. "Questions for the operator": anything the intent, schema or matrix does not settle.

Then open a pull request titled "Operator first-piece screen: plan" and show me the link.

You will see recreated screen

claude — acme-platform
⏺ Read(docs/INTENT.md)
⎿ Read 38 lines
⏺ Read(docs/matrix.json)
⎿ Read 112 lines
1
⏺ Write(docs/screens/operator-first-piece.md)
+## Fields (part 7741, from characteristics)
+1. Hole position, mm, limits 11.90 to 12.10, decimal keypad
+2. Flange height, mm, limits 24.80 to 25.20, decimal keypad
+3. Burr height, mm, limit 0.10 maximum, decimal keypad
+Blank = not measured. Never saved as 0.
2
⏺ Write(docs/screens/operator-first-piece.md)
+## What the database can refuse
+- A lot at a site you are not a member of: "You can only record for Cleveland."
+- The same entry twice: kept once, shown as sent.
+## Questions for the operator
+1. Do you measure all three, or only flange height at night?
+2. Phone in the hand, or a tablet on the press guard?
3
⏺ Pull request #31 adds docs/screens/operator-first-piece.md: one screen, three fields, no code. Two questions at the end need the operator's answer before anything is built.
Claude Code reads your four documents first, then writes the plan. The fields here are the stamping plant's; yours follow your characteristics table.
  1. It reads the matrix to find who may use the screen. If it does not, say: Read docs/matrix.json first.
  2. Each field comes from the characteristics table, with its unit and limits. No invented fields.
  3. The refusals and questions are the most valuable part: they become tests and corrections.

Check it worked

The pull request has one new file, docs/screens/operator-first-piece.md, with fields, the floor rules, what happens offline, what can be refused, a text sketch and a list of questions.

If it goes wrong

Claude Code started writing the page anyway

Say: Stop and remove the code. I need the plan in plain words first, as asked. A screen nobody has checked with the operator is a screen you build twice.

The plan adds fields the intent never mentions (photos, comments, a signature pad)

Say: Move every field the intent and the paper form do not need under a heading Not now, with the reason. Every extra field is a tap the operator makes forever.

It lists a refusal you do not understand

Ask: Explain refusal N to me as you would to the operator, and say which rule in the schema or the matrix causes it. If no rule causes it, it should not be in the plan.

Step 2

Check the plan with an operator, at the press

20 minutes

Why

The operator knows what the plan cannot: whether gloves come off to measure, where the tablet would hang, which value they skip at night. Each answer is a field, a size or a rule. Finding it at the press costs twenty minutes; finding it after go-live costs a rebuild, a retest and the operator's trust.

Do this

Print the text sketch from the plan, or draw it on paper at full phone size (the Form Builder tool in the course pack does the same, if you use it). Take it to the press where the screen will be used, at the time of a real die change, with the area supervisor's permission and the plant's safety equipment. With the operator:

  • Hold it where it will be used. Phone in the hand or tablet on a stand? Measure the distance to their eyes. Capital letters must be at least that distance divided by 156 (700 mm gives 4.5 mm).
  • Tap it in their gloves. Ask them to point at each field and the Save button with a gloved finger. Any target they hesitate over is too small or too close to another.
  • Walk the task. "The die is changed. What do you measure first? What do you write down?" Note any value they record that the plan lacks, and any field they never fill.
  • Answer the questions at the end of the plan, in their words.

Then give Claude Code the answers:

Paste into Claude Code, after replacing the <...> parts
The operator on press <number> checked docs/screens/operator-first-piece.md with me at the press:
1. <paste their answer to question 1>
2. <paste their answer to question 2>
The device will be <a phone in the hand | a tablet on a stand>, read from <distance> mm. They also said: <anything else they changed>.

Update the plan to match, including the minimum capital-letter height for that distance, add a line "Checked with the operator on press <number> on <today's date>" at the top, and push to the same pull request.

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

You will see recreated screen

github.com/acme-ops/acme-platform/pull/31/files
ConversationCommitsFiles changed
docs/screens/operator-first-piece.md
Checked with the operator on press 03 on 2026-10-261
DeviceTablet on a stand at 700 mm: capital letters at least 4.5 mm. Gloves stay on.
Burr heightMeasured only when flange height is outside its limits: optional, blank means not measured.2
The plan on GitHub after the operator's answers: a sign-off line, and changes that came from the press, not from the intent.
  1. Who checked it, where and when.
  2. A rule that came from the press. This is what the step is for.

Check it worked

docs/screens/operator-first-piece.md is merged on main, with the sign-off line, the device and distance, and no open questions.

Fastest path

Go at a real die change, not between them. You see the task done, the gloves and the light as they are, and one visit answers every question.

If it goes wrong

The operator wants the screen to decide hold or release

That is the quality lead's decision (your intent says so). Write their wish in the plan under Not now, and show them the supervisor review in Session 13: it is where an out-of-limit result gets a person's decision quickly.

The operator's gloves do not work on the touchscreen at all

Many work gloves do not register on a phone or tablet. Ask the safety lead whether touchscreen-compatible gloves are allowed at that press, and test with them. If not, a stylus on a lanyard or a larger tablet with 64 px targets everywhere are the usual answers. Record the choice in the plan.

Knowledge check

Operators at the press wear touchscreen gloves. Under the course rule, how big must the Save button be?

Knowledge check

The operator leaves burr height blank because they did not measure it. What should be saved?

References

  1. Apple Human Interface Guidelines: Accessibility. https://developer.apple.com/design/human-interface-guidelines/accessibility
  2. W3C: Understanding WCAG 2.2 Success Criterion 2.5.8 Target Size (Minimum). https://www.w3.org/WAI/WCAG22/Understanding/target-size-minimum.html
  3. W3C: Understanding WCAG 2.2 Success Criterion 2.5.5 Target Size (Enhanced). https://www.w3.org/WAI/WCAG22/Understanding/target-size-enhanced.html
  4. MDN Web Docs: inputmode. https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/inputmode
  5. National Eye Institute: Color blindness. https://www.nei.nih.gov/learn-about-eye-health/eye-conditions-and-diseases/color-blindness
  6. W3C: Understanding WCAG 2.2 Success Criterion 1.4.3 Contrast (Minimum). https://www.w3.org/WAI/WCAG22/Understanding/contrast-minimum.html

Chapter 2 · Session 12

Build it with one complete brief

One brief, in the Session 3 template, with its acceptance checks written first, turns the signed-off plan into the screen, the outbox that keeps entries through a network drop, and the tests that prove both. You read Claude Code's answers to seven questions; GitHub runs the proof.

40 min2 stepsOne pull request

By the end of this chapter you can

  • Explain the outbox: an entry kept on the device, with an id made there, accepted by the database exactly once.
  • Give Claude Code one complete brief that builds the screen, the outbox and its tests in one pull request.
  • Read the change through seven questions, each answered with the line that proves it.

Working when the network drops

Every plant has a dead spot. An operator who loses an entry once goes back to paper. A plain web form sends the entry when the operator taps Save; if the network is down the entry is gone. Worse is the half-failure: the entry reaches the database, the reply is lost, the device thinks it failed and sends it again, and the first-piece result is recorded twice.

Retry without and with an idLeft: a retried send creates two rows. Right: the tablet's id makes the second insert a no-op. Without an id made on the tabletWith an id made on the tabletSend checkSend check a91f…Reply lost in a dead spotReply lost in a dead spotTablet sends againTablet sends againServer2 rows: thecheck countedtwiceServer1 row: secondinsert ignored,same idPhones retry. The record must be the same however many times it arrives.
Why the id is made on the device. With it, the second arrival is recognised and ignored.

The answer is an outbox on the device:

  • When the operator taps Save, the screen makes an id for each result on the device (crypto.randomUUID() [1]) and keeps the entry in the browser's IndexedDB storage, which survives a reload or a closed tab [2]. The screen says Saved on this device.
  • A small sender tries to send each waiting entry, waiting a little longer after each failure (backoff). An entry leaves the outbox only when the database confirms it.
  • The inspections table gets a new column, client_id, that must be unique. A second arrival with the same id is ignored [3], so a retry can never make a second row. The column arrives as a new migration: Session 5's rule that an applied migration is never edited still holds.
  • A service worker, a small script the browser keeps beside the page, stores the screen and the part's limits so the screen opens with no network at all [4].
Working offline with an outboxThe form saves to an outbox on the tablet with an id made there; when the network returns the server inserts by id, so a retry never creates a second row. On the tabletFormid made here (UUID)Outboxkept in IndexedDBStatus pill"2 waiting to send"network dropsand comes backOn the serverInserton conflict (id)do nothingRecordexactly one rowReply: savedoutbox removes the entry
The outbox, end to end. The record is created exactly once, however many times the network drops.
Outbox entry statesAn entry goes from queued to sending to sent; a network failure retries; a refusal by the server is kept and shown to the operator. Each outbox entry moves through these states; nothing is deleted until the server says savedQueuedSendingSentFailedretry with backoffRefused by the serverkept, shown to the operatorA network failure retries quietly. A refusal (a bad value, no access) needs a person, never a silent drop.
What happens to each entry. A network failure retries quietly. A refusal by the database needs a person, and is never dropped.

Why one complete brief

You learned the brief in Session 3: goal, context, acceptance checks written first, out of scope, and how to show it works. This step's brief is long because each line replaces a round of back and forth. It names the documents to read, the tests that must fail before the code exists, the files Claude Code must not touch, and what to report. One complete brief builds the screen, the outbox, the migration and the tests in one pull request, and Claude Code fixes its own red checks before it reports.

Two things in it are specific to this stack. This version of Next.js differs from older guides, so the brief tells Claude Code to read the guides in node_modules/next/dist/docs/ before writing a page or the service worker; request middleware is in proxy.ts [5]. And sign-in denies every route by default (Session 9), so a new page is refused for everyone until docs/matrix.json opens it for a role. The brief adds the screen to the matrix and regenerates the route list; it never edits the generated file by hand.

Step 3

One brief: the screen, the outbox and its tests

20 minutes

Why

Writing the brief with its acceptance checks first means the proof arrives with the screen, and you never merge a screen nothing tests. Putting the plan, the floor rules, the offline behaviour, the matrix change and the report you want into one prompt replaces the dozen messages it takes to add each rule as you remember it.

Do this

Paste into Claude Code
Save everything between the two lines of dashes below as docs/briefs/12-operator-first-piece.md on a new branch ui/operator-first-piece, commit it, then carry it out.
----------
# Brief 12: the operator's first-piece entry

## Goal
After a die change, an operator at a press records the first-piece results for the new lot, gloves on, at arm's length, even where the wi-fi drops, and every result reaches the inspections table exactly once.

## Context (read first)
- docs/screens/operator-first-piece.md (signed off by the operator): the screen, field by field.
- docs/INTENT.md, docs/SCHEMA-PLAN.md, docs/matrix.json, docs/naming-standard.md, CLAUDE.md.
- supabase/migrations/ (inspections is append-only: a correction is a new row), lib/access/routes.ts and proxy.ts.
- This Next.js version differs from older guides. Before writing any page, the service worker or proxy code, read the relevant guides in node_modules/next/dist/docs/ and follow them.

## Acceptance checks (write these first, run them, show me they fail, then build)
Playwright tests in tests/e2e/operator-first-piece.spec.ts, at 360 and 390 px wide with touch, signed in as the operator test user, against the local Supabase database with the made-up seed, the same way the Session 9 route tests run. Never against the development or production project.
1. Every tappable control is at least 44 x 44 px with 8 px between them; Save is at least 64 px high and full width; every field's text is at least 16 px; there is no sideways scroll.
2. Each measurement field uses inputmode="decimal".
3. Three entries saved offline show "3 waiting to send"; back online the screen shows "All sent" and the database holds exactly the new rows for those three entries, never twice as many.
4. The same result sent twice with the same client_id makes one row.
5. An entry the database refuses (a lot at the other made-up site the Session 8 cross-site test uses) stays on the screen with a plain sentence saying why, is never shown as sent, and is never dropped.
6. A blank field is saved as no value, never 0, and the screen says "not measured".
7. Each row's recorded_by is the signed-in operator, set by the database from the session, whatever the page sends.
8. Signed out, /operator/first-piece sends you to sign in; signed in as a role the matrix does not give this screen, it is refused.

## What to build
1. A new migration (npx supabase migration new inspections_client_id) adding client_id uuid, unique, to inspections, with a pgTAP test that a second row with the same client_id is refused. Do not edit any existing migration.
2. The screen at /operator/first-piece, exactly as the plan describes. Add it to the screens in docs/matrix.json for the operator role only, and regenerate lib/access/routes.ts with the existing generator. Do not edit generated files by hand.
3. The outbox: on Save, give each result a client_id from crypto.randomUUID(), keep the entry in IndexedDB, show "Saved on this device", and send in the background with backoff. Insert with the operator's own session, never the service role key, and treat a duplicate client_id as already sent. An entry leaves the outbox only when the database confirms it.
4. A service worker so the screen and the part's limits open with no network. Cache only this screen and the reference data it needs. Clear the outbox and the cache when a different person signs in.
5. A status line: "All sent" or "N waiting to send". Never "Online" from navigator.onLine.
6. Run the screen tests in CI on every pull request (in the existing phone check if there is one, otherwise as a new job).

## Out of scope
Supervisor review and the manager view (Session 13). Holding or releasing lots. Changing any existing test, check or limit. Touching the development or production project.

## How to show it works
Open a pull request titled "Operator first-piece screen". Wait for every check on GitHub to finish. Then report in plain words: each acceptance check, pass or fail, and how you showed it failing before the code existed; the new migration's file name; and the preview link. If a check fails, fix the code, never the check, and wait again before reporting.
----------

You will see recreated screen

claude — acme-platform
⏺ Bash(git add docs/briefs/12-operator-first-piece.md && git commit -m "Brief 12")
⎿ 1 file changed
⏺ Read(node_modules/next/dist/docs/…/progressive-web-apps.md)
⎿ Read 214 lines
1
⏺ Bash(npx playwright test tests/e2e/operator-first-piece.spec.ts)
⎿ 16 failed (page /operator/first-piece does not exist yet)
2
⏺ Bash(npx supabase migration new inspections_client_id)
⎿ Created new migration at supabase/migrations/20261027091200_inspections_client_id.sql
⏺ Write(docs/matrix.json)
  "screens": {
+ "/operator/first-piece": { "operator": "use" },
3
⏺ Bash(gh pr checks --watch)
⎿ c1-build pass · schema pass · access pass · c9-phone pass · Vercel Preview ready
⏺ Pull request #32 is green. All 8 acceptance checks pass at 360 and 390 px; before the code existed all 16 runs failed. New migration: 20261027091200_inspections_client_id.sql. Preview: https://acme-platform-git-ui-operator-first-piece-acme-ops.vercel.app/operator/first-piece
Claude Code saves the brief, writes the tests first and shows them failing, then builds until GitHub's checks are green.
  1. It reads this Next.js version's own guide before writing the service worker. If it does not, say: Read the guides in node_modules/next/dist/docs/ first.
  2. Red first: the tests fail because nothing exists yet. A test that never failed proves nothing.
  3. The screen opened for the operator role only, in the matrix. Default deny keeps it shut for everyone else.

Check it worked

Pull request Operator first-piece screen is green on GitHub, and Claude Code's report lists all eight acceptance checks as passing and says how each was shown failing first.

Fastest path

"Wait for every check and fix it before reporting" saves a whole round trip: Claude Code reads its own red checks and fixes them while you do something else. Leave it running and come back to the report.

If it goes wrong

The page exists, but every role, even operator, is sent to sign in or refused

That is default deny working: the screen is not in docs/matrix.json, or the route list was not regenerated. Say: The new screen is refused for the operator. Add it to the screens in docs/matrix.json for the operator role and regenerate lib/access/routes.ts with the generator. Do not edit the generated file or the proxy by hand.

A check named for a list fails (the routes or the policies), though the screen works

The generated list no longer matches the matrix. Say: The "<check name>" check failed. Read its log, run the command that regenerates the list, commit the result, and show me what changed in it. If the list shows a screen open to a role I did not ask for, stop and tell me.

Saving fails with "new row violates row-level security policy"

An insert that returns its new row also needs the right to read it. Say: The insert into inspections is refused by row-level security. Check the operator's read right covers the row after the insert. Do not use the service role key. If the matrix must change, show me the change and wait.

Claude Code made the tests pass by changing them (a smaller size, a skipped test)

Say: Undo every change to the acceptance checks. Fix the screen, not the check. If you think a check is wrong, explain why and wait. Read the list of changed files on every pull request before the summary.

It reports success but a check on GitHub is red

Say: The check on the pull request is red. Run gh pr checks, read the failed log, fix the cause and wait for green before you report. We learned to trust the check on GitHub, never the summary.

It tries the same failing fix again and again

After the second identical failure, say: Stop. Do not try again yet. Tell me what failed (quote the error), what you have tried, and whether the cause is in our code or outside it.

Step 4

Read the change through seven questions

15 minutes

Why

You do not need to read TypeScript to review a screen. You need to know it does what the plan says, keeps the floor rules and the access rules, and invents nothing. Seven fixed questions, each answered with the file and line that proves it, turn a large change into yes-or-no answers you can check in the Files changed tab, and catch the plausible shortcuts agents take.

Do this

Paste into Claude Code
Explain pull request "Operator first-piece screen" to me as you would to the operator. Then answer each question below with Yes or No, the file and line that shows it, and anything I should worry about:

1. Does the screen show only what docs/screens/operator-first-piece.md lists, and nothing extra?
2. Is the client_id change a new migration, with client_id unique, and is every existing migration unchanged?
3. Is every insert made with the operator's own session, never the service role key, and does recorded_by come from the database, not from the page?
4. Is there anywhere a value is shown or saved that nobody typed: a 0 for blank, a default, a sample number, a hard-coded limit instead of the characteristics table?
5. Does the screen say "sent" only after the database confirmed it, and keep every refused entry with its reason?
6. Was the screen added to docs/matrix.json for the operator role only, and lib/access/routes.ts regenerated rather than edited?
7. Did any existing test, check, limit or CI step change?

Do not change anything. If any answer is not what it should be, say what you would change and wait.

You will see recreated screen

claude — acme-platform
⏺ 1 Yes. Three fields, the context bar and the status line, as the plan lists (app/operator/first-piece/page.tsx, lines 12–88). 2 Yes. One new file, 20261027091200_inspections_client_id.sql; client_id uuid unique (line 3). No other migration changed. 3 Yes. lib/outbox.ts line 41 inserts with the signed-in client; recorded_by defaults to auth.uid() in the table (Session 5). The page sends no user id. 4 No issues. Blank becomes null (line 66). Limits come from characteristics (line 23). 5 Yes. An entry is removed only on a confirmed insert or a duplicate client_id (lib/outbox.ts lines 52–60); refusals are kept with the message (line 71). 6 Yes. One line in docs/matrix.json; routes.ts regenerated (its header says so). 7 No existing test or check changed.1
⏺ One note: the burr field is optional, as the operator asked, so a blank burr is not an error. If the quality lead wants burr measured on every lot, that is a change to the plan, not to the code.2
The review: seven answers, each with the line that proves it.
  1. Seven answers with file and line: each can be checked in the Files changed tab.
  2. The note is where the real findings are. This one is a question for the quality lead, not a bug.

Check it worked

Questions 1, 2, 3, 5 and 6 are Yes; questions 4 and 7 find nothing. Any note has been answered or turned into a change.

If it goes wrong

An answer is not what it should be

Say: Make the change you described, push it, wait for every check to be green, then answer the seven questions again.

Question 4 finds a made-up or default number

Say: Remove it. Where there is no value, show "not measured" or "no data", and add a test that renders the screen with no data and expects those words. Our own platform once showed a savings counter that ticked up by itself, a chart graded on twelve hard-coded points, and seven admin users who did not exist. Each looked finished.

Question 3 shows the service role key, or a user id sent from the page

Stop: do not merge. The service role key ignores every access rule, and a user id from the page can be anyone's. Say: Insert with the operator's own session only, and let the database set recorded_by from the session. Add a test that two different operators each save an entry and each row records the right person.

Knowledge check

The database saved an entry but the reply was lost in a dead spot, so the device sends it again. What stops a second row?

Knowledge check

The new page is refused for every role, even operator, though the code is right. What is the likely cause?

References

  1. MDN Web Docs: Crypto.randomUUID(). https://developer.mozilla.org/en-US/docs/Web/API/Crypto/randomUUID
  2. MDN Web Docs: IndexedDB API. https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API
  3. PostgreSQL Documentation: INSERT (ON CONFLICT clause). https://www.postgresql.org/docs/current/sql-insert.html
  4. MDN Web Docs: Service Worker API. https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API
  5. Next.js Docs: Progressive Web Apps guide. https://nextjs.org/docs/app/guides/progressive-web-apps
  6. Supabase Docs: JavaScript client, insert data. https://supabase.com/docs/reference/javascript/insert

Chapter 3 · Session 12

Prove it: on a phone, offline, and in CI

Green checks are where you start, not where you stop. You open the preview on a real phone, in gloves, at the press distance; you take it offline and count the rows; you make Claude Code show that the screen tests fail when the screen is broken; then you merge and let the deploy apply the migration.

35 min4 stepsEnds with a gate

By the end of this chapter you can

  • Apply the branch's migration to the development project yourself, and open the preview on a phone.
  • Check the screen in gloves and with a ruler, and take it offline by hand.
  • Prove the screen tests can fail, then merge and confirm the deploy applied the migration.

The screen testing protocol

These are the checks every operator screen in this course must pass before it merges. Each one is here because we shipped without it once:

CheckWhat it provesWhy it is here
Targets, fields and no sideways scroll at 360 and 390 pxThe screen works on the smallest phones operators carrySizes that look fine on a laptop are too small under a gloved thumb
Offline: N entries saved, N rows arrive, never 2NNo entry is lost or doubled by a dead spotA doubled first-piece result corrupts every count above it
Refused entries kept, with the reasonThe screen never says saved when the database said noWe shipped a button that reported every message sent while none left the building
Blank is not 0Nothing on screen or in the table was inventedAn unreadable sensor shown as 0 is a false reading, not a missing one
The author comes from the sessionThe right person is on every recordOn our platform every record once said it was created by the founder, whoever was signed in
Signed out and wrong-role visits refusedDefault deny still holds for the new screenA new page is the easiest place for an open route to appear
Each test shown failing firstThe test can catch the fault it is named forWe found tests that could never fail: one reported 350 pages present and 0 absent
Step 5

Open the preview on a phone, in gloves, at the press

15 minutes

Why

The preview is the pull request running at its own address, on the development project's made-up data (Session 11 pointed previews there), before anything reaches the floor. Opening it on the real device, in gloves, at the real distance, finds what no test at a desk can: glare, a thumb that cannot reach, a letter too small at 700 mm. The new column must exist in the development project first, and changing a database is kept for a person.

Do this

In a terminal (not inside Claude Code), apply the branch's migration to the development project. It asks for that project's database password: copy it from the password manager entry Supabase: acme-platform-dev database password.

Terminal or PowerShell
cd ~/code/acme-platform && git fetch && git switch ui/operator-first-piece && npx supabase link --project-ref tsrqponmlkjihgfedcba && npx supabase migration list
Terminal or PowerShell
npx supabase db push

From Session 11 on, production gets migrations only from the deploy workflow on merge. Your computer stays linked to the development project. Then open the pull request and its preview link:

Open

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

Open Operator first-piece screen, then the Vercel comment's Visit Preview. Send the link to your phone and add /operator/first-piece if it is not there.

Sign in as the development project's operator test user. Then, at the press, with the operator:

  • Enter a lot's first piece ten times in gloves. Count every mis-tap and write down what was hit instead.
  • Hold a ruler against a capital letter in a field label and in an entered value. Each must be at least the distance from the plan divided by 156.
  • Enter a value outside its limits. The value is the only thing in colour, and the words say by how much and which way.

You will see recreated screen

Terminal
$ npx supabase migration list
Local | Remote | Time (UTC)
20261016091500 | 20261016091500 | 2026-10-16 09:15:00
20261027091200 | | 2026-10-27 09:12:001
$ npx supabase db push
Do you want to push these migrations to the remote database? • 20261027091200_inspections_client_id.sql [Y/n] y2
Finished supabase db push.
migration list shows the branch's new file on your computer (Local) but not yet in the development project (Remote). db push applies exactly that file to the development project.
  1. The new migration, on the branch only.
  2. Check the prompt names the development project's migration, and only that one.

You will see recreated screen

acme-platform-git-ui-operator-first-piece-acme-ops.vercel.app/operator/first-piece
First piece · lot L-04121
Cleveland · Press 03 · part 7741 · Shift B · signed in: operator (test)
Hole position (mm) · limits 11.90 to 12.1012.04
Flange height (mm) · limits 24.80 to 25.2025.31
Burr height (mm) · 0.10 maximumnot measured3
Save4
The preview on the operator's phone. One task, the context on top, one value outside its limits in words, and the waiting count at the bottom.
  1. Who and where, always shown: a shared tablet never records under the wrong press or person.
  2. The abnormal value in words, not colour alone.
  3. Blank stays blank. Nothing is invented.
  4. Full width, at the bottom, at least 64 px.

Check it worked

Ten gloved entries with no mis-tap you could not explain, letters at least the distance divided by 156, and the out-of-limit value named in words. Write any finding as a comment on the pull request.

Fastest path

Do this at the same press visit as Step 2's next die change: the operator, the gloves and the light are all there, and their comments go straight onto the pull request.

If it goes wrong

The preview asks me to sign in to Vercel

That is Vercel's Deployment Protection: previews are only for your team. Sign in to Vercel on the phone with your acme.com account, then sign in to the platform. A refusal from Vercel before the platform's own sign-in page is not your code.

The preview shows "column client_id does not exist"

The migration is on the branch but not in the development project. Run the two commands above. If migration list shows it under Remote already, ask Claude Code: The preview says column client_id does not exist although the development project has the migration. Check which Supabase project the preview's environment points at, by variable name only.

Remote migration versions not found in local migrations directory

The development project has a migration your branch does not (another branch was pushed there). Do not force anything. Merge main into the branch first (ask Claude Code: Merge origin/main into this branch, no rebase, and push), then run the commands again. If it still differs, ask Claude Code to explain which versions differ without changing any project.

There is no operator test user in the development project

Create one by hand: tsrqponmlkjihgfedcba/auth/users" href="https://supabase.com/dashboard/project/tsrqponmlkjihgfedcba/auth/users" target="_blank" rel="noopener">Authentication, Users, Add user, Create new user, with an address at acme.com and Auto confirm on, password in the password manager. Then ask Claude Code for the SQL that gives that user the operator role at cle in memberships, and run it yourself in the development project's SQL editor. Never in production.

Gloved taps hit the wrong field

Comment on the pull request and say to Claude Code: Operators in gloves hit <field> when aiming at <field>. Increase the space between targets to at least 16 px and make every field 64 px high, keep the acceptance checks as they are, and wait for green.

Step 6

Take it offline by hand, and count the rows

10 minutes

Why

The outbox exists for the dead spot behind the press, so prove it there, not only in a test. Counting rows in the development project is the honest check: the screen saying All sent is a claim; the table is the evidence.

Do this

On the phone, with the preview open on the screen: turn on airplane mode. Enter three first pieces for three different lots. The screen must say 3 waiting to send. Close the browser tab and open it again from the history (still offline): the three must still be waiting. Turn airplane mode off and wait for All sent. Then count the rows:

Open

https://supabase.com/dashboard/project/tsrqponmlkjihgfedcba/sql/new

The development project's SQL editor. Paste the query below and press Run.

Supabase SQL Editor (development project)
-- Results saved from the new screen (they have a client_id), one line per lot. Each result must appear once.
select l.lot_code, count(*) as results, count(distinct i.client_id) as distinct_ids
from public.inspections i join public.lots l on l.id = i.lot_id
where i.client_id is not null
group by l.lot_code order by l.lot_code;

Then walk the real phone to the worst wi-fi spot in the plant, enter one more, walk back, and run the query again.

You will see recreated screen

supabase.com/dashboard/project/tsrqponmlkjihgfedcba/sql/new
Table EditorSQL EditorDatabaseAuthentication
select l.lot_code, count(*) as results, count(distinct i.client_id) as distinct_ids …
1
lot_coderesultsdistinct_ids
L-041233
L-041333
L-041422
Three lots entered offline, each result recorded once: results equals distinct_ids on every line.
  1. Results equal distinct ids: nothing doubled. L-0414 has two because burr was not measured, and blank is not a row.
  2. If a lot is missing, its entry is still waiting or was refused: look at the phone.

Check it worked

Every entry made offline is in the table exactly once, and the phone says All sent. Note the date and the place you tested in the pull request.

If it goes wrong

The phone says All sent but a lot is missing from the table

Stop: the screen claims success it did not have. Say to Claude Code: An entry made offline shows as sent but is not in inspections. Find where the outbox removes an entry without a confirmed insert, fix it so only a confirmed insert or a duplicate client_id removes it, and add a test for this case that fails before the fix.

A lot shows results greater than distinct_ids

Two rows have the same client_id, so the unique rule is missing in this database. Run npx supabase migration list: the client_id migration must be under Remote. If it is, ask Claude Code why a duplicate client_id was accepted.

After reopening the tab offline, the screen does not load

The service worker is not caching the screen. Say: With no network, /operator/first-piece does not open. Read the service worker guide in node_modules/next/dist/docs/ again, fix the caching for this screen and its reference data only, and add a Playwright test that opens the screen offline after one online visit.

Step 7

Make Claude Code show the screen tests can fail

5 minutes

Why

A test that cannot fail is worse than none: it is green while the screen is broken, and everyone trusts it. We found tests that only checked a word was present in a file, and a probe that could only ever answer present. Planting each fault once, and watching the test turn red, is the cheapest proof the tests guard what their names say.

Do this

Paste into Claude Code
On the branch ui/operator-first-piece, without committing anything, prove three of the acceptance checks can fail:
1. Make the Save button 40 px high; run the size test; show it fails; undo.
2. Make the outbox remove an entry before the database confirms; run the offline test; show it fails; undo.
3. Save a blank field as 0; run the not-measured test; show it fails; undo.
For each, show me the command, its exit code and the last lines of its output, run directly, not through a pipe. Finish with git status showing nothing changed, and add the three results to the pull request description under "Shown failing".

You will see recreated screen

claude — acme-platform
⏺ Bash(npx playwright test -g "targets")
⎿ 1 failed: Save is 40 px high, expected at least 64 · exit code 1
1
⏺ Bash(npx playwright test -g "offline")
⎿ 1 failed: expected 3 rows, received 0 · exit code 1
⏺ Bash(npx playwright test -g "not measured")
⎿ 1 failed: expected no burr height result, found value_mm 0 · exit code 1
⏺ Bash(git status --short)
⎿ (nothing: every planted fault undone)
2
⏺ All three checks failed when their fault was planted and pass with it removed. The results are in the pull request description under Shown failing.
Each planted fault turns its test red; the branch ends unchanged.
  1. The exit code, not the summary: 1 means the test failed.
  2. Nothing committed. The proof is in the description, not in the code.

Check it worked

The pull request description has a Shown failing section with three red results, and the checks on GitHub are still green.

If it goes wrong

A planted fault leaves its test green

The test cannot catch what it is named for. Say: Test <name> stayed green with its fault planted. Rewrite it so it checks what the operator would see or what the database would hold, show it failing with the fault and passing without, and push.

Claude Code shows output piped through tail or head

A pipe reports the exit code of the last command, not of the tests. Say: Run the test command on its own and show me its exit code.

Step 8

Merge, and let the deploy apply the migration

5 minutes

Why

Since Session 11, merging is what changes production: the deploy workflow applies the new migration before the new code goes live, and the daily check compares production with main. Watching this first screen go through proves the pipeline carries a schema change and a screen together, with no person touching the live database.

Do this

Owner two reads the pull request (description, Shown failing, Files changed), opens the preview, approves; merge it. Then watch the deploy:

Open

https://github.com/acme-ops/acme-platform/actions/workflows/deploy.yml

The latest run, for the merge commit. Open it and find the migration step.

Open

https://acme-platform.vercel.app/operator/first-piece

The live screen. Signed out, it must send you to sign in.

You will see recreated screen

github.com/acme-ops/acme-platform/actions/workflows/deploy.yml
deploy · Operator first-piece screen (#32)
The deploy run after the merge: the migration applied before the new code went live.
  1. The migration reached production through the pipeline, not from anyone's laptop.
  2. The daily comparison from Session 11, green.

Check it worked

The deploy run is green with the migration applied, and https://acme-platform.vercel.app/operator/first-piece sends a signed-out visitor to the sign-in page.

If it goes wrong

The deploy run fails at the migration step

Production keeps the old code: the pipeline stops before the new code goes live. Do not run anything against production yourself. Say to Claude Code: The deploy failed at the migration step. Read the log and explain in plain words why, without changing any project. Then follow docs/runbook.md.

The production deploy shows Canceled

A newer merge replaced it within a minute. A canceled deploy that a newer ready deploy replaced is not a failure: check the newest run instead.

The live screen opens without sign-in

Stop and treat it as an incident (docs/runbook.md): the route list or the proxy is wrong. Ask Claude Code which file lets it through, without changing anything, and roll back first.

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

Knowledge check

The phone says All sent, but a lot is missing from the table. What does that show?

Knowledge check

Why does a person, not Claude Code, apply the branch's migration to the development project?

References

  1. Playwright: Emulation (viewport, touch, offline). https://playwright.dev/docs/emulation
  2. Playwright: BrowserContext.setOffline. https://playwright.dev/docs/api/class-browsercontext#browser-context-set-offline
  3. Vercel Docs: Deployment protection. https://vercel.com/docs/deployment-protection
  4. Supabase CLI reference: supabase db push. https://supabase.com/docs/reference/cli/supabase-db-push
  5. Chrome for Developers: Network features reference (DevTools). https://developer.chrome.com/docs/devtools/network/reference

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. Why is the operator screen built before the supervisor and manager screens?
2. What is the course rule for the smallest tap target on any screen?
3. A tablet will be read from 700 mm. About how tall must a capital letter be?
4. Why does Claude Code write a plain-English screen plan before any code?
5. A measurement field was left blank. What is saved?
6. What stops a retried entry from making a second row?
7. Where does the outbox keep entries so a closed tab does not lose them?
8. The database refuses an entry because the lot is at a site the operator is not a member of. What should the screen do?
9. A new page is refused for every role, even operator. What is the likely cause?
10. Why does the brief tell Claude Code to read node_modules/next/dist/docs/ first?
11. Why make Claude Code plant each fault and show the screen test fail?
12. After merge, how does the client_id migration reach production?