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.
Let something else handle the context boundary before compaction kicks in. aigent-os watches context use, and at a threshold (80% by default) it saves a verified checkpoint file called a capsule, runs /clear, and resumes in a fresh session from that capsule. Its shipped settings also set "idleCompaction": false, so Claude Code’s idle compaction can’t replace that step.
Claude Code has a fixed context window. When it fills, your built-in options are auto-compact (the model summarizes the conversation and keeps going on the summary) or /clear (you start over and re-explain). aigent-os takes a third path, called Managed Auto-Refresh:
AIGENT_PRESSURE_THRESHOLD_PCT, default 80).Capsule Complete, Ready For Clear in Claude’s own reply./clear and checks that a fresh session started.No acknowledgement, no clear. If a compaction happens anyway, a PreCompact hook first flushes the latest state into the capsule and hands the compactor pointers into the memory vault.
This isn’t “better than compaction”. It’s a different trade-off: an explicit checkpoint you can read and a clean window, instead of a summary the model wrote.
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.
aigent-os ships settings with idleCompaction set to false, and it refreshes the session at 80% context so compaction is not the path it relies on. If a compaction still happens, a PreCompact hook saves state first.
Use /compact when a summary is good enough. Use /clear when you want a clean window. aigent-os gives you the clean window of /clear without re-briefing by running save, clear and resume for you.
No. The plugin is manual: you run /capsule or /refresh, then /clear yourself. A plugin can’t type /clear for you. Hands-off refresh at a threshold needs the full aigent-os install.