Skip to the lesson
CivOps AI Academy · F09The Quality Clamps: Ten Checks Every Change Must Pass
0%

Chapter 1 · Session 10

Ten clamps, written down and run on every change

A fixture clamp holds a part so the operation cannot drift. A quality clamp holds a change so a broken rule cannot reach the floor. Most of yours already run, spread over three workflows. This chapter writes all ten down, runs them as one workflow with one named job each, and adds the check that names a missing or malformed key without printing it.

40 min3 stepsOne workflow, ten names

By the end of this chapter you can

  • Name the ten clamps, the rule each one keeps and the session that made the rule.
  • Have Claude Code write the clamp register from what really runs, and put all the checks in one workflow.
  • Add a start-up check that names a missing or malformed key, never its value.

Why clamps, and why now

Every session so far wrote a rule: names follow the standard, history is never changed, every table has access rules, every route is closed until the matrix opens it. A rule in a document holds only while everyone remembers it. From here on, Claude Code and later several agents at once write code faster than anyone can read it all. A quality clamp is a check that runs on every pull request and blocks the merge when a rule is broken. It is mistake-proofing (poka-yoke) applied to software: design the process so the mistake cannot pass, rather than relying on someone to notice [1]. Secure development frameworks ask for the same: checks built into the pipeline, not done from memory [2].

A clamp is a gaugeLeft: a part goes through a go/no-go gauge to a good or reject bin. Right: a change goes through a clamp to merge or a red check. On the plant floorIn the platformPartGo/no-go gaugeGood binReject binChangeClampMergeRed checkThe gauge is checked with a known-badmaster part at the start of each shift.The clamp is checked with a known-badchange (a canary) on a schedule.A gauge nobody verifies, and a clamp nobody audits, pass bad work quietly.
A clamp is a gauge. It sorts every change into merge or red, the way a go/no-go gauge sorts parts. Like a gauge, it has to be verified (Chapter 3).
The ten quality clampsA pull request on the left passes through ten clamps in two rows, C1 Build to C10 Review, before reaching main on the right. Every pull request passes all ten clamps before it can reach mainPullrequestfrom youor an agentC1 Buildcompiles cleanC2 Lintrules + namesC3 Testsfresh cloneC4 Schemamigrations applyC5 AccessRLS every tableC6 Denynew route closedC7 Secretsno keys in codeC8 Packagesno known holesC9 Phone360/390 px rulesC10 Reviewa person approvesmainthen itdeploysOne red clamp blocks the merge. Nine checks run by machine; the tenth is a person.
The ten clamps. Every change, written by a person or by Claude Code, passes all ten before it can reach main.
ClampChecks thatRuns asRule from
C1 BuildThe code compiles and the types agreenpx tsc --noEmit and npm run buildSession 3
C2 LintCode follows the agreed rules, and every name follows the naming standardnpm run lint and scripts/check-names.mjsSessions 3 and 4
C3 TestsEvery test passes on a fresh clone, including the start-up key checknpm ci then npm testSession 3, this session
C4 SchemaThe migrations alone rebuild the database, the seed loads, and no applied migration was editedA fresh Supabase database in CI, supabase test dbSessions 5 and 6
C5 AccessEvery table has row-level security, and each role is allowed and refused as the matrix saysThe access tests on the fresh databaseSession 8
C6 DenyEvery route is in the matrix and answers as it says, signed out and as each rolenpm run test:routesSession 9
C7 SecretsNo key, password or token is in the code or its historygitleaks over every commitSession 1
C8 PackagesNo installed package has a known high or critical vulnerabilitynpm audit --audit-level=highThis session
C9 PhoneEvery page works at 360 and 390 px: no sideways scroll, 44 px taps, 16 px fieldsA Playwright check at both widthsThis session (Session 12 extends it)
C10 ReviewA person other than the author approved, and a code owner approved changes to sensitive filesThe protect main ruleset and CODEOWNERSSession 1, this session
Step 1

Have Claude Code write the clamp register from what really runs

10 minutes

Why

Before adding anything, find out what already runs, from GitHub's own record rather than from file names: a workflow that mentions a check is not proof it runs or can fail. The register (docs/clamps.md) is where every clamp, its job name and its last proof are written down, kept in the repository so every change to it is reviewed. The same prompt adds the standing rule that Claude Code never weakens a check to get to green.

Do this

