session-stripper
БесплатноЗапускает вложенные скриптыНе проверенManually trim, compact, persist, and repair Claude Code conversation sessions stored as JSONL files. Use when the user wants to: (1) fix a session hitting…
от vicnaum★ 53 звезды на GitHubОб этом скилле
Session Surgery
CLI tool for trimming Claude Code JSONL sessions. Sessions live at ~/.claude/projects/<project-path>/<uuid>.jsonl.
Identify the session FIRST — never guess by mtime
Every mutating command operates on the exact <session.jsonl> path you pass. Getting that path right is the single most important step: strip the wrong file and you silently corrupt a different, possibly active, session.
To strip the CURRENT session, resolve it from $CLAUDE_CODE_SESSION_ID — the env var Claude Code exports into every Bash tool call, which matches the real transcript filename:
SKILL=<skill-dir>/scripts/stripper.py
SESS=$(python3 "$SKILL" current --quiet) # resolves $CLAUDE_CODE_SESSION_ID → its .jsonl (any cwd)
python3 "$SKILL" strip-all "$SESS"
current (without --quiet) prints the id, path, and whether it exists.
NEVER select the session with ls -t ... | head -1 (most-recently-modified). In a project folder with more than one session running — increasingly common with parallel/multi-agent work — the newest file is frequently a different live session, and you will strip someone else's work. $CLAUDE_CODE_SESSION_ID is the only reliable source; if it is unset you are not inside a CC session, so ask the user which file to strip rather than guessing.
When the user names a specific session id or file (e.g. "strip session abc123"), use that instead; current is only for "strip this/my session".
Fork-first: mutations never touch the session you pass
Mutating commands write a fork by default. The result is a new session, <newSessionId>.jsonl next to the original, with forkedFrom stamped on every record. The original is only read. Every command ends with the resume line:
python3 stripper.py strip-all <session.jsonl>
# ...
# Stripped session: ~/.claude/projects/<dir>/<newSessionId>.jsonl
# Resume it: claude -r <newSessionId>
Nothing has to be swapped in, and nothing the original records later is ever discarded. The original can keep running while you strip; quit it whenever you like and claude -r <newSessionId>. If you kept working in the original after stripping, its newer turns are not in the fork: strip again (--new-fork) to include them.
Why (incident 2026-11-11): the old default wrote <session>.jsonl.pending and needed the CLI to quit so apply could swap it in. The user kept working in the session meanwhile, so the copy went stale: swapping it in would have discarded those turns, and the session never got smaller. Before that (incident 2026-08-05), in-place rewrites raced the live CLI's appends; one collapsed a 763-message chain to 14. A fork has neither problem.
Mechanics:
- Back-to-back passes build ONE fork. A second mutating command on the same session reuses its fork while nobody has resumed it (
analyze→persist-range→strip-all→ …). It says so, and notes if the original has grown since. A command aimed at the fork itself edits it in place, too. - A resumed fork is never edited. The stripper records each fork's size and mtime after its last write, in
<fork>.jsonl.stripper.json(outside CC's*.jsonlglob). Once a CLI has appended to the fork, the next command forks the original afresh.--new-forkalways takes a fresh one. - Dry runs never create a fork.
- No
.baks are written while mutating a fork: the untouched original is the backup. compactalways writes a new session file anyway.migrate-persistedmoves shared sidecar files on disk, so it keeps the in-place flow below.- After a fork, anything keyed to the old session id is stale; for example, re-register on agent-chat in the resumed session.
--in-place: keep the session id
For a session that must keep its id, --in-place keeps the older copy-first flow. It mutates <session>.jsonl.pending and swaps it over the original with one atomic rename:
python3 stripper.py strip-all <session.jsonl> --in-place # writes <session.jsonl>.pending
python3 stripper.py apply <session.jsonl> # the one write to the real file
- Multi-pass
--in-placestrips reuse the same pending copy.snapshot --refreshre-snapshots. applyaccepts either path (original or.pending). It refuses to swap when the original is being written right now (it grew during a 400ms settle check), when the original was rewritten since the snapshot (prefix-hash mismatch), or when the pending copy failsverify. Refusals leave everything in place.- Anything appended to the original after the snapshot is discarded by apply, by design (counted and reported). In the self-strip flow that tail is the stripping turn itself.
applyrefuses if someone typed messages into the session after the snapshot: the copy is stale, and swapping it in would discard them. Slash commands, tool results and task notifications don't count, so the self-strip tail never trips this. Strip again (a fork loses nothing), or pass `--dis
Установить session-stripper в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл session-stripper?
Manually trim, compact, persist, and repair Claude Code conversation sessions stored as JSONL files. Use when the user wants to: (1) fix a session hitting 'Prompt is too long' errors, (2) manually compact or strip a session to reduce context, (3) analyze a session's token usage and message chain, (4) strip tool call inputs and results from a session, (5) strip thinking blocks from a session, (6) compact part of a session before a specific message, (7) verify or repair a broken session chain, (8) persist and summarize tool results to reduce context intelligently, (9) perform any JSONL-level surgery on Claude Code sessions. Triggers on mentions of session surgery, session trimming, session stripping, context compaction, session repair, prompt too long, session compact, manual session manipulation, summarize tool results, or persist tool output.
Как установить скилл session-stripper?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл session-stripper запускает скрипты?
Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic