Claude Code session transcript cleaner. Reduces transcript size by 60-80% while preserving conversation flow.
curl -sL https://raw.githubusercontent.com/professional-ALFIE/context-cleaner-skill/main/install.sh | bashThis installs the skill and scripts to ~/.claude/skills/context-cleaner/.
This hook is required β it provides the transcript path to Claude and copies the resume command to your clipboard. Without it, Claude cannot locate the transcript file.
It also auto-detects cleaned sessions: when a session ID contains 00effaced, the hook displays a notice explaining what was preserved and removed.
After running the install script, register the hook in ~/.claude/settings.json. Add the SessionStart entry to the hooks object (don't remove existing hooks):
{"SessionStart":[{"hooks":[{"type":"command","command":"${HOME}/.claude/skills/context-cleaner/src/contextCleaner_sessionStartHook.sh"}]}]}After registration, restart your Claude Code session.
Copy the block below and paste it into Claude Code. It will handle everything automatically.
Install the context-cleaner skill from this repo: https://github.com/professional-ALFIE/context-cleaner-skill
Step 1 - Run the install script:
curl -sL https://raw.githubusercontent.com/professional-ALFIE/context-cleaner-skill/main/install.sh | bash
Step 2 - Add this SessionStart hook entry to ~/.claude/settings.json inside the "hooks" object. Do NOT remove any existing hooks:
{"SessionStart":[{"hooks":[{"type":"command","command":"${HOME}/.claude/skills/context-cleaner/src/contextCleaner_sessionStartHook.sh"}]}]}
After all steps, tell me to restart the session.
Strips bulky data from .jsonl transcript files:
- Thinking blocks, file contents, diffs, stdout/stderr
- Full file paths β filenames only
- Hook progress lines, tool result duplicates, meta content (injected SKILL.md, etc.)
Preserves: conversation text, edit intent, filenames, uuid chain.
- Cleans β Removes heavy data (thinking, file contents, bash output, etc.) and replaces with lightweight markers like
[context-cleaner: Read] - Generates new file β Original file stays untouched. A new file is created with
00effacedin the filename ("effaced" = erased/removed) - Maintains uuid chain β When lines are deleted,
parentUuidreferences are remapped so the conversation tree stays intact. Claude--resumeworks correctly - Unifies sessionId β All
sessionIdentries are updated to match the new filename, preventing session detection issues - Copies resume command β After cleaning,
claude --resume <new_id> --verboseis automatically copied to your clipboard (macOS)
Original: 9c4c1a42-...-239d2e110282.jsonl
Cleaned: 9c4c1a42-...-00effaced001.jsonl
Re-clean: 9c4c1a42-...-00effaced002.jsonl (number increments)
00effaced= prefix00+ "effaced" (erased/removed)- The SessionStart hook detects this pattern and shows a context-cleaned session notice
Claude Code records every action to a JSONL transcript. The cleaner replaces bulky fields with lightweight markers while preserving conversation structure.
Each assistant response includes Extended Thinking content.
message.content[N].thinkingβ replaced
Reading a file records its full content in the transcript.
- Call:
input.file_pathβ trimmed to filename only - Result:
toolUseResult.file.contentβ replaced - Result duplicate:
tool_result.contentβ replaced
Writing a file records the written content and the original file.
- Call:
input.file_pathβ trimmed to filename only,input.contentβ replaced - Result:
toolUseResult.content,.originalFile,.structuredPatchβ replaced - Result duplicate:
tool_result.contentβ replaced
Editing records old/new strings and the original file.
- Call:
input.file_pathβ trimmed to filename only,input.old_string,input.new_stringβ replaced - Result:
toolUseResult.oldString,.newString,.originalFile,.structuredPatchβ replaced - Result duplicate:
tool_result.contentβ replaced
Running a command records the command text and its full output.
- Call:
input.commandβ replaced - Result:
toolUseResult.stdout,.stderrβ replaced - Progress:
data.output,data.fullOutput(bash_progress lines) β replaced - Result duplicate:
tool_result.contentβ replaced
Searching records a list of matched file paths.
- Result:
toolUseResult.filenamesβ replaced with[""]
Calling a subagent records the prompt and the agent's full output. The prompt is stored in three locations (Path A/B/C).
- Call (Path A):
input.promptβ replaced - Result:
toolUseResult.task.outputortoolUseResult.content[N].textβ replaced - Result prompt (Path C):
toolUseResult.promptβ replaced - Progress (Path B):
data.message.message.content(agent_progress lines) β replaced - Result duplicate:
tool_result.contentβ replaced
Fetching a URL records the full page content.
- Result:
toolUseResult.result(string) β replaced
Exiting plan mode records the plan text.
- Call:
input.planβ replaced
Not tied to a specific tool, but still cleaned.
- Image attachments:
source.database64 β 1x1 transparent PNG,source.media_typeβimage/png - hook_progress: entire line deleted (uuid chain preserved via parentUuid remapping)
- Meta messages (isMeta):
content[N].textβ replaced (injected SKILL.md, system prompts, etc.) - Bash tags:
<bash-stdout>...<bash-stderr>patterns in user messages β replaced - User-marked content:
<clean>...</clean>patterns β replaced - teammate-message: tag body β replaced (opening tag attributes including
summarypreserved) - local-command-stdout: tag body β replaced when over 200 characters (short outputs preserved)
Wrap any part of your prompt with <clean>...</clean> tags to mark it for deletion on the next clean. Useful for pasting large text that you don't need in future context.
<clean>paste your large content here</clean>
After cleaning, you get a detailed report:
β
Context Cleaner v2 completed!
π Cleaning Statistics:
Thinking blocks: 42 cleaned (128,400 bytes)
Read results: 18 cleaned (95,200 bytes)
...
πΎ Total saved: 892,103 bytes (871.2 KB)
π¦ Original size: 1,245,678 bytes
π¦ New size: 353,575 bytes (71.6% reduction)
π To resume this cleaned session, run:
claude --resume 9c4c1a42-...-00effaced001 --verbose
π Copied to clipboard!
Just tell Claude: "context cleanν΄μ€" or "transcript μ 리ν΄μ€"
~/.claude/skills/context-cleaner/scripts/context-cleaner.py /path/to/session.jsonlAfter cleaning, the resume command is automatically copied to your clipboard. Just paste and run:
claude --resume 9c4c1a42-...-00effaced001 --verboseThe --verbose flag lets you see the SessionStart hook output (including the cleaned session notice) in the terminal.
- Python 3
jq(for the hook script)- macOS (pbcopy for clipboard β hook and cleaner script)