You’re deep into a coding session with Claude Code. Everything’s going great. You’ve built context, explained your architecture, and Claude finally understands your spaghetti codebase. Life is good.
Then you make a fatal mistake: you ask Claude to read a PDF. Or maybe you paste a screenshot. Or perhaps you uploaded an image that was slightly too large.
And suddenly:
API Error: 400 {"type":"error","error":{"type":"invalid_request_error",
"message":"messages.43.content.1: thinking or redacted_thinking blocks
in the latest assistant message cannot be modified."}}
Congratulations. Your conversation is now cursed.
Or maybe you’re seeing one of these:
PDF too large. Try reading the file a different way (e.g., extract text with a CLI tool).
API Error: 400 - image dimensions exceed max allowed size
All three errors have the same root cause. And the same fix.
The Problem
Or: Why Your Conversation File Is Now 47MB
Here’s what happens when you feed Claude Code a large file: it gets base64-encoded and stored in your conversation history. That’s fine for small files. But for that 8MB architecture diagram? That base64 blob is now sent with every single API request.
Forever.
The errors you’ll see:
| Error | Translation |
|---|---|
thinking or redacted_thinking blocks cannot be modified |
Your conversation file is corrupted beyond recognition |
PDF too large. Try reading the file a different way |
Claude choked on your 200-page PDF |
image dimensions exceed max allowed size |
That 4K screenshot was a poor life choice |
The “official” solution? Clear your conversation and start over. Lose all that precious context. Explain your codebase from scratch. Again.
Fun fact: Your conversation lives in ~/.claude/projects/ as .jsonl files. Some of these can grow to hundreds of megabytes. Yes, really.
The Solution
Or: Surgery Without Amputation
Enter claude-code-toolkit by Asif Kibria. It’s a scalpel where Anthropic offers you a chainsaw.
Instead of nuking your entire conversation, it:
- Scans your conversation files for oversized content
- Identifies the exact problematic blobs
- Replaces them with harmless placeholders
- Creates backups before touching anything
No context lost. No starting over. Just surgical removal of the tumor.
Quick Fix
Don’t want to install anything? Just run:
1. See what's broken
npx @asifkibria/claude-code-toolkit scan
1. Fix it
npx @asifkibria/claude-code-toolkit fix
That’s it. Two commands. Your conversation is healed.
Full Installation
For repeat offenders (and let’s be honest, you’ll be back):
1. Global install
npm install -g @asifkibria/claude-code-toolkit
1. Now you can use the short alias
cct scan
cct fix
The Command Arsenal
| Command | What It Does |
|---|---|
cct health |
Quick diagnosis with recommendations |
cct scan |
Dry-run. Shows problems without fixing |
cct fix |
Actually removes oversized content |
cct stats |
Size breakdown of your conversations |
cct context |
Estimate token usage |
| `cct restore | |
| ` | Undo a fix using backups |
cct backups |
List all backup files |
cct cleanup |
Delete old backups |
Pro tip: Always run scan before fix. Trust, but verify.
What Gets Removed?
The toolkit has sensible defaults:
| Content Type | Size Limit | What Happens |
|---|---|---|
| Images (base64) | > 100KB | Replaced with [Image removed - exceeded size limit] |
| PDFs (base64) | > 100KB | Replaced with [PDF removed - exceeded size limit] |
| Documents | > 100KB | Replaced with placeholder |
| Text blobs | > 500KB | Truncated |
Your actual conversation? Preserved. The 15MB screenshot of your terminal? Gone. Good riddance.
Prevention: macOS Screenshot Settings
Or: Stop Creating 8MB PNGs
If you’re on a Mac, your screenshots are probably massive PNGs. Retina displays + PNG compression = files that make Claude choke.
Switch to JPEG (smaller files):
1. Change default format to JPEG
defaults write com.apple.screencapture type jpg
1. Apply the change
killall SystemUIServer
Other format options:
| Format | Command | Best For |
|---|---|---|
| JPEG | defaults write com.apple.screencapture type jpg |
General screenshots, smallest size |
| PNG | defaults write com.apple.screencapture type png |
When you need transparency |
| HEIC | defaults write com.apple.screencapture type heic |
Apple ecosystem, good compression |
| TIFF | defaults write com.apple.screencapture type tiff |
Print quality (avoid for Claude) |
Disable the shadow (even smaller files):
1. Remove the drop shadow from window screenshots
defaults write com.apple.screencapture disable-shadow -bool true
killall SystemUIServer
Pro tip: For quick one-off conversions, use sips:
1. Convert PNG to JPEG at 80% quality
sips -s format jpeg -s formatOptions 80 screenshot.png --out screenshot.jpg
Quick Reference Card
┌─────────────────────────────────────────────────────────────────┐
│ CLAUDE CODE TOOLKIT CHEATSHEET │
├─────────────────────────────────────────────────────────────────┤
│ │
│ EMERGENCY FIX (no install): │
│ $ npx @asifkibria/claude-code-toolkit scan │
│ $ npx @asifkibria/claude-code-toolkit fix │
│ │
│ INSTALL GLOBALLY: │
│ $ npm install -g @asifkibria/claude-code-toolkit │
│ │
│ COMMON WORKFLOW: │
│ $ cct health → Check status │
│ $ cct scan → Find problems │
│ $ cct fix → Remove oversized content │
│ $ cct backups → Verify backup exists │
│ │
│ CONVERSATION FILES: │
│ 📁 ~/.claude/projects/**/*.jsonl │
│ │
│ SIZE LIMITS: │
│ • Images/PDFs/Docs: 100KB base64 │
│ • Text content: 500KB │
│ │
└─────────────────────────────────────────────────────────────────┘
Conclusion
Key takeaways:
- 🔴 Large files get embedded in your conversation history. They’re sent with every API call until the end of time.
- 🔴 The cryptic API errors mean your conversation is corrupted. Not your fault. Mostly.
- ✅ Don’t nuke your conversation. Use
cct scanandcct fixinstead. - ✅ Backups are automatic. You can always restore if something goes wrong.
- 🟡 Prevention beats cure. Think twice before uploading that 4K screenshot.
Acknowledgments
A big thank you to Asif Kibria for building this tool and saving countless Claude Code users from conversation purgatory. Open source at its finest.
Stay debugging, stay caffeinated. ☕
Related Resources:
Leave a Reply