{"id":43784524,"url":"https://github.com/chrishutchinson/claude-receipts","last_synced_at":"2026-02-05T19:01:20.676Z","repository":{"id":335252871,"uuid":"1144922872","full_name":"chrishutchinson/claude-receipts","owner":"chrishutchinson","description":"Bring receipts from your Claude Code sessions","archived":false,"fork":false,"pushed_at":"2026-01-29T09:47:28.000Z","size":182,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-01-29T22:55:01.815Z","etag":null,"topics":["claude","claude-code","receipt-printer","vibe-coding"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/claude-receipts","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/chrishutchinson.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2026-01-29T07:49:01.000Z","updated_at":"2026-01-29T14:29:52.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/chrishutchinson/claude-receipts","commit_stats":null,"previous_names":["chrishutchinson/claude-receipts"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/chrishutchinson/claude-receipts","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrishutchinson%2Fclaude-receipts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrishutchinson%2Fclaude-receipts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrishutchinson%2Fclaude-receipts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrishutchinson%2Fclaude-receipts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chrishutchinson","download_url":"https://codeload.github.com/chrishutchinson/claude-receipts/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrishutchinson%2Fclaude-receipts/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29130097,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-05T18:55:47.139Z","status":"ssl_error","status_checked_at":"2026-02-05T18:55:04.010Z","response_time":65,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5: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":["claude","claude-code","receipt-printer","vibe-coding"],"created_at":"2026-02-05T19:01:19.898Z","updated_at":"2026-02-05T19:01:20.663Z","avatar_url":"https://github.com/chrishutchinson.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"# claude-receipts\n\n\u003e Bring receipts from your Claude Code sessions\n\n\u003cdetails\u003e\n\n\u003csummary\u003e\u003cstrong\u003eExamples\u003c/strong\u003e\u003c/summary\u003e\n\n## Thermal printer receipt\n\n![A photos of an example printed receipt](thermal-receipt.jpg)\n\n## HTML receipt\n\n![A screenshot of an example receipt](screenshot.jpeg)\n\n\u003c/details\u003e\n\n## Installation\n\n```bash\nnpx claude-receipts setup\n```\n\nThis will:\n\n- Configure the `SessionEnd` hook in your global `~/.claude/settings.json`\n- Create a config file at `~/.claude-receipts.config.json`\n\nFrom now on, every time you exit a Claude Code session, your receipt will be generated and opened in your browser.\n\n### Manual generation\n\nGenerate a receipt for your most recent session:\n\n```bash\nnpx claude-receipts generate\n```\n\n## Commands\n\n### `generate`\n\nGenerate a receipt for a Claude Code session.\n\n```bash\n# Generate for most recent session\nnpx claude-receipts generate\n\n# Generate HTML (saved to ~/.claude-receipts/projects/)\nnpx claude-receipts generate --output html\n\n# Print to thermal printer\nnpx claude-receipts generate --output printer --printer usb\n\n# Multiple outputs (HTML + printer)\nnpx claude-receipts generate --output html,printer\n\n# Specific session by UUID prefix\nnpx claude-receipts generate --session 9356d5e2\n\n# Override location\nnpx claude-receipts generate --location \"Paris, France\"\n```\n\n**Options:**\n\n- `-s, --session \u003cid\u003e` - Generate for a specific session ID or UUID prefix\n- `-o, --output \u003cformat\u003e` - Output format: \"html\", \"console\", or \"printer\" (supports multiple, comma-separated)\n- `-l, --location \u003ctext\u003e` - Override location detection\n- `-p, --printer \u003cname\u003e` - Printer interface (e.g., \"usb\", \"tcp://192.168.1.100\")\n\n**Output Formats:**\n\n- `html` - Beautiful styled receipt saved to `~/.claude-receipts/projects/`\n- `console` - ASCII art display in terminal\n- `printer` - Send to thermal printer (requires Epson TM-T88V or compatible)\n\n### `setup`\n\nConfigure automatic receipt generation.\n\n```bash\n# Run interactive setup\nnpx claude-receipts setup\n\n# Uninstall the hook\nnpx claude-receipts setup --uninstall\n```\n\nThis modifies `~/.claude/settings.json` to add a SessionEnd hook that automatically generates receipts.\n\n### `config`\n\nManage your receipt configuration.\n\n```bash\n# Show current configuration\nnpx claude-receipts config --show\n\n# Set a configuration value\nnpx claude-receipts config --set location=\"Kuala Lumpur, Malaysia\"\nnpx claude-receipts config --set timezone=\"Asia/Kuala_Lumpur\"\nnpx claude-receipts config --set printer=usb\n\n# Reset to defaults\nnpx claude-receipts config --reset\n```\n\n**Available settings:**\n\n- `location` - Default location (string)\n- `timezone` - Timezone for dates (string, e.g., \"Asia/Macau\")\n- `printer` - Default printer interface (string, e.g., \"usb\" or \"tcp://192.168.1.100\")\n\n## Configuration\n\nConfiguration is stored at `~/.claude-receipts.config.json`.\n\n**Default configuration:**\n\n```json\n{\n  \"version\": \"1.0.0\"\n}\n```\n\n**Optional settings:**\n\n- `location` - Custom location string (otherwise auto-detected)\n- `timezone` - Custom timezone for date formatting\n- `printer` - Default printer interface for thermal printing\n\n### Location Detection\n\nLocation is determined in this order:\n\n1. `--location` flag (if provided)\n2. Config file `location` setting\n3. Auto-detection via IP geolocation (offline, using geoip-lite)\n4. Fallback: \"The Cloud\"\n\n## How It Works\n\n1. **SessionEnd Hook**: When you exit Claude Code, it calls `npx claude-receipts generate --output html` via stdin with the session ID\n2. **Data Collection**: The package calls `ccusage session --id \u003csession-id\u003e` to get accurate session token/cost data\n3. **Transcript Parsing**: Reads the session transcript JSONL to extract metadata (session name, timestamps, message count)\n\n### HTML output\n\n4. **Receipt Generation**: If `--output html` is specified, generates a styled HTML receipt with token breakdowns by model\n5. **Output**: Saves HTML to `~/.claude-receipts/projects/[session-name].html` and/or prints to thermal printer\n6. **Auto-open**: Opens the HTML receipt in your default browser automatically (hook mode only)\n\n### Printer output\n\n1. **Thermal Printing**: If `--output printer` is specified, sends the receipt to a thermal receipt printer\n\n## Requirements\n\n- Node.js \u003e= 22.0.0\n- Claude Code (for automatic generation)\n\n## Thermal Printing\n\nclaude-receipts supports printing to Epson TM-T88V thermal printers (and compatible models) via:\n\n- **USB**: Auto-detect via `--printer usb` (or `config --set printer=usb`)\n- **Network**: Direct TCP via `--printer tcp://192.168.1.100`\n\n\u003e [!WARNING]\n\u003e Your mileage with printing may vary. I have tested with an Epson TM-T88V, printing from macOS and it works well, but other models may have different capabilities or require adjustments to the code. I am more than happy to accept PRs to improve printer compatibility.\n\nThe receipt includes:\n\n- Claude ASCII logo\n- Session details and location\n- Token breakdown by model (input, output, cache read/write)\n- Total cost\n- QR code linking to the GitHub repo\n\n## Troubleshooting\n\n### \"Cannot determine transcript path\"\n\nThis means you're trying to manually generate a receipt but the most recent session doesn't have a valid project path. Solutions:\n\n- Run from within a SessionEnd hook (use `setup` command)\n- Work in a Claude Code session and let it auto-generate\n\n### \"No session data found\"\n\nccusage couldn't find any sessions. Make sure you've used Claude Code recently and that ccusage is working:\n\n```bash\nnpx ccusage session --json\n```\n\n### Hook not triggering\n\nCheck that the hook is installed:\n\n```bash\ncat ~/.claude/settings.json\n```\n\nYou should see a `SessionEnd` hook pointing to `claude-receipts`.\n\n### Session shows wrong cost or is missing\n\nVery short sessions (e.g., just \"hello world\" + immediate exit) may not appear in ccusage yet. The hook will exit silently rather than printing a wrong receipt. For sessions that exist, the package now uses `ccusage session --id` to fetch accurate totals rather than sub-session slices.\n\n### Printer not found\n\nIf using `--printer usb`, ensure:\n\n- Printer is connected via USB\n- Printer is an Epson TM-T88V or compatible ESC/POS model\n- On Linux, you may need permission to access USB devices (`/dev/usb/lp*`)\n\nFor network printers, use `--printer tcp://\u003cip-address\u003e` with port 9100 (default ESC/POS port).\n\n## Contributing\n\n## Roadmap\n\n- [x] HTML receipts with auto-open in browser\n- [x] Console ASCII art mode\n- [x] Real thermal receipt printing (Epson TM-T88V)\n- [x] Accurate session cost tracking (via `ccusage --id`)\n- [x] Session matching by UUID or prefix\n- [ ] Image export (PNG/JPEG)\n- [ ] Plugin for Opencode ([opencode issue](https://github.com/anomalyco/opencode/issues/10524))\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchrishutchinson%2Fclaude-receipts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchrishutchinson%2Fclaude-receipts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchrishutchinson%2Fclaude-receipts/lists"}