Przejdź do treści
Biblioteka skilli
Programowanie · Przegląd i audyt

greenlight

/greenlight

Uruchamia zewnętrzne przeglądy PR w pętli: przetwarza uwagi, poprawia błędy i ponawia przegląd, aż nie zostaną nowe sugestie.

Repozytorium
solopreneur ↗
Licencja
MIT
Ostatnia zmiana repozytorium
08.11.2026

Ocena i bezpieczeństwo

89/ 100Klasa: dobry
Format25 / 25
Frontmatter z nazwą i opisem, poprawna nazwa, opis do 1024 znaków, nazwa zgodna z folderem.
Odkrywalność25 / 25
Opis mówi, kiedy użyć skilla, ma sensowną długość i jest w 3. osobie.
Treść26 / 35
Co najmniej 150 słów i do 500 linii, nagłówki, listy kroków, przykłady albo kod.
Higiena13 / 15
Bez zaślepek typu TODO, bez ścieżek Windows, z licencją.
Ryzykobrak sygnałów w skanie
Pliki w paczce
8
Skrypty
6
Komentarze HTML
0
Adresy URL w SKILL.md
1
Przestarzałość

Brak sygnałów. Repozytorium zmienione 08.11.2026, bez odwołań do wycofanych modeli i API.

Licencja

MIT, otwarta: można używać i zmieniać, z zachowaniem informacji o autorze.

Co sprawdzić przed instalacją
  • 6 skryptów w paczce. Przejrzyj je przed instalacją, bo Claude może je uruchomić.

Skrypty: scripts/config.sh, scripts/reviewer-registry.mjs, scripts/reviewer-state.mjs, tests/reviewer-registry.test.mjs, tests/reviewer-state.test.mjs, tests/skill-sync.test.mjs

Co robi i kiedy

Uruchamia zewnętrzne przeglądy PR w pętli: przetwarza uwagi, poprawia błędy i ponawia przegląd, aż nie zostaną nowe sugestie.

Wyzwalacze z opisu

greenlightrun reviews until cleanget this PR approved
Oryginalny opis (EN)

Automated PR review loop that keeps running until the PR is clean. Triggers external reviewers (Codex bot, Codex CLI, and the Gemini bot when activity detection sees it on the repo), processes feedback, fixes issues, and re-triggers — repeating until no new suggestions remain. Supports `/greenlight external` to skip internal review and go straight to external reviewers, and `/greenlight external gemini` to specify a starting reviewer. Use when the user says "greenlight", "run reviews until clean", "get this PR approved", or wants automated review cycling on an open PR. Also auto-detects uncomm

Jak działa

  1. Verification gate
  2. Inner verify loop (objective verifier gate)
  3. Escalation taxonomy (halt / flag / note)
  4. Sizing (S/M/L risk profile)
  5. Pre-flight Checks
  6. Argument Parsing
  7. Uncommitted Mode
  8. Post-commit Mode
  9. Phase 1: Internal Review
  10. Phase 2: Consolidate + Fix
Sekcje z nagłówków SKILL.md, w oryginale · 2 942 linii, 25 937 słów
Podgląd SKILL.md
---
name: greenlight
description: |
  Automated PR review loop that keeps running until the PR is clean. Triggers
  external reviewers (Codex bot, Codex CLI, and the Gemini bot when activity
  detection sees it on the repo), processes feedback, fixes issues, and
  re-triggers — repeating until no new suggestions remain.
  Supports `/greenlight external` to skip internal review and go straight to
  external reviewers, and `/greenlight external gemini` to specify a starting
  reviewer. Use when the user says "greenlight", "run reviews until clean",
  "get this PR approved", or wants automated review cycling on an open PR.

  Also auto-detects uncommitted mode: when on main branch with uncommitted
  changes and no PR, runs Codex CLI `--uncommitted` review loop only, fixes
  in-place without committing, until codex reports clean.

  Also supports post-commit mode (explicit `/greenlight post-commit <SHA>`
  or `<SHA1>..<SHA2>`): Phase 1 subagents + Codex CLI + agy (Gemini-family CLI)
  in parallel, fixes as new commits on top (no amend, no new PR), pushes after
  each round.
---

# Greenlight

Automated review loop. Three modes:

- **PR mode** (default, for open PRs on feature branches) — three phases:
  ```
  Phase 1: Internal Review (subagents review in parallel, report-only)
  Phase 2: Consolidate + Fix (merge reports → fix via /receiving-code-review → commit + push)
  Phase 3: External Review Loop (Codex/Gemini/CodeRabbit cycle until clean)
  ```
- **Uncommitted mode** (auto-detected when on `main` + uncommitted changes + no PR):
  Codex CLI `--uncommitted` loop only. Fixes in-place, does NOT commit.
- **Post-commit mode** (explicit `/greenlight post-commit <SHA>` invocation only,
  no auto-detect): Phase 1 subagents + Codex CLI `--commit <SHA>` + agy in
  parallel; merge findings; fix as new commits on top (no amend, no new PR). Skips
  PR-bound bots.

### Host support

On **Claude Code** this skill is fully supported: every mode, every phase.

On **Codex it is `degraded`** — it runs on exec, TUI, and App with a documented
smaller surface:

| | On Codex |
|---|---|
| Modes | PR mode only. Phase 1 runs there with whichever reviewers exist: `/specialist-review` (row 4) is published on Codex, the other four rows are Claude-only or third-party plugins, so an M-size run reviews with one reviewer and continues into Phase 2 under the existing at-least-one rule. `external` still skips Phase 1 + 2 when that is the intent. Uncommitted and post-commit modes **halt at pre-flight** — they have no gate and never call `resolve`, so their clean signal would be `codex review` approving its own host's work |
| Gate | `claude-cli` — the gate must be independent of the host's model family (see [Host-family independence](#host-family-independence)) |
| Sizes | **S and M only**; an L-size run halts at pre-flight |
| Invocation | the explicit `$greenlight` mention, plus the `unattended` token for any unattended caller — a one-shot exec session has nobody to answer a prompt |

Limitation reference: `docs/spec/2026-08-10-codex-greenlight-port.md`. The
filtered Codex publication includes this degraded surface. Reviewed-head
binding remains a shared Claude/Codex defect, not a Codex parity gate.

**Phase 1 is verified on Codex exec only**
(`docs/spec/2026-08-15-codex-greenlight-phase1.md`). TUI and App run the same
shared body with no surface gate, so Phase 1 is expected to work there and is
simply unproven; if it does not, the all-reviewers-unavailable rule already
carries those runs to Phase 3. Phase 3 itself is accepted on all three
surfaces.

### Arguments

