---
name: autopilot
description: Full OMX-style autonomous pipeline for Omagy: interview, plan, goal execution, optional team, review, and UltraQA.
---

# Autopilot

Autopilot is the strict autonomous delivery orchestrator for non-trivial work.
Its default contract is:

```text
/omagy:deep-interview -> /omagy:ralplan -> /omagy:ultragoal -> /omagy:team when needed -> /omagy:code-review -> /omagy:ultraqa
```

It records each phase artifact in `.omagy/state/autopilot-state.json`, gates on
clean review, runs UltraQA after review, and routes non-clean review or QA
findings back into the pipeline instead of claiming completion.

## Use When

- The user wants hands-off execution from a vague idea, issue, PRD, or
  requirements artifact to reviewed and QA-verified code.
- The user says `/omagy:autopilot`, `autopilot`, `auto pilot`, `autonomous`,
  `build me`, `create me`, `make me`, `full auto`, or `handle it all`.
- The task needs clarification, planning, durable execution, verification, code
  review, adversarial QA, and automatic follow-up when gates are not clean.

## Do Not Use When

- The user wants to explore options or brainstorm only; use `/omagy:plan` or
  `/omagy:ralplan`.
- The user says "just explain", "draft only", or "what would you suggest".
- The user wants a single focused code change; use `/omagy:ralph` or direct
  implementation.
- The user wants only review or critique of existing code; use
  `/omagy:code-review`.

## Runtime Contract

Start or resume with the runtime CLI:

```bash
omagy autopilot status --json
omagy autopilot start --input '{"task":"<task>","desired_outcome":"<outcome>"}' --json
omagy autopilot next --json
```

Use `skip_deep_interview:true` only when the user explicitly provides a
launch-ready spec or asks to skip clarification. Use `team_required:true` when
parallel execution is already known to be required.

Autopilot state carries:

- `current_phase`
- `iteration`
- `review_cycle`
- `qa_cycle`
- `team_required`
- `phase_cycle: ["deep-interview","ralplan","ultragoal","team","code-review","ultraqa"]`
- `handoff_artifacts.context_snapshot_path`
- `handoff_artifacts.deep_interview`
- `handoff_artifacts.ralplan`
- `handoff_artifacts.ultragoal`
- `handoff_artifacts.team`
- `handoff_artifacts.code_review`
- `handoff_artifacts.ultraqa`
- `review_verdict`
- `qa_verdict`
- `return_to_ralplan_reason`
- `return_to_ultragoal_reason`

Before phase work, Autopilot creates or reuses a grounded context snapshot
under `.omagy/context/` and carries that path through all handoffs.

## Phase Execution

### `deep-interview`

Run `/omagy:deep-interview` from the context snapshot unless explicitly skipped.
Record the crystallized spec and handoff:

```bash
omagy autopilot record-phase --input '{"phase":"deep-interview","artifacts":{"spec_path":"<path>","handoff_path":"<path>","ambiguity_score":0.18}}' --json
```

### `ralplan`

Run `/omagy:ralplan` from the context snapshot and interview artifact. If this
is a return from non-clean review, include `return_to_ralplan_reason` and the
review artifacts as planning input.

```bash
omagy autopilot record-phase --input '{"phase":"ralplan","artifacts":{"prd_path":"<path>","test_spec_paths":["<path>"],"team_required":false}}' --json
```

### `ultragoal`

Run `/omagy:ultragoal` from the approved planning artifacts. Ultragoal owns the
durable goal ledger and execution evidence. If this is a return from failed
UltraQA, include `return_to_ultragoal_reason` and the QA artifacts.

```bash
omagy autopilot record-phase --input '{"phase":"ultragoal","artifacts":{"goals_path":".omagy/ultragoal/goals.json","ledger_path":".omagy/ultragoal/ledger.jsonl","verification_evidence":["<evidence>"],"changed_files":["<path>"],"team_required":false}}' --json
```

If `team_required`, `needs_team`, or `execution_owner:"team"` is recorded,
Autopilot routes to the `team` phase before review.

### `team`

Run `/omagy:team` only when the planning or execution artifact requires
parallel execution. Team workers may execute bounded tasks, but Ultragoal
remains the durable goal source of truth.

```bash
omagy autopilot record-phase --input '{"phase":"team","artifacts":{"team_name":"<team>","task_count":3,"verification_evidence":["<evidence>"]}}' --json
```

### `code-review`

Run `/omagy:code-review` on the Ultragoal and Team outputs. Record the verdict:

```bash
omagy autopilot record-review --input '{"review_verdict":{"recommendation":"APPROVE","architectural_status":"CLEAR","final_recommendation":"APPROVE","clean":true,"summary":"Review clean."},"review_report_path":"<path>"}' --json
```

If the verdict is not clean, Autopilot transitions back to `ralplan` and keeps
the review findings in `handoff_artifacts.code_review`.

### `ultraqa`

Run `/omagy:ultraqa` only after clean code review. Record QA:

```bash
omagy autopilot record-qa --input '{"qa_verdict":{"clean":true,"skipped":false,"summary":"UltraQA clean."},"scenario_matrix_path":".omagy/reports/ultraqa-report.md","evidence":["<evidence>"]}' --json
```

If UltraQA is not clean, Autopilot transitions back to `ultragoal` and keeps
the QA findings in `handoff_artifacts.ultraqa`.

## Continuation

When the user says `continue`, `resume`, or `keep going`, run:

```bash
omagy autopilot next --json
```

Continue from `current_phase`; do not restart discovery and do not discard
handoff artifacts.

## Stop Conditions

- Stop and report a blocker when required credentials or authority are missing.
- Stop when the same review failure recurs across 3 review cycles with no
  meaningful new plan.
- Stop when the same UltraQA failure recurs across 3 QA cycles with no
  meaningful execution change.
- Stop when the user says stop, cancel, or abort:

```bash
omagy autopilot cancel --json
```

Cancellation preserves handoff artifacts for manual recovery.

## Final Checklist

- [ ] `/omagy:deep-interview` produced or was explicitly skipped due to a
      launch-ready spec.
- [ ] `/omagy:ralplan` produced or updated approved planning artifacts.
- [ ] `/omagy:ultragoal` executed the approved plan and recorded durable goal
      evidence.
- [ ] `/omagy:team` ran only when artifacts required parallel execution.
- [ ] `/omagy:code-review` returned a clean verdict (`APPROVE` + `CLEAR`).
- [ ] `/omagy:ultraqa` returned a clean or explicitly skipped QA verdict.
- [ ] `review_verdict.clean` is true and `qa_verdict.clean` or
      `qa_verdict.skipped` is true.
- [ ] Autopilot state is marked `complete` or cancellation/blocker state is
      preserved coherently.
- [ ] The user receives a concise summary with interview, plan, execution,
      review, QA, and cleanup evidence.
