$deep-interview -> $ralplan -> $ultragoal (+ $team if needed) -> $code-review -> $ultraqa
If $code-review or $ultraqa is not clean, Autopilot returns to $ralplan with the findings as the next planning input, then continues again through $ultragoal, $code-review, and $ultraqa until the gates are clean or a hard blocker is reported. Ralph is a legacy/explicit alternate execution loop only; do not advertise Ralph as the default Autopilot path.
Phase deep-interview — Socratic requirements clarification gate
- Run or resume
$deep-interview to clarify intent, scope, non-goals, constraints, and decision boundaries.
- Required handoff artifact: a clarified spec or concise requirements summary suitable for
$ralplan.
Phase ralplan — consensus planning gate
- Ground the task with pre-context intake and the deep-interview artifact.
- Run or resume
$ralplan to produce/update PRD and test-spec artifacts.
- PRD/test-spec files alone are not completion evidence. Ralplan may hand off only after durable consensus evidence records a subsequent
Architect approval first and a subsequent Critic approval second.
- When returning from a non-clean review or QA pass, include
return_to_ralplan_reason and the findings as first-class planning input.
- If either review is missing, blocked, out of order, or non-approving, remain in
ralplan or report an explicit blocker/max-iteration outcome; do not progress to $ultragoal, $team, $ralph, or implementation.
- Required handoff artifact: an approved plan/test spec plus
ralplan_consensus_gate evidence suitable for $ultragoal.
Phase ultragoal — durable implementation + verification loop
- Run
$ultragoal from the approved ralplan artifacts.
- Ultragoal owns durable Codex goal handoffs,
.omx/ultragoal ledger checkpoints, implementation, tests, build/lint/typecheck evidence, cleanup, and final review gate discipline.
- Use
$team only inside an active Ultragoal story when the story clearly benefits from coordinated parallel execution (for example independent file/module lanes, broad test matrix work, or multi-domain implementation). Team remains explicit and leader-owned; Ultragoal keeps the goal/ledger state.
- Required handoff artifact: implementation evidence, changed-file summary, verification evidence, and Ultragoal ledger/checkpoint references suitable for
$code-review.
Phase code-review — merge-readiness gate
- Run
$code-review on the diff/artifacts produced by $ultragoal.
- A clean review means final recommendation
APPROVE with architectural status CLEAR.
COMMENT, REQUEST CHANGES, any architectural WATCH/BLOCK, or any unresolved finding is not clean.
- If not clean, increment the review cycle, persist
review_verdict, set return_to_ralplan_reason, and transition back to Phase ralplan.
Phase ultraqa — adversarial QA gate
- Run
$ultraqa after a clean code review when user-facing behavior, workflows, CLI/runtime behavior, integration surfaces, or regression risk warrant adversarial QA.
- For docs-only or trivially non-runtime changes, record
ultraqa as skipped with an explicit condition and evidence.
- If UltraQA finds issues, persist the QA verdict/evidence, set
return_to_ralplan_reason, and transition back to Phase ralplan.
The only normal terminal state is complete after clean code review and a passed or explicitly skipped UltraQA gate. Cancellation, blocked credentials, unrecoverable repeated failures, or explicit user stop may terminate earlier with preserved state.
Before Phase deep-interview or ralplan starts or resumes:
- Derive a task slug from the request.
- Reuse the latest relevant
.omx/context/{slug}-*.md snapshot when available.
- If none exists, create
.omx/context/{slug}-{timestamp}.md (UTC YYYYMMDDTHHMMSSZ) with:
- task statement
- desired outcome
- known facts/evidence
- constraints
- unknowns/open questions
- likely codebase touchpoints
- If brownfield facts are missing, run
explore first before or during $deep-interview ($deep-interview --quick <task> remains acceptable for bounded low-ambiguity intake); do not skip the clarification gate merely because the task sounds actionable.
- Carry the snapshot path in Autopilot state and all handoff artifacts.
</Pre-context Intake>
Required fields:
{
"mode": "autopilot",
"active": true,
"current_phase": "deep-interview",
"iteration": 1,
"review_cycle": 0,
"max_iterations": 10,
"phase_cycle": ["deep-interview", "ralplan", "ultragoal", "code-review", "ultraqa"],
"handoff_artifacts": {
"context_snapshot_path": ".omx/context/<slug>-<timestamp>.md",
"deep_interview": null,
"ralplan": null,
"ralplan_consensus_gate": {
"required": true,
"sequence": ["architect-review", "critic-review"],
"planning_artifacts_are_not_consensus": true,
"required_review_roles": ["architect", "critic"],
"ralplan_architect_review": null,
"ralplan_critic_review": null,
"complete": false
},
"ultragoal": null,
"code_review": null,
"ultraqa": null
},
"review_verdict": null,
"qa_verdict": null,
"return_to_ralplan_reason": null
}
- On start:
omx state write --input '{"mode":"autopilot","active":true,"current_phase":"deep-interview","iteration":1,"review_cycle":0,"state":{"phase_cycle":["deep-interview","ralplan","ultragoal","code-review","ultraqa"],"handoff_artifacts":{"context_snapshot_path":"<snapshot-path>","deep_interview":null,"ralplan":null,"ralplan_consensus_gate":{"required":true,"sequence":["architect-review","critic-review"],"planning_artifacts_are_not_consensus":true,"required_review_roles":["architect","critic"],"ralplan_architect_review":null,"ralplan_critic_review":null,"complete":false},"ultragoal":null,"code_review":null,"ultraqa":null},"review_verdict":null,"qa_verdict":null,"return_to_ralplan_reason":null}}' --json
- On deep-interview -> ralplan: set
current_phase:"ralplan", persist the clarified spec/requirements under handoff_artifacts.deep_interview.
- On ralplan -> ultragoal: only after
ralplan_consensus_gate.complete:true, with ralplan_architect_review.agent_role:"architect" and ralplan_architect_review.verdict:"approve" recorded before ralplan_critic_review.agent_role:"critic" and ralplan_critic_review.verdict:"approve"; set current_phase:"ultragoal" and persist the plan/test-spec paths under handoff_artifacts.ralplan.
- On missing ralplan consensus evidence: keep
current_phase:"ralplan", persist ralplan_consensus_gate.complete:false with blocked_reason, and report an explicit blocker or max-iteration outcome instead of handing off to execution.
- On ultragoal -> code-review: set
current_phase:"code-review", persist implementation/test/ledger evidence under handoff_artifacts.ultragoal.
- On code-review -> ultraqa: set
current_phase:"ultraqa", persist the clean review under handoff_artifacts.code_review.
- On clean review + passed/skipped QA: set
active:false, current_phase:"complete", persist review_verdict:{recommendation:"APPROVE", architectural_status:"CLEAR", clean:true}, qa_verdict:{clean:true, skipped:<boolean>, reason:<string|null>}, and completed_at.
- On non-clean review or failed QA: increment
iteration and review_cycle, set current_phase:"ralplan", persist review_verdict or qa_verdict, persist the phase handoff, and set return_to_ralplan_reason to a concise findings-driven reason.
- Legacy Ralph state: if a user explicitly selected the legacy Ralph execution lane, phase names and handoff keys may include
ralph; preserve and resume them rather than rewriting history to Ultragoal.
- On cancellation: run
$cancel; preserve progress for resume rather than deleting handoff artifacts.
Do not restart discovery or discard handoff artifacts on continuation.
deep-interview -> ralplan -> ultragoal -> code-review -> ultraqa
Pipeline state should use current_phase values that match the same phase names (deep-interview, ralplan, ultragoal, code-review, ultraqa, complete, failed) and should carry iteration, review_cycle, handoff_artifacts, review_verdict, qa_verdict, and return_to_ralplan_reason alongside stage results. $team is not a default pipeline stage; it is an explicit conditional execution engine inside an Ultragoal story.
1---2name: autopilot3description: [OMX] Strict autonomous loop: $deep-interview -> $ralplan -> $ultragoal (+ $team if needed) -> $code-review -> $ultraqa4---56<Purpose>7Autopilot is the strict autonomous delivery loop for non-trivial work. Its recommended/default contract is exactly:89```text10$deep-interview -> $ralplan -> $ultragoal (+ $team if needed) -> $code-review -> $ultraqa11```1213If `$code-review` or `$ultraqa` is not clean, Autopilot returns to `$ralplan` with the findings as the next planning input, then continues again through `$ultragoal`, `$code-review`, and `$ultraqa` until the gates are clean or a hard blocker is reported. Ralph is a legacy/explicit alternate execution loop only; do not advertise Ralph as the default Autopilot path.14</Purpose>1516<Use_When>17- User wants hands-off execution from a concrete idea, issue, PRD, or requirements artifact to reviewed and QA-checked code18- User says `$autopilot`, "autopilot", "auto pilot", "autonomous", "build me", "create me", "make me", "full auto", "handle it all", or "I want a/an..."19- Task needs clarification, planning, durable execution, verification, code review, and QA with automatic follow-up when gates are not clean20</Use_When>2122<Do_Not_Use_When>23- User wants to explore options or brainstorm -- use `$plan` / `$ralplan`24- User says "just explain", "draft only", or "what would you suggest" -- respond conversationally25- User wants a single focused code change -- use `$ultragoal`, `$ralph` only when explicitly requested, or direct executor work26- User wants only review/critique of existing code -- use `$code-review`27</Do_Not_Use_When>2829<Strict_Loop_Contract>30Autopilot must not run a separate broad expansion/planning/execution/QA/validation lifecycle as its primary behavior. It delegates those concerns to the canonical workflow phases below:31321. **Phase `deep-interview`** — Socratic requirements clarification gate33 - Run or resume `$deep-interview` to clarify intent, scope, non-goals, constraints, and decision boundaries.34 - Required handoff artifact: a clarified spec or concise requirements summary suitable for `$ralplan`.35362. **Phase `ralplan`** — consensus planning gate37 - Ground the task with pre-context intake and the deep-interview artifact.38 - Run or resume `$ralplan` to produce/update PRD and test-spec artifacts.39 - PRD/test-spec files alone are not completion evidence. Ralplan may hand off only after durable consensus evidence records a subsequent `Architect` approval first and a subsequent `Critic` approval second.40 - When returning from a non-clean review or QA pass, include `return_to_ralplan_reason` and the findings as first-class planning input.41 - If either review is missing, blocked, out of order, or non-approving, remain in `ralplan` or report an explicit blocker/max-iteration outcome; do not progress to `$ultragoal`, `$team`, `$ralph`, or implementation.42 - Required handoff artifact: an approved plan/test spec plus `ralplan_consensus_gate` evidence suitable for `$ultragoal`.43443. **Phase `ultragoal`** — durable implementation + verification loop45 - Run `$ultragoal` from the approved ralplan artifacts.46 - Ultragoal owns durable Codex goal handoffs, `.omx/ultragoal` ledger checkpoints, implementation, tests, build/lint/typecheck evidence, cleanup, and final review gate discipline.47 - Use `$team` only inside an active Ultragoal story when the story clearly benefits from coordinated parallel execution (for example independent file/module lanes, broad test matrix work, or multi-domain implementation). Team remains explicit and leader-owned; Ultragoal keeps the goal/ledger state.48 - Required handoff artifact: implementation evidence, changed-file summary, verification evidence, and Ultragoal ledger/checkpoint references suitable for `$code-review`.49504. **Phase `code-review`** — merge-readiness gate51 - Run `$code-review` on the diff/artifacts produced by `$ultragoal`.52 - A clean review means final recommendation `APPROVE` with architectural status `CLEAR`.53 - `COMMENT`, `REQUEST CHANGES`, any architectural `WATCH`/`BLOCK`, or any unresolved finding is not clean.54 - If not clean, increment the review cycle, persist `review_verdict`, set `return_to_ralplan_reason`, and transition back to Phase `ralplan`.55565. **Phase `ultraqa`** — adversarial QA gate57 - Run `$ultraqa` after a clean code review when user-facing behavior, workflows, CLI/runtime behavior, integration surfaces, or regression risk warrant adversarial QA.58 - For docs-only or trivially non-runtime changes, record `ultraqa` as skipped with an explicit condition and evidence.59 - If UltraQA finds issues, persist the QA verdict/evidence, set `return_to_ralplan_reason`, and transition back to Phase `ralplan`.6061The only normal terminal state is `complete` after clean code review and a passed or explicitly skipped UltraQA gate. Cancellation, blocked credentials, unrecoverable repeated failures, or explicit user stop may terminate earlier with preserved state.62</Strict_Loop_Contract>6364<Pre-context Intake>65Before Phase `deep-interview` or `ralplan` starts or resumes:661. Derive a task slug from the request.672. Reuse the latest relevant `.omx/context/{slug}-*.md` snapshot when available.683. If none exists, create `.omx/context/{slug}-{timestamp}.md` (UTC `YYYYMMDDTHHMMSSZ`) with:69 - task statement70 - desired outcome71 - known facts/evidence72 - constraints73 - unknowns/open questions74 - likely codebase touchpoints754. If brownfield facts are missing, run `explore` first before or during `$deep-interview` (`$deep-interview --quick <task>` remains acceptable for bounded low-ambiguity intake); do not skip the clarification gate merely because the task sounds actionable.765. Carry the snapshot path in Autopilot state and all handoff artifacts.77</Pre-context Intake>7879<Execution_Policy>80- Always execute the recommended phases in order: `deep-interview`, then `ralplan`, then `ultragoal`, then `code-review`, then `ultraqa`.81- `$team` is conditional and explicit: use it only within an Ultragoal story when parallel execution materially improves throughput, quality, or safety.82- Never skip directly from vague/freeform expansion to implementation; unclear input must be clarified and planned through `$deep-interview` and `$ralplan`.83- A non-clean `$code-review` or failed `$ultraqa` always returns to `$ralplan`; do not patch findings ad hoc outside the loop.84- Each phase must write/update Autopilot state before handing off.85- Use existing hooks, `.omx/state`, `$deep-interview`, `$ralplan`, `$ultragoal`, optional `$team`, `$code-review`, `$ultraqa`, and pipeline primitives; do not invent a separate execution framework.86- Preserve legacy compatibility: if a user explicitly requests the old Ralph execution lane, use `$ralph` as an intentional alternate execution phase, but do not present it as Autopilot's default recommended loop.87- Continue automatically through safe reversible phase transitions. Ask only for destructive, credential-gated, or materially preference-dependent branches.88- Apply the shared workflow guidance pattern: outcome-first framing, concise visible updates for multi-step execution, local overrides for the active workflow branch, validation proportional to risk, explicit stop rules, and automatic continuation for safe reversible steps. Ask only for material, destructive, credentialed, external-production, or preference-dependent branches.89</Execution_Policy>9091<State_Management>92Use the CLI-first state surface (`omx state ... --json`) for Autopilot lifecycle state. State must be session-aware when a session id exists. If the explicit MCP compatibility surface is already available, equivalent `omx_state` tool calls remain acceptable but are not required.9394Required fields:9596```json97{98 "mode": "autopilot",99 "active": true,100 "current_phase": "deep-interview",101 "iteration": 1,102 "review_cycle": 0,103 "max_iterations": 10,104 "phase_cycle": ["deep-interview", "ralplan", "ultragoal", "code-review", "ultraqa"],105 "handoff_artifacts": {106 "context_snapshot_path": ".omx/context/<slug>-<timestamp>.md",107 "deep_interview": null,108 "ralplan": null,109 "ralplan_consensus_gate": {110 "required": true,111 "sequence": ["architect-review", "critic-review"],112 "planning_artifacts_are_not_consensus": true,113 "required_review_roles": ["architect", "critic"],114 "ralplan_architect_review": null,115 "ralplan_critic_review": null,116 "complete": false117 },118 "ultragoal": null,119 "code_review": null,120 "ultraqa": null121 },122 "review_verdict": null,123 "qa_verdict": null,124 "return_to_ralplan_reason": null125}126```127128- **On start**: `omx state write --input '{"mode":"autopilot","active":true,"current_phase":"deep-interview","iteration":1,"review_cycle":0,"state":{"phase_cycle":["deep-interview","ralplan","ultragoal","code-review","ultraqa"],"handoff_artifacts":{"context_snapshot_path":"<snapshot-path>","deep_interview":null,"ralplan":null,"ralplan_consensus_gate":{"required":true,"sequence":["architect-review","critic-review"],"planning_artifacts_are_not_consensus":true,"required_review_roles":["architect","critic"],"ralplan_architect_review":null,"ralplan_critic_review":null,"complete":false},"ultragoal":null,"code_review":null,"ultraqa":null},"review_verdict":null,"qa_verdict":null,"return_to_ralplan_reason":null}}' --json`129- **On deep-interview -> ralplan**: set `current_phase:"ralplan"`, persist the clarified spec/requirements under `handoff_artifacts.deep_interview`.130- **On ralplan -> ultragoal**: only after `ralplan_consensus_gate.complete:true`, with `ralplan_architect_review.agent_role:"architect"` and `ralplan_architect_review.verdict:"approve"` recorded before `ralplan_critic_review.agent_role:"critic"` and `ralplan_critic_review.verdict:"approve"`; set `current_phase:"ultragoal"` and persist the plan/test-spec paths under `handoff_artifacts.ralplan`.131- **On missing ralplan consensus evidence**: keep `current_phase:"ralplan"`, persist `ralplan_consensus_gate.complete:false` with `blocked_reason`, and report an explicit blocker or max-iteration outcome instead of handing off to execution.132- **On ultragoal -> code-review**: set `current_phase:"code-review"`, persist implementation/test/ledger evidence under `handoff_artifacts.ultragoal`.133- **On code-review -> ultraqa**: set `current_phase:"ultraqa"`, persist the clean review under `handoff_artifacts.code_review`.134- **On clean review + passed/skipped QA**: set `active:false`, `current_phase:"complete"`, persist `review_verdict:{recommendation:"APPROVE", architectural_status:"CLEAR", clean:true}`, `qa_verdict:{clean:true, skipped:<boolean>, reason:<string|null>}`, and `completed_at`.135- **On non-clean review or failed QA**: increment `iteration` and `review_cycle`, set `current_phase:"ralplan"`, persist `review_verdict` or `qa_verdict`, persist the phase handoff, and set `return_to_ralplan_reason` to a concise findings-driven reason.136- **Legacy Ralph state**: if a user explicitly selected the legacy Ralph execution lane, phase names and handoff keys may include `ralph`; preserve and resume them rather than rewriting history to Ultragoal.137- **On cancellation**: run `$cancel`; preserve progress for resume rather than deleting handoff artifacts.138</State_Management>139140<Continuation_And_Resume>141When the user says `continue`, `resume`, or `keep going` while Autopilot is active, read `autopilot-state.json` and continue from `current_phase`:142- `deep-interview`: clarify requirements and record the handoff artifact.143- `ralplan`: run/update consensus planning from current handoffs and any `return_to_ralplan_reason`.144- `ultragoal`: execute the approved plan durably and record verification/ledger evidence.145- `team`: continue explicit team work only when it is nested under the active Ultragoal story and report evidence back to the leader.146- `code-review`: review the current diff and decide clean vs return-to-ralplan.147- `ultraqa`: run or explicitly skip adversarial QA based on the documented condition, then finish if clean or transition to `ralplan` with findings if not clean.148- `ralph`: resume only for explicit legacy Ralph-path Autopilot state.149- `complete`: report completion evidence; do not restart.150151Do not restart discovery or discard handoff artifacts on continuation.152</Continuation_And_Resume>153154<Pipeline_Orchestrator>155Autopilot may be represented by the configurable pipeline orchestrator (`src/pipeline/`) when useful. The default Autopilot pipeline contract is:156157```text158deep-interview -> ralplan -> ultragoal -> code-review -> ultraqa159```160161Pipeline state should use `current_phase` values that match the same phase names (`deep-interview`, `ralplan`, `ultragoal`, `code-review`, `ultraqa`, `complete`, `failed`) and should carry `iteration`, `review_cycle`, `handoff_artifacts`, `review_verdict`, `qa_verdict`, and `return_to_ralplan_reason` alongside stage results. `$team` is not a default pipeline stage; it is an explicit conditional execution engine inside an Ultragoal story.162</Pipeline_Orchestrator>163164<Escalation_And_Stop_Conditions>165- Stop and report a blocker when required credentials/authority are missing.166- Stop and report when the same review or QA failure recurs across 3 review cycles with no meaningful new plan.167- Stop when the user says "stop", "cancel", or "abort" and run `$cancel`.168- Otherwise, continue the loop until `$code-review` is clean and `$ultraqa` has passed or been explicitly skipped with evidence.169</Escalation_And_Stop_Conditions>170171<Final_Checklist>172- [ ] Phase `deep-interview` produced/updated clarified requirements or a concise spec173- [ ] Phase `ralplan` produced/updated approved planning artifacts and durable sequential evidence from a subsequent `Architect` approval followed by a subsequent `Critic` approval174- [ ] Phase `ultragoal` implemented and verified the plan with fresh evidence and durable ledger/checkpoint references175- [ ] `$team` was used only if the active Ultragoal story needed coordinated parallel work, or explicitly recorded as not needed176- [ ] Phase `code-review` returned a clean verdict (`APPROVE` + `CLEAR`)177- [ ] Phase `ultraqa` passed, or was explicitly skipped because the change was docs-only/trivially non-runtime with evidence178- [ ] `review_verdict.clean` is true, `qa_verdict.clean` is true, and `return_to_ralplan_reason` is null179- [ ] Tests/build/lint/typecheck evidence from Ultragoal is available in handoff artifacts180- [ ] Autopilot state is marked `complete` or cancellation state is preserved coherently181- [ ] User receives a concise summary with clarification, plan, implementation, verification, review, and QA evidence182</Final_Checklist>183184<Examples>185<Good>186User: `$autopilot implement GitHub issue #42`187Flow: create/load context snapshot -> `$deep-interview` requirements check -> `$ralplan` issue plan -> `$ultragoal` durable implementation + tests (launch `$team` only if a story needs parallel lanes) -> `$code-review` -> `$ultraqa`; if review or QA requests changes, return to `$ralplan` with findings.188</Good>189190<Good>191User: `continue`192Context: Autopilot state says `current_phase:"code-review"`.193Flow: run `$code-review` on current diff, persist verdict, transition to `ultraqa` if clean or to `ralplan` with findings if not clean.194</Good>195196<Good>197User: `$autopilot --legacy-ralph finish the migration`198Flow: preserve the explicit legacy Ralph execution choice and run the old Ralph execution lane as an alternate, without changing the documented default Autopilot recommendation.199</Good>200201<Bad>202Autopilot invents independent "Expansion", "QA", and "Validation" phases and treats them as the primary lifecycle.203Why bad: this bypasses the strict `$deep-interview -> $ralplan -> $ultragoal -> $code-review -> $ultraqa` contract.204</Bad>205</Examples>