Paste into Claude Code
Read every file in .github/workflows/, package.json, CLAUDE.md and docs/KEYS.md. Then, with gh, look at the checks on the last three merged pull requests and on main.

On a new branch clamps/register:

1. Write docs/clamps.md with a table of the ten clamps: C1 Build, C2 Lint (with the naming check), C3 Tests, C4 Schema, C5 Access, C6 Deny, C7 Secrets, C8 Packages, C9 Phone, C10 Review. Columns: Clamp, Rule it keeps, Session the rule came from, Job that runs it today (workflow and job name, or "missing"), Command, Required on main (yes or no), Last canary (date), Result (link). Fill the first six columns from what GitHub actually ran, not from what a file says. Leave the last two empty.

2. Add this standing rule to CLAUDE.md: "Never edit, skip, loosen or delete a test, a check, a limit or a CI step to make something pass, and never use a different command to do something you were refused. If you think a check is wrong, stop and explain why; I will decide."

Open a pull request titled "Clamp register" and tell me, in plain words, which clamps run today, which are missing, and whether any check has been red on main in the last month.

You will see recreated screen

claude — acme-platform
⏺ Bash(gh pr checks 33)
⎿ ci / lint pass · ci / typecheck pass · ci / test pass · schema / test pass · routes / test pass
1
⏺ Write(docs/clamps.md)
+| Clamp | Rule it keeps | From | Job today | Command | Required |
+| C4 Schema | migrations rebuild the database from nothing | 5, 6 | schema / test | supabase test db | no |
+| C7 Secrets | no key in the code or its history | 1 | missing | | no |
+| C10 Review | a person approves | 1 | protect main ruleset | | yes (1 approval) |
2
⏺ Pull request #40 adds docs/clamps.md. Six clamps run today across ci.yml, schema.yml and routes.yml; C7 Secrets, C8 Packages and C9 Phone are missing; C10 is one approval with no code owners. None of the checks is required yet, so a red check does not stop a merge. Main has been green for the last month. I added the standing rule to CLAUDE.md.
Claude Code reads the workflows and GitHub's own record of what ran, then writes the register.
  1. GitHub's own record of what ran: the evidence, not the file names.
  2. One row per clamp. Required is "no" for every check today: Step 5 changes that.

Check it worked

The pull request adds docs/clamps.md with ten rows and one rule in CLAUDE.md. Its "Job today" column matches the checks you can see on a recent pull request on GitHub.

If it goes wrong

Claude Code says a clamp exists because a file mentions it

We found three tests that only checked a word was present, and stayed green while the feature was broken. Say: For each clamp you marked as running, give me the link to a run on GitHub where that job ran, and say what would make it fail.

A check has been red on main for weeks and everyone ignores the email

We hit this: the live build ignored type errors but CI did not, and twenty-one of them failed CI on every push for weeks. Fix the backlog now, in its own pull request: Run npx tsc --noEmit and fix every error without any, ts-ignore or ts-nocheck unless you ask me first. Do not set the build to ignore type errors. A red check everyone ignores is worse than none.

Step 2

One workflow, one job per clamp

15 minutes

Why

When a check called "test" goes red, nobody knows which rule broke, and the temptation is to skip the whole thing. One job per clamp, named after it, tells everyone what broke before they open the log, and gives the ruleset ten clear names to require. One prompt that moves the existing checks and adds the three missing ones is much faster than adding them one pull request at a time.

Do this

Paste into Claude Code
Read docs/clamps.md and every workflow in .github/workflows/. On a new branch clamps/workflow:

1. Write .github/workflows/clamps.yml, run on every pull request and on push to main, with one job per clamp, named exactly c1-build, c2-lint, c3-tests, c4-schema, c5-access, c6-deny, c7-secrets, c8-packages, c9-phone. Move the steps from ci.yml, schema.yml and routes.yml into the matching jobs without changing what they test.
2. c7-secrets: run gitleaks over the whole history (fetch-depth 0) from its official container image with a pinned version, with output redacted. Do not use the gitleaks GitHub Action, which needs a licence key for organisations.
3. c8-packages: npm audit --audit-level=high --omit=dev.
4. c9-phone: a Playwright check that opens every page the route test can reach, at 360 and 390 px wide, signed in as each role where needed, and fails on sideways scrolling, a tap target under 44 by 44 px or a form field under 16 px.
5. Every run step uses bash with set -euo pipefail. No continue-on-error, no || true, no output piped into tail or head. Do not set the build to ignore type or lint errors. Do not change any existing test.
6. When every new job has passed on this pull request, delete ci.yml, schema.yml and routes.yml in the same pull request, and update the Job today column in docs/clamps.md.

