add-compact

Solid

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.

AI & Automation 29,820 stars 12908 forks Updated today MIT

Install

View on GitHub

Quality Score: 93/100

Stars 20%
100
Recency 20%
100
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
50
License 10%
100
Description 5%
100

Skill Content

# 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 `qwibitai/nanoclaw`. 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 `container/agent-runner/src/index.ts` ### Validate ```bash npm test npm run build ``` ### Rebuild container ```bash ./container/build.sh ``` ### Restart service ```bash launchctl kickstart -k gui/$(id -u)/com...

Details

Author
qwibitai
Repository
qwibitai/nanoclaw
Created
4 months ago
Last Updated
today
Language
TypeScript
License
MIT

Integrates with

Similar Skills

Semantically similar based on skill content — not just same category