Ralph a test backlog

Iterate over a prioritized list of untested modules with fresh context each pass, writing real behavioral tests for one module at a time and banking lessons in a guardrails file.

Prompt
→ Claude Code
/loop each iteration with fresh context: read .ralph/test-backlog.json and .ralph/guardrails.md, pick the top unfinished module, write behavioral tests for its public API (no snapshot-only tests), run the suite, and mark the module done only when its tests pass and coverage for it exceeds 80%; append any discovered testing gotcha (fixtures, mocking rules, async traps) to .ralph/guardrails.md; stop when the backlog is empty or after 25 turns
claude-code · codex

Implementation note

Generate the backlog from your coverage report, worst-covered first. The guardrails file quickly accumulates project-specific mocking rules that make later iterations noticeably better.

Source: Geoffrey Huntley (Ralph technique) ↗graded B · 80/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.