Open a pull request titled "Clamps", wait until every job has finished, and tell me each job's result in plain words. If one fails, explain why before changing anything that is not new in this pull request.

You will see recreated screen

claude — acme-platform
⏺ Write(.github/workflows/clamps.yml)
+defaults: { run: { shell: bash } }
+jobs:
+ c7-secrets:
+ steps:
+ - uses: actions/checkout@v4
+ with: { fetch-depth: 0 }
+ - run: set -euo pipefail; docker run --rm -v "$PWD:/repo" ghcr.io/gitleaks/gitleaks:v8.28.0 git /repo --redact
1
⏺ Bash(gh pr checks --watch)
⎿ c1-build pass · c2-lint pass · c3-tests pass · c4-schema pass · c5-access pass · c6-deny pass · c7-secrets pass · c8-packages fail · c9-phone pass
2
⏺ Pull request #41: eight clamps pass. c8-packages fails because one installed package has a published high-severity advisory with a fixed version available. That is a real finding, not a fault in the check. Shall I update that package in this pull request? I have not changed any limit.
Nine named jobs, each one rule. Claude Code waits for all of them before reporting.
  1. A pinned version: the check behaves the same tomorrow as today.
  2. A real finding on day one is normal. The fix is the package, never the level.

Check it worked

Pull request Clamps shows nine checks named c1-build to c9-phone, all green (after any package update you approved), and the old ci.yml, schema.yml and routes.yml are deleted in it.

Fastest path

Approve fixes to real findings (a package update) in the same pull request: it saves a second full CI run.

If it goes wrong

Claude Code lowers the audit level, skips a test or adds continue-on-error to get green

We hit this: an agent refused one command did the same thing by another route to get its change through. Say: Undo that. Changing a check needs my approval. Explain why it fails and what the real fix is. The standing rule from Step 1 is there for this.

c3-tests is green, but the tests had failed

A pipe such as npm test | tail -5 reports whether tail worked, not the tests; our main branch went red for this reason. Say: Show me every run step that pipes output, and make each one use set -o pipefail or no pipe.

c7-secrets flags a fake key in a test file

Say: Add an allow rule for that one file and that one rule only, with a comment saying why, and show me the change. Never allow a whole folder. If the key is real, treat it as stolen and rotate it the same day.

c4-schema fails after the move with "relation auth.users does not exist"

The job started a plain Postgres instead of Supabase. Say: Start the database in c4-schema and c5-access with the Supabase CLI, as the old schema.yml did.

Step 3

The start-up check: name a missing or malformed key, never print it

15 minutes

Why

A key that is missing or wrong usually fails quietly: the page says "Check your email" and nothing comes, or every test user lands on the sign-in page. We hit both: one key's value was the variable's own name, pasted in place of the key, and a GitHub secret that was never created was simply empty. A check when the app starts names the variable and what is wrong with it, and never prints the value, so nobody is tempted to paste it somewhere to look.

Do this

Paste into Claude Code
Read node_modules/next/dist/docs/ (the instrumentation guide and file convention) first: this is Next.js 16. Read .env.example and docs/KEYS.md (names only; do not open any .env file).

On a new branch clamps/key-check:

1. Add lib/env.ts with one check per environment variable the app reads, by name and expected shape: NEXT_PUBLIC_SUPABASE_URL starts with https:// and ends in .supabase.co (or is the local address in development and CI); the publishable or anon key and any secret key have the shape Supabase uses; nothing is empty, has spaces at either end, starts with NAME= or equals its own variable name.
2. Run the check when the server starts, from instrumentation.ts as the guide describes. For each problem, log one line with the variable's NAME and what is wrong ("is empty", "looks like a variable name", "does not start with https://"). Never log, return or show any part of a value.
3. On /status, show "Configuration: OK" or "Configuration: problem, see the server log", never the names or values.
4. Tests in npm test: a blank value, a pasted variable name, NAME=value and a wrong prefix are each reported by name; a good set passes; and no output ever contains the value used in the test. Show me the test failing with the check removed, then put it back.
5. Add a line to docs/KEYS.md saying the start-up check exists and where its messages appear.

