Agent skill

Add Compact

by sbusso in sbusso/claudeclaw

Add /compact command for manual context compaction. An agent skill from sbusso/claudeclaw.

MITAuto-check passedAgent Workflows

Install Add Compact

skills CLI
$ npx skills add sbusso/claudeclaw --skill add-compact -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install sbusso/claudeclaw add-compact --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/sbusso/claudeclaw.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/add-compact .claude/skills/add-compact && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
add-compact
GitHub stars
194
Token cost
~1.8k tokens
SKILL.md length
819 words
Files
1
Skills in repo
23
Repo updated
First seen
Licence
MIT

At a glance

Add /compact command for manual context compaction. An agent skill from sbusso/claudeclaw.

  • Works in 3 steps: Pre-flight → Apply Code Changes → Verify
  • Tasks that involve Context engineering
  • SKILL.md covers Phase 1: Pre-flight, Phase 2: Apply Code Changes, Phase 3: Verify and Security Constraints, plus 2 more sections
  • Calls npm, git and claude

What it does

Add Compact is an agent skill from sbusso/claudeclaw. Add /compact command for manual context compaction. Solves context rot in long sessions by forwarding the SDK's built-in /compact slash command. Main-group or trusted sender only.

Its SKILL.md is about 1.8k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in Agent Workflows, covering Context engineering and Hooks and plugins. The repository describes itself as: Use Claude to orchestrate agents like OpenClaw. The licence is MIT.

When your agent uses it

  • Tasks that involve Context engineering
  • Tasks that involve Hooks and plugins

Example prompts

  • “/add-compact”

Requirements

  • Docker

Workflow steps

3 steps, taken from the step headings in SKILL.md.

  1. Pre-flight
  2. Apply Code Changes
  3. Verify

What it can do on your machine

Read from SKILL.md and the folder at commit 1395af4. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • npm
    • git
    • claude

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md. Its commands use npm and git, which can reach the network depending on how they are called.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Add Compact loads about 1.8k tokens when it runs. Until then it costs about 48 tokens; SKILL.md has 819 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~48
When it runs · the whole SKILL.md, loaded when a task matches
~1.8k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from sbusso/claudeclaw at commit 1395af4, republished under its MIT licence (© sbusso). 819 words, ~1,794 tokens.

Download SKILL.mdSave it as .claude/skills/add-compact/SKILL.md (or your agent's skills folder).
name
add-compact
description
Add /compact command for manual context compaction. Solves context rot in long sessions by forwarding the SDK's built-in /compact slash command. Main-group or trusted sender only.

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:

bash
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:

bash
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
bash
npm test
npm run build
Rebuild container
bash
./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
bash
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
Show full SKILL.md (251 more words)Show less
Validation on Fresh Clone
bash
git clone <your-fork> /tmp/claudeclaw-test
cd /tmp/claudeclaw-test
claude  # then run /add-compact
npm run build
npm test
./src/runtimes/docker/build.sh
# Manual: send /compact from main group, verify compaction + continuation
# Manual: send @<assistant> /compact from non-main as non-admin, verify denial
# Manual: send @<assistant> /compact from non-main as admin, verify allowed
# Manual: verify no auto-compaction behavior

Security Constraints

  • Main-group or trusted/admin sender only. The main group is the user's private self-chat and is trusted (see docs/SECURITY.md). Non-main groups are untrusted — a careless or malicious user could wipe the agent's short-term memory. However, the device owner (is_from_me) is always trusted and can compact from any group.
  • No auto-compaction. This skill implements manual compaction only. Automatic threshold-based compaction is a separate concern and should be a separate skill.
  • No config file. ClaudeClaw's philosophy is customization through code changes, not configuration sprawl.
  • Transcript archived before compaction. The existing PreCompact hook in the agent-runner archives the full transcript to conversations/ before the SDK compacts it.
  • Session continues after compaction. This is not a destructive reset. The conversation continues with summarized context.

What This Does NOT Do

  • No automatic compaction threshold (add separately if desired)
  • No /clear command (separate skill, separate semantics — /clear is a destructive reset)
  • No cross-group compaction (each group's session is isolated)
  • No changes to the container image, Dockerfile, or build script

Troubleshooting

  • "Session commands require admin access": Only the device owner (is_from_me) or main-group senders can use /compact. Other users are denied.
  • No compact_boundary in logs: The SDK may not emit this event in all versions. Check the agent-runner logs for the warning message. Compaction may still have succeeded.
  • Pre-compact failure: If messages before /compact fail to process, the error message says "Failed to process messages before /compact." The cursor advances past sent output to prevent duplicates; /compact remains pending for the next attempt.

© sbusso, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in skills/add-compact of sbusso/claudeclaw.

Open the folder on GitHubat commit 1395af4

Compare with similar skills

Add Compact next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Add Compact compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Add Compact this skillsbusso/claudeclaw194—~1.8kAutomated safety check: PassMIT
Plugin Skill Development Guideanthropics/claude-plugins-official38k9 repos~5.6kAutomated safety check: PassApache-2.0
Token-Saver Configurationppgranger/token-saver153—~1kAutomated safety check: PassApache-2.0
Claude Code Mastery Squadohmyjahh/xquads-squads276—~1.1kAutomated safety check: PassMIT
Hook Development for Claude Code Pluginsanthropics/claude-plugins-official38k11 repos~4.1kAutomated safety check: NotesApache-2.0
Claude Code Agent Developmentanthropics/claude-plugins-official38k8 repos~2.8kAutomated safety check: PassApache-2.0

Similar skills

  • Plugin Skill Development Guide

    anthropics/claude-plugins-official

    Official

    Explains how to design and write skills for Claude Code plugins: SKILL.md frontmatter, bundled scripts, references and assets, and descriptions that trigger at the right time.

    38k GitHub starsUsed in 9 repos~5.6k tokens
    Agent WorkflowsAuto-check passed
  • Token-Saver Configuration

    ppgranger/token-saver

    Checks and tunes token-saver output compression: reads stats, explains why a command was or was not compressed, and edits config files or environment variables.

    153 GitHub stars~1k tokensUpdated 19 days ago
    Agent WorkflowsAuto-check passed
  • Claude Code Mastery Squad

    ohmyjahh/xquads-squads

    Routes a request to one of eight specialist agents covering hooks, skills, subagents, MCP integration and context engineering for Claude Code.

    276 GitHub stars~1.1k tokensUpdated 9 days ago
    Agent WorkflowsAuto-check passed
  • Hook Development for Claude Code Plugins

    anthropics/claude-plugins-official

    Official

    Explains how to write Claude Code plugin hooks, both prompt-based checks and bash commands, for events such as PreToolUse, Stop and SessionStart.

    38k GitHub starsUsed in 11 repos~4.1k tokens
    Agent WorkflowsAuto-check: notes
  • Claude Code Agent Development

    anthropics/claude-plugins-official

    Official

    Explains how to write agents for Claude Code plugins: the markdown file with YAML frontmatter, trigger descriptions, model and color settings, and system prompt design.

    38k GitHub starsUsed in 8 repos~2.8k tokens
    Agent WorkflowsAuto-check passed
  • Claude Code Skill Developer Guide

    diet103/claude-code-infrastructure-showcase

    A guide to creating and managing Claude Code skills with auto-activation: skill-rules.json triggers, hooks, enforcement levels, YAML frontmatter and progressive disclosure.

    10k GitHub starsUsed in 11 repos~3.5k tokens
    Agent WorkflowsAuto-check passed

More from sbusso/claudeclaw

All 23 skills in this repo
  • Debug

    sbusso/claudeclaw

    Debug container agent issues. An agent skill from sbusso/claudeclaw.

    194 GitHub starsUsed in 1 repo~3.3k tokens
    Auto-check: notes
  • X Integration

    sbusso/claudeclaw

    X (Twitter) integration for ClaudeClaw. An agent skill from sbusso/claudeclaw.

    194 GitHub stars~3k tokensUpdated 1 mo ago
    Auto-check: notes
  • Add Gmail

    sbusso/claudeclaw

    Add Gmail integration to ClaudeClaw. An agent skill from sbusso/claudeclaw.

    194 GitHub stars~1.9k tokensUpdated 1 mo ago
    Auto-check passed
  • Add Qmd

    sbusso/claudeclaw

    Add QMD (Query Markup Documents) as an advanced memory search backend.

    194 GitHub stars~629 tokensUpdated 1 mo ago
    Auto-check passed
  • Add Telegram

    sbusso/claudeclaw

    Add Telegram as a channel. An agent skill from sbusso/claudeclaw.

    194 GitHub stars~1.7k tokensUpdated 1 mo ago
    Auto-check: notes
  • Add Telegram Swarm

    sbusso/claudeclaw

    Add Agent Swarm (Teams) support to Telegram. An agent skill from sbusso/claudeclaw.

    194 GitHub stars~3.7k tokensUpdated 1 mo ago
    Auto-check: notes

Categories

Questions about Add Compact

What does Add Compact do?

Add /compact command for manual context compaction. An agent skill from sbusso/claudeclaw. Add Compact is an agent skill from sbusso/claudeclaw. Add /compact command for manual context compaction.

When should I use Add Compact?

Add Compact fits situations like: tasks that involve Context engineering; tasks that involve Hooks and plugins.

How do I install Add Compact in Claude Code?

Run `npx skills add sbusso/claudeclaw --skill add-compact -a claude-code`. Or copy the skill folder (skills/add-compact in sbusso/claudeclaw) into .claude/skills/add-compact in your project. Claude Code loads it when a task matches its description.

How do I install Add Compact in Codex?

Run `npx skills add sbusso/claudeclaw --skill add-compact -a codex`. Or copy the skill folder (skills/add-compact in sbusso/claudeclaw) into .agents/skills/add-compact in your project. Codex loads it when a task matches its description.

Can I use Add Compact in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add sbusso/claudeclaw --skill add-compact -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/add-compact, .gemini/skills/add-compact, .github/skills/add-compact and .opencode/skills/add-compact in your project.

What does Add Compact need to run?

Going by SKILL.md and its folder, Add Compact needs the command-line tools its instructions call (npm, git and claude). Our summary lists: Docker.

Does Add Compact access the network?

SKILL.md contains no URLs. Its commands use npm and git, which can reach the network depending on how they are called. This is read from the text; nothing was executed.

Is Add Compact safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Add Compact use?

Add Compact is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Add Compact use?

About 1.8k tokens (SKILL.md is roughly 7.2k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Add Compact?

Skills that share tags, products or a category with Add Compact: Plugin Skill Development Guide (anthropics/claude-plugins-official, 38k stars), Token-Saver Configuration (ppgranger/token-saver, 153 stars), Claude Code Mastery Squad (ohmyjahh/xquads-squads, 276 stars) and Hook Development for Claude Code Plugins (anthropics/claude-plugins-official, 38k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Add Compact?

sbusso (a GitHub user) maintains it in sbusso/claudeclaw, which has 194 GitHub stars. The repository holds 23 skills in this directory. The repository was last updated on August 12, 2026.

Source: sbusso/claudeclaw on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.