Made-with: Cursor
6.0 KiB
Autopilot State Management
State File: _docs/_autopilot_state.md
The autopilot persists its state to _docs/_autopilot_state.md. This file is the primary source of truth for re-entry. Folder scanning is the fallback when the state file doesn't exist.
Format
# Autopilot State
## Current Step
step: [0-6 or "2b" / "2c" / "2d" / "2e" / "2f" / "2g" / "2h" / "2hb" / "2i" or "5b" or "done"]
name: [Problem / Research / Plan / Blackbox Test Spec / Decompose Tests / Implement Tests / Refactor / New Task / Implement / Run Tests / Security Audit / Deploy / Decompose / Done]
status: [not_started / in_progress / completed / skipped / failed]
sub_step: [optional — sub-skill internal step number + name if interrupted mid-step]
retry_count: [0-3 — number of consecutive auto-retry attempts for current step, reset to 0 on success]
## Step ↔ SubStep Reference
(include the step reference table from the active flow file)
When updating `Current Step`, always write it as:
step: N ← autopilot step (0–6 or 2b/2c/2d/2e/2f/2g/2h/2hb/2i or 5b)
sub_step: M ← sub-skill's own internal step/phase number + name
retry_count: 0 ← reset on new step or success; increment on each failed retry
Example:
step: 2
name: Plan
status: in_progress
sub_step: 4 — Architecture Review & Risk Assessment
retry_count: 0
Example (failed after 3 retries):
step: 2b
name: Blackbox Test Spec
status: failed
sub_step: 1b — Test Case Generation
retry_count: 3
## Completed Steps
| Step | Name | Completed | Key Outcome |
|------|------|-----------|-------------|
| 0 | Problem | [date] | [one-line summary] |
| 1 | Research | [date] | [N drafts, final approach summary] |
| ... | ... | ... | ... |
## Key Decisions
- [decision 1: e.g. "Tech stack: Python + Rust for perf-critical, Postgres DB"]
- [decision N]
## Last Session
date: [date]
ended_at: Step [N] [Name] — SubStep [M] [sub-step name]
reason: [completed step / session boundary / user paused / context limit]
notes: [any context for next session]
## Retry Log
| Attempt | Step | Name | SubStep | Failure Reason | Timestamp |
|---------|------|------|---------|----------------|-----------|
| 1 | [step] | [name] | [sub_step] | [reason] | [date-time] |
| ... | ... | ... | ... | ... | ... |
(Clear this table when the step succeeds or user resets. Append a row on each failed auto-retry.)
## Blockers
- [blocker 1, if any]
- [none]
State File Rules
- Create the state file on the very first autopilot invocation (after state detection determines Step 0)
- Update the state file after every step completion, every session boundary, every BLOCKING gate confirmation, and every failed retry attempt
- Read the state file as the first action on every invocation — before folder scanning
- Cross-check: after reading the state file, verify against actual
_docs/folder contents. If they disagree (e.g., state file says Step 2 but_docs/02_document/architecture.mdalready exists), trust the folder structure and update the state file to match - Never delete the state file. It accumulates history across the entire project lifecycle
- Retry tracking: increment
retry_counton each failed auto-retry; reset to0when the step succeeds or the user manually resets. Ifretry_countreaches 3, setstatus: failedand add an entry toBlockers - Failed state on re-entry: if the state file shows
status: failedwithretry_count: 3, do NOT auto-retry — present the blocker to the user and wait for their decision before proceeding
State Detection
Read _docs/_autopilot_state.md first. If it exists and is consistent with the folder structure, use the Current Step from the state file. If the state file doesn't exist or is inconsistent, fall back to folder scanning.
Folder Scan Rules (fallback)
Scan _docs/ to determine the current workflow position. The detection rules are defined in each flow file (flows/greenfield.md and flows/existing-code.md). Check the existing-code flow first (Pre-Step detection), then greenfield flow rules. First match wins.
Re-Entry Protocol
When the user invokes /autopilot and work already exists:
- Read
_docs/_autopilot_state.md - Cross-check against
_docs/folder structure - Present Status Summary with context from state file (key decisions, last session, blockers)
- If the detected step has a sub-skill with built-in resumability (plan, decompose, implement, deploy all do), the sub-skill handles mid-step recovery
- Continue execution from detected state
Session Boundaries
After any decompose/planning step completes (Step 2c, Step 2f, or Step 3), do not auto-chain to implement. Instead:
- Update state file: mark the step as completed, set current step to the next implement step with status
not_started- After Step 2c (Decompose Tests) → set current step to 2d (Implement Tests)
- After Step 2f (New Task) → set current step to 2g (Implement)
- After Step 3 (Decompose) → set current step to 4 (Implement)
- Write
Last Sessionsection:reason: session boundary,notes: Decompose complete, implementation ready - Present a summary: number of tasks, estimated batches, total complexity points
- Use Choose format:
══════════════════════════════════════
DECISION REQUIRED: Decompose complete — start implementation?
══════════════════════════════════════
A) Start a new conversation for implementation (recommended for context freshness)
B) Continue implementation in this conversation
══════════════════════════════════════
Recommendation: A — implementation is the longest phase, fresh context helps
══════════════════════════════════════
These are the only hard session boundaries. All other transitions auto-chain.