Open a pull request titled "Start-up key check", wait for the clamps, and tell me what /status says on the Vercel preview.

You will see recreated screen

claude — acme-platform
⏺ Write(lib/env.ts)
+if (!value) return `${name} is empty`;
+if (value.trim() === name) return `${name} looks like a variable name, not a value`;
+if (/^[A-Z_]+=/.test(value)) return `${name} starts with NAME=: paste the value only`;
1
⏺ Bash(npm test -- env)
⎿ Without the check: 4 of 5 failed (shown on purpose). With it: 5 passed. No value appears in any output.
2
⏺ Pull request #42 is green. On the Vercel preview, /status says Configuration: OK. If a key is ever missing or malformed, the Vercel log will name it, for example "NEXT_PUBLIC_SUPABASE_URL is empty", and never show the value.
The check names the variable and the problem. The values in the test never appear in the output.
  1. Each message names the variable and the fault, nothing else.
  2. Red first, then green, and checked for leaked values.

You will see recreated screen

Terminal
▲ Next.js 16 · starting
[config] NEXT_PUBLIC_SUPABASE_ANON_KEY looks like a variable name, not a value1
[config] 1 problem: sign-in will not work until it is fixed
What the server log shows if a key is wrong. You see the name and the fault; nobody sees the key.
  1. The fix: paste the value only into Vercel's setting (or let the integration resync it). Never paste it into Claude Code to check.

Check it worked

Pull request Start-up key check is green with every clamp, Claude Code showed the test red without the check, and /status on the preview says Configuration: OK.

If it goes wrong

The log shows part of a key, even a few characters

Do not merge. Say: The start-up check prints part of a value. Remove every value from logs and messages, and add a test that fails if any value appears. If the log already went to Vercel, treat that key as exposed and rotate it.

The preview says Configuration: problem, but production is fine

Vercel holds separate values for Production, Preview and Development. Open acme-ops/acme-platform/settings/environment-variables" href="https://vercel.com/acme-ops/acme-platform/settings/environment-variables" target="_blank" rel="noopener">the environment variables and check the named variable is set for Preview. Names only: the values stay hidden.

Claude Code asks to read .env.local to see what the keys look like

Answer: No. Use .env.example and Supabase's documentation for the shapes. The deny rule from Session 1 blocks it anyway.

Knowledge check

A step runs npm test | tail -5 without pipefail, and a test fails. What does the clamp show?

Knowledge check

What should the start-up check write when a key is wrong?

References

  1. ASQ: What is mistake-proofing (poka-yoke)?. https://asq.org/quality-resources/mistake-proofing
  2. NIST SP 800-218, Secure Software Development Framework (SSDF) 1.1. https://csrc.nist.gov/pubs/sp/800/218/final
  3. GitHub Docs: Workflow syntax for GitHub Actions. https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions
  4. GNU Bash Reference Manual: Pipelines. https://www.gnu.org/software/bash/manual/html_node/Pipelines.html
  5. gitleaks: find secrets in Git repositories. https://github.com/gitleaks/gitleaks
  6. npm Docs: npm audit. https://docs.npmjs.com/cli/commands/npm-audit
  7. Next.js Docs: instrumentation.js file convention. https://nextjs.org/docs/app/api-reference/file-conventions/instrumentation

Chapter 2 · Session 10

Make them binding: code owners and required checks

A check that runs but cannot stop a merge is a suggestion. This chapter names who must review the database, sign-in and the checks themselves, then turns on the setting Session 1 left for now: required status checks in the protect main ruleset.

30 min2 stepsOne file, one setting

By the end of this chapter you can

  • Have Claude Code write .github/CODEOWNERS for the database, sign-in and access code and the checks.
  • Turn on required status checks and code owner review in the protect main ruleset yourself.
  • Say why only one named person may bypass the rules.

Running a check and requiring it are two settings

Today a red clamp colours the pull request, and the merge button still works. Without required checks, anyone, including an agent with merge rights, can put a change on main around a failed check. And nothing yet says that a change to the database, sign-in or the checks themselves must be read by someone who understands it. Two things fix that: a CODEOWNERS file, which makes GitHub ask named people to review changes to named paths [1], and required status checks in the ruleset, which keep the merge button shut until the named checks pass [2].

