Context Optimizer plugin
The context-optimizer plugin shows Claude session cost, trims context and hands file reads and tests to cheap Haiku agents.
- 130 ★ on the repository
- Last commit
- MIT
Extended access
Why this level
- Hooks run on Claude Code events, read transcripts under `~/.claude/projects/` and keep paths and prompt previews in `~/.claude-context-optimizer/`.
- The scout and runner sub-agents run tests, builds and linters.
Install
- Works in
In your terminal, with SkillFoxx CLI
npx skillfoxx add plugins/context-optimizerDetects the agents on your machine, shows the access level and pins the version.
Other ways to install
Access and checks
How we reviewExtended accessThe tool runs code or makes network calls and only reads external data.
- Hooks run on Claude Code events, read transcripts under `~/.claude/projects/` and keep paths and prompt previews in `~/.claude-context-optimizer/`.
- The scout and runner sub-agents run tests, builds and linters.
This is third-party code. Review the repository files before installing.
What it does
The plugin works in three places. In claude.ai chat and the desktop app these are skills Claude picks up by itself: `fresh-start` hands a long chat over to a new one, `doc-digest` condenses a document into a working digest, `project-context` turns repeated background into project instructions, `token-check` sizes text and `sharpen-prompt` tightens a request. In Cowork two Haiku 5.5 sub-agents are added: `scout` reads and searches, `runner` runs tests and builds. Claude Code gets everything, including the `/cco` command: a session board, an audit of your own transcripts, task state that survives `/compact` and cost reports. Hooks skip repeat reads of unchanged files, warn at 50, 70, 85 and 95 percent of the budget and note when a pause let the prompt cache go cold. Read exclusions go into `.contextignore`.
Who it is for. Claude Code and claude.ai users whose long sessions burn through limits quickly and who want numbers on spend.
Good fit when
- A long chat slows down and recalls early details worse: you need a handoff to a new conversation with a short summary.
- Limits drain fast and you want your own transcripts to show where the money went: `/cco audit`.
- The agent reads many files and runs tests, and that is worth handing to a cheap sub-agent.
- You want task state preserved through `/compact` and a warning before the budget runs out.
Not a fit when
- You need hard savings guarantees: the author says read dedup turned out to be rare, and the real wins come from a smaller context and a cheaper model.
- You work in an IDE without Claude Code: hooks and `/cco` need Claude Code, and chat keeps five skills.
- You use Windows without Git Bash or WSL: the hooks need a POSIX shell.
Example request
Show the /cco board and run /cco audit: where did tokens go in my recent sessions?Limitations
The hooks and `/cco` need Node.js 18 or newer and a POSIX shell: macOS and Linux work as they are, Windows needs Git Bash or WSL. Only Read triggers a hook before the tool runs, about 50 to 65 ms per event. Data stays local in `~/.claude-context-optimizer/`: paths and line counts without file contents, a 200-character prompt preview and token counts from the Claude Code transcript. Session history is pruned after 90 days and live-session state after 14. The author reports that in long Opus sessions about 60 percent of cost is cache reads, so real savings depend on your work. The 4.x commands moved under `/cco` in version 5.0.
How to disable. Run `claude plugin uninstall context-optimizer@cco`. Local data sits in `~/.claude-context-optimizer/` and can be deleted separately.
FAQ
How do I install context-optimizer in Claude Code?
Run `claude plugin marketplace add egorfedorov/claude-context-optimizer`, then `claude plugin install context-optimizer@cco` and restart Claude Code. In claude.ai and Cowork add it from the Directory by name, Context Optimizer.
What do the scout and runner sub-agents do?
`scout` reads and searches the project through Read, Grep and Glob and returns a short answer with `path:line` references. `runner` runs tests, builds and linters and reports pass or fail and the failing items. Both run on Haiku 5.5.
Does the plugin send data anywhere?
No. The plugin code makes no network calls and sends no telemetry, and everything is stored in `~/.claude-context-optimizer/`. Only local `git` runs for `/cco git`, `/cco pack` and `/cco anatomy`.
What does /cco audit show?
The command reads your transcripts under `~/.claude/projects/` and prints totals only: where the money went and what the plugin saved, including the cost of its own messages.
How do I reduce the starting context of a session?
`/cco overhead` shows the fixed context every session starts with. `/cco claudemd` and `.contextignore` help trim instructions and keep unneeded files out of reads.
Discussion
No questions or reviews yet.
Related
PluginsA local proxy and plugin for Claude Code and Codex that trims tool output, keeps the prompt cache warm and shows the savings
An installer for a set of hooks, commands and plugins that compress tool output and save tokens in Claude Code.
A plugin that cuts token use in long sessions: prunes stale tool output, picks a subagent model and narrows the skill list.
A Claude Code plugin that replaces built-in file tools with lighter versions so a session spends fewer tokens
An environment for Claude Code that keeps context across sessions via hooks, ledgers and handoffs, orchestrates agents and saves tokens
A file-based context system keeps tasks, decisions and learnings between sessions so an agent never starts from zero.
Comparison with similar tools
Cards that share the main search query, and how they differ.
| Tool | Official | Repository stars | Main difference |
|---|---|---|---|
| Context Optimizer (this card) | no | 130 | |
| Token Optimizer | no | 2,964 | a Claude Code and Codex plugin that keeps work across sessions; this one centers on spend visibility, Haiku sub-agents and skills for claude.ai |
| Claude Token Optimizer: fewer tokens at startup | no | 653 | the cto utility counts startup context and trims CLAUDE.md; this one adds session reports, hooks and the /cco command |
README in short
The README splits features across three environments: chat and the app, Cowork and Claude Code, with a `/cco` command table, a list of automatic actions and upgrade notes from 4.x. A privacy section lists what the plugin stores and which data never leaves the machine. A measurement on real transcripts explains where savings come from.