$npx -y skills add xwtro0tk1t-cloud/harness --skill harness-resume--- description: Trigger when user says "harness resume", "resume context", "recover context", "load context", "resume after compact", "I want to continue where I left off", "restore work context". Lightweight same-session context recovery after /compact. Do NOT trigger for: "con
| 1 | # Harness Resume — Lightweight Context Recovery |
| 2 | |
| 3 | --- |
| 4 | description: Trigger when user says "harness resume", "resume context", "recover context", "load context", "resume after compact", "I want to continue where I left off", "restore work context". Lightweight same-session context recovery after /compact. Do NOT trigger for: "continue writing X function" (just code), "help me understand this file" (single file read), bare "resume" without context (too vague), "I'm new here" (use harness handoff instead). |
| 5 | --- |
| 6 | |
| 7 | ## Behavior |
| 8 | |
| 9 | Perform lightweight context recovery for the current project. Core principle: **Index-First, Fragment-on-Demand** — only load indexes, read fragments on demand. |
| 10 | This is for same-session /compact recovery only. For new agent handoff or crash recovery, use `harness handoff`. |
| 11 | |
| 12 | --- |
| 13 | |
| 14 | ## Steps |
| 15 | |
| 16 | ### Step 1: task_plan.md Phase Anchor |
| 17 | |
| 18 | - If `task_plan.md` exists → Read the file |
| 19 | - Use regex `^#{1,3}\s.*([Pp]hase)` to locate current Phase heading (covers `#`/`##`/`###`) |
| 20 | - Extract **±30 lines** around the match (shrink to ±15 if token budget exceeded) |
| 21 | - WIP signals: unchecked `- [ ]`, 🚧, WIP, in progress, (doing) |
| 22 | - If no `task_plan.md` → skip, output "No task_plan.md found" |
| 23 | |
| 24 | ### Step 2: MEMORY.md Best-Match |
| 25 | |
| 26 | Locate the project-specific MEMORY.md using this algorithm: |
| 27 | |
| 28 | ``` |
| 29 | target = cwd.replace('/', '-').lstrip('-') |
| 30 | candidates = glob('~/.claude/projects/*/memory/MEMORY.md') |
| 31 | matches = [c for c in candidates if c.parents[1].name.lstrip('-') == target] |
| 32 | ``` |
| 33 | |
| 34 | - `len == 1` → Read that file (first 50 lines, index section) |
| 35 | - `len == 0` → Skip |
| 36 | - `len > 1` → List candidates and ask user to choose |
| 37 | |
| 38 | ### Step 3: docs/ INDEX Tree |
| 39 | |
| 40 | - Read `docs/INDEX.md` if it exists |
| 41 | - Glob `docs/**/INDEX.md`, read up to 5 files |
| 42 | - If no INDEX files → skip |
| 43 | |
| 44 | ### Step 4: Output Structured Summary |
| 45 | |
| 46 | ``` |
| 47 | 📍 Current Phase: [Phase name / status] |
| 48 | ⏳ Unfinished: [unchecked items] |
| 49 | ⏸ Last stopped at: [latest progress entry] |
| 50 | 🧠 Relevant memory: [MEMORY.md relevant entries] |
| 51 | 📚 Doc index: [INDEX tree summary] |
| 52 | |
| 53 | Next: Tell me what you want to do, I'll read specific doc fragments on demand |
| 54 | ``` |
| 55 | |
| 56 | --- |
| 57 | |
| 58 | ## Token Budget |
| 59 | |
| 60 | Target **3-5k tokens**: |
| 61 | - Phase ±30 lines ≈ 1-2k (shrink to ±15 if budget tight) |
| 62 | - MEMORY ≤50 lines ≈ 0.5-1k |
| 63 | - INDEX ≤5 files ≈ 0.5-1k |
| 64 | |
| 65 | If exceeded, truncate Phase to ±15 lines first. |
| 66 | |
| 67 | --- |
| 68 | |
| 69 | ## Empty Rendering |
| 70 | |
| 71 | - If a row field is empty → **omit the entire row** |
| 72 | - If all 4 core rows are empty → print fallback: |
| 73 | > No work context found — this may be a new project. Say `harness` to start initialization. |
| 74 | |
| 75 | ## Graceful Degradation |
| 76 | |
| 77 | Any file missing → skip that step, output "Step skipped (file not found)" and continue. Never error out. |