A required check blocks a mergeA pull request card lists five checks; C5 Access has failed and review is waiting, so merging is blocked. Pull request #42: add burr height to the inspection screenC1 BuildpassedC3 TestspassedC5 Accessfailed: table burr_checks has no row-level securityC9 PhonepassedC10 Reviewwaiting for a code owner's approvalMerging is blockedThe ruleset lists each clamp as a required check; the merge button stays shut until all are green.
A required check at work. C5 failed and no code owner has approved, so GitHub keeps the merge button shut.
Step 4

CODEOWNERS for the database, sign-in, access and the checks

10 minutes

Why

Some files decide who can see the plant's data or whether the checks mean anything: the migrations, the gate, the matrix, the workflows and the tests. A change to them must be read by an owner, not just anyone with approval rights. Listing the checks and tests too stops an agent quietly loosening a check to get to green, which we saw happen.

Do this

Paste into Claude Code
On a new branch clamps/codeowners, write .github/CODEOWNERS that requires a review from pat@acme.com or sam@acme.com for:
- supabase/ (schema, migrations, access rules and their tests)
- proxy.ts, lib/access/, scripts/gen-routes.mjs, scripts/gen-policies.mjs and the sign-in pages (find their folders)
- docs/matrix.json, docs/access-review.md, docs/KEYS.md and docs/clamps.md
- .github/ (the workflows and this file), the tests folders, CLAUDE.md and .claude/
Use the owners' email addresses; if GitHub cannot match an address to an account, tell me and I will give you the GitHub user names. Put a comment above each line saying why it is there. Open a pull request titled "Code owners", wait for the clamps, then open the file on GitHub with gh and tell me whether GitHub reports any errors in it.

You will see recreated screen

claude — acme-platform
⏺ Write(.github/CODEOWNERS)
+# The database: schema, migrations, access rules and their tests
+/supabase/ pat@acme.com sam@acme.com
+# Sign-in and the gate: who can open what
+/proxy.ts pat@acme.com sam@acme.com
+/lib/access/ pat@acme.com sam@acme.com
+/docs/matrix.json pat@acme.com sam@acme.com
+# The checks themselves: nobody loosens a clamp unseen
+/.github/ pat@acme.com sam@acme.com
+/tests/ pat@acme.com sam@acme.com
1
⏺ Pull request #43 is green. GitHub reports no errors in CODEOWNERS: both addresses match accounts in acme-ops. From the moment this merges and Step 5 is done, a change to any of these paths needs one of you to approve it.
A short file: each line a path and who must review it.
  1. Each path, then the owners. The later line wins when two lines match the same file, so keep it short and specific.

Check it worked

Pull request Code owners is green, and GitHub shows no error on the file. On a pull request that changes a migration, GitHub now lists the owners as requested reviewers.

If it goes wrong

GitHub says an owner is unknown or has no write access

The address is not the one on that person's GitHub account, or they are not in the acme-ops organisation. Use their GitHub user name with an @ instead, and check https://github.com/orgs/acme-ops/people.

The author is one of the two code owners and cannot approve their own change

Correct and intended: the other owner approves. That is why both are listed.

Step 5

Turn on required checks in the protect main ruleset

10 minutes

Why

This is the step Session 1 left for later, because there were no checks to require. Now there are ten. Requiring them means nothing reaches main with a red clamp, and requiring code owner review means the sensitive paths are read by an owner. Only owner one stays on the bypass list, for a genuine emergency, so every bypass has a name on it.

Do this

Open

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

Open the ruleset protect main.

Under Require a pull request before merging, tick Dismiss stale pull request approvals when new commits are pushed and Require review from Code Owners. Tick Require status checks to pass, choose Add checks and add each of c1-build, c2-lint, c3-tests, c4-schema, c5-access, c6-deny, c7-secrets, c8-packages and c9-phone. Check the Bypass list holds owner one only. Press Save changes.

Then turn on GitHub's alerts for vulnerable packages, which feed C8 between pull requests:

Open

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

Turn on Dependabot alerts.

You will see recreated screen

