Ship PR Until Green
A CI-focused loop for coding agents that should not stop at “code written.” It gives the agent a repeatable protocol for local verification, PR creation, CI inspection, log-based fixes, and a strict green-check exit condition.
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.
Supported agents
Goal
Open or update a pull request and stop only when all required PR checks are green.
Feedback gate
gh pr checksStop condition
All required pull request checks are successful and the PR is ready for review or merge.
Give the agent these inputs before it starts the loop. This keeps discovery bounded and prevents vague retries.
The loop assumes these commands or integrations are available. Missing tools should be reported as blockers, not ignored.
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.
The diagram shows the order. This checklist keeps only the action, command, and failure handling needed during a real pass.
1. Scope the branch and change
Inspect the repository, current branch, and requested task. Create or switch to a feature branch if needed.
git status --short && git branch --show-currentIf blocked: If there are unrelated user changes, stop and ask before touching them.
2. Implement and verify locally
Make the smallest correct code changes, then run the project-specific tests and build checks.
pnpm buildIf blocked: Fix root causes instead of broad rewrites. Preserve existing project conventions.
3. Push and open the PR
Commit with a clear message, push the branch, and open or update the GitHub pull request.
git add . && git commit -m "Implement scoped change" && git push -u origin HEADIf blocked: If commit or push fails, report the exact Git error and resolve only safe conflicts.
4. Read CI and iterate
Run the check command, inspect failing jobs, fix the smallest root cause, push again, and repeat until green.
gh pr checksIf blocked: If failures repeat after several attempts, summarize evidence and blockers before continuing.
This is the text copied by Use loop. It is intentionally shorter than the Markdown export.
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.Quality
94/100
Safety
91/100
Expected output
A PR URL, a final CI status summary, the changed files, and any residual risks or blockers.
Related loops
Browse allCI Failure Watcher
Poll CI status, read failing job logs, and produce the smallest actionable fix plan or patch.
Kickoff preview
Monitor the PR checks, inspect failing logs, fix the smallest root cause, push, and continue until CI passes or a real blocker is reported. Goal: Turn failing CI logs into a verified fix or clear blocker report. Check command: gh pr checks --watch Exit condition: The failing CI check is fixed, or a blocker is documented with log evidence. 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 paste secret-bearing logs into public output. Redact tokens and credentials.
Test Until Green
Run the project test suite, fix root causes, and keep iterating until the selected test command passes.
Kickoff preview
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.
Independent Verifier Pass
Review an agent-produced change as a skeptical verifier before it is marked done.
Kickoff preview
Act as an independent verifier. Restate the requirements, inspect the diff, run relevant checks, and return a pass/fail/blocker verdict with evidence. Goal: Prove the implementation satisfies the request without relying on the implementer’s claim. Check command: git diff --stat && git diff --check Exit condition: The verifier can map each requirement to code and verification evidence. Max iterations: 3 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 rubber-stamp. Find at least one plausible failure mode and check it.
SEO Metadata Audit Loop
Audit title, description, canonical, Open Graph, headings, and indexability for SEO-critical pages.
Kickoff preview
Audit SEO metadata from server-rendered HTML for the target pages. Verify title, description, canonical, H1, Open Graph, and indexability, then fix and re-check. Goal: Ensure SEO-critical pages have unique, server-rendered metadata and indexable content. Check command: curl -sL $URL | head -80 Exit condition: Each target page has unique title, description, canonical, visible H1, and no accidental noindex. Max iterations: 5 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 rely only on client-rendered metadata for SEO-critical pages. Verify server HTML.