---
name: dead-advisor
description: Fallback when the built-in `advisor` tool fails with an API/network/server error. Triggers on /dead-advisor, "advisor is dead", "advisor API error", "advisor keeps failing", "fallback advisor". Spins up once per session a reusable advisor subagent reconstructing the conversation from the transcript; continue via SendMessage.
---

# dead-advisor

audience: AI coding agents first.

Drop-in replacement for the built-in `advisor` tool when its API is down. The `advisor` auto-forwards your entire live context; this skill gives a `[[dead-advisor]]` subagent (fable, high effort) a RECONSTRUCTION of that conversation by having it READ your transcript, then returns its critique. The reconstruction is lossy (no system prompt / injected memory, trimmed tool output, and your current unflushed turn is absent) — hence the QUESTION rule below.

## When to use

Use it the moment an `advisor()` call returns an API/network/server error AND you would still call `advisor` per its own rules (before substantive work, when stuck, before declaring done). Same trigger discipline as `advisor` — this just survives the outage.

## Procedure (main thread — keep it tiny)

1. **Build the MARKER.** Take the VERBATIM text of the most recent real *user* turn currently in your context (the user's words, not a tool result, not your own text). Pick a distinctive **ASCII** substring (no quotes/newlines/unicode — they are JSON-escaped on disk and break the literal match). This disambiguates your transcript from concurrent sessions sharing `~/.claude/projects/<slug>/`. If the last user turn is trivial/generic, use a longer or earlier distinctive user-turn substring.

   **Also build the APPROACH.** Your CURRENT turn is not yet on disk, so the subagent cannot see the decision you're about to make — which is exactly what advisor exists to challenge. State, verbatim and concretely, the approach/interpretation/next step you are about to commit to. This goes in QUESTION below. Skipping it makes the subagent review the state BEFORE your decision — useless for a pre-commit check.

2. **Resolve session + reuse state (single bash call — fail-closed, do NOT hand-roll it):**
   ```
   ~/.claude/skills/dead-advisor/resolve.sh lookup "<MARKER>"
   ```
   Prints `TRANSCRIPT=<path>`, `SESSION=<uuid>`, `AGENT=<id-or-empty>`, `LASTREAD=<n>`, `NOW=<n>`,
   each value shell-quoted for `eval` — an unset `AGENT` prints as `AGENT=''`.
   - `AGENT` = on-disk reuse record; survives compaction → source of truth for "did I already spawn one?", NOT your memory.
   - `LASTREAD` = transcript line count the subagent last read; `NOW` = current line count. The subagent has NO live memory of the main conversation, so the new range `LASTREAD+1 .. NOW` is exactly the turns it must catch up on this call.
   - Exit 3 (MARKER matched nothing) → redo step 1 with a more unique/earlier substring.
   - Any other nonzero → report the stderr; do not proceed on a guess.

3. **First call vs follow-up — branch on the `AGENT` value:**
   - **`AGENT=` empty → FIRST CALL.** Spawn via the `Agent` tool, `subagent_type: dead-advisor`, **`run_in_background: false`** (blocking — see FOREGROUND rule). Prompt verbatim:
     ```
     MODE: FIRST CALL.
     TRANSCRIPT: <the TRANSCRIPT path from step 2 — read THIS file; do not re-resolve>
     READ RANGE: lines <LASTREAD+1>..<NOW> (first call: 1..NOW = the whole file)
     MARKER: <the distinctive ASCII user-turn substring from step 1>
     QUESTION: <what you want advice on> + APPROACH I'M ABOUT TO COMMIT TO: <the verbatim approach from step 1 — the subagent cannot see your unflushed current turn>
     Reconstruct the conversation from TRANSCRIPT (the READ RANGE), then advise on QUESTION treating APPROACH as the decision under review.
     ```
     The spawned agentId is recorded automatically by the PostToolUse hook (`dead-advisor-record.mjs`) — you do NOT save it. **Just advance the read cursor** (use the `NOW` from step 2, so anything appended during this turn is re-read next call):
     ```
     ~/.claude/skills/dead-advisor/resolve.sh mark "<SESSION>" "<NOW>"
     ```
   - **`AGENT=<id>` present → FOLLOW-UP.** Do NOT spawn. `SendMessage` to that exact `agentId`:
     ```
     MODE: FOLLOW-UP.
     TRANSCRIPT: <same path>
     READ RANGE: lines <LASTREAD+1>..<NOW> — the turns that elapsed since your last advice. You do NOT hold the main conversation in memory; read this delta before advising. (If LASTREAD+1 > NOW, nothing new — say so.)
     MARKER: <a distinctive ASCII substring of the newest user turn>
     QUESTION: <current question> + APPROACH I'M ABOUT TO COMMIT TO: <verbatim>
     Read the READ RANGE delta from TRANSCRIPT, fold it into your prior context, then advise.
     ```
     **Then advance the cursor** (same as first call):
     ```
     ~/.claude/skills/dead-advisor/resolve.sh mark "<SESSION>" "<NOW>"
     ```

4. **Relay the advice.** The subagent's final message is its critique. Give it the same weight you'd give `advisor` output: if a step fails empirically or you have primary-source evidence against a specific claim, adapt; otherwise follow it. Surface its verdict to the user in your normal final response.

## Rules

- **FOREGROUND / BLOCKING — NEVER let it run in the background.** dead-advisor is a pre-commit GATE, exactly like `advisor`: you MUST hold its critique IN HAND before doing the substantive work it reviews. FIRST CALL via `Agent` → `run_in_background: false`. FOLLOW-UP via `SendMessage` auto-resumes a completed agent in the BACKGROUND (no foreground flag exists) → after sending you MUST WAIT for its completion notification and READ the critique BEFORE proceeding. NEVER treat the send/spawn as advice-received and continue — proceeding before the critique lands defeats the gate and violates the all-agents-foreground rule ([[feedback_no_background_agents]]).
- NEVER paste transcript content into the subagent prompt — it reads the TRANSCRIPT path itself. You pass only the path + MARKER + QUESTION.
- ONE `dead-advisor` subagent per session — enforced deterministically, not by your memory: a PostToolUse hook auto-records the agentId on spawn, and a PreToolUse hook (`dead-advisor-dedupe.mjs`) BLOCKS a second spawn and points you to SendMessage. Still `lookup` first and branch on `AGENT` so you pick SendMessage cleanly; if you ever try to spawn a duplicate, the gate stops you and names the existing agentId.
- Reuse keeps the subagent's warm context, but correctness never depends on it: every call re-passes TRANSCRIPT+MARKER so the subagent re-reads the live transcript.
- Exit 3 from `lookup` → re-mark with a more unique substring; never advise on an unverified transcript.
- This is a fallback. When `advisor` works again, go back to it.

## Why (secondary)

`advisor` is dead frequently; losing the stronger-reviewer check mid-task is the real cost. The transcript JSONL on disk is the same ground truth `[[fix-rot]]` uses — full and un-summarized — so a subagent reading it can reconstruct a close approximation of what `advisor` reviews (lossy: see fidelity ceiling above). fable, high effort (pinned in the `dead-advisor` agent frontmatter) matches the "stronger reviewer" bar, and gives a review genuinely independent of the opus main thread.

First defense is still a plain retry: advisor outages are often transient, and a retry restores FULL fidelity. Use this skill when retries don't clear it.

Compaction resilience: the SessionStart hook `~/.claude/hooks/dead-advisor-remind.mjs` re-injects "advisor was dead this session, prefer /dead-advisor" after a `compact`/`resume` (keyed off the sidecar `.id` file), so a context reset doesn't make you silently revert to the broken tool. Distinct from the sidecar's spawn-vs-continue role.
