Getting it into your agent
It runs from inside its repository, so the clone comes first — what it calls does not travel with the file alone.
git clone --depth 1 https://github.com/sbusso/claudeclawnpx agentmods add skills/sbusso/claudeclaw/add-compactWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/skills/sbusso/claudeclaw/add-compact)<a href="https://agentmods.dev/skills/sbusso/claudeclaw/add-compact"><img src="https://agentmods.dev/badge/skills/sbusso/claudeclaw/add-compact/github.svg" alt="Measured on agentmods" height="20"></a>Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.
<a href="https://agentmods.dev/skills/sbusso/claudeclaw/add-compact"><img src="https://agentmods.dev/badge/skills/sbusso/claudeclaw/add-compact.svg" alt="Reviewed on agentmods" width="80" height="20"></a>- NVIDIA SkillSpector pass
What it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00040 | $0.01676 |
| Opus 5.5 | $0.00016 | $0.00670 |
| Sonnet 5.5 | $0.00008 | $0.00335 |
| Haiku 4.5 | $0.00004 | $0.00168 |
Grade A, and why
add-compact scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3mo ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
Copies of this mod
8 near-identical copies found in the catalogue:
- add-compact — 94% identical, 22 lines differ
- add-compact — 94% identical, 22 lines differ
- add-compact — 94% identical, 22 lines differ
- add-compact — 94% identical, 22 lines differ
- add-compact — 94% identical, 22 lines differ
- add-compact — 94% identical, 22 lines differ
- add-compact — 94% identical, 22 lines differ
- add-compact — 91% identical, 30 lines differ
How it starts
The opening of the file, as written. The whole thing — 138 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Add /compact Command
Adds a /compact session command that compacts conversation history to fight context rot in long-running sessions. Uses the Claude Agent SDK's built-in /compact slash command — no synthetic system prompts.
Session contract: /compact keeps the same logical session alive. The SDK returns a new session ID after compaction (via the init system message), which the agent-runner forwards to the orchestrator as newSessionId. No destructive reset occurs — the agent retains summarized context.
Phase 1: Pre-flight
Check if src/session-commands.ts exists:
test -f src/session-commands.ts && echo "Already applied" || echo "Not applied"
If already applied, skip to Phase 3 (Verify).
Phase 2: Apply Code Changes
Merge the skill branch:
git fetch upstream skill/compact
git merge upstream/skill/compact
Note:
upstreamis the remote pointing tosbusso/claudeclaw. If using a different remote name, substitute accordingly.
This adds:
src/session-commands.ts(extract and authorize session commands)src/session-commands.test.ts(unit tests for command parsing and auth)- Session command interception in
src/index.ts(bothprocessGroupMessagesandstartMessageLoop) - Slash command handling in
agent/runner/src/index.ts
Validate
npm test
npm run build
Rebuild container
./src/runtimes/docker/build.sh
Service name: Derived from the directory name:
com.claudeclaw.<dirname>(macOS) /claudeclaw-<dirname>(Linux). For example, if cwd ismy-assistant, the service iscom.claudeclaw.my-assistant. Determine the correct service name before running service commands below.
Restart service
launchctl kickstart -k gui/$(id -u)/com.claudeclaw # macOS
# Linux: systemctl --user restart claudeclaw
Phase 3: Verify
Integration Test
- Start ClaudeClaw in dev mode:
npm run dev - From the main group (self-chat), send exactly:
/compact - Verify:
- The agent acknowledges compaction (e.g., "Conversation compacted.")
- The session continues — send a follow-up message and verify the agent responds coherently
- A conversation archive is written to
groups/{folder}/conversations/(by the PreCompact hook) - Container logs show
Compact boundary observed(confirms SDK actually compacted) - If
compact_boundarywas NOT observed, the response says "compact_boundary was not observed"
- From a non-main group as a non-admin user, send:
@<assistant> /compact - Verify:
- The bot responds with "Session commands require admin access."
- No compaction occurs, no container is spawned for the command
- From a non-main group as the admin (device owner /
is_from_me), send:@<assistant> /compact - Verify:
- Compaction proceeds normally (same behavior as main group)
- While an active container is running for the main group, send
/compact - Verify:
- The active container is signaled to close (authorized senders only — untrusted senders cannot kill in-flight work)
- Compaction proceeds via a new container once the active one exits
- The command is not dropped (no cursor race)
- Send a normal message, then
/compact, then another normal message in quick succession (same polling batch): - Verify:
- Pre-compact messages are sent to the agent first (check container logs for two
runAgentcalls) - Compaction proceeds after pre-compact messages are processed
- Messages after
/compactin the batch are preserved (cursor advances to/compact's timestamp only) and processed on the next poll cycle
- Pre-compact messages are sent to the agent first (check container logs for two
- From a non-main group as a non-admin user, send
@<assistant> /compact: - Verify:
- Denial message is sent ("Session commands require admin access.")
- The
/compactis consumed (cursor advanced) — it does NOT replay on future polls - Other messages in the same batch are also consumed (cursor is a high-water mark — this is an accepted tradeoff for the narrow edge case of denied
/compact+ other messages in the same polling interval) - No container is killed or interrupted
- From a non-main group (with
requiresTriggerenabled) as a non-admin user, send bare/compact(no trigger prefix): - Verify:
- No denial message is sent (trigger policy prevents untrusted bot responses)
- The
/compactis consumed silently - Note: in groups where
requiresTriggerisfalse, a denial message IS sent because the sender is considered reachable
- After compaction, verify no auto-compaction behavior — only manual
/compacttriggers it
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 3mo ago First seen · 138 lines · 40 tokens per session scan A 11e4877e00a7
add-compact is a skill published in the GitHub repository sbusso/claudeclaw (194 stars, last pushed 3mo ago), licensed MIT. It adds 40 tokens to every session and 1,676 once invoked, about $0.0002 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.
add-compact compared with skills from other repositories
| Mod | Type | Stars | Last push | Licence | Scan | Tokens | Works with |
|---|---|---|---|---|---|---|---|
| add-compactsbusso/claudeclaw | Skill | 194 | 3mo ago | MIT | A | 40 | Claude Code |
| memmachine-memoryMemMachine/MemMachine | Skill | 3.1k | yesterday | Apache-2.0 | A | 96 | Codex |
| memmy-projectMemTensor/memmy-agent | Skill | 2.4k | 2d ago | MIT | A | 277 | Claude Code, Codex |
| computer-historyMemTensor/memmy-agent | Skill | 2.4k | 2d ago | MIT | A | 42 | Claude Code, Codex |
| docxMemTensor/memmy-agent | Skill | 2.4k | 2d ago | MIT | A | 40 | Claude Code, Codex |
| update-setupMemTensor/memmy-agent | Skill | 2.4k | 2d ago | MIT | A | 0 | Claude Code, Codex |
| skill-creatorMemTensor/memmy-agent | Skill | 2.4k | 2d ago | MIT | A | 28 | Claude Code, Codex |