{"id":30717809,"url":"https://github.com/spences10/claude-code-analytics","last_synced_at":"2026-05-09T06:02:42.190Z","repository":{"id":312471431,"uuid":"1047603654","full_name":"spences10/claude-code-analytics","owner":"spences10","description":"👀 Local-first analytics and statusline for Claude Code - capture sessions, tool calls, costs, and performance into SQLite for fast, actionable insights.","archived":false,"fork":false,"pushed_at":"2026-04-10T05:03:36.000Z","size":249,"stargazers_count":10,"open_issues_count":7,"forks_count":3,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-04-10T07:14:56.045Z","etag":null,"topics":["analytics","claude","claude-code","cli","sqlite","statusline"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/spences10.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"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":"2025-08-30T19:39:36.000Z","updated_at":"2026-03-20T13:22:15.000Z","dependencies_parsed_at":"2025-08-30T22:08:00.884Z","dependency_job_id":"d9f79b23-9c82-4f8b-b7bf-5cbbb9b02104","html_url":"https://github.com/spences10/claude-code-analytics","commit_stats":null,"previous_names":["spences10/claude-code-analytics"],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/spences10/claude-code-analytics","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spences10%2Fclaude-code-analytics","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spences10%2Fclaude-code-analytics/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spences10%2Fclaude-code-analytics/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spences10%2Fclaude-code-analytics/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/spences10","download_url":"https://codeload.github.com/spences10/claude-code-analytics/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spences10%2Fclaude-code-analytics/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32809147,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-08T08:22:46.396Z","status":"online","status_checked_at":"2026-05-09T02:00:06.633Z","response_time":123,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["analytics","claude","claude-code","cli","sqlite","statusline"],"created_at":"2025-09-03T09:02:07.217Z","updated_at":"2026-05-09T06:02:42.183Z","avatar_url":"https://github.com/spences10.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Claude Code Analytics\n\nThis is Claude Code Analytics! It uses ClaudeCode statusline and\nClaude Code hooks to store information about your Claude Code sessions\nin a local SQLite database.\n\n## Hook-Driven Architecture\n\n**Why use hooks instead of just reading statusline data?**\n\nThe statusline updates every 300ms, so we _could_ do all analytics\ncalculations in real-time. But this marvellous monstrosity explores a\ndifferent approach:\n\n- **Hooks do heavy lifting** during natural Claude Code pauses\n  (PostToolUse, UserPromptSubmit)\n- **Statusline stays responsive** with sub-millisecond lookups of\n  pre-computed data\n- **True zero-impact analytics** - expensive queries happen when\n  Claude Code is already waiting\n- **Separation of concerns** - data processing vs. display logic\n\nThe result? A statusline that can show complex productivity insights,\ncache efficiency metrics, and sparkline visualizations without ever\nslowing down your workflow.\n\n_Sometimes the best solution is the most over-engineered one!_ 😂\n\nThere's a CLI for reports and analytics, for example Cost Analytics...\n\n```ascii\n◇  How many days to analyze?\n│  7\n\nCost Trend (Last 7 Days)\n\n   $21.47    ┤                           ╭────────────────╮\n   $19.55    ┤                         ╭─╯                ╰──╮\n   $17.63    ┤                       ╭─╯                     ╰──╮\n   $15.71    ┤                     ╭─╯                          ╰──╮\n   $13.78    ┤                  ╭──╯                               ╰───╮\n   $11.86    ┤                ╭─╯                                      ╰─\n    $9.94    ┤             ╭──╯\n    $8.02    ┤   ╭─────────╯\n    $6.10    ┼───╯\n\nTotal Cost        │$68.11\nTotal Sessions    │87\nAvg Cost/Session  │$0.78\nDaily Average     │$9.73\n```\n\nActivity patterns...\n\n```ascii\n◇  How many days to analyze?\n│  7\n\nActivity Heatmap (Last 7 Days)\n\nTotal: 88 sessions across 5 days\nPeak: 13 sessions on 2025-08-27 at 20:00\n\n    00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23\nSun ░░ ░░ ░░ ░░ ░░ ░░ ░░ ░░ ░░ ░░ ░░ ░░ ░░ ░░ ░░ ░░ ░░ ░░ ░░ ░░ ░░ ░░ ░░ ░░\nMon ░░ ░░ ░░ ░░ ░░ ░░ ░░ ░░ ░░ ░░ ░░ ░░ ░░ ░░ ░░ ░░ ░░ ░░ ░░ ░░ ░░ ░░ ░░ ░░\nTue ░░ ░░ ░░ ░░ ░░ ░░ ░░ ░░ ▓▓ ▓▓ ▓▓ ░░ ░░ ░░ ░░ ░░ ▓▓ ░░ ░░ ▓▓ ░░ ░░ ░░ ░░\nWed ░░ ░░ ░░ ░░ ░░ ░░ ░░ ▓▓ ░░ ░░ ░░ ░░ ░░ ░░ ░░ ░░ ░░ ░░ ▓▓ ░░ ██ ▓▓ ░░ ░░\nThu ░░ ░░ ░░ ░░ ░░ ░░ ░░ ░░ ▓▓ ██ ░░ ░░ ░░ ░░ ░░ ░░ ▓▓ ▓▓ ▓▓ ▓▓ ░░ ░░ ░░ ░░\nFri ░░ ░░ ░░ ░░ ░░ ▓▓ ▓▓ ▓▓ ▓▓ ░░ ░░ ▓▓ ░░ ░░ ░░ ░░ ▓▓ ░░ ░░ ░░ ░░ ░░ ░░ ░░\nSat ░░ ░░ ░░ ░░ ░░ ░░ ░░ ░░ ░░ ▓▓ ░░ ░░ ░░ ░░ ░░ ░░ ░░ ▓▓ ░░ ▓▓ ▓▓ ▓▓ ░░ ░░\n\n██ High (9+)  ▓▓ Medium (5-9)  ░░ Low (0-5)\n\nTop Activity Hours:\n  1. Wed 20:00 (2025-08-27): 13 sessions\n  2. Thu 09:00 (2025-08-28): 9 sessions\n  3. Tue 10:00 (2025-08-26): 8 sessions\n  4. Thu 18:00 (2025-08-28): 7 sessions\n  5. Thu 16:00 (2025-08-28): 6 sessions\n```\n\n## Installation\n\nInstall globally with your preferred package manager:\n\n```bash\n# npm\nnpm install -g claude-code-analytics\n\n# pnpm\npnpm add -g claude-code-analytics\n\n# bun\nbun add -g claude-code-analytics\n\n# volta\nvolta install claude-code-analytics\n```\n\n## First Run (Onboarding)\n\nRun interactive setup to install the statusline and hooks:\n\n```bash\nclaude-code-analytics config\n```\n\nThis lets you:\n\n- Install the statusline and/or lightweight hooks in\n  `~/.claude/settings.json`.\n- Enable or disable local data collection in\n  `~/.claude/claude-code-analytics.json`.\n\nNote: Running `claude-code-analytics` with no arguments is intended\nfor Claude Code statusline integration and isn’t useful on its own in\na terminal. Use subcommands like `config`, `analytics`, or\n`quick-stats`.\n\nTip: To confirm the CLI is available on your PATH, try:\n\n```bash\nclaude-code-analytics -h\n```\n\nThis should print the help text.\n\n## Commands\n\n- `claude-code-analytics config`: Interactive configuration\n  (statusline, hooks, settings).\n- `claude-code-analytics analytics`: Interactive analytics dashboard\n  (tables and ASCII charts).\n- `claude-code-analytics quick-stats`: One-shot 7‑day summary.\n- `claude-code-analytics install | uninstall`: Install/remove\n  statusline and hooks without prompts.\n- `claude-code-analytics --help | --version`: Show help/version.\n\nDefault behaviour: When invoked without arguments (or by Claude Code),\nthe binary runs in statusline mode.\n\n## Usage\n\n- Use Claude Code normally. The statusline and hooks record session\n  metadata locally for analytics.\n- View analytics anytime with `claude-code-analytics analytics` or a\n  quick summary with `claude-code-analytics quick-stats`.\n\n## Data \u0026 Privacy\n\n- Database: `~/.claude/claude-code-analytics.db` (SQLite, local-only).\n- Config: `~/.claude/claude-code-analytics.json`.\n- Claude integration: `~/.claude/settings.json` (non-destructive; only\n  our entries).\n- No telemetry or network calls.\n\nTo disable collection, set `data_collection: false` in\n`~/.claude/claude-code-analytics.json`.\n\n### Per‑Project Configuration\n\nYou can override settings per project with a local config file at:\n\n- `\u003cproject\u003e/.claude/claude-code-analytics.json`\n\nExample (this repo):\n`claude-code-analytics/.claude/claude-code-analytics.json`\n\nProject config deep‑merges over the global config. Useful for:\n\n- Disabling collection in a specific repo\n- Customizing the statusline layout per project\n\nExample:\n\n```json\n{\n\t\"data_collection\": true,\n\t\"display\": {\n\t\t\"layout\": [\n\t\t\t[\"git\", \"model\"],\n\t\t\t[\"cost\", \"duration\", \"lines_changed\"]\n\t\t]\n\t}\n}\n```\n\n## Theming \u0026 Display\n\nYou can customize the statusline’s look globally or per‑project.\n\n- Config files:\n  - Global: `~/.claude/claude-code-analytics.json`\n  - Project: `\u003cproject\u003e/.claude/claude-code-analytics.json` (overrides\n    global)\n\nDisplay keys\n\n- `display.theme`: `minimal` (default), `ascii`, or `emoji`\n- `display.icons`: enable/disable icons globally (default: true)\n- `display.powerline`: boolean (auto‑detect when omitted)\n- `display.icon_overrides`: map of symbol name → string\n- `display.layout`: string[][] to control segment order and lines\n\nExamples\n\nMinimal (default) with Powerline forced:\n\n```json\n{\n\t\"display\": {\n\t\t\"theme\": \"minimal\",\n\t\t\"powerline\": true\n\t}\n}\n```\n\nPure ASCII:\n\n```json\n{\n\t\"display\": {\n\t\t\"theme\": \"ascii\",\n\t\t\"icons\": true\n\t}\n}\n```\n\nEmoji (opt‑in) with simple overrides:\n\n```json\n{\n\t\"display\": {\n\t\t\"theme\": \"emoji\",\n\t\t\"icon_overrides\": {\n\t\t\t\"branch\": \" \",\n\t\t\t\"ahead\": \"↑\",\n\t\t\t\"behind\": \"↓\"\n\t\t}\n\t}\n}\n```\n\nNotes\n\n- No environment variables are used for theming. Configure via JSON\n  only.\n- Project config deep‑merges over global config.\n\n## Terminal Visuals\n\nThe CLI uses color and layout for readability without relying on heavy\nemoji.\n\n- `chalk` for subtle, meaningful color (headings, axes, legends)\n- `cli-table3` for clean, aligned tables\n- `asciichart` for compact line charts with scaled y‑axis labels\n- Powerline glyphs when the terminal supports them (auto‑detected)\n\nUpcoming improvements\n\n- Color cues for session rank, cache efficiency, and tool success\n- Theme presets that bundle layout + color choices (e.g., Minimal,\n  Dense)\n- Optional ASCII‑only mode across all views for maximal portability\n\n## Statusline Segments\n\nAdd segments to `display.layout` (each inner array is a row).\nAvailable segments:\n\n- Core: `git`, `model`, `cost`, `duration`, `lines_changed`,\n  `tool_performance`, `cache_efficiency`, `working_directory`\n- Gauges: `tool_gauge` (tool success %), `cache_gauge` (cache\n  efficiency %), `context_gauge` (context tokens vs limit)\n- Bars: `lines_bar` (added vs removed)\n- Sparklines: `cost_sparkline` (recent session costs),\n  `cache_reads_sparkline` (cache read tokens per session)\n- Activity: `activity_strip` (last 24h hourly activity), `streak_bar`\n  (last 7 days usage)\n- Mix: `model_mix` (top 3 models compact bands)\n- Ambient: `ambient_wave`, `ambient_bounce`, `ambient_marquee`,\n  `ambient_spinner`, `ambient_twinkle`, `ambient_wave_sine`\n\nSegment options (under `display`)\n\n- `colors`: boolean — enable color cues (default: true)\n- `bar_width`: number — width for gauges/bars (default: 10–12)\n- `sparkline`: `{ width, height, points }` — size and history length\n  for sparklines\n- `context`: `{ token_limit, mode, recent_n }` — context gauge\n  configuration\n  - `token_limit`: default `200000` (200k tokens)\n  - `mode`: `latest` | `session_total` | `recent_n` (default `latest`)\n  - `recent_n`: number of assistant turns when `mode = recent_n`\n\nExample multi‑row layout\n\n```json\n{\n\t\"display\": {\n\t\t\"theme\": \"minimal\",\n\t\t\"colors\": true,\n\t\t\"bar_width\": 12,\n\t\t\"sparkline\": { \"width\": 20, \"height\": 2, \"points\": 20 },\n\t\t\"context\": {\n\t\t\t\"token_limit\": 200000,\n\t\t\t\"mode\": \"latest\",\n\t\t\t\"recent_n\": 5\n\t\t},\n\t\t\"layout\": [\n\t\t\t[\"working_directory\"],\n\t\t\t[\"git\", \"model\"],\n\t\t\t[\"cost\", \"duration\"],\n\t\t\t[\"tool_gauge\", \"cache_gauge\"],\n\t\t\t[\"context_gauge\"],\n\t\t\t[\"activity_strip\"],\n\t\t\t[\"streak_bar\"],\n\t\t\t[\"model_mix\"],\n\t\t\t[\"cache_reads_sparkline\"],\n\t\t\t[\"ambient_wave\"],\n\t\t\t[\"ambient_bounce\"],\n\t\t\t[\"ambient_marquee\"],\n\t\t\t[\"ambient_spinner\"],\n\t\t\t[\"ambient_twinkle\"],\n\t\t\t[\"ambient_wave_sine\"],\n\t\t\t[\"cost_sparkline\"]\n\t\t]\n\t}\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspences10%2Fclaude-code-analytics","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fspences10%2Fclaude-code-analytics","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspences10%2Fclaude-code-analytics/lists"}