cost-optimize

cost-optimize is a skill for Claude Code from ChewbaccaRoars/claude-code-cost-tracker. It costs 52 tokens per session (483 once invoked), scanned A, original, MIT.

A cost-analysis skill for finding ways to reduce spending on Claude Code by examining usage logs.

In plain words
What is it for?
It helps review spending for a day, week, month, or all recorded usage and produces recommendations based on model, project, session, time, and context patterns.
Why use it?
It identifies expensive usage patterns such as using a costly model for routine work, oversized context, inefficient caching, or unnecessary subagents.

Skill for Claude Code

Written for Claude Code: allowed-tools in frontmatter. Also seen: reads .claude/ paths; mentions subagents; mentions Claude Code.

Runs only inside its plugin — its command needs a path that Claude Code sets for a plugin’s own hooks and for nothing else. Install the plugin, not this.

Part of the cost-tracker plugin — 6 skills, 3 hooks shipped together

Install

Getting it into your agent

This one installs as part of its plugin. Adding the marketplace and installing the plugin brings it with everything else the plugin ships.

Claude Code
/plugin marketplace add ChewbaccaRoars/claude-code-cost-tracker
Claude Code
/plugin install cost-tracker

Made for: Claude Code.

Or install cost-tracker, the plugin that ships this one along with the rest of its 6 skills, 3 hooks.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for cost-optimize

README.md
[![agentmods](https://agentmods.dev/badge/skills/chewbaccaroars/claude-code-cost-tracker/cost-optimize.svg)](https://agentmods.dev/skills/chewbaccaroars/claude-code-cost-tracker/cost-optimize)
Your own site
<a href="https://agentmods.dev/skills/chewbaccaroars/claude-code-cost-tracker/cost-optimize"><img src="https://agentmods.dev/badge/skills/chewbaccaroars/claude-code-cost-tracker/cost-optimize.svg" alt="Measured on agentmods" height="20"></a>
Per session 52 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 483 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00052 $0.00483
Opus 5 $0.00026 $0.00242
Sonnet 5 $0.00010 $0.00097
Haiku 4.5 $0.00005 $0.00048

Measured 6d ago against content hash 7cae91c6d3f0, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-06, from the pricing page.

Security

Grade A, and why

cost-optimize scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 6d ago.

The scan reads SKILL.md. This mod also ships 1 executable file (scripts/recommend.js), listed below but not scanned — reading those needs a real analyzer, not pattern matching.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

plugins/cost-tracker/skills/cost-optimize/SKILL.md · 48 lines

What it actually says

Cost Optimizer - Smart Spending Recommendations

You are a cost optimization advisor. The user wants actionable recommendations to reduce their Claude Code spending based on their actual usage patterns.

How It Works

The optimizer analyzes the user's cost log and identifies specific patterns:

  • Model tier mismatches — Opus sessions that could run on Sonnet
  • Cache inefficiency — short sessions that waste cache warmup costs
  • Context bloat — sessions with excessive context window usage
  • Project patterns — projects using expensive models for routine work
  • Session name patterns — correlating task types (debug, review, docs) with costs
  • Time patterns — when the most expensive sessions happen
  • Subagent overhead — multi-model session cost patterns

Running the Analyzer

node "${CLAUDE_PLUGIN_ROOT}/skills/cost-optimize/scripts/recommend.js" $ARGUMENTS

Available arguments: today, week, month, all (default: all)

Instructions

  1. Run the recommendation script with the user's requested time range
  2. Present the findings directly — the output is pre-formatted markdown
  3. If the user asks follow-ups, read ~/.claude/cost-tracker/cost-log.jsonl and analyze specific patterns they're interested in
  4. Be specific and actionable — don't just say "use a cheaper model," explain WHEN and WHY based on their data

Key Principles

  • Every recommendation must reference the user's actual data (session counts, dollar amounts)
  • Savings estimates should be conservative — underpromise and overdeliver
  • Recommendations should be easy to act on: specific commands, settings, or workflow changes
  • Never recommend downgrading when it would hurt quality — acknowledge when Opus is worth the cost
  • Consider the user's workflow holistically — a session that costs more but saves developer time is still a good trade
Files

What ships with it

1 file beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 6d ago First seen · 48 lines · 52 tokens per session scan A 7cae91c6d3f0

Subscribe to this mod's changes

cost-optimize is a skill published in the GitHub repository ChewbaccaRoars/claude-code-cost-tracker (6 stars, last pushed 2mo ago), licensed MIT. It adds 52 tokens to every session and 483 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.