Jev Prune keeps long Claude Code sessions sharp. It removes old tool results (big file reads, long terminal output) that no longer matter to what you are doing now. Your chat history in the terminal stays the same; only the context sent to Claude gets smaller.
It runs on your machine as a small proxy between Claude Code and Anthropic.
You need Node.js 20+, Claude Code, and a TypeSafe API key.
git clone https://github.com/j-ctang/claude-code-jev-prune
cd claude-code-jev-prune
npm linknpm link adds a jev-prune command you can run from any folder. To skip it, run ./jev-prune from this folder instead.
Use jev-prune wherever you used claude:
cd ~/my-project
jev-pruneThe first run asks for your TypeSafe key, then opens Claude Code. After that it opens Claude Code right away.
Claude Code options work the same way:
jev-prune --continue
jev-prune --resume
jev-prune ~/other-projectYou can run it in several terminals at once. The proxy stops when the last one closes, and restarts itself if it crashes. When a session ends, Jev Prune prints how much it pruned.
Other commands:
jev-prune --stats # how much stale context has been pruned so far
jev-prune --doctor # check the install and explain any problem
jev-prune --update # download the latest version
jev-prune --setup # answer the setup questions again- Automatic: When the context reaches about 120K tokens, Jev Prune removes stale tool results the next time you send a prompt. It never prunes while Claude is in the middle of a task.
- Manual: Type
/jev-pruneto prune now. - Recent tool results and all normal conversation text are kept.
- If TypeSafe is slow or down, your request goes through unchanged.
- MCP tools still load on demand. Claude Code normally turns this off behind a proxy;
jev-pruneturns it back on (ENABLE_TOOL_SEARCH=true) and never prunes the results that load tools.
If your CLAUDE.md tells Claude to start every reply with a fixed word, setup can use it as a canary. When Claude stops using it, Jev Prune suggests /jev-prune. Type /jev-prune-auto to prune on those misses automatically, or /jev-prune-auto-off to go back to suggestions.
Set JEV_PRUNE_SKILL_SHADOW=true in .env to measure possible savings from removing a full skill body after its task finishes. This experiment does not remove skill content. It looks for an exact match to a local user or project SKILL.md body in the request, then asks Jev whether the task is complete after a finished assistant reply. Unknown or ambiguous content and uncertain answers produce no finding.
All launchers sharing one proxy must use the same shadow setting. If you change the flag while another session is running, close that session or use another PORT before launching.
jev-prune --stats reports observations, high-confidence completions, and approximate potential tokens separately from tokens actually removed. When the proxy has served only one jev-prune launcher, it also prints one short terminal line for a completion finding. If launchers share the proxy, terminal notices stay suppressed until the proxy restarts so one terminal cannot show another session's finding. The log contains only metadata, not skill or conversation text. Completion checks make additional TypeSafe calls only for sessions where a full skill body was identified.
If launchers from different projects share a proxy, shadow mode observes user skills only. It skips project skills because the proxy cannot reliably assign each request to a project.
Jev Prune can answer hard prompts with a stronger model. The first time you send a hard prompt, Claude asks whether to turn this on. Type /jev-route-auto to turn it on, or /jev-route-off to keep your model. When routing is on, a hard prompt moves the conversation to the hard model, and the next easy, unrelated task moves it back. Claude tells you each time the model changes.
Only requests on JEV_ROUTE_DEFAULT_MODEL are routed, so a model you pick with /model is never changed. If your account can't use the hard model, Jev Prune stays on your model and tells you.
Settings are in .env in this folder. The useful ones:
| Setting | Default | What it does |
|---|---|---|
JEV_PRUNE_THRESHOLD |
120000 |
Context size that starts automatic pruning |
JEV_PRUNE_KEEP_RECENT |
5 |
Newest tool results that are never pruned |
JEV_PRUNE_ENABLED |
true |
false passes everything through untouched |
JEV_PRUNE_SKILL_SHADOW |
false |
Observe full skill bodies and estimate possible cleanup savings without removing them |
JEV_ROUTE_DEFAULT_MODEL |
claude-opus-5-5 |
Model for easy prompts; the only model that is routed |
JEV_ROUTE_HARD_MODEL |
claude-fable-5-1 |
Model for hard prompts |
PORT |
5590 |
Local port for the proxy |
All settings are listed in .env.example.
Run jev-prune --doctor first. It checks Node.js, Claude Code, your key, TypeSafe, the port, and settings that bypass the proxy.
- Logs:
~/.claude/jev-prune.log - "Port 5590 is used by another program": set a different
PORTin.env. - "
claudewas not found": install Claude Code and check thatclauderuns in your terminal. - Skip Jev Prune for a session: run
claudeas usual. - Using a custom
ANTHROPIC_BASE_URL: Jev Prune sends traffic on to it instead of the Anthropic API. If it is set in~/.claude/settings.json, Claude Code skips the proxy; move it toANTHROPIC_UPSTREAM_URLin.env. - Bedrock or Vertex: not supported. Claude Code skips the proxy when
CLAUDE_CODE_USE_BEDROCKorCLAUDE_CODE_USE_VERTEXis set. - "Jev Prune was updated": close all
jev-prunesessions so the proxy restarts on the new version.
npm unlink -g claude-code-jev-prune
rm -rf ~/.claude/commands/jev-prune*.md ~/.claude/jev-prune*Then delete this folder.
How pruning decides what to remove: docs/ARCHITECTURE.md. Run npm run check to lint, build, and test.
MIT