Auto-resize oversized images and repair corrupted sessions in Claude Code. Useful for operations teams handling large image inputs from MCP screenshot tools or drag-and-drop. Integrates with Claude Code to maintain session integrity and improve workflow efficiency.
git clone https://github.com/MussaCharles/claude-code-image-sanitizer.gitClaude Code Image Sanitizer prevents and fixes session corruption caused by oversized images from MCP screenshot tools like Playwright, Puppeteer, and Chrome DevTools, or from drag-and-drop uploads. The tool automatically resizes images before they corrupt your session, and includes a repair command to fix already-corrupted sessions without losing context. It hooks into Claude Code's image processing pipeline to enforce safe dimension and file size limits while maintaining image quality. Operations teams and developers handling large visual inputs benefit from avoiding the /clear workaround that loses all conversation history.
[{"step":"Install the skill in your Claude Code environment by running `claude install claude-code-image-sanitizer` in the terminal.","tip":"Ensure you have write permissions to the current directory and at least 100MB of free disk space for temporary files."},{"step":"Run the sanitizer on your target directory with: `claude-code-image-sanitizer --max-dimension 2048 --max-size 5MB --format JPEG`","tip":"Use `--dry-run` first to preview changes without modifying files. Add `--verbose` for detailed logs."},{"step":"For corrupted sessions, use: `claude-code-image-sanitizer --repair-session session_2024-05-15_14-30-22.json`","tip":"The tool will create a backup of the original session before attempting repairs. Check `/tmp/claude-repair-logs/` for recovery details."},{"step":"Review the generated report and verify all images are accessible in the resumed session.","tip":"If any images still appear corrupted, manually replace them with the sanitized versions from the cache directory."},{"step":"Integrate the skill into your MCP screenshot workflow by adding it as a post-processing step in your automation scripts.","tip":"For CI/CD pipelines, use `claude-code-image-sanitizer --batch` to process multiple sessions sequentially."}]
Prevent session corruption when using MCP screenshot tools with large page captures
Auto-resize drag-and-drop images that exceed Anthropic's 8000px dimension limit
Recover corrupted sessions without losing work context using /sanitizer-repair
Handle multi-image workflows where dimension limits are stricter (2000px for 20+ images)
No install command available. Check the GitHub repository for manual installation instructions.
git clone https://github.com/MussaCharles/claude-code-image-sanitizerCopy the install command above and run it in your terminal.
Launch Claude Code, Cursor, or your preferred AI coding agent.
Use the prompt template or examples below to test the skill.
Adapt the skill to your specific use case and workflow.
Use claude-code-image-sanitizer to automatically resize oversized images and repair corrupted sessions in Claude Code. Process all images in the current directory with the following constraints: [MAX_DIMENSION=2048px], [MAX_FILE_SIZE=5MB], [FORMAT=JPEG]. For corrupted sessions, attempt to recover the last valid state and log the repair actions taken. Output a summary report with before/after metrics.
## Image Sanitization & Session Repair Report ### Session Recovery - **Corrupted Session Detected**: `session_2024-05-15_14-30-22.json` - **Recovery Status**: Successfully restored from backup at `session_2024-05-15_14-28-15.json` - **Actions Taken**: - Recovered 42 tool calls - Restored 17 image assets (total 3.2MB) - Logged 3 corrupted image references (now replaced with placeholders) - **Result**: Session resumed with 98% integrity (2% metadata loss). ### Image Processing Summary | File | Original Size | Resized Size | Dimensions | Format | Status | |------|---------------|--------------|------------|--------|--------| | screenshot_1.png | 8.4MB | 1.8MB | 4096x2160 → 2048x1080 | JPEG | ✅ Resized | | diagram.png | 3.1MB | 1.2MB | 3840x2160 → 2048x1152 | JPEG | ✅ Resized | | corrupted_img.jpg | - | 0.8MB | 1280x720 | JPEG | ⚠️ Repaired (corruption detected) | **Total Savings**: 11.2MB disk space recovered (68% reduction) **Processing Time**: 42 seconds (3 images) ### Recommendations - For future sessions, enable auto-backup every 5 minutes to minimize data loss risk. - Consider pre-processing images with `claude-code-image-sanitizer` before drag-and-drop to avoid session corruption. - Monitor `/tmp/claude-image-cache/` for temporary files exceeding 5MB (automatic cleanup enabled).
Safe collectibles marketplace
AI assistant built for thoughtful, nuanced conversation
Get more done every day with Microsoft Teams – powered by AI
Automate your spreadsheet tasks with AI power
Agentic AI Workflow platform
Connected workspace for docs, wikis, and projects
Take a free 3-minute scan and get personalized AI skill recommendations.
Take free scan