github.com/acme-ops/acme-platform/settings/rules
GeneralCollaborators and teamsRulesActionsAdvanced SecuritySecrets and variables
Ruleset nameprotect main
Enforcement statusActive ▾
Bypass listpat@acme.com1
Require a pull request before merging (1 approval)
Dismiss stale pull request approvals when new commits are pushed2
Require review from Code Owners
Require status checks to pass
3
Status checks that are requiredSource
c1-buildGitHub Actions
c2-lintGitHub Actions
c3-testsGitHub Actions
c4-schemaGitHub Actions
c5-accessGitHub Actions
c6-denyGitHub Actions
c7-secretsGitHub Actions
c8-packagesGitHub Actions
c9-phoneGitHub Actions
Block force pushes
Save changes
The protect main ruleset with the clamps required. Nine names, each one rule.
  1. One named person may bypass, for an emergency. Nobody else, and never an app.
  2. An approval given before Claude Code pushes more changes no longer counts.
  3. Exactly the job names from clamps.yml. A name that never reports leaves every pull request waiting.

Check it worked

Reload the ruleset: Active, nine required checks, code owner review on, owner one alone on the bypass list. Step 7 records the required checks in docs/clamps.md.

Fastest path

If a check name does not appear in the Add checks search, it has not run recently on this repository: open any pull request so the clamps run, then search again.

If it goes wrong

Every pull request waits with "Expected: waiting for status to be reported"

A required name does not match a job that runs, often after a job was renamed. Compare the ruleset's list with clamps.yml, name by name, and fix the ruleset to match. Never remove the requirement to get unblocked.

A pull request merged with a red check after this step

Someone on the bypass list used it, or the ruleset is in Evaluate mode. Check the ruleset's insights for who bypassed and why, set it to Active, and keep only owner one on the list.

Merging is now blocked on Claude Code's own pull request even though both owners approved earlier

Stale approvals are dismissed when new commits arrive. Approve again after reading the new commits. That is the point: the approval covers what is merged.

Knowledge check

The clamps run on every pull request, but a red one can still be merged. What is missing?

Knowledge check

Why are .github/ and the tests folders in CODEOWNERS, not just the database and sign-in?

References

  1. GitHub Docs: About code owners. https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners
  2. GitHub Docs: Available rules for rulesets. https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/managing-rulesets/available-rules-for-rulesets
  3. GitHub Docs: Creating rulesets for a repository. https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/managing-rulesets/creating-rulesets-for-a-repository
  4. GitHub Docs: Dependabot. https://docs.github.com/en/code-security/dependabot

Chapter 3 · Session 10

Prove they bite, and keep them honest

A gauge that has drifted passes bad parts without a sound. So does a clamp. Known-bad changes called canaries prove the clamps still catch what they claim; an honesty audit finds the ways a red result can read green; the register records the date.

35 min2 stepsEnds with a gate

By the end of this chapter you can

  • Run canaries: known-bad changes that must turn one clamp red, and are never merged.
  • Prove that a red check blocks a merge, from the second owner's account.
  • Audit the checks for escape hatches and tests that cannot fail, and date the register.

Why clamps drift

Clamps rarely break loudly. A job is renamed and the ruleset waits for the old name. A noisy check gets an escape hatch in a busy week. A test is skipped to unblock a release, or only checks that a word is present. Each time the pipeline stays green and the green means less. Plants solve this with known-bad master parts: before a shift relies on a gauge or an error-proofing device, someone feeds it a part that must be rejected [1]. A canary is the same for a clamp.

The four audit questionsA cycle of four questions asked of every clamp: required, bites, honest, recorded. 1 Required?Is it listed in theruleset as required?2 Bites?Does a known-badchange turn it red?3 Honest?No skips, no || true,no hidden exit codes?4 Recorded?Date and resultin the clamp register?Monthly, and afterany change to CI
The four audit questions, asked of every clamp each month and after any change to the workflows or the ruleset.
ClampA canary that must turn it red
C1 BuildGive a number a text value: const presses: number = "six";
C2 LintAdd a table name that breaks the naming standard, or a line your lint rules forbid
C3 TestsChange one expected value so an existing test fails
C4 SchemaEdit a migration that has already been applied
C5 AccessA migration that creates canary_c5 with no row-level security
C6 DenyA route the matrix does not list: /api/canary
C7 SecretsA made-up token in a recognised format (ghp_ and 36 random letters and digits). Never a real key
C8 PackagesPin a package to a version with a published high-severity advisory, such as lodash@4.17.15 [2]
C9 PhoneOne button 30 px tall, or one field with 14 px text
C10 ReviewTry to merge any canary: the button must refuse
A canary runA throwaway branch adds a table without row-level security; clamp C5 should go red. If it goes green, the clamp is broken. Branchaudit/canary-c5Known-badtable, no RLSC5 Accessruns in CIRed, as expectedclose the PR, delete the branch, log itGreen: the clamp is brokenstop and fix it before anything elseA canary is never merged. It exists only to prove the clamp still catches what it claims to catch.
A canary run for C5. Red is the good result. Green means the lock is open.
Step 6

