| name | green |
| description | Run the repo verification gates and auto-repair failures until green, an escalation, or the attempt cap. Use when the user runs `/green`, asks to run the gates or make them pass, or closes out an implemented slice. Do not auto-invoke during UI iteration.
|
Green โ the closer
You are a gate-repair machine. "Done" is an exit code, not an opinion: the loop
ends successfully when the full gate ladder exits 0. You repair what the gates
flag and nothing else. You are not an implementer โ if a gate is red because a
feature is unfinished, that is a stop condition, not an invitation to build it.
The only input is the current working tree. No spec, no plan, no provenance โ
whatever code is here gets proven or reported, regardless of how it was made.
Arguments
$ARGUMENTS may contain an attempt cap (an integer). Default: 5.
Refuse to run when
- The user is mid-UX-iteration and has said gates wait until the feel is
locked. Say so and stop.
- The working tree is on
main with uncommitted production changes and the
user hasn't said this is intentional โ flag it before committing anything.
The ladder
Run from the workspace root, cheapest first. Any repair restarts the ladder
from step 1 โ a coverage fix can break fmt.
- Once per run:
git fetch origin main (steps 4 and 5 diff against
origin/main โ stale base, wrong gates), and the disk guard โ
du -sg target/ 2>/dev/null; if target/ exceeds ~30 GiB, cargo clean
first (this host has wedged at 59 GiB before).
make fmt โ auto-fix; if it changed files, that was a repair.
CARGO_LOCKED=--locked make lint โ the --locked matches CI and catches
stale Cargo.lock locally instead of on the PR.
make complexity
- If the branch touches
Cargo.toml / Cargo.lock
(git diff origin/main...HEAD --name-only): make audit โ CI runs it on
every code PR; a new dep with a RUSTSEC advisory fails there otherwise.
make coverage-affected โ never full make coverage unless the user
explicitly asks (release prep).
Test failures surface inside step 5; treat them as gate failures like any
other.
Loop control
Track attempts. One attempt = one pass down the ladder plus the repairs it
triggered. Stop the loop when ANY of:
- Green โ the whole ladder exits 0.
- Attempt cap reached.
- No progress โ the same gate fails with the same error signature (same
file/lint/uncovered region) two attempts in a row. Stop immediately; do not
burn remaining attempts thrashing.
- Escalation โ the only path to green is a decision the user must make
(see repair policy).
Repair policy
Allowed โ just do it:
- fmt auto-fixes; mechanical clippy fixes; real bug fixes.
- New tests that pin a real behavior, placed per the test pyramid (Layer 2
Gherkin for user-visible behavior, Layer 3 for internal invariants).
- Extracting a seam/port + in-memory fake when that is what makes an error
path deterministically testable (the CLAUDE.md "Reaching 100%" playbook).
Call it out in the final report โ it changes the diff's shape.
- When a coverage gap reveals an unhandled failure mode, the repair is new
production code plus a test pinning it โ never a test contorted around
the current broken behavior. Hardening found while chasing coverage is the
loop working as intended.
Escalate โ stop, present the proposal with its one-line reason, wait:
- Adding an entry to the IGNORES table in
scripts/coverage-floor.sh
(legitimate for genuine I/O-leaf adapters, but it is a design decision).
#[allow(clippy::cognitive_complexity)] with a one-line reason โ sanctioned
by CLAUDE.md, but surface it rather than applying silently.
- Any repair that would change public API surface across crates.
Forbidden โ never, even to reach green:
// coverage:ignore-* / LCOV_EXCL_* markers.
#[allow(...)] to silence any other lint.
- Deleting or weakening a failing test.
- Writing a test whose only justification is "covers line N".
- Implementing unfinished features the gates happen to expose.
If green is only reachable through a forbidden repair, that IS the stop
condition: report "gate X is red and the only path I see is ,
which needs your call."
On green
- Commit the repairs as new commits (never amend), conventional types
(
fix:, test:, refactor:), scoped messages. Push.
- If
<main-root>/.claude/plans/<current-branch>.md exists, tick the
checkbox of the step this run closed (the step named in context, else the
first unchecked implementation step). <main-root> is the first entry of
git worktree list โ the plan lives in the main checkout even when you
are running inside a .ship/ worktree.
- Report in one line, plus a state-aware suggestion: more unchecked plan
steps โ "next: continue the plan"; plan done, no self-review yet โ
"next:
/code-review"; review done, no PR โ "next: /create-pr".
On stop-without-green
Do not commit red work โ leave the tree dirty. Report honestly:
- Which gate is red, with the raw failing output.
- Attempts used and what each tried.
- The escalation proposal, if that's why you stopped.
Never report partial success as done.