A tool to fix broken Claude Code sessions caused by the image dimension limit bug (anthropics/claude-code#13480).
When you put your computer to sleep during a long-running Claude Code session with many screenshots, the session can break. Upon returning, every request fails with:
An image in the conversation exceeds the dimension limit for many-image requests (2000px).
The irony: the last task had nothing to do with images. The failure is retroactive—screenshots that worked fine during the session now trigger the API limit on replay.
This tool strips base64 images from your session JSONL files, freeing up context space and restoring functionality.
- Safe: Creates numbered backups before any modification (
.bak,.bak.1,.bak.2, etc.) - Efficient: Processes files line-by-line, handling 16MB+ sessions without memory issues
- Complete: Recursively finds images hidden in nested JSON structures
- Atomic: Uses temp file + rename to prevent corruption
- Zero dependencies: Pure Python stdlib—no pip, no venv, no setup
skill install https://github.com/ianbmacdonald/claude-session-rescueThen just ask Claude: "Fix my broken session with ID xyz123"
# Clone the repo
git clone https://github.com/ianbmacdonald/claude-session-rescue
cd claude-session-rescue
# Run directly with uv
uv run --script scripts/session_rescue.py --help# Dry run first—see what would be fixed
uv run --script scripts/session_rescue.py --session-id 03d04fb2 --dry-run
# Then fix it
uv run --script scripts/session_rescue.py --session-id 03d04fb2uv run --script scripts/session_rescue.py --latestuv run --script scripts/session_rescue.py --all| Flag | Description |
|---|---|
--session-id ID |
Find session by UUID prefix match |
--session-name NAME |
Find session by custom title |
--latest |
Process most recently modified session |
--all |
Process all sessions |
--project PATH |
Scope search to project directory |
--dry-run |
Report images found without modifying |
--min-images N |
Only process sessions with >= N images (default: 1) |
--verbose |
Detailed output |
- Session Discovery: Finds JSONL files in
~/.claude/projects/<project>/ - Backup First: Creates
.bak(or.bak.1,.bak.2, etc. for subsequent runs) - Line-by-Line Processing: Parses each line as JSON without loading the full file
- Recursive Image Detection: Finds base64 images in nested structures like
tool_result.content[] - Image Stripping: Replaces images with placeholders like
[image removed: image/jpeg, 197000 chars] - Atomic Write: Writes to temp file, then renames to preserve permissions and prevent corruption
Claude Code stores sessions as JSONL (JSON Lines) files:
- Each line is a独立的 JSON message
- Messages have types:
user,assistant,system,tool_result, etc. - Images are base64-encoded in
contentarrays - Images nest deeply inside
tool_resultobjects
The tool looks for objects where:
type == "image"ANDsource.type == "base64"
This avoids false positives from text that merely mentions "image".
- First run:
session.jsonl.bak - Second run:
session.jsonl.bak.1 - Third run:
session.jsonl.bak.2 - And so on...
Always review your backups before deleting them.
Found a bug? Have a suggestion? Open an issue or submit a PR.
MIT
Built using Lemonade for local model inference.
See the v10.2.0 release where we're named as a contributor.