[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-82746":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":15,"subscribersCount":15,"size":15,"stars1d":15,"stars7d":16,"stars30d":17,"stars90d":15,"forks30d":15,"starsTrendScore":13,"compositeScore":18,"rankGlobal":10,"rankLanguage":10,"license":19,"archived":20,"fork":20,"defaultBranch":21,"hasWiki":22,"hasPages":20,"topics":23,"createdAt":10,"pushedAt":10,"updatedAt":24,"readmeContent":25,"aiSummary":26,"trendingCount":15,"starSnapshotCount":15,"syncStatus":27,"lastSyncTime":28,"discoverSource":29},82746,"cc-sanitizer","YonghaoZhao722\u002Fcc-sanitizer","YonghaoZhao722","Fix Claude Code's \"Invalid signature in thinking block\" error when switching models","",null,"TypeScript",68,1,54,0,6,8,44.7,"MIT License",false,"main",true,[],"2026-06-12 04:01:38","\u003Cdiv align=\"center\">\n\n\u003Cimg src=\"https:\u002F\u002Fraw.githubusercontent.com\u002FYonghaoZhao722\u002Fcc-sanitizer\u002Fmain\u002Fassets\u002Fhero.svg\" alt=\"cc-sanitizer — strip invalid thinking blocks to fix cross-model Claude Code sessions\" width=\"100%\">\n\n# CC-Sanitizer\n\n### A CLI tool to clean thinking blocks from [Claude Code](https:\u002F\u002Fdocs.anthropic.com\u002Fen\u002Fdocs\u002Fclaude-code) sessions, fixing cross-model compatibility issues.\n\n[![Version](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002Fversion-0.1.5-blue.svg)](https:\u002F\u002Fwww.npmjs.com\u002Fpackage\u002Fcc-sanitizer)\n[![Platform](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002Fplatform-Windows%20%7C%20macOS%20%7C%20Linux-lightgrey.svg)](https:\u002F\u002Fwww.npmjs.com\u002Fpackage\u002Fcc-sanitizer)\n[![Built with TypeScript](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002Fbuilt%20with-TypeScript-3178C6.svg)](https:\u002F\u002Fwww.typescriptlang.org\u002F)\n[![License](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002Flicense-MIT-green.svg)](LICENSE)\n\n\n\n\u003C\u002Fdiv>\n\n---\n\n## About\n\nWhen you switch between third-party models (GLM, DeepSeek, etc.) and official Anthropic models in Claude Code, the session can break with:\n\n```\n400 invalid_request_error: messages.X.content.0: Invalid signature in thinking block\n```\n\nThis happens because third-party models produce thinking blocks without valid Anthropic signatures. `cc-sanitizer` strips these blocks from your session files so you can continue using official models.\n\n## Quick Start\n\nNo install needed. Scan all your Claude Code sessions for suspect thinking blocks:\n\n```bash\nnpx cc-sanitizer scan\n```\n\nFound a broken session? Preview, then strip the suspect blocks:\n\n```bash\nnpx cc-sanitizer strip \u003Csession>.jsonl --dry-run       # preview changes\nnpx cc-sanitizer strip \u003Csession>.jsonl --suspect-only  # remove blocks with no valid signature\n```\n\n## Commands\n\n> **Targets** — `scan`, `strip`, and `restore` accept a file path, **or** a bare\n> session id (`\u003Cuuid>` or `\u003Cuuid>.jsonl`) or a project name. Bare ids and names are\n> resolved against `~\u002F.claude\u002Fprojects\u002F`, so you can copy a name straight from the\n> output of `cc-sanitizer scan` and pass it back — no full path needed. Run any\n> command with no argument to list projects (or, for `scan`, scan everything).\n\n### `scan`\n\nScan session files for thinking blocks and report valid vs suspect signatures.\n\n```bash\n# Scan a single session\ncc-sanitizer scan session.jsonl\n\n# Scan all sessions in a project\ncc-sanitizer scan ~\u002F.claude\u002Fprojects\u002Fmy-project\u002F --project\n\n# Scan all projects\ncc-sanitizer scan\n```\n\n### `strip`\n\nRemove thinking blocks from session files.\n\n```bash\n# Preview changes (dry-run)\ncc-sanitizer strip session.jsonl --dry-run\n\n# Strip with backup (default)\ncc-sanitizer strip session.jsonl\n\n# Only remove blocks without valid Anthropic signatures\ncc-sanitizer strip session.jsonl --suspect-only\n\n# Strip without backup\ncc-sanitizer strip session.jsonl --no-backup\n\n# Strip all sessions in a project\ncc-sanitizer strip ~\u002F.claude\u002Fprojects\u002Fmy-project\u002F --project\n```\n\n**Options:**\n\n| Flag | Description |\n|------|-------------|\n| `-n, --dry-run` | Preview changes without modifying files |\n| `-b, --backup` | Create `.bak` backup before modifying (default: on) |\n| `-s, --suspect-only` | Only remove blocks without a valid Anthropic signature |\n| `-p, --project` | Treat path as a project directory |\n\n### `restore`\n\nRestore session files from `.bak` backups created by `strip`.\n\n```bash\n# Restore a single session\ncc-sanitizer restore session.jsonl\n\n# Restore all backups in a project\ncc-sanitizer restore ~\u002F.claude\u002Fprojects\u002Fmy-project\u002F --project\n```\n\n## How It Works\n\nClaude Code stores sessions as JSONL files in `~\u002F.claude\u002Fprojects\u002F\u003Cencoded-cwd>\u002F\u003Cuuid>.jsonl`. Each line is a JSON event; assistant messages contain a `content` array with blocks like `text`, `tool_use`, `thinking`, and `redacted_thinking`.\n\n`cc-sanitizer` parses each assistant message and removes thinking blocks. The remaining content (text, tool results, tool calls) is preserved, keeping the conversation history intact.\n\n### Signature Validation\n\nAnthropic thinking blocks carry a base64-encoded signature (~700-1000 chars). Third-party models either omit this or produce non-standard formats. The `--suspect-only` mode uses this heuristic to distinguish them:\n\n- **Valid**: base64 string, 600-1200 chars\n- **Suspect**: missing signature, short string, or non-base64 characters\n\n## Limitations\n\n- **Cannot repair signatures** — Anthropic signatures are generated server-side with private keys. This tool can only remove blocks, not create valid ones.\n- **Heuristic detection** — `--suspect-only` uses signature length\u002Fformat as a heuristic. If a third-party model produces a 600+ char base64 string, it may be missed.\n- **Empty events** — If an assistant message contains only thinking blocks, stripping them removes the entire event from the session.\n\n## Related Issues\n\n- [anthropics\u002Fclaude-code#21726](https:\u002F\u002Fgithub.com\u002Fanthropics\u002Fclaude-code\u002Fissues\u002F21726) — Original bug report\n- [anthropics\u002Fclaude-code#10154](https:\u002F\u002Fgithub.com\u002Fanthropics\u002Fclaude-code\u002Fissues\u002F10154) — Gemini CLI issue\n\n## License\n\nMIT\n","CC-Sanitizer 是一个命令行工具，用于清理 Claude Code 会话中的无效思考块，解决跨模型兼容性问题。它通过移除第三方模型产生的无有效签名的思考块，使用户能够顺利切换并继续使用官方 Anthropic 模型。该工具基于 TypeScript 构建，支持 Windows、macOS 和 Linux 平台，并提供扫描、清理和恢复等核心功能。适用于需要在不同 AI 模型间切换 Claude Code 会话且遇到“Invalid signature in thinking block”错误的开发者或研究人员。",2,"2026-06-11 04:09:07","CREATED_QUERY"]