--- name: recover description: 'Recover session context.' skill_api_version: 1 context: window: inherit intent: mode: none intel_scope: none metadata: tier: session dependencies: [] output_contract: "stdout: recovered context summary" --- # /recover — Context Recovery After Compaction > **Purpose:** Help you get back up to speed after context compaction. Automatically detects in-progress work (RPI runs, evolve cycles), loads relevant knowledge, summarizes what you were doing and what's next. Codex v0.115.0+ uses native hooks automatically; for older Codex versions, prefers the explicit hookless fallback path (`ao codex start`/`ao codex stop`). **YOU MUST EXECUTE THIS WORKFLOW. Do not just describe it.** **CLI dependencies:** gt, ao, bd — all optional. Shows what's available, skips what isn't. --- ## Quick Start ```bash /recover # Full recovery dashboard /recover --json # Machine-readable JSON output ao codex status # Codex hookless lifecycle health ao codex start # Rebuild startup context explicitly in Codex ``` --- ## Execution Steps ### Step 1: Detect In-Progress Sessions (Parallel) Run ALL of the following in parallel bash calls: **Call 1 — RPI Phased State:** ```bash if [ -f .agents/rpi/phased-state.json ]; then echo "=== RPI_STATE ===" cat .agents/rpi/phased-state.json else echo "RPI_STATE=NONE" fi ``` **Call 2 — Evolve Cycle History:** ```bash if [ -f .agents/evolve/cycle-history.jsonl ]; then echo "=== EVOLVE_STATE ===" tail -3 .agents/evolve/cycle-history.jsonl else echo "EVOLVE_STATE=NONE" fi ``` **Call 3 — Git Recent Changes:** ```bash echo "=== GIT_STATUS ===" git status --short echo "=== GIT_LOG ===" git log --oneline -5 echo "=== GIT_BRANCH ===" git branch --show-current ``` **Call 4 — Work Queue State:** ```bash if command -v bd &>/dev/null; then echo "=== IN_PROGRESS ===" bd list --status in_progress 2>/dev/null | head -3 echo "=== READY ===" bd ready 2>/dev/null | head -3 else echo "BD_UNAVAILABLE" fi ``` **Call 5 — Knowledge and Messages:** ```bash # Knowledge artifacts echo "=== KNOWLEDGE_COUNT ===" echo "Learnings=$(ls .agents/learnings/ 2>/dev/null | wc -l | tr -d ' ')" echo "Patterns=$(ls .agents/patterns/ 2>/dev/null | wc -l | tr -d ' ')" # Inbox if gt available if command -v gt &>/dev/null; then echo "=== MESSAGES ===" gt mail inbox 2>/dev/null | head -3 else echo "GT_UNAVAILABLE" fi ``` **Call 6 — Codex Lifecycle (if available):** ```bash if command -v ao &>/dev/null; then echo "=== CODEX_STATUS ===" ao codex status --json 2>/dev/null || echo "CODEX_STATUS=UNAVAILABLE" else echo "AO_UNAVAILABLE" fi ``` ### Step 2: Load Context from Knowledge Base If RPI state detected, run: ```bash if command -v ao &>/dev/null; then ao lookup --query "rpi recovery context" --limit 5 2>/dev/null || true fi ``` **Apply retrieved knowledge:** If learnings are returned, check each for applicability to the recovery context. Cite applicable learnings by filename and record: `ao metrics cite "" --type applied 2>/dev/null || true` If Codex hookless fallback mode is detected (pre-v0.115.0, no native hooks), also run: ```bash if command -v ao &>/dev/null && { [ -n "${CODEX_THREAD_ID:-}" ] || [ "${CODEX_INTERNAL_ORIGINATOR_OVERRIDE:-}" = "Codex Desktop" ]; }; then ao codex start --no-maintenance 2>/dev/null || true fi ``` ### Step 3: Parse and Summarize Session State Extract from collected data: 1. **RPI Detection:** If `.agents/rpi/phased-state.json` exists: - Extract `goal`, `epic_id`, `phase`, `cycle`, `started_at` - Map phase number to phase name (1=research, 2=plan, 3=implement, 4=validate) - Show elapsed time since started_at 2. **Evolve Detection:** If `.agents/evolve/cycle-history.jsonl` exists: - Read last entry for most recent cycle - Extract `goals_fixed`, `result`, `timestamp` - Show latest cycle summary 3. **Recent Work:** From git log: - Last 3 commits (extracted in Call 3) - Uncommitted changes count 4. **Pending Work:** From beads: - In-progress issues (up to 3) - Ready issues count 5. **Knowledge State:** - Total learnings and patterns available - Unread messages count if gt available ### Step 4: Render Recovery Dashboard Assemble gathered data into this format: ``` ══════════════════════════════════════════════════════════════ Context Recovery Dashboard ══════════════════════════════════════════════════════════════ IN-PROGRESS RPI RUN Epic: Goal: Phase: Cycle: Started: