Yes or No?
Arcos @0xarcos
https://x.com/0xarcos/status/2123038548580245659
Verification Engineering: The $400K Skill of Running 30 Fable 5.2 Agents (Full Course)
plaintext
tests pass ✓
types check ✓
lint clean ✓
login works ✓
rate limit returns 429 ✓
no secrets in diff ✓plaintext
FAKE WHAT YOU SEE → CAUGHT BY
NO-OP TEST a test that can't fail → property tests
TEST EDIT the test changed to pass → locked checks
HAPPY PATH only the case that works → end-to-end run
SELF REVIEW the same model says lgtm → a check with an exit code
MOCK WORLD everything mocked, nothing real → the verify skill
SILENT SKIP "3 skipped" buried in the log → skipped = failed
SCOPE CREEP a fix became a rewrite → file listpython
# test_props.py - a test the agent can't pass by accident
from hypothesis import given, strategies as st
from app.codec import encode, decode
from app.ledger import Ledger
@given(st.text())
def test_round_trip(s):
assert decode(encode(s)) == s
@given(st.lists(st.integers(min_value=0, max_value=10_000)))
def test_balance_never_negative(deposits):
ledger = Ledger()
for d in deposits:
ledger.deposit(d)
assert ledger.balance >= 0python
# test_diff.py - the old code is the oracle
import random
from legacy.pricing import price as old_price
from app.pricing import price as new_price
def test_new_matches_old():
random.seed(7)
for _ in range(5000):
cart = [random.randint(1, 500) for _ in range(random.randint(0, 12))]
assert new_price(cart) == old_price(cart), cartplaintext
your-repo/
CLAUDE.md the definition of done
.claude/skills/verify/SKILL.md run the real app, write the proof
.claude/hooks/stop_gate.py no PASS, no "done"
.claude/hooks/commit_gate.py no proof, no commit
.claude/settings.json turns both hooks on
.verify/checks.json checks with triggers from the diff
.verify/triggers.py which checks this diff needs
.verify/gate.json off / observe / enforce
.verify/evidence.md written fresh for every changeplaintext
Set up the verification layer from the article above in this repo.
1. Create these files exactly as the article shows them:
CLAUDE.md (append if it exists), .claude/skills/verify/SKILL.md,
.claude/hooks/stop_gate.py, .claude/hooks/commit_gate.py,
.claude/settings.json (merge with mine if it exists),
.verify/checks.json, .verify/triggers.py, .verify/gate.json
2. Find this repo's real test command and how to start the app locally.
Write both into the Run section of the verify skill.
3. Add .verify/.tries, .verify/gate.log and .verify/proof/ to .gitignore.
4. Set .verify/gate.json to observe. Do not turn on enforce.
5. If this machine has no python3 command, use python in settings.json.
6. Commit the new files on main, so the checks live on the base branch.
7. Show me the file tree. Don't change any app code.markdown
# Done means proven
- You are done when .verify/evidence.md says VERDICT: PASS for this change. Not when it looks done.
- Before you say done, use the verify skill. Every time. Even for "small" changes.
- Never edit tests, .verify/, .claude/hooks/ or .claude/skills/verify/ to make something pass.
- A skipped test is a failed test. Say which one and why.
- If verify fails 3 times, stop and write what blocks you in .verify/NEEDS-HUMAN.md.
- Every commit message ends with the Verified-by: line from evidence.md.markdown
---
name: verify
description: Prove a change works before saying done. Run the real app, run the checks the diff triggers, write .verify/evidence.md. Use before every commit and before saying a task is finished.
---
# Verify
## Run
- Tests: npm test (replace with this repo's test command)
- App: npm run dev, then open http://localhost:3000
## Steps
1. Run the tests. Copy the summary line, with skipped and failed counts.
2. Run: python3 .verify/triggers.py
It prints the checks this diff triggers. Do every one of them.
3. Start the app and do the user flow your change touches, the way a QA
engineer would. Browser for web, a simulator for mobile, curl for an API.
Try the happy path and at least 2 ways it can break.
4. Save screenshots or responses to .verify/proof/
5. Write .verify/evidence.md in the format below. Fill every field.
## evidence.md format
VERDICT: PASS or FAIL
CHANGE: one line
TESTS: <summary line> (skipped must be 0)
TRIGGERED: <check id>: pass/fail, one line of proof each
E2E: what you did in the real app, what you saw, file in proof/
NOT CHECKED: what you could not verify, and why
VERIFIED-BY: e2e,unit,checks(<n>)
Never write PASS if anything above failed or was skipped.json
{
"checks": [
{"id": "auth-retry", "when": ["src/auth/*"], "check": "log in twice in a row, then with a wrong password: 2nd login works, wrong one gets 401", "why": "login broke on the 2nd try"},
{"id": "rate-limit", "when": ["src/api/*", "*ratelimit*"], "check": "send 11 requests in 10 seconds: the 11th gets 429", "why": "limiter silently disabled"},
{"id": "old-data", "when": ["*schema*", "*migrations/*", "*models/*"], "check": "load a record saved before this change: no crash, no missing field", "why": "old rows had no new column"},
{"id": "secrets", "when": ["*"], "check": "no keys, tokens or .env values in the diff", "why": "a key shipped in a commit"},
{"id": "deps", "when": ["package.json", "requirements*.txt", "*.lock"], "check": "fresh install and build pass from a clean clone", "why": "worked only on one machine"}
]
}python
# .verify/triggers.py - prints the checks this diff triggers.
# Reads checks.json from the BASE branch, so a change can't rewrite its own checklist.
import fnmatch, json, subprocess, sys
BASE = "main"
LOCKED = [".verify/checks.json", ".verify/triggers.py", ".claude/hooks/*", ".claude/skills/verify/*"]
def git(*args):
return subprocess.run(["git", *args], capture_output=True, text=True).stdout
checks = json.loads(git("show", f"{BASE}:.verify/checks.json") or "{}").get("checks", [])
changed = git("diff", "--name-only", BASE).split() + git("ls-files", "--others", "--exclude-standard").split()
touched = [f for f in changed if any(fnmatch.fnmatch(f, p) for p in LOCKED)]
if touched:
print("FAIL locked file changed: " + ", ".join(touched))
sys.exit(1)
hits = [c for c in checks if any(fnmatch.fnmatch(f, p) for f in changed for p in c["when"])]
for c in hits:
print(f"[{c['id']}] {c['check']} (why: {c['why']})")
print(f"{len(hits)} checks triggered by {len(changed)} changed files")python
# .claude/hooks/stop_gate.py - Claude can't say "done" without a fresh PASS.
# 3 rounds max, then a human gets NEEDS-HUMAN.md.
import json, os, subprocess, sys
event = json.load(sys.stdin)
root = event.get("cwd", ".")
ev = os.path.join(root, ".verify", "evidence.md")
tries = os.path.join(root, ".verify", ".tries")
status = subprocess.run(["git", "status", "--porcelain"], cwd=root, capture_output=True, text=True).stdout
files = [l[3:] for l in status.splitlines() if not l[3:].startswith(".verify/")]
if not files:
sys.exit(0) # nothing changed, nothing to prove
last_edit = max([os.path.getmtime(os.path.join(root, f)) for f in files if os.path.isfile(os.path.join(root, f))] or [0])
fresh = os.path.exists(ev) and os.path.getmtime(ev) >= last_edit
passed = fresh and "VERDICT: PASS" in open(ev, encoding="utf-8").read()
n = int(open(tries).read()) if os.path.exists(tries) else 0
if passed or n >= 3:
if not passed:
open(os.path.join(root, ".verify", "NEEDS-HUMAN.md"), "a").write("verify failed 3 times, see evidence.md\n")
if os.path.exists(tries):
os.remove(tries)
sys.exit(0)
open(tries, "w").write(str(n + 1))
print("Not done: no fresh VERDICT: PASS in .verify/evidence.md. Use the verify skill, fix what fails, then finish.", file=sys.stderr)
sys.exit(2)python
# .claude/hooks/commit_gate.py - blocks commits without proof. Modes: off / observe / enforce.
import json, os, sys, time
event = json.load(sys.stdin)
cmd = event.get("tool_input", {}).get("command", "")
if "git commit" not in cmd:
sys.exit(0)
root = event.get("cwd", ".")
mode = json.load(open(os.path.join(root, ".verify", "gate.json"))).get("mode", "observe")
if mode == "off" or "Verified-by: none" in cmd:
sys.exit(0) # an honest "none" with a reason is allowed, and you can find it later
ev = os.path.join(root, ".verify", "evidence.md")
text = open(ev, encoding="utf-8").read() if os.path.exists(ev) else ""
why = []
if "VERDICT: PASS" not in text:
why.append("no VERDICT: PASS in .verify/evidence.md")
if "Verified-by:" not in cmd:
why.append("no Verified-by: line in the commit message")
if not why:
sys.exit(0)
sid = event.get("session_id", "-")
log = os.path.join(root, ".verify", "gate.log")
open(log, "a").write(f"{time.strftime('%Y-%m-%d %H:%M')} {mode} would-block {sid}: {'; '.join(why)}\n")
blocked = open(log).read().count(f"enforce would-block {sid}")
if mode == "observe" or blocked > 2:
sys.exit(0) # observe never blocks; enforce lets the 3rd try in a session through, logged
print("Commit blocked: " + "; ".join(why) + ". Use the verify skill, or add 'Verified-by: none - <reason>'.", file=sys.stderr)
sys.exit(2)json
{
"hooks": {
"Stop": [
{"hooks": [{"type": "command", "command": "python3 \"$CLAUDE_PROJECT_DIR/.claude/hooks/stop_gate.py\""}]}
],
"PreToolUse": [
{"matcher": "Bash", "hooks": [{"type": "command", "command": "python3 \"$CLAUDE_PROJECT_DIR/.claude/hooks/commit_gate.py\""}]}
]
}
}json
{"mode": "observe"}plaintext
Verified-by: e2e,unit,checks(4)plaintext
Verified-by: none - docs only, nothing to runbash
git log --since="2 weeks ago" --grep="Verified-by: none" --onelineplaintext
Not done: no fresh VERDICT: PASS in .verify/evidence.md.plaintext
VERDICT: PASS
CHANGE: "remember me" checkbox on login, 30-day cookie
TESTS: 214 passed, 0 failed, 0 skipped
TRIGGERED: auth-retry: pass, 2nd login ok, wrong password 401
rate-limit: pass, 11th request 429
secrets: pass, no keys in diff
E2E: logged in with remember-me, closed the tab, reopened: still in
logged out, reopened: logged out (failed on try 1, fixed)
proof/remember-1.png, proof/remember-2.png
NOT CHECKED: Safari private mode, no Safari on this machine
VERIFIED-BY: e2e,unit,checks(3)plaintext
MODE WHAT HAPPENS HOW LONG
off nothing until the files exist
observe logs "would block", blocks none 1 to 2 weeks
enforce blocks, 3rd try passes, logged from then onplaintext
SYMPTOM → MISSING
"tests pass" but the feature is broken → end-to-end in the verify skill
a test changed in the PR it judges → locked files, checks read from main
works for "hello", breaks on emoji → property tests
rewrite returns slightly different data → differential tests
the same outage twice → one check in checks.json
"done" with no proof → the stop gate
you still read every diff → evidence.md + Verified-by
the gate keeps blocking good work → back to observe modeplaintext
reads per ship =
diffs you actually opened
─────────────────────────
changes that shipped
escapes =
bugs found after merge that a check should have caughtplaintext
[ ] "Done" is defined before the work starts
[ ] Every change ends with evidence.md: VERDICT, TESTS, E2E, NOT CHECKED
[ ] Claude runs the real app, not only the tests
[ ] Skipped tests count as failed
[ ] Checks are read from main, never from the branch
[ ] No change can touch tests, checks, hooks or the verify skill
[ ] One reviewer with a rubric, not two without one
[ ] 3 failed rounds stops the agent and brings in a human
[ ] Every commit has a Verified-by line, "none" included
[ ] New gates start in observe mode
[ ] Every escape becomes one check, pruned after 60 quiet days
zes or no ;-)


Žádné komentáře:
Okomentovat