[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M71E11GE2Y2R8FDY558YQ5MW":3,"skill-same:01M71E11GE2Y2R8FDY558YQ5MW":64},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":29,"linkOnly":30,"markdownContent":31,"markdownBody":32,"frontMatter":33,"refName":35,"commitSha":36,"skillDirectory":37,"forksCount":38,"repositoryHtmlUrl":39,"repositoryHomepageUrl":6,"ownerHtmlUrl":40,"ownerBlogUrl":41,"ownerDescription":42,"updatedAt":43,"install":44,"resources":57},"01M71E11GE2Y2R8FDY558YQ5MW","recover-session",null,"Recover sessions that hit context limits without a handoff.","indigoai-us\u002Fhq-core","indigoai-us","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F122242446?v=4","01M71DTQ5NGD10GT1Z7E6XKWC5","HQ","01M71DTQ6BKSYYBNC9RAKT3YDK",95,"MIT","https:\u002F\u002Fgithub.com\u002Findigoai-us\u002Fhq-core\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Frecover-session\u002FSKILL.md",[],[19,20,21,22,23,24,25,26,27,28],"session","recover session","handoff","sessions","Bash","grep","read","write","context","limits","2026-11-10 10:12:30",false,"---\nname: recover-session\ndescription: Recover sessions that hit context limits without a handoff.\nallowed-tools: Read, Write, Bash, Glob, Grep, AskUserQuestion\n---\n\n# \u002Frecover-session - Dead Session Recovery\n\nFind and recover Claude Code sessions that died from context limits (\"Prompt is too long\") without running `\u002Fhandoff`. Reconstructs thread JSON from JSONL session data so work is tracked in HQ.\n\n**User's input:** $ARGUMENTS\n\n## Arguments\n\n- No args: scan last 7 days, interactive selection\n- `--days N`: scan last N days (default 7)\n- `--session UUID`: recover specific session by ID\n- `--dry-run`: show what would be recovered, don't write anything\n\n## Process\n\n### 1. Scan for Dead Sessions\n\nParse arguments. Set `DAYS` from `--days` or default to 7.\n\n**Death signals** (from real data — the session ends with these patterns):\n- Assistant content `\"Prompt is too long\"` (the API rejects the request)\n- `\u002Fcompact` fails with `\"Error during compaction: Error: Conversation too long\"`\n- No productive content follows the error (session is dead)\n\n**Step 1a: Find candidates** — search for error strings in JSONL files. Exclude subagent files (in `subagents\u002F` dirs):\n\n```bash\nSESSIONS_ROOT=\"$HOME\u002F.claude\u002Fprojects\"\nfind \"$SESSIONS_ROOT\" -name \"*.jsonl\" -not -path \"*\u002Fsubagents\u002F*\" -mtime -${DAYS} -size +10k 2>\u002Fdev\u002Fnull | while read f; do\n  if grep -q \"Prompt is too long\\|Conversation too long\\|Error during compaction\" \"$f\" 2>\u002Fdev\u002Fnull; then\n    echo \"$f\"\n  fi\ndone\n```\n\nIf `--session UUID` was provided, only check files matching `*\u002F${UUID}.jsonl`.\n\n**Step 1b: Verify death** — a session is truly dead only if the error appears near the end. Sessions that compacted successfully and continued are NOT dead. Check the last 20 lines:\n\n```bash\ntail -20 \"$JSONL_FILE\" | grep -q \"Prompt is too long\\|Conversation too long\\|Error during compaction\"\n```\n\nOnly keep sessions where the error is in the tail (nothing productive follows).\n\n**Step 1c: Extract metadata** — the slug may not be in the first line (first line is often `queue-operation`). Scan up to 30 lines:\n\n```bash\nhead -30 \"$JSONL_FILE\" | python3 -c \"\nimport json, sys\nfor line in sys.stdin:\n    try:\n        d = json.loads(line)\n        if d.get('slug'):\n            print(json.dumps({\n                'session_id': d.get('sessionId',''),\n                'slug': d.get('slug',''),\n                'cwd': d.get('cwd',''),\n                'git_branch': d.get('gitBranch',''),\n                'started': d.get('timestamp','')\n            }))\n            break\n    except: continue\n\"\n```\n\n**Step 1d: Cross-reference** — check `workspace\u002Fthreads\u002F` for existing threads. Skip sessions that already have a `recovered` thread:\n\n```bash\ngrep -rl \"original_session_id.*SESSION_ID\" workspace\u002Fthreads\u002F 2>\u002Fdev\u002Fnull\n```\n\nBuild candidate list. If empty, report \"No unrecovered dead sessions found\" and stop.\n\n### 2. Present Candidates\n\nIf `--session UUID` was provided, skip to step 3 with that session.\n\nOtherwise display a table:\n\n```\nDead Sessions Found (last {DAYS} days):\n\n  # | Died       | Slug                     | Project | Size\n  1 | 2026-02-12 | linked-watching-lovelace | HQ      | 3.4MB\n  2 | 2026-02-11 | merry-nibbling-coral     | {company}  | 858KB\n```\n\nUse `AskUserQuestion` to let user pick which to recover (number, or \"all\").\n\n### 3. Extract State from JSONL\n\n**CRITICAL: Never read the full JSONL. Always stream via Python.**\n\nFor each selected session, run this extraction script via Bash. It streams line-by-line and outputs a compact ~3KB summary JSON:\n\n```bash\npython3 \u003C\u003C 'PYEOF'\nimport json, sys\n\nJSONL_PATH = \"SESSION_PATH_HERE\"\n\nout = {\n    \"session_id\": None, \"slug\": None, \"cwd\": None, \"git_branch\": None,\n    \"started_at\": None, \"died_at\": None, \"first_user_message\": None,\n    \"files_edited\": [], \"files_written\": [], \"git_commands\": [],\n    \"last_5_summaries\": [], \"death_count\": 0, \"total_lines\": 0,\n    \"project_dir_encoded\": None\n}\n\nfiles_edited = set()\nfiles_written = set()\ngit_cmds = []\nsummaries = []\nfirst_user = False\n\nwith open(JSONL_PATH) as f:\n    for line in f:\n        out[\"total_lines\"] += 1\n        try:\n            d = json.loads(line)\n        except:\n            continue\n\n        # Session metadata from first slug-bearing line\n        if not out[\"slug\"] and d.get(\"slug\"):\n            out[\"session_id\"] = d.get(\"sessionId\")\n            out[\"slug\"] = d[\"slug\"]\n            out[\"cwd\"] = d.get(\"cwd\")\n            out[\"git_branch\"] = d.get(\"gitBranch\")\n            out[\"started_at\"] = d.get(\"timestamp\")\n\n        # Track last timestamp as death time\n        if d.get(\"timestamp\"):\n            out[\"died_at\"] = d[\"timestamp\"]\n\n        # First user message (truncated). Skip command XML wrappers and\n        # compact summaries — find the first real user message\n        if not first_user and d.get(\"type\") == \"user\":\n            if d.get(\"isCompactSummary\"):\n                continue\n            msg = d.get(\"message\", {})\n            content = msg.get(\"content\", \"\")\n            text = \"\"\n            if isinstance(content, str) and content:\n                text = content\n            elif isinstance(content, list):\n                for c in content:\n                    if isinstance(c, dict) and c.get(\"type\") == \"text\":\n                        text = c[\"text\"]\n                        break\n            if text:\n                # Extract command name if wrapped in XML\n                import re\n                cmd_match = re.search(r\"\u003Ccommand-name>(\u002F\\S+)\u003C\u002Fcommand-name>\", text)\n                args_match = re.search(r\"\u003Ccommand-args>(.*?)\u003C\u002Fcommand-args>\", text, re.DOTALL)\n                if cmd_match:\n                    out[\"first_user_message\"] = cmd_match.group(1)\n                    if args_match:\n                        out[\"first_user_message\"] += \" \" + args_match.group(1).strip()[:400]\n                else:\n                    out[\"first_user_message\"] = text[:500]\n                first_user = True\n\n        # Tool use: find file edits and git commands\n        if d.get(\"type\") == \"assistant\":\n            msg = d.get(\"message\", {})\n            content = msg.get(\"content\", [])\n            if isinstance(content, list):\n                for c in content:\n                    if not isinstance(c, dict):\n                        continue\n                    if c.get(\"type\") == \"tool_use\":\n                        name = c.get(\"name\", \"\")\n                        inp = c.get(\"input\", {})\n                        if name == \"Edit\" and inp.get(\"file_path\"):\n                            files_edited.add(inp[\"file_path\"])\n                        elif name == \"Write\" and inp.get(\"file_path\"):\n                            files_written.add(inp[\"file_path\"])\n                        elif name == \"Bash\":\n                            cmd = inp.get(\"command\", \"\")\n                            if \"git commit\" in cmd or \"git push\" in cmd:\n                                git_cmds.append(cmd[:150])\n                    elif c.get(\"type\") == \"text\":\n                        text = c[\"text\"]\n                        if text == \"Prompt is too long\":\n                            out[\"death_count\"] += 1\n                        elif len(text) > 30:\n                            summaries.append(text[:300])\n\n        # Check for subagent (skip these)\n        if d.get(\"subagentId\"):\n            print(json.dumps({\"skip\": True, \"reason\": \"subagent\"}))\n            sys.exit(0)\n\nout[\"files_edited\"] = sorted(files_edited)\nout[\"files_written\"] = sorted(files_written)\nout[\"git_commands\"] = git_cmds[-10:]\nout[\"last_5_summaries\"] = summaries[-5:]\n\n# Detect project from path\nparts = JSONL_PATH.split(\"\u002F\")\nfor i, p in enumerate(parts):\n    if p == \"projects\" and i + 1 \u003C len(parts):\n        out[\"project_dir_encoded\"] = parts[i + 1]\n        break\n\nprint(json.dumps(out, indent=2))\nPYEOF\n```\n\nRead the output JSON. If `{\"skip\": true}`, skip this session (subagent).\n\n### 4. Detect Company\n\nDecode `project_dir_encoded` and inspect `cwd` + `files_edited`\u002F`files_written`:\n\n- `cwd` contains `repos\u002Fprivate\u002F{company}` → {company}\n- `cwd` contains `repos\u002Fprivate\u002F{company}-` → {company}\n- `cwd` contains `repos\u002Fprivate\u002F{company}-` → {company}\n- `files_touched` include `companies\u002F{co}\u002F` → that company\n- Fallback: \"personal\"\n\nDecode project dir for display:\n- `-Users-{your-username}-Documents-HQ` → \"HQ\"\n- `-Users-{your-username}-Documents-HQ-repos-private-{company}` → \"{company}\"\n- etc. (replace leading path + `-` with readable name)\n\n### 5. Generate Thread JSON\n\nUsing extracted data, generate a summary and next_steps from:\n- `first_user_message` — what the session set out to do\n- `last_5_summaries` — what it was doing when it died\n- `files_edited` + `files_written` — scope of work\n\nBuild thread in HQ format:\n\n```json\n{\n  \"id\": \"T-{YYYYMMDD}-{HHMMSS}-recovered-{slug-fragment}\",\n  \"created_at\": \"{died_at}\",\n  \"summary\": \"{1-2 sentence AI-generated summary}\",\n  \"status\": \"interrupted\",\n  \"category\": \"recovered\",\n  \"company\": \"{detected company}\",\n  \"git\": {\n    \"branch\": \"{git_branch}\",\n    \"repos\": {}\n  },\n  \"files_touched\": [\"{relativized file paths}\"],\n  \"next_actions\": [\"{inferred from death context}\"],\n  \"recovery\": {\n    \"original_session_id\": \"{session_id}\",\n    \"original_slug\": \"{slug}\",\n    \"death_timestamp\": \"{died_at}\",\n    \"death_count\": 0,\n    \"total_lines\": 0,\n    \"project_dir\": \"{decoded project name}\"\n  }\n}\n```\n\nUse the death timestamp (not current time) for the thread ID — represents when work happened.\n\nRelativize file paths: strip `~\u002FHQ\u002F` prefix.\n\nIf `--dry-run`, display what would be written and stop here. Do NOT write any files.\n\nWrite to `workspace\u002Fthreads\u002F{thread_id}.json`.\n\n### 6. Update Handoff Artifacts\n\n**Update `workspace\u002Fthreads\u002Frecent.md`:**\nRegenerate table of last 15 threads (sorted by date descending):\n```markdown\n| Thread | Created | Summary | Status |\n|--------|---------|---------|--------|\n| T-...-recovered-... | 2026-02-12 | ... | interrupted |\n```\n\n**Update `workspace\u002Fthreads\u002FINDEX.md`:**\nAdd recovered thread to the full threads table.\n\n**Write `workspace\u002Fthreads\u002Fhandoff.json`:**\n```json\n{\n  \"created_at\": \"{now ISO8601}\",\n  \"message\": \"Recovered dead session: {slug}\",\n  \"last_thread\": \"{thread_id}\",\n  \"thread_path\": \"workspace\u002Fthreads\u002F{thread_id}.json\",\n  \"context_notes\": \"{summary}. Died from context limits. {next_actions[0] if any}\"\n}\n```\n\n**Skip** (unsafe in recovery context):\n- Auto-committing repos (can't know what was dirty at death vs now)\n- Personal\u002Fcore knowledge repo commits (company knowledge changes sync through the company vault)\n- qmd reindex (user can run `qmd update`)\n\n### 7. Report\n\n```\nSession Recovery Complete\n═════════════════════════\n\nThread:   {thread_id}\nDied:     {death timestamp}\nSession:  {slug} ({session_id})\nCompany:  {company}\nSummary:  {conversation_summary}\nFiles:    {N} files touched\nCommits:  {N} git commands found in session\n\nThread saved: workspace\u002Fthreads\u002F{thread_id}.json\n\nNext:\n  - Review: Read workspace\u002Fthreads\u002F{thread_id}.json\n  - Continue: \u002Fnexttask (recovered thread will appear)\n  - Reindex: qmd update (if needed)\n```\n\nIf multiple sessions recovered, show summary table then per-session details.\n\n## Rules\n\n- NEVER cat\u002Fread entire JSONL files — always stream via python3 or use grep\u002Ftail\n- Keep total context from extraction under 5KB per session\n- Cross-reference existing threads BEFORE running extraction (cheap check first)\n- Recovery threads use death timestamp, not current time, for thread_id\n- Never auto-commit repos during recovery — user must verify what's dirty now vs then\n- Skip subagent JSONL files (they have `subagentId` in their lines)\n- Relativize all file paths to HQ root in thread JSON\n- `--dry-run` must not write any files\n","# \u002Frecover-session - Dead Session Recovery\n\nFind and recover Claude Code sessions that died from context limits (\"Prompt is too long\") without running `\u002Fhandoff`. Reconstructs thread JSON from JSONL session data so work is tracked in HQ.\n\n**User's input:** $ARGUMENTS\n\n## Arguments\n\n- No args: scan last 7 days, interactive selection\n- `--days N`: scan last N days (default 7)\n- `--session UUID`: recover specific session by ID\n- `--dry-run`: show what would be recovered, don't write anything\n\n## Process\n\n### 1. Scan for Dead Sessions\n\nParse arguments. Set `DAYS` from `--days` or default to 7.\n\n**Death signals** (from real data — the session ends with these patterns):\n- Assistant content `\"Prompt is too long\"` (the API rejects the request)\n- `\u002Fcompact` fails with `\"Error during compaction: Error: Conversation too long\"`\n- No productive content follows the error (session is dead)\n\n**Step 1a: Find candidates** — search for error strings in JSONL files. Exclude subagent files (in `subagents\u002F` dirs):\n\n```bash\nSESSIONS_ROOT=\"$HOME\u002F.claude\u002Fprojects\"\nfind \"$SESSIONS_ROOT\" -name \"*.jsonl\" -not -path \"*\u002Fsubagents\u002F*\" -mtime -${DAYS} -size +10k 2>\u002Fdev\u002Fnull | while read f; do\n  if grep -q \"Prompt is too long\\|Conversation too long\\|Error during compaction\" \"$f\" 2>\u002Fdev\u002Fnull; then\n    echo \"$f\"\n  fi\ndone\n```\n\nIf `--session UUID` was provided, only check files matching `*\u002F${UUID}.jsonl`.\n\n**Step 1b: Verify death** — a session is truly dead only if the error appears near the end. Sessions that compacted successfully and continued are NOT dead. Check the last 20 lines:\n\n```bash\ntail -20 \"$JSONL_FILE\" | grep -q \"Prompt is too long\\|Conversation too long\\|Error during compaction\"\n```\n\nOnly keep sessions where the error is in the tail (nothing productive follows).\n\n**Step 1c: Extract metadata** — the slug may not be in the first line (first line is often `queue-operation`). Scan up to 30 lines:\n\n```bash\nhead -30 \"$JSONL_FILE\" | python3 -c \"\nimport json, sys\nfor line in sys.stdin:\n    try:\n        d = json.loads(line)\n        if d.get('slug'):\n            print(json.dumps({\n                'session_id': d.get('sessionId',''),\n                'slug': d.get('slug',''),\n                'cwd': d.get('cwd',''),\n                'git_branch': d.get('gitBranch',''),\n                'started': d.get('timestamp','')\n            }))\n            break\n    except: continue\n\"\n```\n\n**Step 1d: Cross-reference** — check `workspace\u002Fthreads\u002F` for existing threads. Skip sessions that already have a `recovered` thread:\n\n```bash\ngrep -rl \"original_session_id.*SESSION_ID\" workspace\u002Fthreads\u002F 2>\u002Fdev\u002Fnull\n```\n\nBuild candidate list. If empty, report \"No unrecovered dead sessions found\" and stop.\n\n### 2. Present Candidates\n\nIf `--session UUID` was provided, skip to step 3 with that session.\n\nOtherwise display a table:\n\n```\nDead Sessions Found (last {DAYS} days):\n\n  # | Died       | Slug                     | Project | Size\n  1 | 2026-02-12 | linked-watching-lovelace | HQ      | 3.4MB\n  2 | 2026-02-11 | merry-nibbling-coral     | {company}  | 858KB\n```\n\nUse `AskUserQuestion` to let user pick which to recover (number, or \"all\").\n\n### 3. Extract State from JSONL\n\n**CRITICAL: Never read the full JSONL. Always stream via Python.**\n\nFor each selected session, run this extraction script via Bash. It streams line-by-line and outputs a compact ~3KB summary JSON:\n\n```bash\npython3 \u003C\u003C 'PYEOF'\nimport json, sys\n\nJSONL_PATH = \"SESSION_PATH_HERE\"\n\nout = {\n    \"session_id\": None, \"slug\": None, \"cwd\": None, \"git_branch\": None,\n    \"started_at\": None, \"died_at\": None, \"first_user_message\": None,\n    \"files_edited\": [], \"files_written\": [], \"git_commands\": [],\n    \"last_5_summaries\": [], \"death_count\": 0, \"total_lines\": 0,\n    \"project_dir_encoded\": None\n}\n\nfiles_edited = set()\nfiles_written = set()\ngit_cmds = []\nsummaries = []\nfirst_user = False\n\nwith open(JSONL_PATH) as f:\n    for line in f:\n        out[\"total_lines\"] += 1\n        try:\n            d = json.loads(line)\n        except:\n            continue\n\n        # Session metadata from first slug-bearing line\n        if not out[\"slug\"] and d.get(\"slug\"):\n            out[\"session_id\"] = d.get(\"sessionId\")\n            out[\"slug\"] = d[\"slug\"]\n            out[\"cwd\"] = d.get(\"cwd\")\n            out[\"git_branch\"] = d.get(\"gitBranch\")\n            out[\"started_at\"] = d.get(\"timestamp\")\n\n        # Track last timestamp as death time\n        if d.get(\"timestamp\"):\n            out[\"died_at\"] = d[\"timestamp\"]\n\n        # First user message (truncated). Skip command XML wrappers and\n        # compact summaries — find the first real user message\n        if not first_user and d.get(\"type\") == \"user\":\n            if d.get(\"isCompactSummary\"):\n                continue\n            msg = d.get(\"message\", {})\n            content = msg.get(\"content\", \"\")\n            text = \"\"\n            if isinstance(content, str) and content:\n                text = content\n            elif isinstance(content, list):\n                for c in content:\n                    if isinstance(c, dict) and c.get(\"type\") == \"text\":\n                        text = c[\"text\"]\n                        break\n            if text:\n                # Extract command name if wrapped in XML\n                import re\n                cmd_match = re.search(r\"\u003Ccommand-name>(\u002F\\S+)\u003C\u002Fcommand-name>\", text)\n                args_match = re.search(r\"\u003Ccommand-args>(.*?)\u003C\u002Fcommand-args>\", text, re.DOTALL)\n                if cmd_match:\n                    out[\"first_user_message\"] = cmd_match.group(1)\n                    if args_match:\n                        out[\"first_user_message\"] += \" \" + args_match.group(1).strip()[:400]\n                else:\n                    out[\"first_user_message\"] = text[:500]\n                first_user = True\n\n        # Tool use: find file edits and git commands\n        if d.get(\"type\") == \"assistant\":\n            msg = d.get(\"message\", {})\n            content = msg.get(\"content\", [])\n            if isinstance(content, list):\n                for c in content:\n                    if not isinstance(c, dict):\n                        continue\n                    if c.get(\"type\") == \"tool_use\":\n                        name = c.get(\"name\", \"\")\n                        inp = c.get(\"input\", {})\n                        if name == \"Edit\" and inp.get(\"file_path\"):\n                            files_edited.add(inp[\"file_path\"])\n                        elif name == \"Write\" and inp.get(\"file_path\"):\n                            files_written.add(inp[\"file_path\"])\n                        elif name == \"Bash\":\n                            cmd = inp.get(\"command\", \"\")\n                            if \"git commit\" in cmd or \"git push\" in cmd:\n                                git_cmds.append(cmd[:150])\n                    elif c.get(\"type\") == \"text\":\n                        text = c[\"text\"]\n                        if text == \"Prompt is too long\":\n                            out[\"death_count\"] += 1\n                        elif len(text) > 30:\n                            summaries.append(text[:300])\n\n        # Check for subagent (skip these)\n        if d.get(\"subagentId\"):\n            print(json.dumps({\"skip\": True, \"reason\": \"subagent\"}))\n            sys.exit(0)\n\nout[\"files_edited\"] = sorted(files_edited)\nout[\"files_written\"] = sorted(files_written)\nout[\"git_commands\"] = git_cmds[-10:]\nout[\"last_5_summaries\"] = summaries[-5:]\n\n# Detect project from path\nparts = JSONL_PATH.split(\"\u002F\")\nfor i, p in enumerate(parts):\n    if p == \"projects\" and i + 1 \u003C len(parts):\n        out[\"project_dir_encoded\"] = parts[i + 1]\n        break\n\nprint(json.dumps(out, indent=2))\nPYEOF\n```\n\nRead the output JSON. If `{\"skip\": true}`, skip this session (subagent).\n\n### 4. Detect Company\n\nDecode `project_dir_encoded` and inspect `cwd` + `files_edited`\u002F`files_written`:\n\n- `cwd` contains `repos\u002Fprivate\u002F{company}` → {company}\n- `cwd` contains `repos\u002Fprivate\u002F{company}-` → {company}\n- `cwd` contains `repos\u002Fprivate\u002F{company}-` → {company}\n- `files_touched` include `companies\u002F{co}\u002F` → that company\n- Fallback: \"personal\"\n\nDecode project dir for display:\n- `-Users-{your-username}-Documents-HQ` → \"HQ\"\n- `-Users-{your-username}-Documents-HQ-repos-private-{company}` → \"{company}\"\n- etc. (replace leading path + `-` with readable name)\n\n### 5. Generate Thread JSON\n\nUsing extracted data, generate a summary and next_steps from:\n- `first_user_message` — what the session set out to do\n- `last_5_summaries` — what it was doing when it died\n- `files_edited` + `files_written` — scope of work\n\nBuild thread in HQ format:\n\n```json\n{\n  \"id\": \"T-{YYYYMMDD}-{HHMMSS}-recovered-{slug-fragment}\",\n  \"created_at\": \"{died_at}\",\n  \"summary\": \"{1-2 sentence AI-generated summary}\",\n  \"status\": \"interrupted\",\n  \"category\": \"recovered\",\n  \"company\": \"{detected company}\",\n  \"git\": {\n    \"branch\": \"{git_branch}\",\n    \"repos\": {}\n  },\n  \"files_touched\": [\"{relativized file paths}\"],\n  \"next_actions\": [\"{inferred from death context}\"],\n  \"recovery\": {\n    \"original_session_id\": \"{session_id}\",\n    \"original_slug\": \"{slug}\",\n    \"death_timestamp\": \"{died_at}\",\n    \"death_count\": 0,\n    \"total_lines\": 0,\n    \"project_dir\": \"{decoded project name}\"\n  }\n}\n```\n\nUse the death timestamp (not current time) for the thread ID — represents when work happened.\n\nRelativize file paths: strip `~\u002FHQ\u002F` prefix.\n\nIf `--dry-run`, display what would be written and stop here. Do NOT write any files.\n\nWrite to `workspace\u002Fthreads\u002F{thread_id}.json`.\n\n### 6. Update Handoff Artifacts\n\n**Update `workspace\u002Fthreads\u002Frecent.md`:**\nRegenerate table of last 15 threads (sorted by date descending):\n```markdown\n| Thread | Created | Summary | Status |\n|--------|---------|---------|--------|\n| T-...-recovered-... | 2026-02-12 | ... | interrupted |\n```\n\n**Update `workspace\u002Fthreads\u002FINDEX.md`:**\nAdd recovered thread to the full threads table.\n\n**Write `workspace\u002Fthreads\u002Fhandoff.json`:**\n```json\n{\n  \"created_at\": \"{now ISO8601}\",\n  \"message\": \"Recovered dead session: {slug}\",\n  \"last_thread\": \"{thread_id}\",\n  \"thread_path\": \"workspace\u002Fthreads\u002F{thread_id}.json\",\n  \"context_notes\": \"{summary}. Died from context limits. {next_actions[0] if any}\"\n}\n```\n\n**Skip** (unsafe in recovery context):\n- Auto-committing repos (can't know what was dirty at death vs now)\n- Personal\u002Fcore knowledge repo commits (company knowledge changes sync through the company vault)\n- qmd reindex (user can run `qmd update`)\n\n### 7. Report\n\n```\nSession Recovery Complete\n═════════════════════════\n\nThread:   {thread_id}\nDied:     {death timestamp}\nSession:  {slug} ({session_id})\nCompany:  {company}\nSummary:  {conversation_summary}\nFiles:    {N} files touched\nCommits:  {N} git commands found in session\n\nThread saved: workspace\u002Fthreads\u002F{thread_id}.json\n\nNext:\n  - Review: Read workspace\u002Fthreads\u002F{thread_id}.json\n  - Continue: \u002Fnexttask (recovered thread will appear)\n  - Reindex: qmd update (if needed)\n```\n\nIf multiple sessions recovered, show summary table then per-session details.\n\n## Rules\n\n- NEVER cat\u002Fread entire JSONL files — always stream via python3 or use grep\u002Ftail\n- Keep total context from extraction under 5KB per session\n- Cross-reference existing threads BEFORE running extraction (cheap check first)\n- Recovery threads use death timestamp, not current time, for thread_id\n- Never auto-commit repos during recovery — user must verify what's dirty now vs then\n- Skip subagent JSONL files (they have `subagentId` in their lines)\n- Relativize all file paths to HQ root in thread JSON\n- `--dry-run` must not write any files\n",{"name":5,"description":7,"allowed-tools":34},"Read, Write, Bash, Glob, Grep, AskUserQuestion","main","205cf61728a27ef15e9153aa38df5856fc8d82f5",".claude\u002Fskills\u002Frecover-session",18,"https:\u002F\u002Fgithub.com\u002Findigoai-us\u002Fhq-core","https:\u002F\u002Fgithub.com\u002Findigoai-us","https:\u002F\u002Fhqforwork.com\u002F","The AI Context Layer for Teams","2026-11-12 06:53:38",{"source":8,"skillName":5,"commands":45,"prompt":55,"zipAvailable":56},[46,49,52],{"tool":47,"command":48},"npx","npx skills add indigoai-us\u002Fhq-core --skill recover-session",{"tool":50,"command":51},"bunx","bunx skills add indigoai-us\u002Fhq-core --skill recover-session",{"tool":53,"command":54},"pnpm","pnpm dlx skills add indigoai-us\u002Fhq-core --skill recover-session","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Findigoai-us\u002Fhq-core\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Frecover-session\u002FSKILL.md",true,[58],{"path":59,"resourceType":60,"resourceTypeDesc":61,"sizeBytes":62,"sourceHtmlUrl":63},"agents\u002Fopenai.yaml","REFERENCE","参考文档",108,"https:\u002F\u002Fgithub.com\u002Findigoai-us\u002Fhq-core\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Frecover-session\u002Fagents\u002Fopenai.yaml",[65,73,80,87,94,101],{"skillNo":66,"name":67,"nameZh":6,"description":68,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":69,"categories":70,"keywords":71,"publishedAt":72},"01M73NTNKZ3T2KJNDP2ZF23645","job","Deprecated alias for \u002Fschedule — Outpost recurring agent jobs. Prefer \u002Fschedule.","https:\u002F\u002Fgithub.com\u002Findigoai-us\u002Fhq-core\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fjob\u002FSKILL.md",[],[],"2026-11-11 15:11:14",{"skillNo":74,"name":75,"nameZh":6,"description":76,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":77,"categories":78,"keywords":79,"publishedAt":72},"01M73NTE0H9DQTT6DNHDKRWTXW","import-claude","Deprecated alias for \u002Fimport-context — bootstrap HQ from your prior AI footprint (Claude Code, Codex, Grok, claude.ai history plus on-disk artifacts).","https:\u002F\u002Fgithub.com\u002Findigoai-us\u002Fhq-core\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fimport-claude\u002FSKILL.md",[],[],{"skillNo":81,"name":82,"nameZh":6,"description":83,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":84,"categories":85,"keywords":86,"publishedAt":72},"01M73NT67433KKX96CCJWDQQ0X","hq-whoami","Show current HQ Cognito identity and session expiry.","https:\u002F\u002Fgithub.com\u002Findigoai-us\u002Fhq-core\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fhq-whoami\u002FSKILL.md",[],[],{"skillNo":88,"name":89,"nameZh":6,"description":90,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":91,"categories":92,"keywords":93,"publishedAt":72},"01M73NT17SVXZV2QPT14C2RPJP","hq-share","Share HQ vault paths through single-use links or direct ACL grants.","https:\u002F\u002Fgithub.com\u002Findigoai-us\u002Fhq-core\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fhq-share\u002FSKILL.md",[],[],{"skillNo":95,"name":96,"nameZh":6,"description":97,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":98,"categories":99,"keywords":100,"publishedAt":72},"01M73NSXYFMD7EHGT8TFDZA3C8","hq-secrets","Use HQ CLI secrets safely through env injection or one-off exec.","https:\u002F\u002Fgithub.com\u002Findigoai-us\u002Fhq-core\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fhq-secrets\u002FSKILL.md",[],[],{"skillNo":102,"name":103,"nameZh":6,"description":104,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":105,"categories":106,"keywords":107,"publishedAt":72},"01M73NSWCXJK29Q8CNG8AS3ZZQ","hq-logout","Sign out of HQ Cognito and clear local tokens.","https:\u002F\u002Fgithub.com\u002Findigoai-us\u002Fhq-core\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fhq-logout\u002FSKILL.md",[],[]]