{"_id":"@akz-tools/claude-fix","_rev":"3-dc8e43b73ac96af5a2d79005f2862ea7","name":"@akz-tools/claude-fix","dist-tags":{"latest":"1.0.2"},"versions":{"1.0.0":{"name":"@akz-tools/claude-fix","version":"1.0.0","keywords":["claude-code","fix","tool-use-concurrency","400-error","conversation-repair","orphaned-tools"],"author":{"name":"akzarma"},"license":"MIT","_id":"@akz-tools/claude-fix@1.0.0","maintainers":[{"name":"akz-tools","email":"akzarma@gmail.com"}],"homepage":"https://github.com/akzarma/claude-fixes#readme","bugs":{"url":"https://github.com/akzarma/claude-fixes/issues"},"bin":{"claude-fix":"cli.mjs"},"dist":{"shasum":"2946c1a1edf2fd6a8c7d363cad75e73c67196006","tarball":"https://registry.npmjs.org/@akz-tools/claude-fix/-/claude-fix-1.0.0.tgz","fileCount":5,"integrity":"sha512-L1RYdj8/u0KFnhKEeJcyWmaTLWrpQp1CU8k/R+XFUkAGe/HA6guqxWagp/wsj4wRxfM6rmOoYHvZq1l8qpAYuw==","signatures":[{"sig":"MEUCIF79QCS4vfd1fEoDuBJtSaO2G1pdbVJKXQHOkNhuyXmWAiEAvMEh1xVrIeqiNcSHpKNUosePZcomMKZVETiHse5fJcA=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":29690},"gitHead":"73d870b3ab492008bd0d9910168faccf2ee25256","_npmUser":{"name":"akz-tools","email":"akzarma@gmail.com"},"repository":{"url":"git+https://github.com/akzarma/claude-fixes.git","type":"git"},"_npmVersion":"10.9.2","description":"Community fix scripts for Claude Code bugs — npx claude-fix <problem>","directories":{},"_nodeVersion":"22.14.0","_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/claude-fix_1.0.0_1774594680771_0.9907550844525752","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"@akz-tools/claude-fix","version":"1.0.1","keywords":["claude-code","fix","tool-use-concurrency","400-error","conversation-repair","orphaned-tools"],"author":{"name":"akzarma"},"license":"MIT","_id":"@akz-tools/claude-fix@1.0.1","maintainers":[{"name":"akz-tools","email":"akzarma@gmail.com"}],"homepage":"https://github.com/akzarma/claude-fixes#readme","bugs":{"url":"https://github.com/akzarma/claude-fixes/issues"},"bin":{"claude-fix":"cli.mjs"},"dist":{"shasum":"84d3fcc08fee2d0e26fada4170e7405a08936aa0","tarball":"https://registry.npmjs.org/@akz-tools/claude-fix/-/claude-fix-1.0.1.tgz","fileCount":5,"integrity":"sha512-nn606Qv9kFAEalsZRAQfqUh7xxGROiLZNaChPScU3eJYBWumRGbUVUT+Qo2o/P2HOyL7fEMyGQDoWLY+LhO2NA==","signatures":[{"sig":"MEUCIFAjaQEIPE/ofkvsRpM08Adq7WYdsDY83+tTkjXs0f/IAiEA2GlPix+KDREnNptu6MNtOs4k6juaMJJ5qptDCil//VQ=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":29366},"gitHead":"6180356b0bbdc6050e05efae3ef836a5931ef19e","_npmUser":{"name":"akz-tools","email":"akzarma@gmail.com"},"repository":{"url":"git+https://github.com/akzarma/claude-fixes.git","type":"git"},"_npmVersion":"10.9.2","description":"Community fix scripts for Claude Code bugs — npx claude-fix <problem>","directories":{},"_nodeVersion":"22.14.0","_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/claude-fix_1.0.1_1774595420201_0.04628109571010919","host":"s3://npm-registry-packages-npm-production"}},"1.0.2":{"name":"@akz-tools/claude-fix","version":"1.0.2","description":"Fix: API Error 400 due to tool use concurrency issues — repairs broken Claude Code conversations","bin":{"claude-fix":"cli.mjs"},"keywords":["claude-code","api-error-400","tool-use-concurrency","orphaned-toolcalls","rewind","conversation-repair","claude-code-fix","tool_use","tool_result"],"author":{"name":"akzarma"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/akzarma/claude-fixes.git"},"_id":"@akz-tools/claude-fix@1.0.2","gitHead":"ab5110746c971d7847a7ccdac9f0a6ec7814fa55","bugs":{"url":"https://github.com/akzarma/claude-fixes/issues"},"homepage":"https://github.com/akzarma/claude-fixes#readme","_nodeVersion":"22.14.0","_npmVersion":"10.9.2","dist":{"integrity":"sha512-bxIlJ7Z9BjwZymDRbapiEHZYrNHpP+mUzYpMYlB0NUrwzfgRTo7DoP0VpNFfxPIR5hvtwyxihsU+vFzb8fHOHQ==","shasum":"b97f21b98f82ea30ef8ef8e596dd463ca21bd7e0","tarball":"https://registry.npmjs.org/@akz-tools/claude-fix/-/claude-fix-1.0.2.tgz","fileCount":5,"unpackedSize":29654,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQCgW9PuvNZsgvGB+Xml6eq3ykB+lnlPVu+ede+HtHZSZQIgOJ1bJUjgaITQjktjQmykvIRRk1AAGEyHxhfcTa5um/w="}]},"_npmUser":{"name":"akz-tools","email":"akzarma@gmail.com"},"directories":{},"maintainers":[{"name":"akz-tools","email":"akzarma@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/claude-fix_1.0.2_1774596834952_0.8902316231600804"},"_hasShrinkwrap":false}},"time":{"created":"2026-03-27T06:58:00.632Z","modified":"2026-03-27T07:33:55.216Z","1.0.0":"2026-03-27T06:58:00.924Z","1.0.1":"2026-03-27T07:10:20.334Z","1.0.2":"2026-03-27T07:33:55.126Z"},"bugs":{"url":"https://github.com/akzarma/claude-fixes/issues"},"author":{"name":"akzarma"},"license":"MIT","homepage":"https://github.com/akzarma/claude-fixes#readme","keywords":["claude-code","api-error-400","tool-use-concurrency","orphaned-toolcalls","rewind","conversation-repair","claude-code-fix","tool_use","tool_result"],"repository":{"type":"git","url":"git+https://github.com/akzarma/claude-fixes.git"},"description":"Fix: API Error 400 due to tool use concurrency issues — repairs broken Claude Code conversations","maintainers":[{"name":"akz-tools","email":"akzarma@gmail.com"}],"readme":"# claude-fix\n\nCommunity fix scripts for Claude Code bugs.\n\n```bash\nnpx @akz-tools/claude-fix <fix-name> <session-id>\n```\n\n## Available Fixes\n\n### `orphaned-toolcalls` — Fix \"400 tool use concurrency\" error\n\n> `API Error: 400 due to tool use concurrency issues. Run /rewind to recover the conversation.`\n\nIf you're seeing this error in Claude Code and `/rewind` doesn't help — this tool fixes it.\n\n**The most reported unfixed bug in Claude Code** ([15+ GitHub issues](https://github.com/anthropics/claude-code/issues/8763), countless Reddit posts). Makes conversations permanently unresumable. `/rewind` doesn't help. `/compact` can make it worse.\n\n#### Usage\n\n```bash\n# Step 1: Find your broken session ID\nnpx @akz-tools/claude-fix orphaned-toolcalls --list\n\n# Step 2: Fix it\nnpx @akz-tools/claude-fix orphaned-toolcalls <session-id>\n\n# Step 3: Resume\nclaude --resume <new-session-id>\n```\n\nYou can also dry-run to see what's wrong without fixing:\n\n```bash\nnpx @akz-tools/claude-fix orphaned-toolcalls --dry-run <session-id>\n```\n\n#### How to find your session ID\n\n- In Claude Code, run: `/conversations`\n- Or: `ls -lt ~/.claude/projects/*/*.jsonl | head -20`\n- Or: `npx @akz-tools/claude-fix orphaned-toolcalls --list`\n\n#### What it does\n\nCreates a **fixed clone** of your broken conversation. The original is never touched.\n\n#### Root cause\n\nClaude Code stores conversations as a **tree** (each message links to its parent via `parentUuid`). When it runs tools concurrently (e.g., two `Read` calls in parallel), it creates **branches**:\n\n```\nassistant: \"Let me read both files\"\n├── tool_use: Read(file_A)     ← branch 1\n│   └── tool_result: <contents of A>\n└── tool_use: Read(file_B)     ← branch 2\n    └── tool_result: <contents of B>\n        └── ... conversation continues on this branch\n```\n\nWhen Claude Code flattens this tree for the Anthropic API, it follows **one branch** — losing the `tool_result` on the sibling branch. The API sees a `tool_use` without a matching `tool_result` and returns **400**.\n\nUser interruptions (pressing Escape) can also create consecutive same-role messages, which violate the API's alternating message requirement.\n\n**The fix:**\n1. Walks the `parentUuid` chain to find the linearized path\n2. Detects missing `tool_result` blocks and consecutive same-role messages\n3. **Grafts** missing results from sibling branches (they exist in the JSONL, just on the wrong branch)\n4. Inserts synthetic error results for truly lost tool calls\n5. Merges consecutive user messages from interruptions\n6. Rebuilds with a clean linear `parentUuid` chain\n\n#### Requirements\n\n- Node.js 18+\n- macOS or Linux\n\n---\n\n## Contributing\n\nFound another Claude Code bug that needs a fix script? PRs welcome. Each fix goes in its own directory:\n\n```\nclaude-fixes/\n├── cli.mjs                    # Router — npx @akz-tools/claude-fix <name>\n├── fix-conversation/          # Fix: orphaned-toolcalls\n│   └── index.mjs\n├── fix-next-bug/              # Fix: next bug someone finds\n│   └── index.mjs\n└── ...\n```\n\n## License\n\nMIT\n","readmeFilename":"README.md"}