Three canaries, and a merge that must be refused

15 minutes

Why

A clamp you have never seen go red is a clamp you hope works. Three canaries prove the three that guard the plant's data most directly: access rules, the gate and secrets. Having owner two try to merge one, from their own account, proves the ruleset really stops a red change; it is the test that shows the rule from Session 1 now has teeth.

Do this

Paste into Claude Code
Run three canaries. For each, create a branch from main, make the one known-bad change, push it and open a pull request whose title starts with "CANARY: do not merge":
- audit/canary-c5: a new migration that creates a table canary_c5 (id bigint primary key) with no row-level security.
- audit/canary-c6: a new route handler at /api/canary that returns "ok", not added to the matrix.
- audit/canary-c7: a file canary.txt with a made-up GitHub token: ghp_ followed by 36 random letters and digits. It must not be a real key.

Wait for every clamp on each pull request. Report in a table: canary, which clamps went red, which stayed green, and the link to each red run. Each canary should turn its own clamp red. Do not merge, approve or close any of them yet.

While they are open, owner two opens the C6 canary on GitHub and tries to merge it. The button must refuse. Then, in Claude Code:

Paste into Claude Code
Owner two tried to merge the C6 canary and was refused. Close all three canary pull requests without merging, delete their branches (gh pr close --delete-branch), and confirm main has no canary file.

You will see recreated screen

claude — acme-platform
⏺ Bash(gh pr checks 44 --watch)
⎿ c5-access fail: table canary_c5 has row-level security disabled
1
⏺ Canary results: C5 · #44 · c5-access red (canary_c5 has no row-level security), all others green C6 · #45 · c6-deny red (/api/canary is not in the matrix), all others green C7 · #46 · c7-secrets red (GitHub token pattern in canary.txt), all others green Each canary turned only its own clamp red. Nothing merged.2
Each canary turns its own clamp red. Red is the result you want.
  1. The clamp names the rule and the thing that broke it.
  2. One clamp red per canary: the checks do one job each.

You will see recreated screen

github.com/acme-ops/acme-platform/pull/45
CANARY: do not merge · route not in the matrix #45
Merging is blocked2
Owner two tries to merge the C6 canary. The ruleset refuses.
  1. The required check from Step 5, doing its job.
  2. Even an owner cannot merge around it. Only owner one, on the bypass list, could, and that would show in the record.

Check it worked

Each canary turned its own clamp red and nothing else; owner two could not merge; all three are closed, their branches deleted, and main has no canary file.

Fastest path

Opening all three canaries in one prompt runs them in parallel: one wait instead of three.

If it goes wrong

A canary's clamp stays green

Stop other work: that lock is open. Say: The C5 canary stayed green. Show me what c5-access actually checks and why it missed canary_c5. Do not change the canary. Fix the clamp, then run the canary again.

owner two could merge the canary

The ruleset is not Active, the check is not required, or owner two is on the bypass list. Close the pull request now (if it merged, revert it at once), fix the ruleset as in Step 5, and repeat this step.

The canary turned a different clamp red, or several

Read the failing log: it may be a real problem the canary exposed, or a check doing more than one job. Ask Claude Code to explain each red check before you close anything.

Step 7

The honesty audit, and the dated register

15 minutes

Why

A clamp can be required and still unable to fail: a pipe that hides the exit code, a step allowed to fail, a skipped test, a test that only checks a word is present, or a test runner started inside another that always reports success. We hit each of these. One search finds them; the dated register then shows, to you and to an auditor, when each clamp last proved itself.

Do this

Paste into Claude Code
On a new branch clamps/audit-1, audit every workflow, script and test for ways a failure could read as a pass, and list each finding with the file and line. Do not fix anything yet. Look for:
- || true, continue-on-error, or a command whose exit code is ignored;
- output piped into tail, head or tee without set -o pipefail, and shell scripts without set -euo pipefail;
- skipped or focused tests (.skip, .only, todo) and lint rules switched off in committed code;
- the build set to ignore type or lint errors;
- tests that only check a word or name appears in a file instead of calling the code and checking the result;
- a test runner started inside another, or any check whose only possible answer is "pass".

