Use for large, phase-based, or long-running implementation work that should run from a prepared plan package.
Prepares phase-by-phase implementation based on master plan documents.
Handles plan validation, uncertainty resolution (Q&A), and execution preparation.
Emits handoff metadata so /moonshot-orchestrator can resume with consistent state.
This is the default public entrypoint for large, phase-based, or long-running implementation work. It owns the Intake-to-Plan transition for phase-driven execution.
When the active runtime is Codex, phase preparation must not rely on automatic .claude/rules/** loading.
Carry these rule files through SPRINT_CONTRACT.md policy anchors and phase-attempt inputs:
.claude/rules/basic-principles.md.claude/rules/workflow.md.claude/rules/context-management.md.claude/rules/communication.md.claude/rules/output-format.md.claude/rules/agents/agent-definition.md.claude/rules/agents/agent-delegation.mdExecution modes:
delegated-terminal: use the concrete autonomous loop backed by agent-loop.sh; prefer this when the user expects uninterrupted end-to-end executionin-session-coordinator: the current session coordinates the loop, but each attempt must run as a fresh fork/sub-agent round; treat this as an interactive thin-coordinator mode, not the default autonomous runtimeExecution start policy:
--prepare-only: stop after seeding state and return prepared execution metadata without executing itIntent interpretation:
--prepare-only, the runner must set prepareOnly: false and autoStartExecution: true.delegated-terminal unless the user explicitly wants interactive coordination or the runtime can only satisfy the request through in-session-coordinator.Plan-directory completion rule:
phase-status.yaml remains pending, in_progress, or retryable failed, the run must keep going through the delegated-terminal loop or the in-session coordinator loop.Channel / return-boundary rule:
phase-status.yaml reports activeExecutionStatus: active, user-facing updates must stay in progress/commentary form.final answer, closeout phrasing, or any wording that implies the run/session ended until assert-return-allowed passes or an explicit stop condition is recorded.Review and finish gate rule:
codex-review-code must appear in applied workflow evidence before clean_finish is allowed.QA_REPORT.md may not claim Next path: clean_finish while Review completed is still no.HANDOFF.md and closeout fields may not remain seeded or placeholder-shaped when the phase is being closed.# Auto-resolve an existing plan or create one at docs/implementation
/moonshot-phase-runner
# Specify plan directory
/moonshot-phase-runner docs/implementation/
# Autonomous mode (skip Q&A)
/moonshot-phase-runner docs/implementation/ --autonomous
# Keep coordination in the current session
/moonshot-phase-runner docs/implementation/ --execution-mode in-session-coordinator
# Prepare only, do not auto-start execution
/moonshot-phase-runner docs/implementation/ --prepare-only
/moonshot-phase-runner [<plan-dir>] [--autonomous] [--execution-mode <mode>] [--prepare-only]
│
├─ 1. Plan Directory Resolution
│ ├─ Reuse explicit `<plan-dir>` when provided
│ ├─ Else reuse existing active plan directory if exactly one safe candidate exists
│ └─ Else run `moonshot-plan-writer` to create `docs/implementation`
│
├─ 2. Plan Directory Validation
│ └─ Verify master plan + phase docs exist
│
├─ 3. Create/Update phase-status.yaml
│ └─ Initialize each phase status
│
├─ 4. Seed execution bridge artifacts
│ └─ Prepare `execution/<phase>/SPRINT_CONTRACT.md`
│ and placeholders for `QA_REPORT.md`, `HANDOFF.md`, `SCORECARD.md`
│
├─ 5. Plan Review (unless --autonomous)
│ └─ Detect uncertainties → Q&A → planConfirmed: true
│
├─ 6. Resolve Execution Mode
│ ├─ delegated-terminal -> build dispatcher command
│ └─ in-session-coordinator -> build fresh-attempt command
│
├─ 7. Auto-Start Execution Skill (default)
│ └─ Execute `moonshot-phase-executor` in the current session
│ unless `--prepare-only` was requested
│
├─ 8. Enforce Review / Finish Gates
│ └─ A phase may advance only after review evidence, completion evidence,
│ and finish-closeout artifacts are consistent
│
└─ 9. Emit Handoff Summary
└─ Orchestrator-readable phaseRunnerResult after the active plan directory is actually done
When <plan-dir> is omitted, resolve it in this order:
.claude/docs/phase-status.yaml if it points to an existing master plan.docs/implementation if it already contains exactly one valid master plan and phase files./moonshot-plan-writer and create or refresh docs/implementation.Archived phase docs under <plan-dir>/close/ are history, not active phase candidates.
Safety rule:
Resolution output:
planResolution:
source: "phase-status" # explicit | phase-status | discovered | plan-writer
planDir: "docs/implementation"
masterPlan: "docs/implementation/00-master-plan-v1.md"