npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

cc-sanitizer

v0.1.5

Published

Clean thinking blocks from Claude Code sessions to fix cross-model compatibility

Readme

CC-Sanitizer

A CLI tool to clean thinking blocks from Claude Code sessions, fixing cross-model compatibility issues.

Version Platform Built with TypeScript License


About

When you switch between third-party models (GLM, DeepSeek, etc.) and official Anthropic models in Claude Code, the session can break with:

400 invalid_request_error: messages.X.content.0: Invalid signature in thinking block

This 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.

Quick Start

No install needed. Scan all your Claude Code sessions for suspect thinking blocks:

npx cc-sanitizer scan

Found a broken session? Preview, then strip the suspect blocks:

npx cc-sanitizer strip <session>.jsonl --dry-run       # preview changes
npx cc-sanitizer strip <session>.jsonl --suspect-only  # remove blocks with no valid signature

Commands

Targetsscan, strip, and restore accept a file path, or a bare session id (<uuid> or <uuid>.jsonl) or a project name. Bare ids and names are resolved against ~/.claude/projects/, so you can copy a name straight from the output of cc-sanitizer scan and pass it back — no full path needed. Run any command with no argument to list projects (or, for scan, scan everything).

scan

Scan session files for thinking blocks and report valid vs suspect signatures.

# Scan a single session
cc-sanitizer scan session.jsonl

# Scan all sessions in a project
cc-sanitizer scan ~/.claude/projects/my-project/ --project

# Scan all projects
cc-sanitizer scan

strip

Remove thinking blocks from session files.

# Preview changes (dry-run)
cc-sanitizer strip session.jsonl --dry-run

# Strip with backup (default)
cc-sanitizer strip session.jsonl

# Only remove blocks without valid Anthropic signatures
cc-sanitizer strip session.jsonl --suspect-only

# Strip without backup
cc-sanitizer strip session.jsonl --no-backup

# Strip all sessions in a project
cc-sanitizer strip ~/.claude/projects/my-project/ --project

Options:

| Flag | Description | |------|-------------| | -n, --dry-run | Preview changes without modifying files | | -b, --backup | Create .bak backup before modifying (default: on) | | -s, --suspect-only | Only remove blocks without a valid Anthropic signature | | -p, --project | Treat path as a project directory |

restore

Restore session files from .bak backups created by strip.

# Restore a single session
cc-sanitizer restore session.jsonl

# Restore all backups in a project
cc-sanitizer restore ~/.claude/projects/my-project/ --project

How It Works

Claude Code stores sessions as JSONL files in ~/.claude/projects/<encoded-cwd>/<uuid>.jsonl. Each line is a JSON event; assistant messages contain a content array with blocks like text, tool_use, thinking, and redacted_thinking.

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.

Signature Validation

Anthropic 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:

  • Valid: base64 string, 600-1200 chars
  • Suspect: missing signature, short string, or non-base64 characters

Limitations

  • Cannot repair signatures — Anthropic signatures are generated server-side with private keys. This tool can only remove blocks, not create valid ones.
  • Heuristic detection--suspect-only uses signature length/format as a heuristic. If a third-party model produces a 600+ char base64 string, it may be missed.
  • Empty events — If an assistant message contains only thinking blocks, stripping them removes the entire event from the session.

Related Issues

License

MIT