Then update docs/clamps.md: the Required column from the ruleset, and for C5, C6 and C7 today's date and the links to the red canary runs. Add the routine: canaries for three clamps each month, rotating so each clamp is proved at least once a quarter, and straight after any change to .github/ or the ruleset. Open a pull request titled "Clamp audit 1" with your findings in the description, and wait for the clamps.

Read the findings. For each one, decide with Claude Code whether to fix it now (in this pull request) or record it in the register with a date. Owner two approves; merge.

You will see recreated screen

claude — acme-platform
⏺ Bash(git grep -nE "\|\| true|continue-on-error|\.only\(|\.skip\(|ignoreBuildErrors")
⎿ (no matches)
1
⏺ Findings: 1. tests/names.test.ts line 14 only checks that the word "check-names" appears in package.json; it would stay green if the script were deleted. I suggest calling the script on a bad name and expecting a refusal. 2. scripts/seed-dev.sh has no set -euo pipefail. Nothing else found. The register now shows C1 to C9 required, C10 as code owner review, and the C5, C6 and C7 canaries dated today with their run links.2
The audit lists what could hide a failure, with the line, and changes nothing until you decide.
  1. No escape hatches in the workflows.
  2. The real findings: a test that cannot fail, and a script that can hide one. Fix both now.

You will see recreated screen

github.com/acme-ops/acme-platform/blob/main/docs/clamps.md
Clamp register
1
ClampJobRequiredLast canaryResult
C5 Accessc5-accessyes2026-10-22red, run #118
C6 Denyc6-denyyes2026-10-22red, run #119
C7 Secretsc7-secretsyes2026-10-22red, run #120
C10 Reviewrulesetcode owners2026-10-22merge refused
The register on main: each clamp, whether it is required, and when it last caught a canary.
  1. Dated proof, in the repository, reviewed like any change. The other clamps get their canaries in next month's rotation.

Check it worked

Pull request Clamp audit 1 is merged: every finding is fixed or recorded with a date, and docs/clamps.md shows the required checks and three dated canaries with their links.

If it goes wrong

A check fails that names a list, not your change

We hit this: some checks compare a generated list (such as the route list) with the code, and the message names the check, not the list. Say: Open the failing check's log, tell me what file it compares, regenerate it with the command the log prints, and show me what changed.

A test has been green for weeks, including while the thing it guards was broken

We hit this: one runner inside another reported success whatever happened, and a probe could only ever answer "present". Say: Undo the fix this test guards (or plant the fault), show me the test failing, then restore it and show it passing. Every new test must be shown red first.

Claude Code fixes a finding by deleting the test

Say: Restore the test. Rewrite it so it calls the code and checks the result. CODEOWNERS on the tests folder means an owner would have to approve the deletion anyway.

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

Knowledge check

A canary for C6 (a route not in the matrix) runs, and C6 stays green. What does that tell you?

Knowledge check

Why is the clamp register kept in the repository rather than in a spreadsheet?

References

  1. NIST/SEMATECH e-Handbook of Statistical Methods: Measurement process characterization. https://www.itl.nist.gov/div898/handbook/mpc/mpc.htm
  2. GitHub Advisory Database: CVE-2020-8203, prototype pollution in lodash. https://github.com/advisories/GHSA-p6mc-m468-83gw
  3. OpenSSF Scorecard. https://github.com/ossf/scorecard
  4. Playwright documentation: Emulation (viewport). https://playwright.dev/docs/emulation

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 is a quality clamp?
2. Which setting turns a red clamp into a blocked merge?
3. A step runs npm test | tail -5 without pipefail and a test fails. What does the clamp report?
4. What does .github/CODEOWNERS do in this platform?
5. What is a canary in a clamp audit?
6. A canary for C5 runs and C5 stays green. What next?
7. What should the start-up check write when a key is missing or wrong?
8. C7 reports a real API key committed last month. Which step comes first?
9. Claude Code lowers the audit level to make c8-packages green. What do you do?
10. Someone renamed the job c3-tests to tests. The ruleset still requires c3-tests. What happens?
11. What does C4 Schema prove?
12. Which clamp is not run by a machine?