claude_code_session_fixer
Version, currently main branch1 version
- main branchlatestMar 1, 2026
github.com/skuznetsov/claude_code_session_fixer
No description declared in shard.yml.
Installation
# Add this to your shard.yml
dependencies:
claude_code_session_fixer:
github: skuznetsov/claude_code_session_fixer
branch: mainmain is a branch, not a release, so this tracks it rather than pinning a version.
Then run:
shards installshard.yml
- Crystal
>= 1.10.0- Target
session_fixerfrom src/session_fixer.cr
Dependencies
This version declares no dependencies.
README
Claude Code Session Fixer
Small Crystal CLI tool to repair broken Claude Code session files by removing
thinking and redacted_thinking blocks from assistant messages in .jsonl
sessions.
What It Does
- Scans Claude sessions under
~/.claude/projects/*/*.jsonl. - Finds assistant messages that contain
thinking/redacted_thinkingblocks. - Removes only those blocks from
message.content. - Drops a line if, after removal,
contentbecomes empty. - Creates a backup before writing changes.
Why
Some Claude session files can become hard to resume when internal thinking blocks are present or malformed for downstream tooling. This utility performs a targeted cleanup without changing unrelated JSON fields.
Requirements
- Crystal
>= 1.10.0
Build
crystal build src/session_fixer.cr -o session_fixer
Usage
# Show help
./session_fixer --help
# List sessions that contain thinking blocks
./session_fixer --list
# Fix by full or partial session ID
./session_fixer <session-id>
# Fix by direct file path
./session_fixer /absolute/path/to/session.jsonl
# Preview changes only (no write)
./session_fixer <session-id-or-path> --dry-run
You can also run without building:
crystal run src/session_fixer.cr -- --list
crystal run src/session_fixer.cr -- <session-id> --dry-run
Session Selection Rules
When you pass an ID (not a file path), matching is:
- Exact UUID match first.
- Partial UUID match second.
- If multiple matches are found, the tool stops with an ambiguity error and asks for a longer ID or full path.
Safety and Backups
- Normal mode writes to a temporary file, then replaces the original.
- A backup is created first:
- preferred:
<session>.bak.jsonl - if that already exists:
<session>.bak.<timestamp>.jsonl
- preferred:
--dry-runnever modifies the source file.
Output Stats
After processing, the tool reports:
- total lines
- modified lines
- removed lines (where content became empty)
- number of thinking blocks removed
- parse errors skipped (if any malformed JSON lines were encountered)
Limitations
- Only assistant messages are modified.
- Non-JSON lines are skipped (counted as parse errors).
- The tool assumes standard Claude session layout under
~/.claude/projects/.
Documentation
Built from the current release. The first visit to a release nobody has asked for starts its build.
Links
This branch
- Branch
main- Seen
- Mar 1, 2026
- Crystal
>= 1.10.0- Indexed
- yes
Dependents
No indexed shard depends on this one yet.
Repository
github.com/skuznetsov/claude_code_session_fixer
Metadata
- Created
- Aug 12, 2026
- Updated
- Aug 15, 2026
- Synced
- Aug 15, 2026
- Versions
- 1