{"slug": "show-hn-claude-code-s-stats-double-counts-tokens-so-i-built-a-local-wrapped", "title": "Show HN: Claude Code's /stats double-counts tokens, so I built a local Wrapped", "summary": "A developer released aurafarm, a zero-dependency Node.js 20+ tool run via `npx aurafarm` that reads local history files from Claude Code, Codex, Gemini CLI and Antigravity to generate a Spotify Wrapped-style recap of a user's AI coding year. The tool's author says Claude Code's `/stats` view refreshes `stats-cache.json` only when opened and counts each reply's tokens once per content block, usually twice, so aurafarm recounts every day it still has a transcript and scales cached tokens for older days by the overcount it measured. aurafarm serves its recap only on 127.0.0.1 on a random port, rejects non-localhost Host headers to block DNS-rebinding attacks, and uses a Content Security Policy that forbids all network requests.", "body_md": "**How much aura did you farm with AI this year?** Spotify Wrapped for Claude Code, Codex, Gemini CLI and Antigravity.\n\n```\nnpx aurafarm\n```\n\n**[See the live demo](https://kartikgupta2007.github.io/aurafarm/)** (sample data, nothing to install).\n\naurafarm reads the history your AI coding tools already keep on your machine. It scores your year in aura points and opens a brutally honest recap in your browser, one full-screen page at a time, like Wrapped. Scroll, swipe, tap or press space to move on. At the end you get a share card for X, LinkedIn or your story.\n\n- **An aura score.** Flexes add aura: your streak, your tokens, a 1,000-message session. Bad habits cost aura: typing \"done\" and walking away, crashing out at a model, waiting up for the 2am limit reset.\n- **A verdict.** The Tokenmaxxer, The 3AM Debugger, The Crashout Coder, The Vibe Delegator, The AI Situationship, and more.\n- **Receipts.** Messages, tokens, an estimated API cost, peak hour, longest streak, most-typed slash command, and a rage report.\n- **Sound.** Every scroll plays the next chord of a tune that climbs toward your verdict. Counters tick as they climb, ranks chime, points land with a coin or a thud, and the verdict lands with a hit. It is synthesised in your browser, with no audio files. Mute it with the button at the top right.\n- **Share cards.** 1200×675 for X, 1200×1200 for LinkedIn and 1080×1920 for stories.**Post on X** and**Post on LinkedIn** copy the card to your clipboard, so you paste it straight into the post.\n\nWhen aurafarm finds more than one tool, it asks which ones to include. Press Enter to include all of them.\n\n| Tool | What it reads | \n|---|---|\n| Claude Code | `~/.claude/history.jsonl` ,`~/.claude/stats-cache.json` and the session transcripts in`~/.claude/projects` (or`$CLAUDE_CONFIG_DIR` ) | \n| Codex | `~/.codex/history.jsonl` , the session files in`~/.codex/sessions` and the session index`~/.codex/state_*.sqlite` (or`$CODEX_HOME` ) | \n| Antigravity | `~/.gemini/antigravity-cli/history.jsonl` and the conversation timestamps | \n| Gemini CLI | `~/.gemini/tmp/*/logs.json` and`~/.gemini/tmp/*/chats/*.json` | \n\nMessage counts, tokens and cost depend on what each tool records. Claude Code, Codex and Gemini CLI record tokens. Antigravity only records prompts.\n\nClaude Code refreshes `stats-cache.json` only when you open `/stats`, and it counts each reply's tokens once per content block, which is usually twice. So aurafarm recounts every day it still has a transcript for, counting each reply once. Claude Code deletes transcripts after 30 days. For older days, aurafarm uses the cache and scales its tokens by the overcount it measured on the days both cover.\n\nCodex's session index needs Node.js 22.13 or later. On older Node, Codex sessions and tokens only come from the session files Codex has not deleted yet.\n\n- aurafarm only reads files. It never uploads, phones home or collects telemetry.\n- The recap is served on `127.0.0.1` only, on a random port. It stops when you press Ctrl+C.\n- The server rejects any request whose `Host` is not localhost. This blocks DNS-rebinding attacks.\n- The page's Content Security Policy forbids every network request, so even the page itself cannot send your stats anywhere.\n- aurafarm ignores folder and project names, and the page never shows prompt text.\n\n```\nnpx aurafarm [year] [--no-open]\n\n  year        Year to wrap. Defaults to this year (last year in January).\n  --no-open   Start the local page but do not open a browser.\n```\n\nRequires Node.js 20 or later. There are no dependencies.\n\nEvery line in the audit comes from a real number. The rules live in [`src/aura.js`](https://github.com/KartikGupta2007/aurafarm/blob/main/src/aura.js).\n\n| Flex | Aura | \n|---|---|\n| Each day of your longest streak | +50 | \n| Every 20 messages | +1 | \n| Each active day | +10 | \n| Every 10M tokens | +1 | \n| Every $10 of estimated API cost | +1 | \n| A session over 1,000 messages | +500 | \n| Each please or thank you | +25 | \n| Each extra AI tool you use | +150 | \n\n| Habit | Aura | \n|---|---|\n| Each lazy prompt (\"ok\", \"continue\", \"done\") | −10 | \n| Each \"fix it\" with no context | −25 | \n| Each swear | −50 | \n| Each ALL CAPS prompt | −100 | \n| Each `/model` switch | −20 | \n| Each 1% of prompts after 10pm (when 25% or more) | −10 | \n| Each 1% of prompts on weekends (when 25% or more) | −5 | \n\nThe cost estimate uses public Anthropic API prices. It is a floor, not an invoice. Models without a published price are left out, and the page says which ones.\n\nRun `npx aurafarm`. It reads the history Claude Code keeps in `~/.claude` and shows your messages, tokens, estimated API cost, peak hour, longest streak and most-used slash commands, one page at a time.\n\nClaude Code saves each reply as several transcript lines, one per content block (thinking, text, tool call), and every line repeats the reply's full token count. `/stats` adds up every line, so most replies are counted two or three times. aurafarm counts each reply once. This is a known open bug: [anthropics/claude-code#91775](https://github.com/anthropics/claude-code/issues/91775).\n\nYes. aurafarm also reads Codex, Gemini CLI and Antigravity history, and it combines them into one recap when you use more than one.\n\naurafarm estimates it from your token counts at public Anthropic API prices. On a subscription you pay your plan price instead. The estimate shows what the same usage would cost on the API.\n\nNo. It only reads local files, and the page cannot make network requests. See [Privacy](#privacy).\n\nYes. It runs on macOS, Linux and Windows with Node.js 20 or later.\n\n```\ngit clone https://github.com/KartikGupta2007/aurafarm && cd aurafarm\nnpm test             # node:test, no install needed\nnode bin/aurafarm.js # run against your own data\nnpm run demo         # rebuild the demo page in docs/ with sample data\n```\n\nTo add a tool, create a file in `src/sources/` that returns the activity shape documented in [`src/sources/index.js`](https://github.com/KartikGupta2007/aurafarm/blob/main/src/sources/index.js). Then register it in the same file and add a test with a fake home folder, as in `test/cli.test.js`.\n\nRoast lines live in [`src/roast.js`](https://github.com/KartikGupta2007/aurafarm/blob/main/src/roast.js). Funnier ones are very welcome. Every line has to be earned by a real number.\n\nMIT", "url": "https://wpnews.pro/news/show-hn-claude-code-s-stats-double-counts-tokens-so-i-built-a-local-wrapped", "canonical_source": "https://github.com/KartikGupta2007/aurafarm", "published_at": "2026-12-06 09:57:39+00:00", "updated_at": "2026-12-06 10:15:12.712783+00:00", "lang": "en", "topics": ["ai-tools", "developer-tools", "ai-agents"], "entities": ["aurafarm", "Claude Code", "Codex", "Gemini CLI", "Antigravity", "Node.js", "Kartik Gupta"], "also_reported_by": [], "takeaway": "Claude Code's `/stats` cache double-counts each reply's tokens per content block, so recount from the 30-day session transcripts and scale older cached days by the measured overcount.", "recommendation": null, "alternates": {"html": "https://wpnews.pro/news/show-hn-claude-code-s-stats-double-counts-tokens-so-i-built-a-local-wrapped", "markdown": "https://wpnews.pro/news/show-hn-claude-code-s-stats-double-counts-tokens-so-i-built-a-local-wrapped.md", "text": "https://wpnews.pro/news/show-hn-claude-code-s-stats-double-counts-tokens-so-i-built-a-local-wrapped.txt", "jsonld": "https://wpnews.pro/news/show-hn-claude-code-s-stats-double-counts-tokens-so-i-built-a-local-wrapped.jsonld"}}