Turn AI token usage into a receipt with a punchline.
ASCII-native
pricing-aware
software-aware
Claude Code
Codex
Trae
Kimi Code
OpenCode
No dashboard. No spreadsheet. No spiritual coping mechanism.
Just a bill that shows up before your denial does.
Most token tools explain usage.
token-receipt itemizes the damage.
It turns invisible AI spend into a thermal-paper artifact you can paste into chat, screenshot instantly, and post with a straight face.
Three rules run the whole project:
Visual firstThe output should look like checkout, not admin UI.Data honestReal local logs first. Official pricing second. Unknowns stay unknown.Artifact over analyticsIf it is not screenshot-worthy, it is not finished.
▐▛███▜▌
▝▜█████▛▘
▘▘ ▝▝
CLAUDE CODE
THANK YOU FOR CODING WITH Claude
RECEIPT #: CC_20260427_151928_7CE382
DATE: 2026-04-27 15:19:28
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
PROVIDER ANTHROPIC
MODEL claude-sonnet-4.5
CONTEXT USED 12,487
────────────────────────────────────────────────
ITEM TOKENS
────────────────────────────────────────────────
Input Tokens 12,487
Output Tokens 3,215
Cache Read Tokens 8,742
Reasoning Tokens 128
Cache Write Tokens 1,024
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
TOTAL 15,702 TOKENS
────────────────────────────────────────────────
USD ESTIMATE $0.062851
PRICE claude-sonnet-4.5
PRICE DATE 2026-04-25
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
THE LOGO LOOKS CALM. THE BILL DOES NOT.
||| ||||| || ||| | | || ||| | |
CC_20260427_151928_7CE382
There are three ways to use token-receipt.
If you installed this repo as a skill, the normal path is not “open terminal and figure it out.”
The normal path is: say what you want in the chat box of the software you are already using.
Strong trigger phrases:
token receipttoken billusage receipttoken 小票对话发票AI 用量账单把这次对话打成小票看看这轮 token 消耗查看本次对话 Token 消耗
You can also be explicit about language:
token receipt in English中文版 token 小票
Claude Code can auto-print a receipt on SessionEnd.
Install the hook:
python3 scripts/install_claude_auto_trigger.pyAfter that, ending a Claude Code session will auto-fire the receipt without an extra chat message.
If you are not invoking it through a skill system, run the script yourself:
python3 scripts/token_receipt.py --agent-tool codex
python3 scripts/token_receipt.py --agent-tool claude-code
python3 scripts/token_receipt.py --agent-tool kimi-code
python3 scripts/token_receipt.py --agent-tool opencode
python3 scripts/token_receipt.py --agent-tool claude-code --language zh-CN
python3 scripts/token_receipt.py --session ~/.local/share/opencode/opencode.db --opencode-session-id ses_xxx --agent-tool opencodeTrigger matrix:
| Software | Manual trigger in chat | Auto trigger |
|---|---|---|
| Codex | Say token receipt or equivalent |
Not shipped |
| Claude Code | Say token receipt or equivalent |
SessionEnd hook after install |
| Trae | Say token receipt or equivalent |
Not shipped |
| Kimi Code | Say token receipt or equivalent; CLI --agent-tool kimi-code |
Not shipped |
| OpenCode | Say token receipt or equivalent; CLI --agent-tool opencode |
Not shipped |
The footer is not decoration. It is the coup de grace.
This project is built around the idea that the last line on the receipt should feel like the model watched you spend context on one more revision and decided to leave a note.
Examples:
THE LOGO LOOKS CALM. THE BILL DOES NOT.REASONING WAS BILLED SEPARATELY.THE LAST REVISION WAS NOT THE LAST.画面稳了,预算死了。最后一版这个词,本来就不诚实。
If the receipt looks good but the footer has no sting, the job is not done.
It bills the software you are actually using. It does not quietly switch to another app's newer logs.
| Software | Status | Data source | Notes |
|---|---|---|---|
| Codex | supported now |
Codex JSONL sessions | Reads local session logs directly |
| Claude Code | supported now |
Claude usage-data + projects | Uses usage logs for tokens and transcripts for model lookup |
| Trae | manual mode now |
Trae app storage | Auto transcript import is not shipped yet |
| Kimi Code | supported now |
kimi-cli context.jsonl (~/.kimi/sessions/ or KIMI_SHARE_DIR) |
Reads cumulative _usage.token_count; USD estimate omitted (no API split); use manual flags if you need priced input/output |
| OpenCode | supported now |
opencode*.db SQLite under ~/.local/share/opencode/ (see OPENCODE_DATA_DIR, XDG_DATA_HOME) |
Reads session/message rows (message.data JSON: tokens, modelID); supports --scope latest-turn | session |
Notes:
- Some Trae builds use
Trae CN/.trae-cninstead ofTrae. - Inside Codex, the runtime can be detected and
token-receiptreads Codex logs. - Inside Claude Code's SessionEnd hook,
token-receiptreads Claude Code usage logs. - If you run the script from a plain shell and more than one local software log exists, pass
--agent-toolexplicitly. Cross-software guessing is intentionally disabled. - In current releases,
--agent-tool traeis honest: it tells you to use manual mode instead of pretending Trae has clean JSONL session logs.
There are two layers of support:
Receipt renderingAny model name can be rendered in manual mode.Price estimationCost only shows up when the model exists inreferences/pricing.json.
Current mapped model families include:
OpenAIGPT-5 family, Codex family, GPT-4.1, GPT-4o,o3,o4-miniAnthropicClaude Opus, Sonnet, and Haiku familiesGoogleGemini 2.x and 3.x familiesMoonshotKimi K2 familyDeepSeekDeepSeek V4 familyAlibabaQwen familyZhipuGLM familyXiaomiMiMo familyMiniMaxM2 family
If your model is not mapped yet, the receipt still renders. The price just refuses to roleplay.
Current receipts intentionally stay conservative about what they print:
Input TokensOutput TokensCache Read TokensTOTALReasoning Tokenswhen actually availableCache Write Tokenswhen actually available
That policy is deliberate.
Better to omit a field than lie with confidence.
No package manager is required right now. It runs on Python's standard library.
python3 scripts/token_receipt.pyIf you run that inside Codex or Claude Code, the current software can be detected automatically.
If you run it from a plain shell with multiple local software logs present, add --agent-tool.
Useful software-specific examples:
python3 scripts/token_receipt.py --agent-tool codex
python3 scripts/token_receipt.py --agent-tool claude-code
python3 scripts/token_receipt.py --agent-tool codex --scope session
python3 scripts/token_receipt.py --agent-tool claude-code --show-fields
python3 scripts/token_receipt.py --agent-tool trae --provider openai --model gpt-5.4 --input-tokens 12487 --output-tokens 3215Useful rendering variants:
python3 scripts/token_receipt.py --width 48 --stream
python3 scripts/token_receipt.py --agent-tool codex --language en
python3 scripts/token_receipt.py --agent-tool claude-code --language zh-CN
python3 scripts/token_receipt.py --agent-tool claude-code --output html --write ./receipt.html
python3 scripts/token_receipt.py --agent-tool claude-code --session ~/.claude/usage-data/session-meta/${CLAUDE_SESSION_ID}.json --write /tmp/token-receipt.txt
python3 scripts/token_receipt.py --footer-tone snarky --conversation-summary "one more revision for visual polish"
python3 scripts/token_receipt.py --provider anthropic --agent-tool claude-code --model claude-sonnet-4.5 --input-tokens 12487 --cached-input-tokens 8742 --output-tokens 3215Inside Claude Code skills, ${CLAUDE_SESSION_ID} resolves to the current Claude session.
What those flags mean in plain English:
--agent-tool codexRead Codex data and use the Codex receipt header.--agent-tool claude-codeRead Claude Code data and use the Claude Code receipt header.--agent-tool traeUse Trae branding. For now, bring your own token counts.--show-fieldsAsk the logs what they can actually prove.--language enPrint the English receipt.--language zh-CNPrint the Chinese receipt without forking the layout.--output htmlExport a browser-printable receipt page instead of the monospace text artifact.--write /tmp/token-receipt.txtSave the receipt quietly instead of dumping it into Bash stdout. This is the cleaner path inside Claude Code chat.--write-html /tmp/token-receipt.htmlKeep the text receipt as the main artifact, but also save a printable HTML copy that can be linked back in hosts that support local file links.--streamPrint like a machine that knows you spent too much.
The main artifact is still the monospace receipt inside chat.
HTML is the secondary route: useful when you want browser print preview, real printer output, or a cleaner handoff to thermal-printer workflows.
python3 scripts/token_receipt.py --agent-tool claude-code --output html --write ./receipt.htmlOpen receipt.html in a browser, hit Print receipt, and let the browser talk to the printer.
If your host can render local file links, the cleaner flow is dual export:
python3 scripts/token_receipt.py --agent-tool claude-code --write /tmp/token-receipt.txt --write-html /tmp/token-receipt.htmlThat keeps the monospace receipt in chat while also giving you a clickable printable HTML file.
The current HTML path is tuned for the same three things people actually notice:
- a gray preview stage with a white receipt body, so the receipt edges stay visible on screen
- a pure white print result, so the browser preview does not lie about the final paper
- software-aware logos in HTML too: Claude Code uses a dedicated vector mark, while Codex and Trae use embedded image assets
Install:
python3 scripts/install_claude_auto_trigger.pyUninstall:
python3 scripts/uninstall_claude_auto_trigger.pyThis wires token-receipt into Claude Code's SessionEnd hook.
The conversation ends. The receipt arrives. The denial window closes.
This project is intentionally opinionated.
- No markdown tables as the primary artifact
- No QR code for now
- No made-up token fields just because another tool exposes them
- No pretending platform-routed pricing is a direct vendor bill
- No sanding away the weird, uncomfortable energy of a real receipt
If the output feels too clean, it probably stopped feeling true.
Before shipping changes, run:
python3 scripts/validate_receipt.pyIt checks things like:
- line width
- required fields
- logo alignment
- barcode presence
- pricing fallbacks
- unsupported field leakage
See CHANGELOG.md for the running update log.
Shipped nowPrintable HTML export for browser print preview and physical receipt workflows.Next upPrinter-first presets for common paper widths and cleaner print defaults.Also plannedTrae automatic session import once its local storage shape is stable enough to trust.
Every prompt leaves a tab.
token-receipt just prints it before you can emotionally recover.
Inspired by chrishutchinson/claude-receipts.
Same receipt instinct. Different attitude. More software. Meaner footer.