Add compact

From sliamh11/Deus · View interactive version

Add compact is an AI agent skill from the GitHub repository sliamh11/Deus. 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.

How to use this skill

Skill file

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

Check if the compact feature files are already present in the local codebase:

test -f src/session-commands.ts && echo "Already present" || echo "Not present"

If not present, the compact feature needs to be implemented locally. The following files are involved:

Validate

npm test
npm run build

Rebuild container

./container/build.sh

Restart service

launchctl kickstart -k gui/$(id -u)/com.deus  # macOS
# Linux: systemctl --user restart deus

Phase 3: Verify

Integration Test

  1. Start Deus in dev mode: npm run dev
  2. From the main group (self-chat), send exactly: /compact
  3. Verify:
  1. From a non-main group as a non-admin user, send: @<assistant> /compact
  2. Verify:
  1. From a non-main group as the admin (device owner / is_from_me), send: @<assistant> /compact
  2. Verify:
  1. While an active container is running for the main group, send /compact
  2. Verify:
  1. Send a normal message, then /compact, then another normal message in quick succession (same polling batch):
  2. Verify:
  1. From a non-main group as a non-admin user, send @<assistant> /compact:
  2. Verify:
  1. From a non-main group (with requiresTrigger enabled) as a non-admin user, send bare /compact (no trigger prefix):
  2. Verify:
  1. After compaction, verify no auto-compaction behavior — only manual /compact triggers it

Validation on Fresh Clone

git clone <your-fork> /tmp/deus-test
cd /tmp/deus-test
claude  # then run /add-compact
npm run build
npm test
./container/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

What This Does NOT Do

Troubleshooting

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.