What this prompt does
This prompt helps you fix flaky tests in a [language]/[framework] project using [test_framework]. Given [flaky_count] intermittently failing tests, the AI produces a script to run the suite [repeat_count] times and collect flakiness statistics, a root-cause checklist for [language] (timing, shared state, DB ordering, async races), deterministic before/after fixes per pattern, a test-isolation audit for shared state, a quarantine strategy to unblock CI, retry configuration that separates flaky from real failures, and a monitoring query to track flakiness over time. You feed it the actual [test_names].
The structure works because it treats flakiness as a diagnosis problem, not a retry problem. The repeat-run script gathers evidence, the root-cause checklist narrows the cause, and the fixes target the real source — usually shared state, timing, or DB ordering. Quarantine keeps CI green while you work, and the retry config prevents masking genuine failures. Providing real [test_names] makes every fix concrete.
When to use it
- Intermittent failures are eroding the team's trust in CI.
- You need to measure flakiness with repeat runs, not guesswork.
- You suspect shared state, timing, or DB ordering but need to confirm which.
- You want a quarantine strategy to unblock CI while fixing.
- You need retry config that distinguishes flaky from real failures.
- You want to track flakiness rate over time with a dashboard query.
Example output
You get a script that runs the suite [repeat_count] times and reports flakiness stats, a [language]-specific root-cause checklist, before/after fixes for the patterns behind your [test_names], a shared-state isolation audit, a quarantine plan, retry configuration, and a monitoring query for tracking the flakiness rate.
Pro tips
- Provide the exact
[test_names]and, if possible, their stack traces so fixes target real causes. - Run the repeat script enough times — a low
[repeat_count]may not reproduce rare flakes. - Work through the root-cause checklist before applying fixes; the wrong fix just moves the flake.
- Use quarantine sparingly and temporarily — it unblocks CI but is not a fix.
- Configure retries to flag, not hide, flaky tests so real regressions still surface.
- Re-run the repeat script after each fix to confirm the flake is actually gone.