When should you use it?
- Your main branch fails randomly
- The team has given up on test reliability
- Test runs are long enough that nobody investigates
Not for: Pipelines where the agent would need write access to production; Teams without anyone to review the pull requests
What do you need, and what do you get?
You need
- CI artifacts and logs (read access)
- 30 days of run history
- A branch the agent may push to
You get
- Pass-rate dashboard by test
- Hypotheses per flaky test
- Draft pull requests with evidence
How does it work, step by step?
- Grant the agent CI read permissionsIt can fetch logs and build outputs, nothing more on day one.
- Track pass ratesHave it build a rolling report of failure rates per test over the last month.
- Pick the worst offendersStart with the tests failing most often and decide if each looks like a test bug or a product bug.
- Reproduce or rerunNarrow to a minimal reproduction; if none, propose a fix and rerun many times to judge it statistically.
- Review in the morningRead each pull request, keep the sound fixes and throw away the rest.
The prompt
Our own prompt, inspired by SeanAnderson on Hacker News and written to work in Claude Code. Values in lime are placeholders.
Fill in the blanks (optional; the copied prompt uses your values)
You have read access to CI results for {repo}. Build a table of each test's failure rate over the last {days} days. For the five worst, state whether the failure looks like a test problem or a product problem and why. Try to reproduce each one; if you cannot, propose a fix and rerun it {n_runs} times. Open draft pull requests with the evidence. Do not merge.
Inspired by SeanAnderson on Hacker News: Hacker News comment on using Claude across legacy engineering teams. The prompt above is written by playbooks.bot in our own words; nothing from the original is quoted.
What can go wrong?
- Some fixes just hide real product bugs; ask the agent to say which kind it thinks each failure is.
- Statistical reruns cost CI minutes; cap the overnight budget.
Our take
Flaky tests are the perfect overnight job: tedious, measurable and easy to verify after the fact. What makes this setup work is the measurement the agent built first. Without a pass-rate history, it would be guessing. SeanAnderson started with read-only access to CI logs and build outputs, which is the right first permission. The agent then built a month of pass and fail rates per test, so it could pick the worst offenders and later judge whether a fix actually helped. For each one, ask it to say whether the failure looks like a test bug or a product bug, because some fixes simply hide real problems. Where no minimal reproduction exists, rerunning a candidate fix many times gives a statistical answer, but those reruns cost CI minutes, so cap the overnight budget. Read every pull request in the morning, keep the sound fixes and discard the rest. Write access to production has no place here.
Where the time goes back: The slow, repetitive rerun-and-compare work happens while you sleep, and you only spend time judging the fixes.
FAQ
How much oversight did it need?
What improved?
Source and credit
Inspired by SeanAnderson on Hacker News. We describe the idea in our own words, link to the original, and wrote the prompt ourselves; nothing is quoted.
- Inspired by
- Hacker News comment on using Claude across legacy engineering teams
- Creator
- SeanAnderson on Hacker News
- Published on
- Hacker News
- Original date
- May 1, 2026
- License
- Not openly licensed (the poster keeps all rights), so we quote nothing and link to the original
- Originally for
- Claude Code
- AI dry run
- Oct 23, 2026: passed. Dry-run tested by our AI test agent on sample input. PASS: Gates held on desk check; no live sends or purchases.
AI dry run on sample data; not run with live connected accounts. The playbooks.bot test agent filled the prompt with synthetic inputs, produced the output and checked it against the page's stated outputs and guardrails. - Verified
- Oct 24, 2026: source link resolves to the original, the credited creator published it, our excerpt or prompt matches it, and the license allows our use.
Are you the creator? Claim or correct this page.