← Back to library

Hunt flaky tests overnight from CI pass-rate history

SeanAnderson on Hacker News, an engineering leader, inherited a legacy pipeline where master passed about forty percent of the time despite retries. Claude got permission to read build outputs, wrote tooling to chart a month of pass and fail rates, and hunted flakes overnight.

  • OutcomeLet a coding agent watch your CI history, rank the flakiest tests, try to reproduce and fix them overnight, and leave pull requests for daytime review.
  • SetupAn afternoon+
  • LevelAdvanced
  • CreditSeanAnderson on Hacker News
View original
Works with
Claude Code

Published Oct 23, 2026Updated Oct 23, 2026AI dry run on sample input: passed Oct 23, 2026Source verified Oct 24, 2026

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?

  1. Grant the agent CI read permissionsIt can fetch logs and build outputs, nothing more on day one.
  2. Track pass ratesHave it build a rolling report of failure rates per test over the last month.
  3. Pick the worst offendersStart with the tests failing most often and decide if each looks like a test bug or a product bug.
  4. Reproduce or rerunNarrow to a minimal reproduction; if none, propose a fix and rerun many times to judge it statistically.
  5. 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)

Prompt3 variables
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?
The author describes very little, mostly reviewing proposals between meetings, while still discarding some bad fixes.
What improved?
He reports a shorter pipeline and a higher pass rate after a few weeks; your results will depend on the codebase.

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.

More in IT & Security

All 82 IT & Security playbooks →

Related playbooks

IT & SecuritySkill✓ AI dry run

Find repeat fixes and good habits in your team's PRs

Have Claude Code look across a chosen window of commits and pull request review comments for the same fix or review note coming up again and again, suggest turning the top ones into a project rule or skill you write in your own words, and list good practices already in the repo that other teams could copy.

Credit: anthropics

Under an hour
IT & SecuritySkill✓ AI dry run

Map CLI help output into skills to cut MCP token use

Replace token-hungry tool servers with lightweight skill files generated by having a coding agent crawl a command line tool's help pages.

Credit: ex1fm3ta on Hacker News

Under an hour
IT & SecurityWorkflow✓ AI dry run

Let a CLI agent drive your screen to test a UI

Check that a UI actually works by letting your terminal coding agent control the screen as a last resort, after it has tried commands and tools first.

Credit: Mohamed EL BATHA

Under an hour
IT & SecurityPrompt✓ AI dry run

Make the coding agent log real numbers before guessing

When a coding agent cannot see the result, such as a window it draws, have it log actual sizes and values or save frames as images instead of guessing.

Credit: u/no-shadowban-lmao on r/ClaudeAI

Minutes