optimAIzr CLI
A local CLI that shows where tokens go in Claude Code, Codex and opencode and holds back expensive messages
- 237 ★ on the repository
- Last commit
- MIT
Extended access
Why this level
- Reads agent logs in your home directory and the opencode database, though it does not parse prompts by default
- apply changes Claude Code and Codex settings, and guard installs hooks
Install
- Works in
Manual install
npx optimaizrRuns the report without installing; needs Node.js 20.11 or newer.
Access and checks
How we reviewExtended accessThe tool runs code or makes network calls and only reads external data.
- Reads agent logs in your home directory and the opencode database, though it does not parse prompts by default
- apply changes Claude Code and Codex settings, and guard installs hooks
This is third-party code. Review the repository files before installing.
What it does
optimAIzr reads the logs your agents already keep on your machine (~/.claude, ~/.codex, the opencode database) and shows where tokens go: re-reading the conversation, loading context into the cache, answers and code. Bare optimaizr prints the breakdown and a prioritized fix list, and optimaizr apply applies a rule such as compaction at 200K tokens for Claude Code and Codex; undo reverts it. Separate commands cover different jobs. Guard, switched on with optimaizr guard on, holds an expensive message aimed at a cold cache and warns before it is sent. live watches every open conversation, statusline shows the cache countdown under the prompt, why splits spend by model and project, and verify tests a cheaper option on your own requests. There is a VS Code extension and a Claude Code plugin.
Who it is for. Claude Code, Codex and opencode users on Pro, Max or Team plans who want to understand their usage and stretch their window limits.
Good fit when
- The weekly limit or the 5-hour window runs out faster than expected and the reason is unclear
- After a break the cache went cold and the next message costs noticeably more
- You want a spend summary by model, project and kind of work over 30 days
- VS Code shows no status line and you want a cache countdown
Not a fit when
- You need team spend tracking on a server: the tool is local and the hosted dashboard is only announced
- History from opencode 2.0 is not read yet
- You want savings on another provider's API billing: verify calls your provider with your key and costs money
Example request
Run optimaizr and show where my Claude Code tokens went over the last 30 daysLimitations
It requires Node.js 20.11 or newer, and reading the opencode database needs Node 22.13 or newer. The savings estimate of up to 30% is computed from your data and depends on it; the README figures come from the author's own stats. The context-compaction rule changes Claude Code and Codex settings, so read what it touches before applying; undo reverts it.
How to disable. Turn modes off with optimaizr guard off and optimaizr statusline off, revert rules with optimaizr undo <rule>. Then remove the plugin with /plugin uninstall optimaizr and the ~/.optimaizr directory.
FAQ
Do my prompts leave the machine?
No, everything runs locally and is stored in ~/.optimaizr. By default the tool counts tokens and does not read your prompts or Claude's answers. Network calls are the npm version check (disabled with OPTIMAIZR_NO_UPDATE_CHECK=1), verify to your own provider and an optional second opinion.
What does guard do?
optimaizr guard on holds an expensive message that would be written into a cold cache and shows a notice before it is sent. It is built on Claude Code hooks; optimaizr guard lists what it held.
Which agents does it work with?
Claude Code, Codex and opencode 1.x with no setup. opencode history is read from ~/.local/share/opencode/opencode.db. Your own app can use the optimaizr.wrap(new Anthropic()) or new OpenAI() wrapper, plus CSV and JSON usage exports.
How do I get the VS Code extension?
Search for optimAIzr in the VS Code extension marketplace. It shows context, the cache countdown and the 5-hour window in the status bar and warns 5 minutes before the cache expires. It watches Claude Code, while savings cover all three agents.
What does optimaizr card show?
Your last 30 days as an image you can share. It carries the same data as the report, so check which projects and files it names before posting.
Discussion
No questions or reviews yet.
Related
CLI toolsA limits and token spend monitor for Claude Code, Codex, Antigravity and Grok CLI: macOS menu bar, Windows tray, HTML reports
Token and cost reports for Claude Code, Codex, Gemini CLI and other agents from local logs, by day, month and session
A CLI and local dashboard that find token overspend in Claude Code and Codex sessions and suggest concrete fixes
Counts token use and cost of Claude Code and Codex sessions from local logs and shows remaining limits in the status line
TokenTracker counts tokens and spend across Claude Code, Codex, Cursor, Gemini CLI and other agents from local logs and shows them on a local dashboard
The claude-crusts CLI splits a Claude Code context into six categories, finds waste and writes a /compact command for the session.
Comparison with similar tools
Cards that share the main search query, and how they differ.
| Tool | Official | Repository stars | Main difference |
|---|---|---|---|
| optimAIzr (this card) | no | 237 | |
| Token Optimizer | no | 2,964 | a plugin with its own set of context-trimming tricks |
| Claude Token Optimizer: fewer tokens at startup | no | 653 | optimizes Claude token usage, while optimAIzr covers Codex and opencode with reports and rule rollback |
README in short
The README starts with the author's motivation: the conversation is re-read on each call and rewritten to the cache after a pause. Then come npx install, the VS Code extension, protection from expensive messages, one-command fixes, a command table, supported agents, privacy and an announced hosted dashboard.