Back to loops
Testingmanual triggermarkdown-export Hardened

Test Until Green

A focused validation loop for agents that frequently stop after one failed test run. It turns the test command into the main feedback gate and requires evidence before completion.

Use loop copies the kickoff prompt. Copy Markdown and Download loop include the complete Markdown page with context, source attribution, anchors, and guardrails. Cursor / Claude Code buttons prepare the shorter kickoff prompt only.

Run shape

Supported agents

CursorClaude CodeCodexGemini CLIOpenCode

Goal

Make the selected test command pass without weakening coverage.

Feedback gate

pnpm test

Stop condition

The test command exits successfully with no failing tests.

Do not weaken, skip, delete, or rewrite the validation command to force success.
Do not claim completion until the stated exit condition is actually satisfied.
If blocked, report the blocker, evidence, and next safest action instead of gaming the metric.
Required context

Give the agent these inputs before it starts the loop. This keeps discovery bounded and prevents vague retries.

The test command to run.
The intended behavior or bug fix.
Files that should not be modified.
Required tools

The loop assumes these commands or integrations are available. Missing tools should be reported as blockers, not ignored.

project package manager
test runner
How to run

Two separate pieces: the kickoff prompt starts the loop, while the downloaded Markdown carries the complete reference page.

1. Copy or download

Use the kickoff for a fast agent run. Download the full Markdown when you need source, context, and attribution in one file.

2. Paste into the agent

Start a fresh agent session in the target repo and provide the requested project context if the loop asks for it.

3. Let it self-pace

The agent should act, check evidence, retry only when the gate fails, and stop at the stated exit condition.

manual triggerTesting AI flow
Manual start
Tests pass without weakening coverage?
Capture failing output
Patch the failing path
Test command exits with no failures
Run selected test command
Find smallest root cause
Re-run narrow then broad tests
not done → return to next actiondone → exit condition met
Manual startTests pass without weakening coverage?doneCapture failing outputPatch the failing pathTest command exits with no failuresRun selected test commandFind smallest root causeRe-run narrow then broad tests
Action checklist

The diagram shows the order. This checklist keeps only the action, command, and failure handling needed during a real pass.

1. Run the test command

Capture the exact failing output before changing code.

pnpm test

If blocked: If the command is missing, inspect package scripts and pick the closest documented test command.

2. Find the root cause

Map the failure to the smallest relevant code path and avoid speculative rewrites.

3. Patch minimally

Apply the smallest code change that fixes the failure while preserving existing patterns.

4. Re-run and stop on green

Repeat until the test command passes or the iteration cap is reached.

pnpm test
Kickoff prompt

This is the text copied by Use loop. It is intentionally shorter than the Markdown export.

Run the project tests, inspect failures, fix the smallest root cause, and repeat until the test command passes. Do not weaken the tests or change the check command.
Goal: Make the selected test command pass without weakening coverage.
Check command: pnpm test
Exit condition: The test command exits successfully with no failing tests.
Max iterations: 8
Guardrails:
- Do not weaken, skip, delete, or rewrite the validation command to force success.
- Do not claim completion until the stated exit condition is actually satisfied.
- If blocked, report the blocker, evidence, and next safest action instead of gaming the metric.
- Do not delete, skip, or mark tests as todo unless explicitly requested.

Quality

91/100

Safety

93/100

Expected output

Passing test output plus a concise summary of fixes and remaining risk.

Related loops

Browse all
Testingevent trigger Hardened

Post-Edit Test Guard

After code edits, detect the affected surface and run the closest relevant validation before declaring completion.

CursorClaude CodeCodex
post-edittestsguard

Kickoff preview

After every code edit, list changed files, choose the closest meaningful validation, run it, and report evidence before claiming completion.
Goal: Run the closest meaningful verification after edits and report evidence.
Check command: git diff --name-only HEAD
Exit condition: Relevant validation has been run and either passes or failures are reported with evidence.
Max iterations: 4
Guardrails:
- Do not weaken, skip, delete, or rewrite the validation command to force success.
- Do not claim completion until the stated exit condition is actually satisfied.
- If blocked, report the blocker, evidence, and next safest action instead of gaming the metric.
- Do not say “not run” without explaining why no meaningful check exists.
View
Testingmanual trigger Hardened

Fix TypeScript Until Clean

Run TypeScript checking, fix typed root causes, and stop only when strict type validation passes.

CursorClaude CodeCodex
typescripttypecheckstrict

Kickoff preview

Run the TypeScript check, group errors by root cause, fix them with strict types, and repeat until the command exits cleanly.
Goal: Make TypeScript validation pass without lowering type safety.
Check command: pnpm tsc --noEmit
Exit condition: TypeScript check exits with code 0.
Max iterations: 8
Guardrails:
- Do not weaken, skip, delete, or rewrite the validation command to force success.
- Do not claim completion until the stated exit condition is actually satisfied.
- If blocked, report the blocker, evidence, and next safest action instead of gaming the metric.
- Do not add `any`, `// @ts-ignore`, or disable strict compiler options unless explicitly approved.
View
Testingmanual trigger Hardened

Build Until Passing

Run the production build, fix compile/runtime bundling failures, and stop only when the build succeeds.

CursorClaude CodeCodex
buildproductionvitenextjs

Kickoff preview

Run the production build, fix root causes while preserving project architecture, and repeat until the build passes.
Goal: Make the production build succeed for the target runtime.
Check command: pnpm build
Exit condition: The production build command exits successfully.
Max iterations: 6
Guardrails:
- Do not weaken, skip, delete, or rewrite the validation command to force success.
- Do not claim completion until the stated exit condition is actually satisfied.
- If blocked, report the blocker, evidence, and next safest action instead of gaming the metric.
- Do not hide build failures with dynamic imports or environment checks unless that is the correct runtime boundary.
View
CImanual trigger Hardened

Ship PR Until Green

Implement a scoped change, open or update a pull request, inspect CI, and continue until all required PR checks pass.

CursorClaude CodeCodex
pull-requestcigithub-actionsverification

Kickoff preview

Take this branch to a green pull request. Implement the requested change, run local verification, open or update the PR, run `gh pr checks`, inspect failures, fix root causes, and repeat until every required check passes or you hit the iteration cap.
Goal: Open or update a pull request and stop only when all required PR checks are green.
Check command: gh pr checks
Exit condition: All required pull request checks are successful and the PR is ready for review or merge.
Max iterations: 10
Guardrails:
- Do not weaken, skip, delete, or rewrite the validation command to force success.
- Do not claim completion until the stated exit condition is actually satisfied.
- If blocked, report the blocker, evidence, and next safest action instead of gaming the metric.
- Do not disable required checks, edit loops to skip jobs, or remove tests to make CI green.
- Do not merge the PR unless the user explicitly asked for merge authority.
View