
Show HN: Reproducible failure drills for AI coding agents
Companion repository for the book The Second Time Is a Bug: A field workbook for
以下正文同步自 Hacker News 最新,版权归原站所有,已转换为易读排版。
Companion repository for the book The Second Time Is a Bug: A field workbook for engineering with AI coding agents. Everything the book shows runs here:
TypeScript on Node, with zero runtime dependencies and no build step.
Book website: https://secondtimeisabug.com
The code the book quotes, and the messages the guards and drills print, are kept within 64 columns, the width of the book's printed page. Guard output wraps with a hanging indent (guards/lib/wrap.ts).
Node.js 22.18 or later. Node runs the .ts files directly (type stripping is on by default from 22.18). Check with node --version.
git (the drills make throwaway git repositories in your temp folder).
For the two browser drills (D13, D14) and npm run e2e: Chromium for Playwright, installed once with npx playwright install chromium.
Quickstart
npm install # dev tools only: typescript, @types/node, @playwright/test, axe-core npm test # unit tests and the legacy golden master npm run typecheck # tsc --noEmit npm run gate # every guard, fast ones first; refuses on any failure npm run drill D06 # one drill: the float-money guard catches a parseFloat npx playwright install chromium # once, for drills D13 and D14 npm run drills # all 26 drills and a summary table (a few minutes) npm run e2e # browser and accessibility tests npm start -- --seed-demo # Invoicer on http://127.0.0.1:3000 with a demo client
Without Playwright's Chromium, npm run drills does not run D13 and D14. It says so and ends with exit code 1, because the run is not complete:
24 of 26 drills behaved as expected; 2 need Chromium (npx playwright install chromium).
Install Chromium and run it again. The runner's own tests, which are not part of npm test: node --test drills/test/*.test.ts.
npm run gate compares your working tree with HEAD. Outside a git repository the diff-based guards report "skipped" rather than guessing. In CI, set GUARD_BASE=origin/main to check a whole branch, as .github/workflows/gate.yml does.
Path What it is
app/src/domain/ Pure rules: money in integer cents, totals, due dates, reminders, CSV
app/src/db/ node:sqlite storage and SQL migrations with up and down steps
app/src/http/ JSON API on node:http, including /health and /version
app/src/ui/ Server-rendered list page and the static invoice form
app/src/jobs/ Overdue-reminder job and a tiny scheduler
app/test/, app/e2e/ Unit tests (node:test) and browser tests (Playwright, axe-core)
legacy/ billing-export.js and its characterisation (golden master) tests
guards/ The guards, gate.ts, seeded-defects.ts, guard-audit.ts, shared lib/
drills/ run.ts and one folder per drill (README.md, drill.json, patch or script)
toy-agent/ loop.ts, scripted-model.ts, tools.ts, unattended.ts and scripts
templates/ AGENTS.md starter, incident log, plan, harness review checklist, hooks
experiment/ Chapter 12 protocol, seven tasks with hidden acceptance tests, score.ts
plans/ Where plan and handoff files go (templates/plan.md)
.github/workflows/gate.yml CI: type check, tests and the gate against the branch's base, then browser tests and mutation runs
.harness/ Guard state: test baseline, approved dependencies; at run time, the guard log and test evidence
AGENTS.md This repository's own instruction file, built from the template
DRILLS.md Every drill's commands and real output, generated by npm run drills:docs
Drills
Run one with npm run drill DNN. Each folder's README.md says what the mistake is, what you will see, and how to try the same mistake with a real agent.
Every guard prints name: ok (...) or name: FAILED followed by one entry per problem: where it is, what is wrong, and what to do next. They are written to be read by an agent as much as by a person. Exit code 0 means pass, 1 means fail; destructive-command.ts uses 2 to block, the usual convention for agent hooks. Each time a guard fires it appends a line to .harness/guard-log.jsonl, which guards/guard-audit.ts reads to find guards ready to retire.
Nothing here needs the network after npm install, except the optional node guards/package-check.ts --online, which asks registry.npmjs.org.
Code: MIT, see LICENSE. The book's text is not part of this repository.
正文由 探How 从来源站点 RSS 同步,内容未经改写;遇到排版缺失或需要图片、视频时请以原文为准。