Your limit, stretched.
Vigil replays your own Claude Code sessions, finds the cheapest setting for each project, and sets it for you. Recalculated every day.
Then start a new Claude Code session.
- Free
- MIT
- Nothing leaves your machine
- One-command undo
- GitHub ↗
Vigil for Claude Code
A free, open-source plugin that sets when your Claude Code sessions compact, per project, based on your own usage history.
Each Claude reply re-reads the whole conversation. By default Claude Code only compacts at about 400k tokens, the same for everyone. Vigil compacts earlier, at the point that costs you least, and tells the compaction what to keep.
Install
Run the command at the top of the page in any terminal, or use Claude Code's own plugin commands. Both install the same plugin. Then start a new Claude Code session.
claude plugin marketplace add ssamuels8/vigil-mcp claude plugin install vigil@vigil-mcp
Requirements: Claude Code and Node 22.18 or newer. Tested on macOS and Linux, not yet on Windows.
On first start Vigil writes a safe starting value, 150k, to ~/.claude/settings.json. One line in the terminal says what it set, what was there before, and how to undo it.
How it works
Once a day, in a separate process no session waits on, Vigil reads your local session logs and picks the cheapest compaction window between 100k and 400k, for you and for each project with enough history (about 300 requests and three long sessions).
When a session reaches that window, Claude Code compacts and Vigil tells the compaction to keep:
- the goal
- decisions, and the reasons for them
- files, with line ranges
- the commands used to check the work
- what is unfinished
Your own /compact instructions always win.
Modelled on the author's 138 past sessions: about 21% less weighted use than Claude Code's default. One person, one setup, so your results will differ. How it was measured ↗
Files it touches
| File | What Vigil writes |
|---|---|
~/.claude/settings.json | One key: autoCompactWindow, your default. |
project/.claude/settings.local.json | That project's own window. Personal and git-ignored. |
~/.vigil-mcp/ | Aggregate scan results, optional config, handoff notes. Private to you. |
- Reads usage numbers only from
~/.claude/projects, never your prompts, code or files. - No network calls, no telemetry.
- Your setting wins. If you set
autoCompactWindoworCLAUDE_CODE_AUTO_COMPACT_WINDOWyourself, Vigil changes nothing.
Commands
All optional. Vigil works without them.
| Command | What it does |
|---|---|
/vigil:auto | Shows the window in use and why it was chosen. |
/vigil:auto off | Restores your settings exactly and stops managing them. |
/vigil:auto on | Starts managing the window again. |
/vigil:first | The largest saving it sees, and one next action. |
/vigil:kept | A weekly report of your use. |
/vigil:levers | Six aggregate reports on where your context goes. |
/vigil:audit | Lists agents and skills loaded every turn but never used. Moves nothing. |
/vigil:handoff | A note of goal, decisions, files and next steps to paste into a fresh session. |
/vigil:doctor | Checks the runtime, hooks, install and private storage. |
Troubleshooting
- The value didn't change
- You set
autoCompactWindowyourself, orCLAUDE_CODE_AUTO_COMPACT_WINDOWis set. Vigil leaves your choice alone. - Nothing changed at all
- A settings file that isn't plain JSON is left untouched. Run
/vigil:doctor. - A project uses your personal value
- It gets its own after about 300 requests and three long sessions.
- A session needs every earlier detail
- Run
/vigil:auto off, then/vigil:auto onafter.
Uninstall
Run /vigil:auto off first. It puts back what was in your settings, or removes the key if there was nothing. Then remove the plugin:
claude plugin uninstall vigil@vigil-mcp