Claude Code harness and alternative to context compaction: at 80% context it writes a verified capsule, runs /clear and resumes with persistent memory in git.
Claude Code itself only compacts automatically; /clear is manual. aigent-os adds the missing loop: at a threshold (80% by default) it gets a capsule and an exact acknowledgement from Claude, sends one /clear, waits for the new session’s SessionStart receipt, and resumes from the capsule.
The aigent launcher runs Claude Code under a local runner (daemons/pty-runner.mjs, using node-pty). Each piece has one job:
daemons/ctx-telemetry.mjs records the current context percentage.skills/context-capsule/SKILL.md writes and checks the capsule, then prints the exact acknowledgement line.daemons/auto-clear-transport.mjs holds the one-cycle authorization, so one acknowledgement buys at most one clear.daemons/boot-receipt.mjs and daemons/sessionstart-reinject.mjs confirm the fresh session.daemons/resume-verb.mjs loads the newest valid capsule.The rules are strict on purpose. The acknowledgement has to be an exact line in a text block of Claude’s own reply, so talking about clearing doesn’t count. An acknowledgement only covers its own cycle. If operator input interrupts a prepared clear, the runner stops at HOLD:clear-stalled-after-ack with a visible notice instead of guessing. There’s no automatic retry.
Change the threshold with AIGENT_PRESSURE_THRESHOLD_PCT. Turn automatic input off per seat with AUTO_CLEAR_OFF=1 or the runtime/auto-clear-off marker. If node-pty can’t load (or you install with --no-deps), Claude still starts and the launcher tells you automatic clear is unavailable.
Full install (needs Claude Code, Node.js 18+ with npm, and bash; on Windows use Git Bash):
git clone https://github.com/wrg32786/aigent-os.git && cd aigent-os && bash install.sh --dry-run
The dry run prints the planned changes and writes nothing. When it looks right, run bash install.sh, open a new terminal and run aigent.
Just want the manual capsule commands? Install the context-capsule plugin inside Claude Code:
/plugin marketplace add wrg32786/aigent-os
/plugin install context-capsule@aigent-os
Full list: the Known limits section of the v1.1.0 release notes.
Not in Claude Code itself; it only compacts automatically. aigent-os adds an auto clear loop: capsule, exact acknowledgement, one /clear, fresh session check, resume.
80% by default, configurable with the AIGENT_PRESSURE_THRESHOLD_PCT environment variable.
Then there is no clear. No acknowledgement means no clear, and one acknowledgement buys one clear.