CLI tools and utilities for measuring, tracking, and reducing Claude Code costs.
| Tool | Language | Purpose | Install |
|---|---|---|---|
| claude-rate | Python (stdlib only) | Local Claude / AI setup rater -- 7 categories, 0-100 score, A+ to F grade, copy-pasteable fixes, monthly-cost projection per model | curl | sh one-shot |
| Token Estimator | Python | Estimate token count and cost for files | pip install tiktoken |
| Usage Analyzer | Python | Analyze session data for cost hotspots | stdlib only |
| Badge Generator | Python | Grade project config (A+ to F) -- precursor to claude-rate, 4-category | stdlib only |
| MCP Cost Server | TypeScript | In-session cost estimation via MCP | npm install |
| VS Code Extension | TypeScript | Status bar token/cost display | npm install |
| /optimize Command | Markdown | Claude Code custom command for auditing | Copy to .claude/commands/ |
| GitHub Action | Python | CI cost audit for PRs | Use in workflow YAML |
All Python tools require Python 3.10+. The token estimator needs tiktoken:
pip install -r ../requirements.txtThe other Python tools use stdlib only -- no install needed.
# Rate the entire project's Claude/AI setup (recommended starting point)
python claude-rate/rate.py .
# Or via curl (no clone needed):
curl -sSL https://raw.githubusercontent.com/Sagargupta16/claude-cost-optimizer/main/tools/claude-rate/install.sh | sh -s -- .
# Estimate tokens for a file
python token-estimator/estimate.py path/to/file.py
# Analyze usage data
python usage-analyzer/analyze.py ~/.claude/projects/
# Grade a project (legacy, 4-category)
python badge-generator/generate.py /path/to/project# MCP Cost Server
cd mcp-cost-server && npm install && npm run build
# VS Code Extension
cd vscode-extension && npm install && npm run compileBrowser-based versions (Cost Calculator, Badge Checker, Repo Analyzer) are built in ../site/ but not yet live on the deployed site -- use claude-rate locally in the meantime.