$npx -y skills add xwtro0tk1t-cloud/harness --skill harness-handoff--- description: Trigger when user says "harness handoff", "handoff context", "new agent takeover", "full project context", "load all context", "crash recovery", "transfer context", "project overview full". Provides deep context recovery (~8k tokens) for new agent handoff or cras
| 1 | # Harness Handoff — Deep Context Transfer |
| 2 | |
| 3 | --- |
| 4 | description: Trigger when user says "harness handoff", "handoff context", "new agent takeover", "full project context", "load all context", "crash recovery", "transfer context", "project overview full". Provides deep context recovery (~8k tokens) for new agent handoff or crash recovery. Do NOT trigger for: "continue writing X function" (just code), "help me understand this file" (single file read), "what is this project" (too vague, use harness guide). |
| 5 | --- |
| 6 | |
| 7 | ## Behavior |
| 8 | |
| 9 | Provide deep context recovery for new agent handoff or crash recovery scenarios. Core principle: **Index-First, Fragment-on-Demand**. |
| 10 | For lightweight same-session /compact recovery, use `harness resume` (~3k tokens). |
| 11 | |
| 12 | --- |
| 13 | |
| 14 | ## Difference from Claude Code Default Behavior |
| 15 | |
| 16 | Claude Code auto-loads only CLAUDE.md. This skill adds: |
| 17 | - a) task_plan Phase anchor (not just project overview) |
| 18 | - b) progress.md tail (recent activity context) |
| 19 | - c) docs/ INDEX tree (document navigation map) |
| 20 | - d) MEMORY.md project-specific memory |
| 21 | - e) .harness state (project scaffold status) |
| 22 | - f) git log (recent commit history) |
| 23 | |
| 24 | --- |
| 25 | |
| 26 | ## Read-tool Steps (1-5, deterministic file reads) |
| 27 | |
| 28 | ### Step 1: CLAUDE.md |
| 29 | - Read project CLAUDE.md |
| 30 | - If >300 lines → read tail 300 (recent conventions/rules are more valuable) |
| 31 | |
| 32 | ### Step 2: task_plan.md Phase Anchor |
| 33 | - Use regex `^#{1,3}\s.*([Pp]hase)` to locate current Phase |
| 34 | - Extract **±50 lines** around match |
| 35 | - WIP signals: unchecked `- [ ]`, 🚧, WIP, in progress, (doing) |
| 36 | - If no task_plan.md → skip |
| 37 | |
| 38 | ### Step 3: progress.md |
| 39 | - <500 lines → read all |
| 40 | - ≥500 lines → read tail 200 |
| 41 | |
| 42 | ### Step 4: docs/ INDEX Tree |
| 43 | - Read `docs/INDEX.md` if exists |
| 44 | - Glob `docs/**/INDEX.md`, read up to **10** files |
| 45 | - If none → skip |
| 46 | |
| 47 | ### Step 5: MEMORY.md Best-Match |
| 48 | ``` |
| 49 | target = cwd.replace('/', '-').lstrip('-') |
| 50 | candidates = glob('~/.claude/projects/*/memory/MEMORY.md') |
| 51 | matches = [c for c in candidates if c.parents[1].name.lstrip('-') == target] |
| 52 | ``` |
| 53 | - `len == 1` → read it |
| 54 | - `len == 0` → skip |
| 55 | - `len > 1` → list candidates, ask user to choose |
| 56 | |
| 57 | --- |
| 58 | |
| 59 | ## Bash-tool Steps (6-7, may fail gracefully) |
| 60 | |
| 61 | ### Step 6: .harness/ Directory Check |
| 62 | ```bash |
| 63 | test -d .harness && ls .harness/ || echo "No .harness directory" |
| 64 | ``` |
| 65 | |
| 66 | ### Step 7: git log |
| 67 | ```bash |
| 68 | git log --oneline -20 2>/dev/null || echo "No git history or not a git repo" |
| 69 | ``` |
| 70 | |
| 71 | --- |
| 72 | |
| 73 | ## Output: 3-Segment Structured Summary |
| 74 | |
| 75 | ``` |
| 76 | ═══ Project Overview ═══ |
| 77 | Main goal (from CLAUDE.md Project Overview or task_plan title) |
| 78 | Git status (recent 20 commits / "no git") |
| 79 | .harness status (contents / "none") |
| 80 | |
| 81 | ═══ Current Work ═══ |
| 82 | Current Phase / latest commit / last stopped at / unfinished items |
| 83 | |
| 84 | ═══ Available Resources ═══ |
| 85 | Document structure (docs/ INDEX tree) |
| 86 | Memory categories (MEMORY.md sections) |
| 87 | Harness state (.harness/ if present) |
| 88 | |
| 89 | Next: Tell me what you want to do, I'll read specific doc fragments on demand |
| 90 | ``` |
| 91 | |
| 92 | --- |
| 93 | |
| 94 | ## Token Budget |
| 95 | |
| 96 | Target **8-12k tokens**: |
| 97 | - CLAUDE.md ≤300 lines ≈ 2-3k |
| 98 | - task_plan Phase ±50 lines ≈ 2k |
| 99 | - progress tail 200 lines ≈ 2k |
| 100 | - 10 INDEX files ≈ 2-3k |
| 101 | - MEMORY.md ≈ 1-1.5k |
| 102 | - git log -20 ≈ 0.3k |
| 103 | |
| 104 | **If exceeded**: truncate progress to 100 lines first, then INDEX to 5 files. |
| 105 | |
| 106 | --- |
| 107 | |
| 108 | ## Empty Rendering |
| 109 | |
| 110 | - If a row field is empty → **omit the entire row** |
| 111 | - If all 3 rows in a segment are empty → **omit segment with its title** |
| 112 | - If everything is empty → print fallback: |
| 113 | > No project context found. Say `harness` to initialize a new project. |
| 114 | |
| 115 | ## Graceful Degradation |
| 116 | |
| 117 | Any file missing → output "Step skipped (file not found)" and continue. Never error out. |