If you freelance or run a boutique dev shop in 2026, your Claude Code, OpenAI Codex CLI, Gemini CLI, and OpenRouter/API spend on client repos can quietly hit $150β$600/month.
Most developers eat that cost out of pocket because attributing token spend to each client's Git repository and producing a clean itemized pass-through invoice takes hours of spreadsheet wrangling.
So I built PromptBill β a 100% local-first, zero runtime dependency, MIT open-core CLI & local web studio that scans local agent logs, attributes spend per Git repository, and outputs client-ready PDF & accounting CSV invoices in seconds.
Try the interactive demo (no install, sample data):
npx github:danielneuron/promptbill scan --demo
npx github:danielneuron/promptbill ui --demo
Four Interesting Engineering Details Under the Hood
1. Deduplicating Streaming Claude Code JSONL Logs
Claude Code writes session logs under ~/.claude/projects/**/*.jsonl. Streaming assistant events can emit multiple chunks sharing the same message.id and requestId as output tokens climb. Counting every JSONL line naively wildly inflates costs. PromptBill deduplicates per (message.id, requestId) pair and retains the highest token total for each request.
2. Computing Codex CLI Cumulative Deltas
OpenAI Codex CLI logs (~/.codex/sessions/**/*.jsonl) report token_count events that may contain last_token_usage or cumulative total_token_usage, where cached_input_tokens is a subset of input_tokens. PromptBill computes exact non-cached deltas (Math.max(0, rawInput - cachedInput)) across turns so cache-hit discounts are accurate and tokens are never double-counted.
3. Worktree-Aware Git Repo Attribution
Each session's cwd is walked upward to its enclosing .git directory (or .git file for worktrees) and matched to its origin remote name in .git/config, cleanly grouping nested subdirectories under the right client repository.
4. Zero-Dependency Native PDF 1.4 Generation
Most invoice CLIs pull in a 300MB Puppeteer/Chromium binary just to print a 1-page PDF. PromptBill writes valid, self-contained %PDF-1.4 binaries directly in ~260 lines of TypeScript (complete with proper byte-offset xref tables, multi-page support, and clean WinAnsi escaping), so the entire package has zero runtime dependencies.
Privacy Architecture
Everything runs strictly on your laptop. Your prompts, source code, and session logs never leave your machine.
Open-Core Model
- Free (MIT Open Source): Full CLI & local web UI, Claude Code / Codex CLI / Gemini CLI parsers, Anthropic/OpenAI/OpenRouter/Cursor CSV importer, Git repo attribution, repo CSV/JSON export, and watermarked PDF previews.
Optional Pro License ($19 one-time): Removes the PDF watermark and unlocks a sanitized Page 2 Client Audit Appendix (dates, repos, models, token totals, and optional commit titles β never code or prompts), Xero & QuickBooks Online invoice CSV exports, and unlimited client profiles.
GitHub (MIT): https://github.com/danielneuron/promptbill
Interactive Pass-Through Calculator & Docs: https://danielneuron.github.io/promptbill/
What other coding agent log formats (Aider, OpenCode, Windsurf, Cline) would you want parsed natively next? Let me know in the comments or open an issue on GitHub!
Top comments (0)