{"id":47713745,"url":"https://github.com/loplop-h/spent","last_synced_at":"2026-04-05T22:00:43.558Z","repository":{"id":347909330,"uuid":"1195708499","full_name":"loplop-h/spent","owner":"loplop-h","description":"Claude Code session cost tracker. Efficiency score, productive vs wasted breakdown, live terminal dashboard.","archived":false,"fork":false,"pushed_at":"2026-04-04T14:35:34.000Z","size":754,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2026-04-04T21:42:57.884Z","etag":null,"topics":["ai","anthropic","claude-code","cli","developer-tools","efficiency","llm","monitoring","python","session-tracker","tui"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/loplop-h.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-03-30T01:35:25.000Z","updated_at":"2026-04-04T18:17:34.000Z","dependencies_parsed_at":"2026-04-04T21:00:37.352Z","dependency_job_id":null,"html_url":"https://github.com/loplop-h/spent","commit_stats":null,"previous_names":["loplop-h/spent"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/loplop-h/spent","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loplop-h%2Fspent","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loplop-h%2Fspent/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loplop-h%2Fspent/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loplop-h%2Fspent/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/loplop-h","download_url":"https://codeload.github.com/loplop-h/spent/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loplop-h%2Fspent/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31451446,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-05T21:22:52.476Z","status":"ssl_error","status_checked_at":"2026-04-05T21:22:51.943Z","response_time":75,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai","anthropic","claude-code","cli","developer-tools","efficiency","llm","monitoring","python","session-tracker","tui"],"created_at":"2026-04-02T18:46:20.025Z","updated_at":"2026-04-05T22:00:43.262Z","avatar_url":"https://github.com/loplop-h.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003ch1 align=\"center\"\u003espent\u003c/h1\u003e\n  \u003cp align=\"center\"\u003e\u003cstrong\u003eSee what your Claude Code sessions really cost.\u003c/strong\u003e\u003c/p\u003e\n  \u003cp align=\"center\"\u003eEfficiency score. Productive vs wasted breakdown. Live terminal dashboard.\u003c/p\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://pypi.org/project/spent/\"\u003e\u003cimg src=\"https://img.shields.io/pypi/v/spent?style=flat-square\" alt=\"PyPI\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://pypi.org/project/spent/\"\u003e\u003cimg src=\"https://img.shields.io/pypi/pyversions/spent?style=flat-square\" alt=\"Python\"\u003e\u003c/a\u003e\n  \u003ca href=\"LICENSE\"\u003e\u003cimg src=\"https://img.shields.io/badge/license-MIT-blue?style=flat-square\" alt=\"License\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://github.com/loplop-h/spent/stargazers\"\u003e\u003cimg src=\"https://img.shields.io/github/stars/loplop-h/spent?style=flat-square\" alt=\"Stars\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n---\n\nYou use Claude Code every day. Do you know how much each session costs? Which tool uses are productive and which are wasted?\n\n**spent** tracks every tool use, classifies it as productive, neutral, or wasted, and gives you an efficiency score. No API keys. No external services. Everything runs locally from Claude Code's own hook system.\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://raw.githubusercontent.com/loplop-h/spent/master/docs/tui-screenshot.png\" alt=\"spent TUI dashboard\" width=\"600\"\u003e\n\u003c/p\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003eWeb dashboard\u003c/strong\u003e\u003c/summary\u003e\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://raw.githubusercontent.com/loplop-h/spent/master/docs/web-dashboard.png\" alt=\"spent web dashboard\" width=\"700\"\u003e\n\u003c/p\u003e\n\u003c/details\u003e\n\n## Quick Start\n\n```bash\npip install spent\nspent cc setup    # install Claude Code hooks (once)\nspent cc live     # open dashboard in a side terminal\n```\n\nThat's it. `spent cc setup` installs three hooks into `~/.claude/settings.json`:\n\n- **PostToolUse** -- logs every tool invocation (Edit, Read, Bash, Grep, etc.)\n- **SessionStart** -- marks when a session begins\n- **Stop** -- marks session end and writes the final summary\n\nRestart Claude Code after setup. Costs are tracked automatically from that point.\n\n## Features\n\n| Feature | Status |\n|---------|--------|\n| Per-session cost tracking | Done |\n| Efficiency score (0-100) | Done |\n| Productive / neutral / wasted classification | Done |\n| Live terminal dashboard (`spent cc live`) | Done |\n| Per-tool cost breakdown | Done |\n| Session history and trends | Done |\n| Web dashboard (`spent cc dashboard`) | Done |\n| Efficiency tips | Done |\n| Claude Code skill (`/spent`) | Done |\n| Statusline integration | Done |\n| JSON export | Done |\n| Multi-model pricing (Opus, Sonnet, Haiku) | Done |\n| Cost anomaly detection | Roadmap |\n| Team cost aggregation | Roadmap |\n| CI usage reports | Roadmap |\n\n## How It Works\n\nClaude Code hooks fire on every tool use. spent logs each event to a local JSONL file at `~/.spent/claude-sessions.jsonl` with:\n\n- Timestamp\n- Tool name (Edit, Read, Bash, Grep, Glob, Agent, etc.)\n- Input/output character counts\n- Session ID\n- Model identifier\n\nFrom this log, spent estimates token counts (characters / 4, plus context overhead that grows with conversation length) and calculates cost using Claude model pricing:\n\n| Model | Input (per 1M tokens) | Output (per 1M tokens) |\n|-------|----------------------|------------------------|\n| Opus | $15.00 | $75.00 |\n| Sonnet | $3.00 | $15.00 |\n| Haiku | $0.80 | $4.00 |\n\nNo API calls. No network requests. Everything is estimated locally from hook data.\n\n## Commands\n\n```bash\n# Setup (run once)\nspent cc setup          # install hooks + statusline\n\n# Live monitoring\nspent cc live           # full-screen terminal dashboard (side pane)\nspent cc status         # quick panel with score + cost + breakdown\nspent cc score          # one-line efficiency score\n\n# Session history\nspent cc history        # last 7 days of sessions\nspent cc history -d 30  # last 30 days\nspent cc tips           # efficiency tips for current session\n\n# Web dashboard\nspent cc dashboard      # open browser dashboard (localhost:5050)\n\n# Controls\nspent cc on             # enable tracking\nspent cc off            # disable tracking\n\n# Data\nspent session           # current session detail\nspent session --today   # all sessions from today\nspent session --json    # machine-readable output\nspent reset             # delete all tracked data\n```\n\n## Efficiency Scoring\n\nEvery tool use is classified into one of three categories:\n\n### Productive\n\nActions that produce code or move work forward.\n\n- **Edit** / **Write** / **MultiEdit** -- code written or modified\n- **Agent** -- task delegation\n- **Bash** -- commands that succeed (no error indicators)\n\n### Neutral\n\nInformation gathering. Necessary but not directly productive.\n\n- **Read** / **Grep** / **Glob** -- searching and reading files\n- **TodoRead** / **TodoWrite** -- task management\n- **WebSearch** / **WebFetch** -- research\n\n### Wasted\n\nActions that cost tokens but didn't advance the task.\n\n- **Bash** with error output -- failed commands, stack traces\n- **Read** of the same file within 60 seconds -- redundant reads\n- **Edit** of the same file within 30 seconds of another Edit -- rapid re-edits (usually fixing a mistake)\n\nThe efficiency score is a weighted formula:\n\n```\nscore = ((productive * 1.0) + (neutral * 0.5) + (wasted * 0.0)) / total * 100\n```\n\nA score of 70+ is good. Below 40 means a lot of time is going to failed attempts and re-work.\n\n## Claude Code Skill\n\nspent includes a `/spent` skill for use directly inside Claude Code sessions:\n\n```\n/spent              # show current session costs and efficiency\n```\n\nThe skill is automatically available if spent is installed. It reads the same JSONL log and displays a formatted summary without leaving your Claude Code session.\n\n## Privacy\n\n- All data stays on your machine at `~/.spent/`\n- No external API calls, no telemetry, no network requests\n- Hook scripts run locally as async shell commands\n- The JSONL log contains only tool names, character counts, and timestamps -- no file contents, no prompts, no code\n\n## Roadmap\n\n- [ ] **Cost anomaly detection** -- alert when a session is burning tokens faster than usual\n- [ ] **Team dashboards** -- aggregate costs across team members\n- [ ] **CI usage reports** -- cost per PR, cost per branch\n- [ ] **Session comparison** -- compare efficiency across sessions\n- [ ] **Custom classification rules** -- let users define their own productive/wasted rules\n- [ ] **Notification thresholds** -- alert when session cost exceeds a limit\n\n## Contributing\n\nContributions welcome. See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.\n\n```bash\ngit clone https://github.com/loplop-h/spent.git\ncd spent\npip install -e \".[dev]\"\npytest\n```\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Floplop-h%2Fspent","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Floplop-h%2Fspent","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Floplop-h%2Fspent/lists"}