add-compact

add-compact is a skill for Claude Code, Codex from sbusso/claudeclaw. It costs 40 tokens per session (1,676 once invoked), scanned A, original, MIT.

A /compact command for shortening a long conversation while keeping its session active. Context is the conversation information an agent uses, and compaction keeps a summary so the session can continue.

In plain words
What is it for?
It is for manually compacting long-running ClaudeClaw sessions with the /compact command while preserving the agent's summarised context.
Why use it?
It reduces context rot, where very long conversations make earlier information harder for the agent to use. It avoids starting a completely new session and is limited to the main group or trusted senders.

Skill for Claude CodeCodex

Part of the claudeclaw plugin — 27 skills shipped together

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/sbusso/claudeclaw/add-compact
Any agent
npx skills add sbusso/claudeclaw --skill add-compact
Clone the repo
git clone --depth 1 https://github.com/sbusso/claudeclaw

Made for: Claude Code, Codex.

Or install claudeclaw, the plugin that ships this one along with the rest of its 27 skills.

Wrote 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.

agentmods badge for add-compact

README.md
[![agentmods](https://agentmods.dev/badge/skills/sbusso/claudeclaw/add-compact.svg)](https://agentmods.dev/skills/sbusso/claudeclaw/add-compact)
Your own site
<a href="https://agentmods.dev/skills/sbusso/claudeclaw/add-compact"><img src="https://agentmods.dev/badge/skills/sbusso/claudeclaw/add-compact.svg" alt="Measured on agentmods" height="20"></a>
Per session 40 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,676 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

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.

ModelPer sessionOnce invoked
Fable 5 $0.00040 $0.01676
Opus 5 $0.00020 $0.00838
Sonnet 5 $0.00008 $0.00335
Haiku 4.5 $0.00004 $0.00168

Measured 5d ago against content hash 11e4877e00a7, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

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 5d 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.

Origin

Copies of this mod

8 near-identical copies found in the catalogue:

skills/add-compact/SKILL.md · 138 lines

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: upstream is the remote pointing to sbusso/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 (both processGroupMessages and startMessageLoop)
  • 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 is my-assistant, the service is com.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

  1. Start ClaudeClaw in dev mode: npm run dev
  2. From the main group (self-chat), send exactly: /compact
  3. 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_boundary was NOT observed, the response says "compact_boundary was not observed"
  4. From a non-main group as a non-admin user, send: @<assistant> /compact
  5. Verify:
    • The bot responds with "Session commands require admin access."
    • No compaction occurs, no container is spawned for the command
  6. From a non-main group as the admin (device owner / is_from_me), send: @<assistant> /compact
  7. Verify:
    • Compaction proceeds normally (same behavior as main group)
  8. While an active container is running for the main group, send /compact
  9. 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)
  10. Send a normal message, then /compact, then another normal message in quick succession (same polling batch):
  11. Verify:
    • Pre-compact messages are sent to the agent first (check container logs for two runAgent calls)
    • Compaction proceeds after pre-compact messages are processed
    • Messages after /compact in the batch are preserved (cursor advances to /compact's timestamp only) and processed on the next poll cycle
  12. From a non-main group as a non-admin user, send @<assistant> /compact:
  13. Verify:
    • Denial message is sent ("Session commands require admin access.")
    • The /compact is 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
  14. From a non-main group (with requiresTrigger enabled) as a non-admin user, send bare /compact (no trigger prefix):
  15. Verify:
    • No denial message is sent (trigger policy prevents untrusted bot responses)
    • The /compact is consumed silently
    • Note: in groups where requiresTrigger is false, a denial message IS sent because the sender is considered reachable
  16. After compaction, verify no auto-compaction behavior — only manual /compact triggers it

Read the full file on GitHub · 138 lines

Changes

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.

  1. 5d ago First seen · 138 lines · 40 tokens per session scan A 11e4877e00a7

Subscribe to this mod's changes

add-compact is a skill published in the GitHub repository sbusso/claudeclaw (193 stars, last pushed 23d ago), licensed MIT. It adds 40 tokens to every session and 1,676 once invoked, about $0.0002 per session on Opus 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.

Related

Other skills, from other repositories

persistent-notes

Save notes locally to /mnt/workspace/notes.json file. Use when user wants to "save a note" or "remember something".

awslabs/agentcore-samples · 32 tokens

memmachine-memory

Use when an agent or model needs durable project, user, or session context from MemMachine, needs to save information to MemMachine memory, has requests involving mem-cli, memmachine, or memmachineclient, has insufficient conversation context, or is tempted to search local files for prior context that should come from…

MemMachine/MemMachine · 96 tokens

external-memory-plugin

Develop, adapt, review, test, and troubleshoot Nexent external memory provider plugins, including plugin.yaml manifests, searchable and ingestible provider protocols, error mapping, network-isolated unit tests, deployment configuration, and Mem0-based examples. Use when adding a new external memory vendor, changing an…

ModelEngine-Group/nexent · 85 tokens

agent-memory-onboarding

On-demand provisioning guide for a Memmy GUI task that fully connects an explicitly named local Agent: discover its active history store, install or remove its rendered Memmy Skill, bootstrap a scan boundary, persist a validated automatic-sync recipe, and verify GUI-visible readiness.

MemTensor/memmy-agent · 57 tokens

session-summaries

What the chat right-panel session summary shows, what it costs, and how to make a session summarize well. Load when the user asks about the session summary panel, why a summary looks wrong or empty, or how to turn it on.

kirodotdev/KiroCrew · 53 tokens

update-setup

One-time setup wizard for the memmy upgrade skill. Triggers: setup update, configure update, 切设置更新, 初始化更新.

MemTensor/memmy-agent · 0 tokens