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.

Terminal
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

FileWhat Vigil writes
~/.claude/settings.jsonOne key: autoCompactWindow, your default.
project/.claude/settings.local.jsonThat 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 autoCompactWindow or CLAUDE_CODE_AUTO_COMPACT_WINDOW yourself, Vigil changes nothing.

Commands

All optional. Vigil works without them.

CommandWhat it does
/vigil:autoShows the window in use and why it was chosen.
/vigil:auto offRestores your settings exactly and stops managing them.
/vigil:auto onStarts managing the window again.
/vigil:firstThe largest saving it sees, and one next action.
/vigil:keptA weekly report of your use.
/vigil:leversSix aggregate reports on where your context goes.
/vigil:auditLists agents and skills loaded every turn but never used. Moves nothing.
/vigil:handoffA note of goal, decisions, files and next steps to paste into a fresh session.
/vigil:doctorChecks the runtime, hooks, install and private storage.

Troubleshooting

The value didn't change
You set autoCompactWindow yourself, or CLAUDE_CODE_AUTO_COMPACT_WINDOW is 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 on after.

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:

Terminal
claude plugin uninstall vigil@vigil-mcp