By wan-huiyan
Diagnose and surgically repair a Claude Code session whose transcript JSONL bricks every request with an HTTP 400 — orphan server_tool_use/tool_result pairs and whitespace-only text blocks. Recovers the session instead of abandoning it.
Repair a Claude Code session whose transcript JSONL has an orphan `server_tool_use` / `*_tool_result` content block, causing every API call (including `/compact` and `claude --resume`) to fail with HTTP 400 "unexpected tool_use_id found in advisor_tool_result blocks: srvtoolu_... Each ... block must have a corresponding server_tool_use block before it". Use when: (1) a Claude Code session dies mid-advisor call with "socket connection was closed unexpectedly", (2) resume / compact returns the 400 above naming `srvtoolu_...`, (3) `/remote-control` (or any system event) activated mid-stream while the assistant was emitting an advisor response. Covers diagnosis via grouping JSONL lines by shared `message.id`, surgical deletion of the orphan pair (both halves), and the line-number-drift gotcha that occurs when the file grows between inspection and edit.
Repair a Claude Code session whose transcript JSONL has assistant messages containing a whitespace-only text block (typically `{"type":"text","text":" "}`), causing every API call (including new prompts, `/compact`, and `claude --resume`) to fail with HTTP 400 "messages: text content blocks must contain non-whitespace text". Use when: (1) a session refuses to accept new input with that exact 400, (2) `/compact` fails with the same 400 (since compact replays the full history first — it does NOT bypass the validator), (3) `claude --resume <id>` immediately exits with the same error. Covers diagnosis via JSON-walking the message.content array (NOT plain grep — the empty block is often nested), the distinction between message.content (sent to API → must fix) and toolUseResult (local metadata → harmless, leave alone), the underlying cause (extended-thinking turn serialization emits a synthetic single-space placeholder before the thinking block), and an idempotent fixer script that replaces " " with "." while preserving message shape.
Own this plugin?
Verify ownership to unlock analytics, metadata editing, and a verified badge. GitHub access is read-only (username + org membership).
Sign in to claimOwn this plugin?
Verify ownership to unlock analytics, metadata editing, and a verified badge. GitHub access is read-only (username + org membership).
Sign in to claimBased on adoption, maintenance, documentation, and repository signals. Not a security audit or endorsement.
Recover a Claude Code session that returns HTTP 400 on every request — typing,
/compact, andclaude --resumeall fail — because its transcript JSONL contains a malformed content block.
When a Claude Code session's transcript gets into a state the Anthropic Messages API rejects, the session is held hostage: every subsequent API call — a new prompt, /compact, even claude --resume <id> — returns the same 400 and exits. Most people give up and abandon the conversation. These skills diagnose the exact corruption and surgically repair the JSONL so the session opens normally again, losing nothing but the one malformed block.
Two distinct corruptions, both producing an unrecoverable-looking 400, each with its own diagnosis and fix:
| Skill | The 400 you see | Root cause | Fix |
|---|---|---|---|
| orphan-advisor-tool-result | unexpected tool_use_id found in advisor_tool_result blocks: srvtoolu_… Each … must have a corresponding server_tool_use block before it | A server-tool call (advisor(), web_search, code_execution) was split across two assistant messages — usually a system command (/usage, /remote-control, auto-rename) firing while the call was in flight. | Group JSONL lines by shared message.id, delete both halves of the orphan pair. |
| whitespace-text-block | messages: text content blocks must contain non-whitespace text | An extended-thinking turn serialized a synthetic single-space placeholder ({"type":"text","text":" "}) before a thinking block. | JSON-walk message.content (the empty block is often nested — plain grep misses it), replace " " with ".". Ships an idempotent fixer script. |
Both are upstream Claude Code serialization bugs (see the 150+ report meta-tracker). Until they're fixed, this is your recovery path — and even after a fix, sessions corrupted before you upgrade still need repair.
You: Resume keeps failing — "API Error: 400 ... unexpected tool_use_id
found in advisor_tool_result blocks: srvtoolu_01Ts..."
Claude: [invokes claude-code-session-jsonl-orphan-advisor-tool-result]
Found the orphan pair — server_tool_use at L89 and its
advisor_tool_result at L94 share one message.id but the client
reconstructed them as two messages. Backing up, deleting both
halves, verifying... orphan blocks now 0. Resume from <cwd>:
claude --resume <id>
Claude Code (plugin — recommended):
/plugin marketplace add wan-huiyan/claude-code-session-repair
/plugin install claude-code-session-repair@wan-huiyan-claude-code-session-repair
Git clone (always works):
git clone https://github.com/wan-huiyan/claude-code-session-repair.git \
~/.claude/skills/claude-code-session-repair-src
# then symlink or copy the two skill dirs under plugins/.../skills/ into ~/.claude/skills/
Note: a corrupted session can't load these skills itself (it 400s before it can do anything). Install them, then run a fresh Claude Code session and point it at the broken one — or follow the SKILL.md steps by hand.
Both skills follow the same shape:
~/.claude/projects/<encoded-cwd>/<sessionId>.jsonl. The encoding collapses both / and _ to - (lossy), so worktree paths need git worktree list to resolve — the skills cover this gotcha.content arrays (whitespace). Plain grep is explicitly not enough for the whitespace case.npx claudepluginhub wan-huiyan/claude-code-session-repair --plugin claude-code-session-repairMulti-agent adversarial review panel — 4-6 AI reviewers debate your code/plans, then a judge delivers a structured verdict with epistemic labels. Bundles plan-review-integrator for applying review findings back into implementation plans.
Coordination toolkit for parallel Claude Code sessions sharing one repo — issue-pickup claim protocol (assignee + wip label), worktree & session-isolation pitfalls, parallel-PR conflict recovery, subagent-integrity edge cases, and squash/merge mechanics for parallel-PR workflows.
Scan Claude Code skills for client-specific data and anonymize them for safe public sharing.
Existence/strategy audit for a portfolio of published Claude Code skills, plugin bundles, or adjacent repos — should each exist at all? Per-artifact KEEP / CONSOLIDATE / KILL / PIVOT verdicts from an existence-pinned adversarial panel with web-verified differentiation against competitor tools and redundancy / maintenance / coherence analysis. The strategy axis the sibling skills skip: quality (skill-portfolio-audit), placement (skill-portfolio-repo-placement-scan), usage (ecosystem-audit).
Keep locally installed Claude Code skills in sync with their GitHub repos
Memory compression system for Claude Code - persist context across sessions
Editorial "Web Designer" bundle for Claude Code from Antigravity Awesome Skills.
Ultra-compressed communication mode. Cuts ~75% of tokens while keeping full technical accuracy by speaking like a caveman.
Frontend design skill for UI/UX implementation
Comprehensive UI/UX design plugin for mobile (iOS, Android, React Native) and web applications with design systems, accessibility, and modern patterns
Marketing skills for AI agents — conversion optimization, copywriting, SEO, paid ads, ad creative, and growth