r/ClaudeCode • u/VShulcz • 5d ago
Tips & Workflows I diffed 43 Claude Code /compact summaries against the raw JSONL transcripts on disk
Claude Code keeps appending every raw tool call and result to ~/.claude/projects/*/*.jsonl. Running /compact only shrinks the API context window, not those logs on disk. Across 43 real compactions diffed against raw JSONL, 77% of prose decisions survived while only 0.2% of shell commands survived.
You can check every raw Bash command still sitting in your logs right now without installing anything:
jq -r '.message.content[]? | select(.type == "tool_use" and .name == "Bash") | .input.command // empty' ~/.claude/projects/*/*.jsonl | wc -l
Reading multi-GB JSONL files by hand across Claude Code, Codex, Cursor, and opencode got slow, so I wired PreCompact (4 KB), SessionStart (2 KB), and UserPromptSubmit (1,536 bytes) hooks in an 18.6 MB MIT Go CLI called deja-vu. It runs in 107 ms on 19,195 sessions (13.6 s cold build), adds one 477-token MCP tool across 52 coding agents, and cut median task tokens 57.6% on a 329-file Go repo.
Caveat: pure BM25 drops to 43.3% hit@1 on keyword-free preference paraphrases (vs 88.9% overall on LongMemEval-S 470q), so optional deja embed covers vector fallback, and noisy recall hurt mean tokens in one control run.
For Claude Code plugin install: claude plugin marketplace add vshulcz/deja-vu (install script and Windows winget/scoop commands are in the README): https://github.com/vshulcz/deja-vu
ā¢
u/AutoModerator 5d ago
Hey! Thanks for posting to r/ClaudeCode
While participating in this thread, please follow our community rules. Keep discussions constructive. Attack the idea, not the person.
For help, project discussions, tips, and general chat, join the ClaudeCode Discord.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
1
u/Accomplished-Tea-822 5d ago
heads up, that jq glob skips subagent transcripts. They live in
<session-id>/subagents/agent-*.jsonlnext to each session file, so something like~/.claude/projects/*/{*.jsonl,*/subagents/*.jsonl}gets both.Also the logs aren't permanent. Claude Code deletes anything older than
cleanupPeriodDays(30 by default), so whatever you build on them only sees about a month unless you raise that.1
u/iFun4ik 5d ago
The commands are interesting, but Iād also check whether the summary kept the reason behind each decision. A command can be recovered from the log; knowing why an approach was rejected is harder to reconstruct after compaction.
1
u/AgentYurt 2d ago
That split matches what I've seen too ā the narrative survives, but the exact commands and the reasons behind a rejection are the first things to go.
What helped me was writing the rejection down at the moment it happens, not reconstructing it later: one line in a per-repo decisions file, in the form 'Tried X, dropped it because Y, revisit if Z.' The 'revisit if' part is what stopped me treating old rejections as permanent and re-arguing them a month later.
I also do a short pre-compact checkpoint in the same file ā current goal, what's done, what's next, open questions, rejected approaches ā then after /compact I ask the agent to restate that checkpoint in its own words. If it can't, I know the summary lost something important before I keep going.
Are the decisions you're losing mostly implicit ones buried across turns, or explicit rejections that the summary just smooths over?