A Claude Code plugin that tracks token usage and calculates costs per project. Tracking is on by default — no setup required.
Claude Code doesn't provide per-project cost breakdowns. If you work across multiple repositories — or bill clients for AI-assisted development — you need to know exactly what each project costs.
Client budgets. When a client allocates a fixed budget for AI-assisted work, you need real-time visibility into spend so you don't exceed the agreement. Set the budget with /cmgr budget and get immediate visual feedback when you're approaching the limit.
Invoicing and billing. The per-project cost logs (~/.claude/cost-logs/*.jsonl) provide a timestamped record of every API call — model used, tokens consumed, dollar cost. This data can form the basis of itemized invoices for contract work.
Multi-project awareness. Developers often context-switch across repositories in a single day. /cmgr projects shows a unified view of spend across all tracked projects, so you can see where your budget is going without switching directories.
Persistent across sessions. Cost data is stored on the filesystem, not in conversation memory. Logs survive /clear, session restarts, plugin reinstalls, and machine reboots. Your cost history is never lost.
The plugin is installed through a Claude Code marketplace. Pick whichever source fits — a local clone (for development) or the git repository (for normal use). Both register a marketplace named ck-costmanager, then install the plugin from it.
Use this when you want to run the plugin from a working copy on disk.
- Clone the repository somewhere convenient:
git clone git@github.com:cyckuan/ck-costmanager.git ~/cc/ck-costmanager- Register the clone as a local marketplace and install the plugin:
claude plugin marketplace add ~/cc/ck-costmanager
claude plugin install ck-costmanager@ck-costmanagermarketplace add reads .claude-plugin/marketplace.json from the repo and registers a directory-source marketplace pointing at your clone. Because it points at the directory, git pull in the clone keeps the plugin up to date.
- Restart Claude Code. The Stop hook registers automatically and tracking begins on the next session.
Equivalently, you can do both steps interactively with /plugin → Manage marketplaces → Add marketplace, then install ck-costmanager from it.
Use this for a normal install without keeping a working copy:
claude plugin marketplace add cyckuan/ck-costmanager
claude plugin install ck-costmanager@ck-costmanagermarketplace add accepts an owner/repo shorthand, a full https:// / git@ URL, or a local path. Restart Claude Code after installing.
Uninstall the plugin and, optionally, remove its marketplace:
claude plugin uninstall ck-costmanager@ck-costmanager
claude plugin marketplace remove ck-costmanager # optionalTo also remove cost logs:
rm -rf ~/.claude/cost-logs/| Command | Description |
|---|---|
/cmgr report |
Show cost summary with cumulative chart (current project) |
/cmgr projects |
Show summary of all tracked projects |
/cmgr budget <USD> |
Set session budget (default: $10) |
/cmgr off |
Pause tracking |
/cmgr on |
Resume tracking |
/cmgr reset |
Clear the log for this project |
The header shows the project name derived from the git remote URL (e.g. cyckuan/ck-costmanager). If no git remote exists, the directory name is used. Each project tracks costs independently.
A table showing token counts and costs grouped by model tier:
- Input — prompt tokens sent to the model
- Output — completion tokens generated by the model
- Cache — combined cache write + cache read tokens (prompt caching reduces cost significantly)
- Cost — dollar cost for that tier, calculated from
config/modelcost.jsonrates
Each tier is color-coded: purple for Opus, blue for Sonnet, green for Haiku.
When Claude Code spawns sub-agents (parallel workers, code reviewers, etc.), their token usage is detected from the transcript and reported separately. Shows the total number of sub-agent calls and their combined cost.
Compares total spend against your configured budget. Displays green "Under budget by $X" or bold red "OVER budget by $X". Set the budget with /cmgr budget <amount>.
A terminal-width-responsive area chart showing how cost accumulated over time:
| Element | Description |
|---|---|
| Dot-grid background | Subtle · characters fill empty cells, giving the chart a graph-paper texture so you can gauge scale even in sparse areas |
| Color gradient | The filled area transitions green → yellow → orange → red as spend approaches and exceeds the budget threshold |
| Budget threshold line | A dashed horizontal line (╌) at your budget amount; changes to solid (═) where spend has crossed it |
| Y-axis labels | Dollar values at 25%, 50%, 75%, and 100% of the chart scale, plus the budget line label |
| Session boundary markers | Vertical ╎ ticks appear where a gap in activity suggests a new session (gap > 3× average interval) |
| Current spend marker | A ◆ diamond on the right edge at the current cumulative cost level |
| Time axis | Start and end timestamps at the bottom of the chart |
Shown as $/hr in the bottom-right of the chart area. Calculated as total cost divided by elapsed wall-clock time from first to last API call.
A single-line miniature chart using block characters (▁▂▃▄▅▆▇█) with the same gradient coloring. Shows the budget utilization percentage. Useful as a quick visual summary.
The report adapts its color scheme to your current Claude Code theme (dark or light). Colors are read from config/colors.json and the active theme is detected from ~/.claude/settings.json. Edit config/colors.json to customize.
Each project is tracked independently. /cmgr report always shows the current project; /cmgr projects shows a summary across all tracked projects:
- Current project marked with
▸ - Cost, budget, and budget utilization percentage per project
- Grand total across all projects
- Last activity timestamp
Projects are identified by git remote URL (e.g. cyckuan/ck-costmanager). If no git remote is found (non-git directories), the full working directory path is used as the project identifier.
A Stop hook fires after each turn and parses the session transcript to extract token usage (input, output, cache write, cache read) per API call. Usage is logged per-project, identified by git remote or working directory path.
Multiple Claude Code sessions in different repos track independently.
Cost logs are written to the filesystem (~/.claude/cost-logs/), not stored in conversation context. This means:
/clearsafe — clearing conversation history does not affect cost data- Restart safe — quitting and restarting Claude Code picks up where it left off
- Reinstall safe — logs are outside the plugin directory and survive plugin removal/reinstall
- Multi-session safe — different terminal sessions writing to the same project append to the same log file
The only way to lose data is to manually delete the log files or run /cmgr reset.
Cost tracking supports teams of developers working on shared projects. Each log entry includes the developer's identity (git username, with OS username as fallback), so costs can be attributed per person.
Point all team members at a shared location by setting the CLAUDE_COST_LOG_DIR environment variable:
export CLAUDE_COST_LOG_DIR=/mnt/shared/claude-costsAdd this to each developer's shell profile. All team members will append to the same per-project log files, with each entry tagged by username. This enables:
- Per-developer cost breakdowns on shared projects
- Team-wide budget tracking
- Centralized data for invoicing and reporting
The shared directory can be a network mount, a synced folder (Dropbox, Google Drive), or any path accessible to all team members.
Each line in a .jsonl log file contains:
{"ts":1717400000000,"user":"alice","model":"opus","input":5000,"output":1200,"cacheWrite":1000,"cacheRead":8000,"isSubagent":false}The user field is the git user.name of the developer who generated the tokens, falling back to the OS username if git is not configured.
By default, logs are stored in ~/.claude/cost-logs/. Override with the CLAUDE_COST_LOG_DIR environment variable. Each project gets one .jsonl file plus a shared state.json for tracking offsets and budgets.
Pricing is configured in config/modelcost.json (per million tokens):
| Model | Input | Output | Cache Write | Cache Read |
|---|---|---|---|---|
| Haiku | $0.80 | $4.00 | $1.00 | $0.08 |
| Sonnet | $3.00 | $15.00 | $3.75 | $0.30 |
| Opus | $15.00 | $75.00 | $18.75 | $1.50 |
Edit this file to update pricing when rates change.
MIT

