{
  "markdown": "# Claude Cost Tracker Plugin\n\nA Claude Code plugin that automatically tracks token usage and cost in real-time. Every tool call is logged to a local SQLite database with developer, project, session, and model metadata -- giving you full visibility into your Claude Code spend.\n\n```\nClaude Code runs a tool (Edit, Bash, Read, Write...)\n        ↓\nPostToolUse hook captures token usage automatically\n        ↓\nWrites to local SQLite with developer, project, model metadata\n        ↓\nQuery via slash command, agent skill, or optional dashboard\n```\n\n## Installation\n\n### From Official Plugin Directory (recommended)\n\nInside Claude Code:\n\n```\n/plugin install claude-cost-tracker@claude-plugins-official\n```\n\nDependencies install automatically on first session start -- no manual `npm install` needed.\n\n### From GitHub\n\n```\n/plugin install https://github.com/MayurBhavsar/claude-cost-tracker-plugin\n```\n\n### Local Development\n\n```bash\ngit clone https://github.com/MayurBhavsar/claude-cost-tracker-plugin.git\ncd claude-cost-tracker-plugin\nclaude --plugin-dir .\n```\n\nAfter installing, start a new Claude Code session to trigger auto-setup.\n\n## What's Included\n\n### PostToolUse Hook (automatic)\n\nFires after every tool call. Captures token counts, calculates cost using the configured model's pricing, and writes a record to `~/.claude-cost-tracker/usage.db`. Also checks alert thresholds and budget caps, firing macOS notifications and stderr warnings when exceeded.\n\nThe hook is non-blocking and pass-through -- it never interferes with Claude Code's operation.\n\n### Slash Command\n\n```\n/claude-cost-tracker:cost-report\n```\n\nGenerates a formatted cost report with today's spend, project breakdown, tool breakdown, and 7-day trend.\n\n```\n/claude-cost-tracker:cost-report csv\n```\n\nIncludes raw CSV export of recent usage data.\n\n### Agent Skill\n\nClaude automatically uses the `cost-status` skill when you ask about spending, costs, or budgets. Just ask naturally:\n\n- \"How much have I spent today?\"\n- \"What's my cost breakdown by project?\"\n- \"Am I within budget?\"\n\n## Features\n\n- **Automatic tracking** -- PostToolUse hook captures every tool call without manual logging\n- **Cost breakdown** -- By developer, project, tool, session, and date\n- **Multi-model pricing** -- Sonnet 4.5, Opus, and Haiku with per-token costs\n- **Budget caps** -- Daily, weekly, and monthly limits with notifications\n- **Cost alerts** -- Configurable thresholds with macOS system notifications\n- **Session grouping** -- Track costs per Claude Code session\n- **Team sharing** -- Optional HTTP server aggregates data from multiple developers\n- **Local by default** -- All data stays on your machine unless you enable optional team sync\n\n## What Makes This Different\n\nMost cost tracking tools give you a number. This plugin gives you actionable intelligence:\n\n- **Full analytics dashboard** -- The only cost tracking plugin that ships a complete web UI with interactive charts, projections, and session drill-down. Not just numbers in a terminal.\n- **Budget enforcement** -- Daily, weekly, and monthly caps with real-time macOS notifications. Not just tracking -- actual enforcement that warns you before you overspend.\n- **Cost projections** -- \"At this rate\" monthly estimate based on 7-day rolling average. Know where you're headed, not just where you've been.\n- **Session intelligence** -- Group costs by Claude Code session with duration and per-tool-call drill-down. See exactly which session burned your budget.\n- **Multi-model awareness** -- Accurate per-token pricing for Sonnet 4.5, Opus, and Haiku with one-command switching. Most trackers assume a single model.\n- **Team aggregation** -- Optional self-hosted server collects data from multiple developers. No third-party cloud service, no data leaving your network.\n- **Three query interfaces** -- Ask Claude naturally (\"how much have I spent?\"), use the slash command (`/claude-cost-tracker:cost-report`), or browse the web dashboard. Pick what fits your workflow.\n\n## Token Pricing\n\n| Model | Input (/1M) | Output (/1M) | Cache Read (/1M) | Cache Create (/1M) |\n|-------|-------------|---------------|-------------------|---------------------|\n| Sonnet 4.5 (default) | $3.00 | $15.00 | $0.30 | $3.75 |\n| Opus | $15.00 | $75.00 | $1.50 | $18.75 |\n| Haiku | $0.80 | $4.00 | $0.08 | $1.00 |\n\nThe active model is stored in `~/.claude-cost-tracker/config.json`. To switch:\n\n```bash\ncd /path/to/claude-cost-tracker-plugin\nnpm run set-model opus\n```\n\n## Optional: Web Dashboard\n\nThe plugin includes a full Next.js analytics dashboard with charts, budgets, projections, and session views.\n\n```bash\ncd /path/to/claude-cost-tracker-plugin\ncd dashboard && npm install && cd ..\nnpm run dashboard\n```\n\nOpen [http://localhost:3000/dashboard](http://localhost:3000/dashboard) to view:\n\n- Daily cost charts with date range filters\n- Cost projection based on 7-day rolling average\n- Budget progress bars (green/amber/red)\n- Session drill-down with per-session cost\n- Developer and project breakdowns\n- Export to CSV or JSON\n\n## Optional: Team Server\n\nFor multi-developer cost tracking, run the team server:\n\n```bash\nnpm run server                              # Start on port 4567\nnpm run configure-remote http://<ip>:4567   # Point hook at team server\n```\n\nThe hook will forward usage records to the team server in addition to writing locally.\n\n## Data Storage\n\nAll data stays on your machine:\n\n- **Database**: `~/.claude-cost-tracker/usage.db` (SQLite)\n- **Config**: `~/.claude-cost-tracker/config.json` (model, remote URL)\n- **Tables**: `usage`, `alerts`, `budgets` (created by hook); `audit_log` (created by dashboard)\n\n## Plugin Structure\n\n```\nclaude-cost-tracker-plugin/\n├── .claude-plugin/\n│   └── plugin.json              # Plugin manifest\n├── hooks/\n│   ├── hooks.json               # PostToolUse hook definition\n│   └── cost-tracker.js          # Hook script (plain JS, no build step)\n├── skills/\n│   └── cost-status/\n│       └── SKILL.md             # Agent skill for cost queries\n├── commands/\n│   └── cost-report.md           # Slash command for reports\n├── db/\n│   └── database.ts              # SQLite schema + queries\n├── server/\n│   └── index.ts                 # Team HTTP server (optional)\n├── scripts/\n│   ├── setup.ts                 # Standalone setup (not needed in plugin mode)\n│   ├── status.ts                # CLI cost summary\n│   ├── set-model.ts             # Switch pricing model\n│   ├── seed-demo.ts             # Populate demo data\n│   ├── reset-db.ts              # Wipe database\n│   └── configure-remote.ts      # Configure team server URL\n├── dashboard/                   # Next.js 14 web dashboard (optional)\n├── package.json\n├── LICENSE\n└── README.md\n```\n\n## CLI Commands\n\nThese scripts work in both plugin mode and standalone mode:\n\n```bash\nnpm run status                    # CLI cost summary\nnpm run set-model sonnet-4.5     # Switch pricing model\nnpm run seed-demo                # Populate demo data for testing\nnpm run reset-db                 # Wipe and recreate the database\n```\n\n## Standalone Mode (Without Plugin System)\n\nIf you're on an older version of Claude Code without plugin support, you can still use this as a standalone tool:\n\n```bash\nnpm run setup    # Registers the hook in ~/.claude/settings.json\n```\n\n## Testing Without Claude Code\n\nSimulate a hook payload to verify the pipeline:\n\n```bash\necho '{\"tool_name\":\"Edit\",\"tool_input\":{\"file_path\":\"/src/app.ts\"},\"tool_output\":{\"usage\":{\"input_tokens\":2000,\"output_tokens\":500,\"cache_read_input_tokens\":1000,\"cache_creation_input_tokens\":0}}}' | node hooks/cost-tracker.js > /dev/null\n```\n\nThen check `npm run status` to confirm the record was written.\n\n## Requirements\n\n- Node.js 18+\n- Claude Code CLI\n- Git (for project name and developer email detection)\n- macOS or Linux\n\n## Troubleshooting\n\n| Problem | Solution |\n|---------|----------|\n| Hook not firing | Start a new session, verify plugin is listed in `/plugin list` |\n| SQLite errors | Check `~/.claude-cost-tracker/` exists and is writable |\n| `better-sqlite3` not found | Restart Claude Code -- the SessionStart hook auto-installs dependencies |\n| Dashboard empty | Run `npm run seed-demo` to populate sample data |\n| No token data | Some tool calls don't include usage data -- handled gracefully |\n\n## License\n\nMIT\n",
  "bytes": 8289,
  "sha": "fc3dfc8f998322c08be78c95d4e801ab3ed38a75c182177d7f32d44cf8bbf22d",
  "repo_slug": "mayurbhavsar/claude-cost-tracker-plugin",
  "fonte": "repo",
  "truncated": false,
  "api": "https://agentalog.com/api/listings/plg_mayurbhavsar_claude_cost_tracker_plugin__12620541/readme"
}