# optimAIzr

> A free, open-source CLI that finds wasted tokens in Claude Code, Codex, opencode and API usage and helps cut spend on the same work.

optimAIzr is a free, MIT-licensed command-line tool that reads the usage logs already on your machine and shows where tokens and dollars go when you use Claude Code, Codex, opencode, or your own Anthropic and OpenAI API calls. It prices each finding in dollars, applies fixes you accept, and measures whether they worked. The project is developed in the open on GitHub and distributed through npm.

## What It Is

optimAIzr is a local token-cost analyzer and optimizer for AI coding agents. Running `optimaizr profile` reads session files from Claude Code, Codex and opencode and reports what your plan does at API-equivalent prices, the savings found, and the biggest win. Findings are split into clear waste, likely savings and up-to savings, which are never added together. Your own app can be covered by wrapping an Anthropic or OpenAI client, or by importing a CSV or JSON usage export.

## Guard and the cache countdown

Claude Code keeps a conversation cached for a limited time, and returning after expiry rewrites the whole context at a higher price. A status line under Claude Code's prompt shows context size, the cost to re-read it and how long the cache stays warm. Guard, enabled through ordinary Claude Code hooks, holds a message to an expired cache once with its price, and lets it through when sent again. Typing `/clear` starts a new conversation from a short note of where the old one stood. Guard also holds whole reads of files over 64KB and a third identical failing command, and nudges `/compact` near the compaction point.

## From finding to measured change

The workflow runs from `profile` and `why` through `recommend`, `simulate`, `verify`, `apply` and `results`. `apply` can set Claude Code and Codex to compact at 200K, and `undo` reverses it. `results` compares cost per prompt after a change against the 3 to 14 days before and marks any trade-offs such as more calls or time waiting on summaries. `verify` replays recorded requests under a cheaper option, using deterministic checks and a pairwise judge. Fourteen detectors cover issues like cache churn, repeat tool calls, model mismatch, error loops and cold resumes.

## Live monitoring and the Claude Code mod

`optimaizr live` shows a row per open conversation with cost so far, cache countdown and warnings. An optional Claude Code mod adds per-turn cost lines, a HUD, handoff notes, and the ability to switch a session to a cheaper model when accepted.

## Privacy and setup

Analysis is local, with no account, telemetry or upload; it reads token counts rather than prompt contents. Network calls are limited to `verify` using your own key, optional opt-in features, and a daily npm version check that can be disabled. It requires Node 20.11 or later, and opencode history needs Node 22.13 or later. The maker describes a hosted Pro version as coming soon and separate from the free CLI.

## Features
- Token and cost profiling for Claude Code, Codex and opencode sessions
- Savings split into clear waste, likely and up-to tiers
- Guard holds expensive messages to expired caches, big file reads and repeated failing commands
- Cache countdown status line under Claude Code's prompt
- Live view of every open conversation
- Session ranking of costliest conversations
- One-command fixes such as compacting at 200K with undo
- Before/after results measurement with trade-offs marked
- Verify replays requests to check a cheaper option
- Fourteen waste detectors
- Optional Claude Code mod with HUD, handoff notes and model switching
- SDK wrap for Anthropic and OpenAI clients and CSV/JSON import
- Monthly budget caps and plan detection
- Local-only analysis with no telemetry

## Integrations
Claude Code, Codex, opencode, Anthropic API, OpenAI API, npm

## Platforms
WINDOWS, MACOS, LINUX, WEB, API, VSC_EXTENSION, DEVELOPER_SDK, CLI

## Pricing
Open Source

## Version
0.12.0

## Links
- Website: https://optimaizr.com
- Documentation: https://www.optimaizr.com/docs
- Repository: https://github.com/blendbunjaku/optimaizr
- EveryDev.ai: https://www.everydev.ai/tools/optimaizr
