Debug a flaky test
Investigate an intermittent test failure using reproducible evidence before proposing a focused fix.
Exact prompt
Investigate the flaky test below using evidence before recommending a change.
Project context:
{{project_context}}
Failing test and observed output:
{{test_output}}
Constraints:
{{constraints}}
Work in this order:
1. Separate confirmed observations from hypotheses.
2. Identify the smallest reliable reproduction you can attempt.
3. Trace shared state, timing, ordering, environment, and cleanup risks that could explain the intermittency.
4. State the most likely root cause and the evidence for it, or say the evidence is insufficient and name the next discriminating check.
5. Propose the smallest root-cause fix without weakening the assertion or hiding the failure.
Return:
- reproduction notes;
- observations and ruled-out hypotheses;
- root cause or next discriminating check;
- proposed patch;
- focused verification steps.
Do not claim the issue is fixed unless the focused verification succeeds.Replace before use
- Project context
{{project_context}} - Relevant language, framework, test runner, environment, and recent changes.Example: Astro 6 with Vitest 4 on Windows and Linux CI
- Test output
{{test_output}} - The failing test, error text, frequency, and any useful logs.Example: The test fails about once in 20 CI runs with a timeout
- Constraints
{{constraints}} - Boundaries the investigation and fix must respect.Example: Do not increase retries or raise the timeout