| Argument | Description | Example |
|----------|-------------|---------|
| `external` | Skip Phase 1 + 2 (internal review), jump to Phase 3 (PR mode only) | `/greenlight external` |
| `codex bot` / `codex cli` / `gemini` | Specify starting reviewer (combinable with `external`, PR mode only) | `/greenlight external gemini` |
| `unattended` | Never prompt — on reviewer exhaustion, log and exit non-zero (fail fast). Passed by unattended callers (todos-babysit auto mode, autopilot dispatch). | `/greenlight external unattended` |
| `size=s\|m\|l` | Advisory starting size for the [S/M/L profile](#sizing-sml-risk-profile). **Upward-only** — greenlight recomputes size from the real diff and takes `max`, so this can raise but never lower review weight. Passed by autopilot from the plan's `size` field. | `/greenlight size=m` |
| `select=<ids>` | Comma-separated [registry](#reviewer-registry) recipe_ids to run this round. Omit to use every reviewer that acts on this repo. | `/greenlight select=coderabbit,codex-bot` |
| `gate=<id>` | The recipe_id whose clean pass ends the loop (see [Reviewer selection](#reviewer-selection-pr-mode)). Omit to take the first available `fallback_order` entry. | `/greenlight gate=codex-bot` |
| `post-commit [<SHA>\|<FROM>..<TO>]` | Force post-commit mode on a commit / range on `main` (pushed or local-only) | `/greenlight post-commit c1e7e256` |

**Parsing rules:**
- `post-commit` keyword (case-insensitive): forces post-commit mode regardless of repo
  state. Remainder is the SHA spec (single SHA, `FROM..TO` range, or empty to ask).
  Other args are ignored.
- `external` keyword (case-insensitive): PR mode only. Remainder is the reviewer spec.
- `unattended` keyword (case-insensitive): fail-fast, no prompts. Stripped before
  reviewer-spec parsing; combinable with any mode.
- `size=` token (case-insensitive, value `s`/`m`/`l`): advisory size for the
  [S/M/L profile](#sizing-sml-risk-profile), used in PR mode. Stripped before
  reviewer-spec parsing, like `unattended`; a malformed value is ignored. Not read
  in post-commit mode (it computes size from the resolved range) or uncommitted mode
  (unsized).
- `select=` / `gate=` tokens (case-insensitive): PR mode only. Stripped before
  reviewer-spec parsing on the **same line** as `unattended` and `size=` — a
  token left in the remainder becomes part of the reviewer spec, so
  `gate=codex-bot` would be looked up as a reviewer *named* `gate=codex-bot` and
  miss on every lookup thereafter. Unknown or since-marked ids degrade with a
  warning inside `resolve`; they never fail the run.
- No keyword: mode comes from auto-detection (see Step 1 table).

Arguments other than `post-commit` are ignored in **Uncommitted mode** and
**Post-commit mode** — those modes have fixed flows.

## Verification gate

An **optional adversarial verification gate** can run between consolidating review
findings and dispatching a fix subagent: each consolidated finding is independently
challenged by 3 skeptic subagents inside one Claude Code
[Workflow](https://code.claude.com/docs/en/workflows), and findings a majority of
skeptics refute are dropped. Only survivors reach the fix subagent. Purpose: cut
false-positive fix cycles — a wrongly "fixed" false positive costs a whole extra
review round.

**Availability check.** The gate runs ONLY when BOTH conditions hold: the effective
size is **L** (see [Sizing](#sizing-sml-risk-profile) — S and M skip the gate
regardless of tooling), AND the `Workflow` tool is present in the current session
(Claude Code v2.1.154+, paid plans). Before each gate, check both:

- **Size L and `Workflow` present** → run the gate. The script, `VERDICT_SCHEMA`,
  args contract, verdict rule, and result mapping are defined once in
  `references/adversarial-verify.md`.
- **Size S or M, or `Workflow` absent** → **skip the gate entirely; the flow is
  exactly today's flow** — hand every consolidated finding straight to the fix
  subagent. The gate is never a hard dependency of greenlight.

The gate applies at exactly three points, each carrying a short callout below:
PR-mode Phase 2a→2b, Post-commit Phase 1→Phase 2, and Post-commit Phase 3
Step 3→Step 4. It does NOT apply to **Uncommitted mode** or **PR-mode Phase 3**
(external review threads carry GitHub resolve/reply obligations and are already
evaluated per-thread through `receiving-code-review`).

**Rejected findings still count.** Gate-rejected findings count as "items pushed
back" in the final report, and their reasoning must be carried into later rounds'
"prior push-backs" context so a repeat finding can push-back-exit.

## Inner verify loop (objective verifier gate)

Every fix dispatch that ends in a commit is wrapped in an **inner verify loop**:
after the fix subagent edits, it runs an objective verify command against the
**working tree before committing**, and may commit + push only once that command
passes. This is a different question from the reviewer-clean stopping criterion —
keep the two roles separate:

- **Verifier (objective, runs code)** — gates whether a fix may **push**. It
  executes the repo's own lint / typecheck / fast-unit command and observes real
  behavior (import errors, type errors, regressions).
- **Reviewer-clean (subjective, reads diffs)** — gates whether the outer loop may
  **stop**. Codex / agy read the diff statically; they cannot run code, so they
  are **not** verifiers. Do not conflate the two, and never position codex/agy as
  the verifier.

Applies to the PR-mode **Phase 2b**, PR-mode **Phase 3** (Step 3b), and both
Post-commit fix dispatches (**Phase 2** initial fix and **Step 5**). **Uncommitted
mode is exempt** — it never commits, so there is nothing to gate; leave it as-is.

### Resolving the verify command

The orchestrator resolves the command **once**, before the first fix dispatch of
the run, and passes it into each fix subagent prompt. Source the config helpers
in the same bash block — the marker block from Pre-flight Step 2, copied as-is —
then:

```bash
# `verify` is stored as { "cmd": "<command>" }; pull the string out. An unset key
# makes read_* print nothing → jq gets empty stdin → 2>/dev/null keeps the block
# alive and VERIFY_CMD ends up empty.
VERIFY_CMD=$(read_solopreneur_config verify | jq -r '.cmd // empty' 2>/dev/null)
[ -z "$VERIFY_CMD" ] && echo "NO_VERIFIER" || echo "VERIFY_CMD=$VERIFY_CMD"
```

- **`VERIFY_CMD` empty (`NO_VERIFIER`)** → skip the inner loop entirely; the fix
  subagent commits exactly as it does today. Add one flag-style line to the final
  report: **"no objective verifier configured for this loop"** (see Flags below).
  Never invent a command.
- **`VERIFY_CMD` set** → pass it into every fix subagent this run, together with
  the inner-loop instructions below.

### Inner loop (inside the fix subagent)

The loop lives INSIDE the fix subagent's instructions — the subagent owns
edit → verify → iterate and only commits on a green verify. When `VERIFY_CMD` is
set, add this block to the fix subagent prompt (on top of that path's own
commit-message and hard-constraint instructions):

```text
You have an objective verify command: <VERIFY_CMD>. Before you commit:

1. Apply your fix edits to the working tree.
2. Run <VERIFY_CMD> against the working tree. Do NOT commit first — lint /
   typecheck / fast-unit are working-tree operations, so verify-before-commit
   holds in EVERY mode, post-commit included (no "broken commit + fix commit"
   sequence is ever created).
3. Pass (exit 0) → proceed to the commit + push step already specified for this
   path (unchanged commit message).
4. Fail (non-zero) → do NOT commit. Feed yourself back only a TRUNCATED log — the
   final failing assertion / first error line plus the tail, capped in size the
   same way this file caps agy input at AGY_MAX_DIFF_BYTES — and retry the fix.
5. Cap: 3 verify attempts total. On the 3rd consecutive failure, do NOT commit or
   push — return a structured halt result (reason `inner-verify-failed`,
   `reason_class: invariant-violation`, the FULL verify log, your attempted-fix
   summary) instead of committing.

Truncate every feedback log this way; the full log rides only in the halt
payload. Three stacked rounds of full logs would otherwise drown the signal.
```

### Anti-gaming guard (before every commit)

The cheapest way to make a failing verify "pass" is to edit the tests or the
verify command itself. The subagent must check, before it commits: **for every
test file or verify-definition file the fix diff touches, this round's findings
must explicitly reference that same file. If the diff touches a test file or the
verify definition that no finding called out → do not commit.** Match per file —
a finding about one test file does not license editing a different, unmentioned
test file. In both modes the immediate action is the same — **do not commit** — with the
reason `anti-gaming: fix touches test/verify definition unprompted`; the level differs
only in what follows. Unattended **halts** the loop (its halt payload carries
`reason_class: authority-boundary` → the orchestrator blocks); attended **flags** it and
lets the present human adjudicate the suspected gaming. This is the one deliberate
unattended-halt / attended-flag split (a suspected gaming edit is cheap to adjudicate
live), an intentional exception to the usual halt→ask projection noted in the
[Escalation taxonomy](#escalation-taxonomy-halt--flag--note).
At size S (added by a later PR) there are no internal reviewers, so this guard is the only
defense against fix-to-pass gaming — it lands here, not in the escalation PR.

### Halt / flag primitive

The level model that assigns halt / flag / note, the two-question rubric,
`reason_class`, the attended projection, and the findings-contradiction table all live
in [Escalation taxonomy](#escalation-taxonomy-halt--flag--note). This subsection is the
operational primitive the inner verify loop uses: how a halt is written and what the
orchestrator must do when one fires.

- **halt** — stop the loop and do not commit. Write a payload file — last round's
  findings + the FULL verify log + attempted-fix summary + a **`reason_class`**
  (`transient-dependency` / `invariant-violation` / `authority-boundary` — retry
  semantics in [Escalation taxonomy](#escalation-taxonomy-halt--flag--note)) +
  suggested next step —
  under `docs/loops/<run>/halts/` when running inside an autopilot run dir, else
  the standalone fallback `docs/loops/<date>_greenlight-<branch-slug>/halts/`
  (`<date>` = `YYYY-MM-DD`, `<branch-slug>` = current branch with every `/`
  replaced by `-`, so a slashed name like `feature/x` stays one flat directory
  instead of nesting). Reference the path in the final report. Unattended
  semantics: report **blocked** and exit non-zero. Attended: surface the payload
  path and ask the user how to proceed.
  - **Orchestrator obligation.** Every fix dispatch below can return a halt
    instead of committing. When it does, route straight to that mode's blocked
    exit: do NOT run the post-dispatch push verification (a halt leaves
    `HEAD == origin/main`, which would false-pass a `HEAD != origin/main` check),
    do NOT resolve review threads, and do NOT start another round.
- **flag** — do NOT stop; keep looping, but record the event in a dedicated,
  prominent **Flags** section of the final report (below) for a human to
  adjudicate afterward.

### Flags section (final report)

When any flag fired (no verifier configured, an attended anti-gaming catch, an
auto-classified size **S** without an explicit override, **a `DETECTION_STATUS`
of `unavailable`**, and the other flag sources in
[Escalation taxonomy](#escalation-taxonomy-halt--flag--note) — a pushed-back P1, a fix
over 20 lines, a merge with no CI signal, findings contradictions ① and ②),
append a prominent section to whichever mode's final report runs:

```text
## Flags (human review suggested)
- <flag reason 1>
- <flag reason 2>
```

Omit the section entirely when nothing flagged.

### Worst-case work bound

The inner loop is a newly multiplied retry layer, so make the nesting explicit.
The **wave ×2** wraps, per attempt, one implement pass followed by the greenlight
loop; within an attempt those two stages run in sequence, so their counts **add**,
they do not multiply. Autopilot's **Step 3 self-fix ×3** runs during implement,
then greenlight's outer review rounds — now **per size** (S 3 / M 5 / L 10; see
[Sizing](#sizing-sml-risk-profile)) — each wrap **inner verify ×3**. At the **L**
ceiling that is 10 × 3 = 30 fix attempts, so a single PR-mode L PR under autopilot
tops out near 2 × (3 + 10 × 3) = **66** fix attempts; a default **M** PR is
2 × (3 + 5 × 3) = **36** and an **S** PR is 2 × (3 + 3 × 3) = **24** — the self-fix
stage is additive with the review rounds, not a multiplier on them. The inner loop
multiplies fix work per round; a repo whose `verify` command is slow pays for it
here — which is why `verify` must stay fast and E2E stays in CI (see config
`verify` key).

## Escalation taxonomy (halt / flag / note)

Every escalation in this skill resolves to one of **three levels**. The model is
**unattended-first** (greenlight runs unattended under autopilot / todos-babysit), with
an [attended projection](#attended-projection) for manual runs. The operational
mechanics — how a halt payload is written, the orchestrator's obligation on a halt —
live in [Halt / flag primitive](#halt--flag-primitive); this section is the model that
assigns a level.

### Two-question rubric

Assign a level by asking, in order:

1. **Can the loop still continue?** A mechanical block — every reviewer tool is down,
   the environment is broken, the round budget is spent, an invariant is violated — is
   a **halt**. Not negotiable.
2. **Is this decision mine to make?** Three checks: **reversibility** (can a wrong call
   be undone cheaply?), **scope** (is it inside the spec / size authorization?), and
   **adjudicability** (is there a test or spec that mechanically decides right from
   wrong?). A decision that is expensive-if-wrong, or that cannot be mechanically
   adjudicated → escalate to a human (**flag**, or **halt** when it also blocks the
   loop). Everything else → act autonomously and leave a trace (**note**).

### The three levels

| Level | Behavior (unattended) | Examples |
|---|---|---|
| **halt** | Stop, write the payload, report — **blocked**, exit non-zero. | External reviewers all down; a broken invariant; a fix that must touch a dangerous path outside the size authorization; inner verify fails 3×. |
| **flag** | Keep looping; record the decision in the report's prominent **Flags** section for a human to adjudicate afterward. | A pushed-back P1; a fix over 20 lines; a loop that ran with no verifier configured; a merge with no CI signal; an auto-classified size **S**; findings contradictions ① and ② (below). |
| **note** | Normal stats — no special surfacing. | `fixed` / `pushed-back` counts; out-of-contract (③ note-tier) and style-only (⑤) push-backs. |

The **flag** middle tier is what makes unattended running safe: without it, an
unattended run could only choose between halting on everything and running fully
autonomously with no human ever told. Keep the Flags section signal-dense —
correctness-flavored events only; style noise stays at **note** (see contradiction ⑤).

### `reason_class` (halt retry semantics)

Every halt payload carries a **`reason_class`** so a downstream orchestrator can route
retry-vs-blocked without re-deriving intent:

| `reason_class` | Meaning | Retry semantics | Fires when |
|---|---|---|---|
| `transient-dependency` | A dependency is down but may recover. | **Retryable** — orchestrator waits and retries. | External reviewers all exhausted (unattended fallback). |
| `invariant-violation` | A hard stop the loop cannot resolve itself — a broken correctness / state invariant, or the round budget spent without convergence. | **Do not retry** — orchestrator marks blocked. | Inner verify fails 3×; a post-commit invariant violation (TIP ≠ HEAD, origin/main unreachable, BASE unreachable, push-verification mismatch, branch changed mid-loop); the round budget spent (max `SIZE_MAX_ROUNDS` reached with findings still unresolved). |
| `authority-boundary` | The next step needs authority the run does not have — refuse. | **Do not retry — a human must intervene.** | A fix would touch a dangerous path outside the size authorization (contradiction ③); the anti-gaming guard's **unattended** halt (a refusal to commit a suspected gaming edit); **no independent gate** (`RESOLVED.gateBlock == "host-family"` — every authorized reviewer shares the host's model family); an **L-size run**, or an **uncommitted / post-commit run**, **on a non-anthropic host**. |

`reason_class` governs only the **unattended** halt's retry routing; it does **not**
dictate the attended projection (that is set by the level — see
[Attended projection](#attended-projection)). The two are independent axes: the
anti-gaming guard writes an `authority-boundary` payload when it halts unattended, yet
its attended level is deliberately **flag**, not the usual halt→ask (the one documented
exception — see [Anti-gaming guard](#anti-gaming-guard-before-every-commit)).

The autopilot orchestrator consumes this from the halt payload greenlight references in
its report — see `../autopilot/references/orchestrator.md` (failure table).

### Attended projection

The three levels are unattended-first, but greenlight is also run manually, and the
flow is full of "ask the user" branches. Attended runs **project** the levels — with no
regression to existing interactive behavior:

| Level | Unattended | Attended |
|---|---|---|
| **halt** | blocked, exit non-zero | **ask the user and wait** — the loop is blocked until they decide (not a hard exit): the reviewer-exhaustion wizard, the invariant stops |
| **flag** | record in the Flags section | **surface inline** during the run (and still record it in the Flags section) — a decision-point flag (a contradiction, a >20-line fix) keeps its existing user prompt so the human can weigh in, but, unlike a halt, the run is never hard-blocked |
| **note** | stats | stats |

The distinction is not "prompt vs. no prompt" — it is whether the loop can proceed. A
**halt** cannot continue without the answer (attended blocks on it; unattended exits);
a **flag** always has a defined next move (unattended records + proceeds per the level /
table), and attended merely surfaces it — keeping any pre-existing prompt — so the human
can redirect. So every existing "ask the user" behavior maps on with no regression: the
reviewer-exhaustion wizard is a halt (ask and wait); an ambiguous consolidation and the
">20 lines discuss first" note are decision-point flags (surfaced with their prompt
intact).

### Findings-contradiction handling table

Reviewers can contradict each other (or the spec), and the verification gate's skeptics
validate each finding independently — they never cross-compare, so both sides of a
contradiction can survive. **Conservative side = leave the current state untouched**
(no-action), never guess one side and execute it. Unattended disposition:

| # | Contradiction | Disposition (unattended) |
|---|---|---|
| ① | **Same-round opposite fixes** for the same code (e.g. ponytail says delete a defensive check, specialist says add a null check) | Apply **neither** — no-action is the only move that negates neither side and keeps the state that already passed prior rounds → record both as pushed-back(contradiction) + **flag**. |
| ② | **Cross-round flip-flop** — a new finding would revert a previously accepted fix (e.g. round 1 extract a helper, round 3 inline it back) | Maintain a per-loop **accepted-fixes journal** and include it in the fix subagent's prompt; a mutually-exclusive new finding is **not executed** → pushed-back(flip-flop) + **flag**. Conservative side = the already-accepted fix (no thrashing). |
| ③ | **Finding conflicts with the spec / size authorization** — mechanically adjudicable, the spec is the judge | The spec wins → pushed-back(out-of-contract) + **note**. If the reviewer's reasoning is correctness-grade (it implies the spec itself is wrong) → escalate to **flag**. If the fix would touch a dangerous path → **halt** (`authority-boundary`). Standalone `/greenlight` with no spec: this type degenerates to ①. |
| ④ | **Reviewer P1 vs fix-subagent false-positive push-back** (reviewer vs fix agent, not two reviewers) | Push back the P1 → **flag** (pre-existing decision; listed for completeness). |
| ⑤ | **Style-only contradiction** — the low-stakes version of ① (e.g. one wants more comments, one finds them noisy) | No action + **note** — never flag; every style contradiction flagged would drown the Flags section, which stays correctness-flavored. |

**Attended runs keep asking** — ①② are decision-point flags and ③'s dangerous-path
case is a halt; either way the [attended projection](#attended-projection) surfaces the
existing user prompt (the flag inline, the halt blocking). One-line summary:
mechanically adjudicable → let the spec judge;
otherwise leave the state untouched — flag the correctness-grade contradictions, note
the style ones; the only halt is a fix that crosses the authorization boundary.

### Where the existing sites map

The taxonomy re-labels existing behavior; only two behaviors change (contradictions no
longer ask the user in unattended runs — the table above; and the orchestrator now
defers its round bound to greenlight — orchestrator.md). The scattered rules map as:

- **Phase 1 all internal reviewers fail** → **unchanged**: skip Phase 1 + 2 and proceed
  to Phase 3 (NOT a halt — internal review is optional; external review still runs).
  See [Phase 1](#phase-1-internal-review) "All fail".
- **External fallback exhausted** (all reviewers down) → **halt**,
  `reason_class: transient-dependency` — see [Fallback Logic](#fallback-logic).
- **No independent gate** (every authorized reviewer shares the host's model
  family) → **halt**, `reason_class: authority-boundary` — waiting cannot add a
  reviewer of another family, so this is deliberately NOT routed as retryable.
  See [Host-family independence](#host-family-independence).
- **Post-commit invariant violations** → **halt**, `reason_class: invariant-violation` —
  the invariant guards in [Post-commit parsing](#post-commit-mode-parsing-modepost-commit-only)
  and the per-round re-checks.
- **Fix over 20 lines** → **flag** (a decision-point flag: attended surfaces it inline
  with the existing "discuss first" prompt; unattended records it and proceeds).
- **Contradictory findings** → the
  [table above](#findings-contradiction-handling-table).
- **Inner verify 3× fail** → **halt**, `reason_class: invariant-violation` — see
  [Inner verify loop](#inner-verify-loop-objective-verifier-gate).
- **Anti-gaming catch** → the deliberate **unattended-halt / attended-flag** split from
  the verifier PR: "do not commit" holds in both modes; unattended halts the loop (payload
  `reason_class: authority-boundary`), attended flags it for the present human to
  adjudicate. See [Anti-gaming guard](#anti-gaming-guard-before-every-commit).

## Sizing (S/M/L risk profile)

Not every PR needs the full review weight — a one-line docs fix and a payment-path
refactor should not run the same five reviewers for ten rounds. Greenlight
classifies each run **by risk** into **S** / **M** / **L** and gates the expensive
phases on the result. **PR mode and Post-commit mode are sized; Uncommitted mode is
exempt** — it is a local, no-commit, interactive flow, keeps its own fixed loop, and
never computes a size.

### Mechanical cascade (bash-computable, no LLM judgment)

Size is computed from the **real diff** — its file list and line counts — by a
deterministic cascade. No model judgment enters the classification. The asymmetry is
deliberate: **L is OR** (any one danger signal escalates) while **S is AND** (every
file must be harmless to de-escalate). When the signals disagree, the cascade
escalates — L is checked first and wins over S.

1. **L — any of these (OR):**
   - a touched path matches `migrations/`, auth / payment / crypto code,
     `.github/workflows/`, a `Dockerfile` / container / infra config (k8s, Helm,
     Terraform), or a dependency manifest with a substantive change — `package.json`,
     `requirements*.txt`, `Pipfile`, `pyproject.toml`, `go.mod`, `build.gradle(.kts)`,
     `pom.xml`, `Podfile`, and the like (lockfiles excluded — they are generated, not
     authored);
   - OR the diff exceeds ~400 changed lines, excluding lockfiles and generated files.
2. **S — all touched files fall inside the whitelist (AND):** `docs/**`
   (**excluding `docs/loops/**`** — that is live orchestration config the autopilot
   reads and executes, not prose), `todos/**`, the **repo-root** `README.md` only
   (plugin READMEs carry install commands and stay out), `LICENSE`, `.gitignore`.
   Never a global `*.md` glob — in a skill-type repo the product *is* markdown, so a
   `SKILL.md` change must classify **M**, not S.
3. **Otherwise → M.** Any uncertainty in classification defaults to **M**.

Config files are deliberately **not** in the S whitelist: a config error is a silent
runtime behavior change, so config edits stay at M. (The former "cross-module
boundary" trigger is deliberately dropped — it is not mechanically computable, so it
is not part of this cascade.)

```bash
# Compute COMPUTED_SIZE from a diff range. Callers set DIFF_RANGE:
#   PR mode      → "main...HEAD"            (three-dot: changes on this branch)
#   Post-commit  → "<BASE_SHA>..<TIP_SHA>"  (two-dot; single commit → "<TIP>^..<TIP>")
FILES=$(git diff --name-only "$DIFF_RANGE")
COMPUTED_SIZE=M

# --- L: any danger signal (OR). Over-matching only over-reviews, which is the safe
#     direction for an OR cascade — a missed danger under-reviews. The auth/payment/
#     crypto tokens match anywhere in a path on purpose (catch oauth, cryptography,
#     prepayment, …); a rare false hit like "author" simply escalates. ---
if printf '%s\n' "$FILES" | grep -qiE \
   '(^|/)migrations/|auth|payment|crypto|^\.github/workflows/|(^|/)Dockerfile|(^|/)(docker-compose|Containerfile)|(^|/)(k8s|kubernetes|helm)/|\.(tf|tfvars)$|(^|/)(package\.json|requirements([-/][^/]*)?\.txt|Pipfile|setup\.(py|cfg)|pyproject\.toml|go\.mod|Gemfile|build\.gradle(\.kts)?|libs\.versions\.toml|pom\.xml|Podfile|Cargo\.toml|Package\.swift|composer\.json)$'; then
  COMPUTED_SIZE=L
fi
# Line budget: additions + deletions, excluding lockfiles + generated files, > ~400 → L.
# numstat is "<add>\t<del>\t<path>", so match the PATH field ($3): its `^` anchors to
# the path start. A line-level (^|/) anchor would MISS a root lockfile — its path is
# preceded by a tab, not "/" or start-of-line, so only nested lockfiles would match.
# ($1/$2 are "-" for binary files; awk reads "-" as 0, so binaries add nothing.)
LINES=$(git diff --numstat "$DIFF_RANGE" | awk -F'\t' '
  $3 ~ /(^|\/)(package-lock\.json|npm-shrinkwrap\.json|yarn\.lock|pnpm-lock\.yaml|bun\.lock|bun\.lockb|deno\.lock|Cargo\.lock|poetry\.lock|uv\.lock|Pipfile\.lock|Gemfile\.lock|composer\.lock|Podfile\.lock|gradle\.lockfile|packages\.lock\.json|go\.sum|Package\.resolved)$/ { next }
  $3 ~ /\.generated\.|\.min\.(js|css)$/ { next }
  { a+=$1; d+=$2 } END { print a+d+0 }')
[ "${LINES:-0}" -gt 400 ] && COMPUTED_SIZE=L

# --- S: every file inside the whitelist (AND), only when not already L. The case
#     matches docs/loops/* FIRST so it is excluded from the docs/ allowance;
#     README.md / LICENSE / .gitignore match the repo root only (a nested path has a
#     slash and falls through to the outside bucket). Any file outside → not S. ---
if [ "$COMPUTED_SIZE" != L ] && [ -n "$FILES" ]; then
  OUTSIDE=$(printf '%s\n' "$FILES" | grep -v '^[[:space:]]*$' | while IFS= read -r f; do
    case "$f" in
      docs/loops/*)                 printf '%s\n' "$f" ;;  # live orchestration config — excluded
      docs/*|todos/*)               ;;                     # whitelisted
      README.md|LICENSE|.gitignore) ;;                     # whitelisted (repo-root only)
      *)                            printf '%s\n' "$f" ;;  # anything else → outside the whitelist (echo would mangle a "-n"/"-e" filename)
    esac
  done | grep -c .)
  [ "${OUTSIDE:-1}" -eq 0 ] && COMPUTED_SIZE=S
fi
echo "COMPUTED_SIZE=$COMPUTED_SIZE"
```

### Size override & freshness

A caller may pass a `size=s|m|l` token (see [Arguments](#arguments)). It is
**advisory and upward-only**: the size computed from the real diff is authoritative,
and the **effective size is `max(passed, computed)`** on the order **S < M < L**. A
token never lowers the computed size. This makes scope creep upgrade-only and defeats
"planned S, grew into M" gaming — a PR scoped `size=s` that actually touches auth is
still reviewed as L.

```bash
# EFFECTIVE_SIZE = max(SIZE_ARG token, COMPUTED_SIZE). SIZE_ARG is the `size=` value
# (empty when absent). Upward-only: the token can only RAISE the computed size.
rank() { case "$1" in [sS]) echo 0;; [mM]) echo 1;; [lL]) echo 2;; *) echo -1;; esac; }
EFFECTIVE_SIZE=$COMPUTED_SIZE
if [ -n "${SIZE_ARG:-}" ] && [ "$(rank "$SIZE_ARG")" -gt "$(rank "$COMPUTED_SIZE")" ]; then
  EFFECTIVE_SIZE=$(printf '%s' "$SIZE_ARG" | tr '[:lower:]' '[:upper:]')
fi
case "$EFFECTIVE_SIZE" in S) SIZE_MAX_ROUNDS=3;; M) SIZE_MAX_ROUNDS=5;; L) SIZE_MAX_ROUNDS=10;; esac
# Auto-S flag: cascade landed on S with no explicit override → flag for a human to
# sanity-check the classification (see the Flags section). An explicit size=s is a
# human decision and is NOT flagged.
[ "$COMPUTED_SIZE" = S ] && [ -z "${SIZE_ARG:-}" ] && echo "FLAG: auto-sized S — verify"
echo "EFFECTIVE_SIZE=$EFFECTIVE_SIZE SIZE_MAX_ROUNDS=$SIZE_MAX_ROUNDS"

# The host's model family, detected the same way `solopreneur_config_home` detects
# the harness: CODEX_THREAD_ID is exported on every Codex session.
HOST_FAMILY=$([ -n "${CODEX_THREAD_ID:-}" ] && echo openai || echo anthropic)
echo "HOST_FAMILY=$HOST_FAMILY"

# L-size is Claude-Code-only. L wants all five Phase 1 reviewers and three of them
# are Claude-only or third-party, so a non-anthropic host cannot staff the size it
# advertises. And wherever fix processing does fall back to inline (see Step 3), one
# incomplete S-size round already measured ~212k tokens, so ten L-size rounds would
# not fit either. Halting here is honest scope; running anyway would degrade
# silently, mid-loop, after paying for reviews.
if [ "$EFFECTIVE_SIZE" = L ] && [ "$HOST_FAMILY" != anthropic ]; then
  echo "HALT: L-size runs need a Claude Code host (reason_class: authority-boundary)"
  exit 1   # a guard that only prints is not a guard — stop before any reviewer runs
fi
```

**An L-size run on a non-anthropic host halts here, before any reviewer is
triggered** — write the halt payload with `reason_class: authority-boundary` and
stop. It is not retryable: the host does not change by waiting. The two real
fixes are to re-run the loop on a Claude Code host, or to split the PR until it
sizes S or M. See [Host support](#host-support).

When the cascade auto-classifies **S** with no explicit override, add one flag-style
line — **"auto-sized S — verify"** — to the final report (see the Flags section under
Inner verify loop).

### Profile — what each size gates

Reviewer selection is expressed in the [Reviewer Registry](#reviewer-registry)
vocabulary; no bot login is hardcoded here.

| Effective size | Phase 1 internal | Verification gate | Phase 3 external loop (`SIZE_MAX_ROUNDS`) |
|---|---|---|---|
| **S** | **skip** | **skip** | Phase 3 only, **one external reviewer** — PR mode via its registry-driven `current_reviewer` + `fallback_order` (no-history default `codex-bot` on a Claude host, `claude-cli` on a Codex host; any available independent reviewer may gate instead — see [Host-family independence](#host-family-independence)); Post-commit via the single preferred available CLI (Codex CLI, else agy) instead of its usual parallel pair — loop to clean, **max 3 rounds** |
| **M** (default) | **2 reviewers** — `/specialist-review` + `ponytail:ponytail-review` (rows 4–5 of the Phase 1 table) | **skip** | standard registry loop, **max 5 rounds** |
| **L** | **all 5 reviewers** | **ON** (when the `Workflow` tool is available) | full registry fallback chain, **max 10 rounds** |

- **S** behaves like `external_only` with a 3-round cap: Phase 1 and Phase 2 are
  skipped and the run goes straight to Phase 3, **still looping to a clean result**
  (S is not a single-pass mode — the cost cap is the round bound, not one shot).
  Because S is external-only, its one reviewer must actually be available: when no
  explicit reviewer arg and no `fallback_order` are configured, resolve the round's
  **gate** to the **first available** external reviewer, preferring codex —
  `codex-cli` when its pre-flight CLI gate passed, else a detected github-bot (prefer
  `codex-bot`), else the `codex-bot` default with the existing not-detected warning.
  This reuses the pre-flight CLI gate and activity detection (registry vocabulary, no
  hardcoded logins), so an unattended S run uses the authed CLI instead of failing on
  an absent bot. **The codex preference above is the Claude-host one.** On a Codex
  host every codex-family candidate is filtered out of gate selection, so the gate
  falls to whichever **independent** candidate is available — `claude-cli` via the
  pre-flight CLI probe when it is the only one, which is the common case, but a
  detected independent bot (`coderabbit`, `bugbot`, `greptile`) is an equally valid
  gate and the resolver may pick it. There is deliberately no preference *among*
  independent reviewers: `claude-cli` is the host-conditional **no-history default**
  (what gets seeded when nothing is known here), not something that outranks a
  reviewer already active on the repo. With no independent candidate at all the run
  halts rather than gating on its own family
  (see [Host-family independence](#host-family-independence)).
  Post-commit S likewise runs a single preferred available CLI (Codex
  CLI, else agy) rather than the usual codex-CLI + agy pair, shedding the doubled cost.
- The **verification gate** already runs only when the `Workflow` tool is present;
  sizing adds a second condition — it runs **only at size L** (S and M skip it even
  when `Workflow` is available).
- The **inner verify loop is not size-differentiated**: every size runs the same
  single `verify` command (see [Inner verify loop](#inner-verify-loop-objective-verifier-gate)).
  Sizing dials review weight, not the objective verifier.

`SIZE_MAX_ROUNDS` (**3 / 5 / 10** for **S / M / L**) is the Phase 3 loop bound in
**both** PR mode and Post-commit mode.

## Pre-flight Checks

### Step 1: Mode detection

Determine whether to run **PR mode** or **Uncommitted mode** based on current repo state:

```bash
CURRENT_BRANCH=$(git branch --show-current)
HAS_UNCOMMITTED=$(git status --porcelain | grep -q . && echo yes || echo no)
# Probe PR existence for current branch (stderr suppressed; no PR → non-zero exit)
if gh pr view --json number,state >/tmp/gl-pr.json 2>/dev/null; then
  PR_EXISTS=yes
  PR_STATE=$(jq -r .state /tmp/gl-pr.json)
else
  PR_EXISTS=no
  PR_STATE=none
fi
# Peek at args (case-insensitive) for the `post-commit` keyword — it forces
# post-commit mode regardless of repo state.
# RAW_ARGS = the args string from the skill invocation; the orchestrator must
# export this before evaluating the snippet.
HAS_POST_COMMIT_ARG=$(echo "$RAW_ARGS" | grep -iq "post-commit" && echo true || echo false)
echo "BRANCH=$CURRENT_BRANCH UNCOMMITTED=$HAS_UNCOMMITTED PR=$PR_EXISTS/$PR_STATE POST_COMMIT_ARG=$HAS_POST_COMMIT_ARG"
```

**Override:**
- If `HAS_POST_COMMIT_ARG=true` AND `CURRENT_BRANCH != main`, **stop with a clear
  error**: post-commit mode is only valid on `main` (Phase 3 hardcodes `main` /
  `origin/main` checks and would crash on a feature branch). Tell the user to
  either switch to `main` or use PR mode (`/greenlight` on the feature branch with
  an open PR).
- If `HAS_POST_COMMIT_ARG=true` AND `CURRENT_BRANCH == main` AND `HAS_UNCOMMITTED=no`,
  set `MODE=post-commit` immediately and skip the rest of this table.
- If `HAS_POST_COMMIT_ARG=true` AND `CURRENT_BRANCH == main` AND `HAS_UNCOMMITTED=yes`,
  **stop and ask the user how to proceed** before continuing — options: (A) stash
  uncommitted changes and proceed with post-commit review, (B) abort, (C) proceed
  but only stage explicit files for the fix commits. Do NOT auto-include uncommitted
  WIP in the post-commit fix commits — they would be pushed to `origin/main` together
  with the review fix.

**Mode table:**

| Branch | Uncommitted | PR (open) | MODE | Action |
|---|---|---|---|---|
| `main` | yes | no | **uncommitted** | Enter Uncommitted mode (skip all phases below) |
| `main` | yes | yes (open) | **ask** | Unusual — ask user: "On main with uncommitted + open PR. Run uncommitted mode on working tree, or abort?" |
| `main` | no | no, AND `HAS_POST_COMMIT_ARG=true` | **post-commit** | Resolve commit range from the SHA argument; enter Post-commit mode |
| `main` | no | — | **stop** | Nothing to review on main; tell user |
| feature / worktree | — | yes (open) | **pr** | Continue with Pre-flight Step 2 below (default flow) |
| feature / worktree | yes | no | **ask** | Ambiguous — ask user: "On feature branch with uncommitted and no PR yet. (A) Commit and push first to create PR, then review (B) Run uncommitted mode on working tree (C) Abort" |
| feature / worktree | no | no | **stop** | No PR + no changes; tell user to commit or create PR first |

The post-commit row is more specific than the stop row — match it first; otherwise fall through to stop.

**Mode guard — PR mode only on a non-anthropic host.** Run this the moment `MODE`
is decided, before Step 2 and before any side effect:

```bash
HOST_FAMILY=$([ -n "${CODEX_THREAD_ID:-}" ] && echo openai || echo anthropic)
if [ "$HOST_FAMILY" != anthropic ] && [ "$MODE" != pr ]; then
  echo "HALT: $MODE mode needs a Claude Code host (reason_class: authority-boundary)"
  exit 1   # stop here, before Step 2 and before any side effect
fi
```

Halt with `reason_class: authority-boundary` and stop. **Uncommitted and
post-commit modes have no gate and never call `resolve`**, so the host-family
independence below does not reach them at all: their terminal clean signal is
`codex review`'s own stdout, which on a Codex host is the host's model family
declaring its own work clean. That is the same-family self-approval the gate
filter exists to prevent, arriving through a door the filter does not watch.
[Host support](#host-support) already scopes Codex to PR mode; this is the check
that makes the scope real rather than merely documented. Not retryable — the
fixes are to run the mode on a Claude Code host, or to open a PR and use PR mode.

In **PR mode** on such a host, Phase 1 runs. Codex creates real child threads,
and `/specialist-review` (row 4) is published there, so at M size one reviewer is
available and the existing at-least-one rule carries the run into Phase 2. The
Claude-only and third-party rows are logged as unavailable, exactly as they are
on a Claude host that lacks them. Phase 1 and 2 are still skipped on the same
three conditions as anywhere else — `external_only == true`,
`EFFECTIVE_SIZE == S`, or *every* selected reviewer turning out unavailable.
Nothing here loosens the Size S rule; `external` remains the way to state that
intent rather than relying on the all-reviewers-unavailable degradation.

If `MODE=uncommitted`, skip Steps 2-5 below and Argument Parsing; jump directly to **[Uncommitted Mode](#uncommitted-mode)**.

If `MODE=post-commit`, skip PR-mode pre-flight Step 2 below; do Argument Parsing (post-commit subsection) to resolve `RANGE_SPEC`, then jump to **[Post-commit Mode](#post-commit-mode)**.

### Step 2: PR mode pre-flight (MODE=pr only)

1. PR info already recorded in Step 1 (`/tmp/gl-pr.json`). Confirm state is `OPEN`; if not, stop.

2. Confirm working directory is clean:
   ```bash
   git status --porcelain
   ```
   If uncommitted changes exist, ask the user whether to commit first.

3. Record the PR number and repo owner/name (from `gh repo view --json owner,name`).

4. Read reviewer fallback config:
   ```bash
   # --- solopreneur config helpers (sourced from shared/config.sh) ---
   # One real shell file, so no harness rewrites the helpers on the way to the
   # shell. Claude Code replaces the ${CLAUDE_SKILL_DIR} token below when it loads
   # this body; Codex does not. It is SINGLE-quoted on purpose — it is a load-time
   # token, not an environment variable, and letting the shell expand the name
   # would source whatever an inherited value happened to point at. Unreplaced, it
   # is not a directory, so substitute the absolute path of the directory holding
   # THIS SKILL.md — every harness states that path to the model.
   SOLO_SKILL_DIR='${CLAUDE_SKILL_DIR}'
   [ -d "$SOLO_SKILL_DIR" ] || SOLO_SKILL_DIR="<absolute path of the directory holding this SKILL.md>"
   SOLO_CONFIG_SH="$SOLO_SKILL_DIR/../../shared/config.sh"
   # Three candidates, one contract. Inside the plugin the helpers sit at ../../shared/;
   # authoring against this repo reaches them under src/solopreneur/shared/; and a
   # skill republished on its own — any flattened skills directory — carries them
   # at scripts/config.sh instead, because shared/ is a sibling of skills/ and does
   # not travel with a per-skill copy. Try each in order, then STOP. Sourcing a
   # file that is not there does not halt the shell: every helper stays undefined,
   # every config read returns empty, and the 2026-08-11 A2 run showed where that
   # leads — the model "rescued" it with a repo-relative path, which resolves only
   # when the repo under review happens to be this plugin's own source repo.
   # Canonical authoring keeps non-skill source under src/.
   [ -f "$SOLO_CONFIG_SH" ] || SOLO_CONFIG_SH="$SOLO_SKILL_DIR/../../../src/solopreneur/shared/config.sh"
   [ -f "$SOLO_CONFIG_SH" ] || SOLO_CONFIG_SH="$SOLO_SKILL_DIR/scripts/config.sh"
   [ -f "$SOLO_CONFIG_SH" ] || { echo "HALT: solopreneur config helpers not found under $SOLO_SKILL_DIR — stop here, do not improvise a path"; exit 1; }
   source "$SOLO_CONFIG_SH"
   # --- end solopreneur config helpers ---

   GL_CFG=$(read_solopreneur_config greenlight)
   [ -z "$GL_CFG" ] && echo "NO_CONFIG" || echo "$GL_CFG"

   # Objective verifier command for the inner verify loop (see "Inner verify
   # loop"). Empty when unconfigured → inner loop is skipped and the run is
   # flagged "no objective verifier configured for this loop".
   VERIFY_CMD=$(read_solopreneur_config verify | jq -r '.cmd // empty' 2>/dev/null)
   [ -z "$VERIFY_CMD" ] && echo "NO_VERIFIER" || echo "VERIFY_CMD=$VERIFY_CMD"
   ```
   If config exists, read `fallback_order` from the `greenlight` key.
   If absent (`NO_CONFIG`), use default: codex-bot as starting reviewer, ask user on failure.

### Step 3: Codex CLI availability (both modes)

```bash
command -v codex &>/dev/null && echo "CODEX_INSTALLED=true" || echo "CODEX_INSTALLED=false"
codex login status 2>/dev/null && echo "CODEX_AUTH=true" || echo "CODEX_AUTH=false"
```

- **PR mode**: Best-effort hint. Used later by Argument Parsing to gate `codex cli` reviewer selection.
- **Uncommitted mode**: Required. If `CODEX_INSTALLED=false` or `CODEX_AUTH=false`, stop with install instructions:
  - Not installed → `npm install -g @openai/codex`
  - Not authenticated → `codex login`

---

## Argument Parsing

> **⏭️ Skip this section entirely if `MODE=uncommitted`** — jump to [Uncommitted Mode](#uncommitted-mode).

### Post-commit mode parsing (MODE=post-commit only)

```
raw_args = args ?? ""
spec = raw_args after "post-commit" keyword (trimmed) — empty if keyword absent

if spec is empty:
  → ask user to provide a SHA or range (e.g., "/greenlight post-commit <SHA>")
elif spec matches a single SHA (verify with `git rev-parse --verify <SHA>^{commit}`):
  RANGE_SPEC = single, BASE_SHA = "<SHA>^", TIP_SHA = "<SHA>"
elif spec matches "<FROM>..<TO>" (verify both SHAs exist):
  # Follow standard git revision-range semantics: FROM is exclusive, TO is inclusive.
  # `git diff <FROM>..<TO>` shows changes between FROM's tree and TO's tree, which
  # equals the cumulative effect of commits (FROM, TO]. Do NOT use "<FROM>^" — that
  # would include FROM itself, contradicting the `..` convention the user typed.
  RANGE_SPEC = range,  BASE_SHA = "<FROM>", TIP_SHA = "<TO>"
else:
  → tell user spec is invalid, stop

# Invariant: TIP_SHA must equal HEAD.
# Reviewing a historical range (TIP_SHA < HEAD) would let downstream tools leak
# past the user's intended tip: `codex review --base BASE` reviews BASE..HEAD
# (not BASE..TIP), and the per-round `TIP_SHA = HEAD` advance in Phase 3 would
# sweep in unrelated intermediate commits on subsequent rounds. Rather than
# silently expanding scope, reject historical ranges up front.
if `git rev-parse <TIP_SHA>` != `git rev-parse HEAD`:
  → stop with: "Post-commit mode requires TIP_SHA == HEAD. Got TIP=<short-SHA>,
     HEAD=<short-SHA>. For historical-only review of a single commit, invoke per-commit
     instead: `codex review --commit <SHA>`."

# Invariant: origin/main must be reachable from HEAD (local main not behind origin).
# Post-commit mode's contract is "review committed work" — push state is not part
# of the contract. Local-only commits (HEAD ahead of origin/main) are allowed: the
# review loop's fix-on-top push will publish them together with the fix commits,
# which is the expected "review then land" flow.
# What we MUST prevent is a stale local main (HEAD behind origin/main): the
# per-round fix-on-top push would be rejected as non-fast-forward, breaking the loop.
# `git merge-base --is-ancestor origin/main HEAD` returns true iff origin/main is
# reachable from HEAD — which holds when HEAD == origin/main OR HEAD is ahead of
# origin/main, but fails when HEAD is behind. Exactly the condition we want.
git fetch origin main
if ! git merge-base --is-ancestor origin/main HEAD:
  → stop with: "Post-commit mode requires local main to not be behind origin/main
     (origin/main must be reachable from HEAD). Got HEAD=<short-SHA>,
     origin/main=<short-SHA>. Pull/rebase first, then re-invoke."

# Invariant: BASE_SHA must be reachable from origin/main.
# When HEAD is ahead of origin/main, the fix-on-top push at end-of-loop will
# publish everything in (origin/main, HEAD]. If RANGE_SPEC starts past
# origin/main (BASE_SHA itself local-only), commits in (origin/main, BASE_SHA]
# would be pushed without ever being reviewed. Require BASE_SHA to be on or
# before origin/main so the reviewed range (BASE_SHA, HEAD] covers every
# local-only commit on the branch.
if ! git merge-base --is-ancestor <BASE_SHA> origin/main:
  → stop with: "BASE_SHA must be reachable from origin/main — the reviewed
     range must cover all local-only commits, otherwise unreviewed commits
     would be pushed by the fix-on-top loop. Got BASE=<short-SHA>, which is
     itself local-only. Either widen the range to start at or before
     origin/main, or push existing local commits first."
```

> These invariant guards — and the per-round re-checks in Phase 3 (Step 1's branch /
> BASE / TIP checks and the push-verification gates) — are **halt /
> `invariant-violation`** in the
> [Escalation taxonomy](#escalation-taxonomy-halt--flag--note): a hard stop the
> orchestrator must not retry (attended: surface the error and ask the user).

After resolving, jump to **[Post-commit Mode](#post-commit-mode)** — skip the PR mode parsing block below.

### PR mode parsing (MODE=pr only)

```
# Parse external mode and reviewer from args
# e.g.: "/greenlight external gemini" → external_only=true, reviewer="gemini"
# e.g.: "/greenlight codex cli"       → external_only=false, reviewer="codex cli"
# e.g.: "/greenlight external"        → external_only=true, reviewer="codex bot" (default)

raw_args = args ?? ""
# Match WHOLE whitespace-delimited tokens case-insensitively — never a substring.
# Substring matching would let "unattendedness" enable unattended mode and would
# corrupt a reviewer name that happens to contain "external".
tokens = raw_args split on whitespace
external_only = tokens has a token equal (case-insensitive) to "external"
unattended    = tokens has a token equal (case-insensitive) to "unattended"
size_arg      = value of a token matching (case-insensitive) "size=<s|m|l>", else ""
                (a malformed size=… value is ignored — treated as "")
select_arg    = value of a token matching (case-insensitive) "select=<ids>" — a
                comma-separated list of recipe_ids from the Reviewer Registry, else ""
gate_arg      = value of a token matching (case-insensitive) "gate=<id>" — the one
                recipe_id whose clean pass ends the loop, else ""
reviewer_args = tokens with the "external"/"unattended"/"size=…"/"select=…"/"gate=…"
                tokens dropped, rejoined + trimmed
current_reviewer = reviewer_args non-empty ? reviewer_args : "codex bot"

# The two selection tokens are handed straight to `resolve` (see Reviewer
# selection). Both are validated there, and a stale one degrades with a warning
# rather than failing — they may come from an autopilot descriptor written days
# ago, and a stale token must not turn an unattended run into an empty one.
SELECTED_RECIPES = select_arg

# `unattended` (set by todos-babysit auto mode / autopilot dispatch): every
# "ask the user" branch in Reviewer selection / Fallback Logic below becomes
# "log the reason and exit non-zero" — never block on input.

# Codex CLI availability gate: if user specified codex cli but CLI unavailable, fall back
if current_reviewer == "codex cli" and pre-flight detected CLI not installed or not authenticated:
  → notify user:
    - not installed: "Codex CLI not installed, switching to Codex GitHub bot. To install: npm install -g @openai/codex && codex login"
    - not authenticated: "Codex CLI not authenticated, switching to Codex GitHub bot. Run: !codex login"
  → current_reviewer = "codex bot"

# Derived LAST, after the CLI gate above may have rewritten current_reviewer —
# deriving it earlier would carry `codex-cli` into the gate on a machine where
# the CLI just failed its availability check.
#
# A positional reviewer alias has always meant "this is the reviewer whose
# verdict ends the loop", which is exactly what a gate is — so it feeds
# GATE_RECIPE. Map the alias through the registry's `aliases (arg)` column to a
# recipe_id; `resolve` compares on ids, so passing the alias spelling straight
# through would match nothing.
#
# Left EMPTY when the caller named nobody. The "codex bot" default above exists
# so the old single-reviewer prose has something to say; passing it as a gate
# would let it silently outrank a configured fallback_order on every plain
# `/greenlight` run.
GATE_RECIPE = gate_arg non-empty ? gate_arg
            : (reviewer_args non-empty ? <recipe_id of current_reviewer> : "")

# Effective size (see Sizing). Run the cascade over the PR diff and take the
# upward max of the passed token and the computed size:
#   export SIZE_ARG="<size_arg>"; DIFF_RANGE="main...HEAD"
#   → run the "Mechanical cascade" + "Size override & freshness" snippets
#   → EFFECTIVE_SIZE ∈ {S,M,L}, SIZE_MAX_ROUNDS ∈ {3,5,10}
# If COMPUTED_SIZE=S and size_arg is empty, record the "auto-sized S — verify" flag.
```

**If `external_only == true` OR `EFFECTIVE_SIZE == S`, skip Phase 1 and Phase 2, jump directly to Phase 3** (size S reviews externally only — see [Sizing](#sizing-sml-risk-profile)).

---

## Uncommitted Mode

> **Only runs when `MODE=uncommitted` from Pre-flight Step 1.** PR mode skips this section entirely.

Codex CLI `--uncommitted` review loop. Fixes in-place, does NOT commit. User reviews and commits manually afterwards.

### Loop

```
round = 0
LOOP (max 10 rounds):
  round += 1

  1. Verify still on main with uncommitted changes:
     ```bash
     git branch --show-current  # must be main
     git status --porcelain     # must be non-empty
     ```
     If either changed (e.g., user switched branch or committed mid-loop) → stop and tell user.

  2. Run codex CLI:
     ```bash
     codex review --uncommitted -c 'model_reasoning_effort="high"' --enable web_search_cached 2>&1
     ```
     Capture full stdout/stderr. Timeout: 5 min.

  3. Parse output:
     - No `[P*]` tags (only summary paragraphs like "looks good" / "no issues") → **clean pass, exit loop**
     - Has `[P*]` tags → extract findings (file, line, priority, description, suggested fix)
     - **Non-zero exit** → stop, tell user codex CLI unavailable, preserve working
       tree. Search the output for "usage limit" / "rate limit" only to name the
       reason for the human, and **only once the exit status is already non-zero**
       — never as the test itself. Capturing `2>&1` merges the reviewer's own prose
       into the text being searched, and a reviewer that quotes those words while
       exiting 0 and returning a verdict is not rate-limited: on 2026-08-11 that
       false positive fired on a `codex review` that had answered normally, because
       it had read a document containing the phrase. A CLI that really is limited
       returns no `[P*]` and no clean sentence, which the rules above already
       classify as unresponsive.

  4. Dispatch fix subagent — see Step 4 below.

  5. After subagent returns, verify working tree still has uncommitted changes (subagent might have accidentally committed).
     If working tree is clean but commits were added → stop and tell user (violates no-commit invariant).

  6. Back to step 1 (next round). Pass prior-round findings to next subagent for push-back awareness.

End: max 10 rounds reached → stop and report to user.
```

### Step 4: Fix subagent (per round)

Dispatch subagent with these explicit instructions. Use `Agent` tool, `general-purpose` type.

```
Agent(
  description: "Fix codex uncommitted review findings (round N)",
  prompt: <see below>
)
```

**Prompt must contain:**

1. **Context**: "You are in uncommitted mode. All changes live in the working tree on the `main` branch. Your job is to address codex review findings by editing files directly."

2. **Findings list** (full stdout from codex, or parsed list with file + line + priority + description + suggested fix).

3. **Prior push-backs** (if round > 1): list of findings from earlier rounds that were pushed back with reasoning. Subagent should reconsider before pushing back again.

4. **Evaluation framework**: "Invoke `superpowers:receiving-code-review` skill first to load the review-receiving mindset. If unavailable, evaluate each finding: fix genuine issues, push back on false positives with solid technical reasoning."

5. **Hard constraints**:
   - **Do NOT run `git commit`, `git push`, `git add && commit`, or any commit operation.**
   - **Do NOT create branches, worktrees, or PRs.**
   - Edit source files directly. Leave all changes uncommitted.
   - If you want to push back on a finding, write reasoning in your final report — do not add code comments explaining the push-back (keeps the diff clean).

6. **Return format**: report what was fixed (file + line + fix summary) and what was pushed back (finding + reasoning).

### Exit Conditions

1. **Clean pass**: codex stdout has no `[P*]` tags → report rounds run, items fixed, items pushed back.
2. **Push-back exit**: all findings this round were already pushed back in prior rounds with the same reasoning → report and exit.
3. **Max 10 rounds**: stop and report last round's findings; let user decide.
4. **Aborted invariants**: branch changed / commits appeared / codex CLI unavailable → stop with specific reason.

### Final report (on any exit)

```
Uncommitted review loop complete.
- Exit reason: <clean pass / push-back / max rounds / aborted>
- Rounds run: <N>
- Items fixed: <M>
- Items pushed back: <K>
- Working tree: has uncommitted changes (run `git diff` to review, then commit manually)
```

**Do not offer to commit or push.** User's CLAUDE.md rule on product repo main branch: wait for 

[…] pełny plik w paczce .zip
Pliki w paczce (8)
  • SKILL.md 171 KB
  • references/adversarial-verify.md 10 KB
  • scripts/config.sh 6 KB
  • scripts/reviewer-registry.mjs 10 KB
  • scripts/reviewer-state.mjs 38 KB
  • tests/reviewer-registry.test.mjs 8 KB
  • tests/reviewer-state.test.mjs 52 KB
  • tests/skill-sync.test.mjs 4 KB

Wersje

RepozytoriumWynikLicencja
Ta strona · hanamizuki/solopreneur89MIT
revylai/greenlight100MIT
hanamizuki/solopreneur89MIT

Migawka bazy z 13.11.2026 · wersja paczki ca743c0f8f5b (skrót SHA-256 całej paczki)

Pobrania w ostatnich 30 dniach: 0 · ranking

Zgłoś problem z tym skillem: szkodliwa treść, błędny opis albo prośba autora o usunięcie.

Podobne skille

  • 95codex-review
    Uruchamia przegląd zmian przez Codex CLI i poprawia je w pętli, aż kod będzie czysty, także jako drugą opinię o commicie.
  • 100review-implementing
    Przetwarza i wdraża uwagi z code review systematycznie: komentarze recenzentów, uwagi do PR i sugestie z przeglądów.
  • 91pr-review-loop
    Prowadzi pętlę uwag do pull requesta: monitoruje CI, pobiera komentarze recenzentów takich jak Gemini Code Assist i Cursor Bugbot oraz iteruje poprawki.
  • 100review-resolution
    Sprawdza technicznie uwagi z przeglądu, komentarze PR, wyniki CI i sugestie recenzentów przed poprawką lub decyzją o odrzuceniu.
  • 95lightning-greenlight
    Opisuje Greenlight od Blockstream, czyli hostowany CLN z podpisywaniem we własnej pieczy użytkownika, do aplikacji mobilnych i webowych Lightning bez pełnego węzła.
  • 100review-loop
    Prowadzi wielorundowy przegląd zmian przez niezależnych recenzentów, aż nie zostaną krytyczne ani istotne problemy.

Uwagi i zgłoszenia

Wiadomość trafi do Bartosza Sokolińskiego. Adres e-mail jest potrzebny tylko do odpowiedzi. Szczegóły w polityce prywatności.