Loop/goalTestingmedium riskintermediatesafety C · 60Forward Future

Stabilize flaky tests for good

Measure the flakiness, fix one root cause at a time, and stop after a defined streak of stable full-suite runs.

Prompt
→ Claude Code
Run [test suite] [N] times under the same conditions and list tests whose result changes. Fix the most frequent flake at its root cause—shared state, timing, ordering, or an external dependency—never with a blind sleep or retry. Run that test [N] times, then rerun the full suite. Repeat until [N] consecutive full-suite runs pass, progress stalls, or approval is required. Return each flake, root cause, fix, evidence, and justified quarantine.
claude-code · codex

Use this when

Use this when a test suite produces inconsistent results across otherwise comparable runs and the failures may come from shared state, timing, ordering, or external dependencies.

How it runs

  1. Choose the test suite, the required run count, and the conditions that must stay fixed, then run the complete suite repeatedly and record every inconsistent test.
  2. Select the most frequent flake, reproduce it as narrowly as practical, and identify the underlying shared-state, timing, ordering, or dependency failure.
  3. Fix the test or product code without adding a blind sleep or retry, then run the affected test repeatedly before returning to the complete suite.
  4. Repeat until the required number of consecutive full-suite runs pass, progress stalls, or approval is needed, and report every root cause, fix, quarantine, and remaining blocker.

Done when

✓ The full test suite passes for the required consecutive-run streak. The repaired test passes repeatedly, [N] consecutive full-suite runs are green under the recorded conditions, and no blind sleep or retry hides an unresolved cause.

Why it works

Repeated runs turn intermittent failures into measurable evidence. Repairing the most frequent flake first and requiring a full-suite streak prevents a local fix from hiding another source of instability.

Implementation note

Choose [N] before the first run and keep the environment comparable. Quarantine is a visible temporary containment step, not proof of repair; record its reason and do not report the suite as fully stabilized while unresolved tests remain quarantined.

Source: Forward Future ↗graded C · 60/100 — how grades work (Safety Score v2) →

/goalTestingmedium risk

Fix the flaky checkout test

Run checkout tests repeatedly until 20 consecutive passes, logging failure modes and hypotheses after each iteration.

prompt
→ Claude Code
/goal Reproduce and fix the flaky checkout test so it passes 20 consecutive runs, verified by npm test -- checkout, while preserving checkout API behavior and existing correctness tests. Use the checkout test files, checkout service code, fixtures, and related logs. Between iterations, record the observed failure mode, hypothesis, change, and rerun result. If reproduction stays unavailable or valid paths are exhausted, stop with reproduction attempts, logs, most likely absent condition, blocker, and next input needed
/goalTestingmedium risk

Reach a coverage target

Add focused tests for the least-covered files and re-measure each turn until coverage hits 80 percent or the turn cap.

prompt
→ Claude Code
/goal test coverage is at least 80% with all tests passing — add focused tests for the least-covered files, re-run coverage each turn, stop at the threshold or after 12 turns
/loopTestinghigh risknew

The product contract conformance loop

A requirements-conformance workflow that turns a product contract into a ledger, checks current evidence, and repairs only confirmed mismatches with regression coverage.

prompt
→ Claude Code
Audit the project against the supplied product contract. Extract every concrete product promise, business rule, permission rule, background job expectation, user workflow, non-goal, and quality bar into a requirement ledger. For each requirement, find current evidence in code, config, tests, docs, jobs, migrations, routes, UI, prompts, queues, or production-safe runtime state. Mark it proved, weak, contradicted, unimplemented, not applicable with reason, or blocked. Fix only confirmed high-impact mismatches one bounded slice at a time, preserving unrelated work and adding regression coverage where practical. Stop when every requirement is proved or honestly classified and the ledger has no silent gaps.