smart-compact
Reviewed
at commit ccecf5f
Offers a one-click compact after a commit or a green test run and a minute before the prompt cache expires, and gives Claude a request_compact tool to ask for…
0 upvotes
Log in to upvote or save- Made by
- hellosverre
- Pinned commit
-
ccecf5f8c5449573c00122d6c5fc237fa83b23bf - What we checked
-
Offers to compact your conversation after a git commit or a passing test run, and a minute before the prompt cache expires. It also adds a request_compact tool Claude can call. Before every compact, including your own /compact and auto-compact, it copies the whole conversation file to a new session listed in /resume as 'Before compact <time>' (on by default, can be switched off). No network calls.
Review details
Static review of the source at the pinned commit; not run. Delta review of the changes since 5808714; the rest carries over from the review at that commit. New in 0.3.2: option suggestAfterWork (default on) to silence commit and test suggestions; the cache timer now re-checks the context percent and whether the cache has already expired when it fires; and a new default-on option backup. On classic.PreCompact (every compact, not only the mod's own) the mod cancels its timer and, when backup is on, runs a host command through $.process.run (sh -c with sed on POSIX, powershell -NoProfile -Command on Windows, 60 s timeout) that copies the session transcript (e.transcript_path, must end in .jsonl) to a new <uuid>.jsonl in the same folder, replacing the old session id with the new one and appending a custom-title line. The command strings are fixed; paths and ids are passed as environment variables, and both session ids must match a UUID pattern, so nothing from the transcript is interpolated into the shell. The copy is a full duplicate of the conversation, including anything sensitive it contains, stored beside the original in Claude's own session folder, so it doubles disk use per compact and adds entries to /resume. A failed copy shows a toast and the compact proceeds; handlers fall back to pass-through. Other hooks unchanged: session.start, tool.call (request_compact, Bash, PowerShell regex matching only), prompt.submit, turn.complete, ui.close, ui.render. Runtime calls: $.tool.register, $.session.usage, $.session.compact, $.clock, $.process.run (backup only), $.ui. No network, no npm dependencies.
- What it uses
-
- Reads your prompts: no
- Sees tool calls: yes
- Blocks or changes tool calls: no
- Reads or writes files: yes
- Runs programs on your machine: yes
- Calls the model (uses tokens): no
- Sends data over the network: no
- Stores data: yes
- Shows something on screen: yes
Compacts at the right moment: after a commit or green tests, a minute before the prompt cache expires, or when Claude asks for it with its own request_compact tool.
Made this mod? Add a badge to your README
Paste this into your README. The badge says reviewed once the current version has been reviewed, and links readers to this page.
[](https://modsforclaude.com/mods/smart-compact/)