{"id":51140788,"url":"https://github.com/doramirdor/openbar","last_synced_at":"2026-06-25T22:30:41.054Z","repository":{"id":364907002,"uuid":"1269687713","full_name":"doramirdor/openbar","owner":"doramirdor","description":"A spending tab for your coding agent — local-first cost + bloat receipts for Claude Code and Codex","archived":false,"fork":false,"pushed_at":"2026-06-17T13:59:57.000Z","size":118,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-06-17T16:42:09.269Z","etag":null,"topics":["ai-agents","claude-code","cli","codex","cost","devtools","hooks","observability"],"latest_commit_sha":null,"homepage":"https://doramirdor.github.io/openbar/","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/doramirdor.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","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-06-15T02:15:09.000Z","updated_at":"2026-06-17T14:03:03.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/doramirdor/openbar","commit_stats":null,"previous_names":["doramirdor/agent-tab","doramirdor/openbar"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/doramirdor/openbar","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doramirdor%2Fopenbar","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doramirdor%2Fopenbar/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doramirdor%2Fopenbar/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doramirdor%2Fopenbar/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/doramirdor","download_url":"https://codeload.github.com/doramirdor/openbar/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doramirdor%2Fopenbar/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34795436,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-25T02:00:05.521Z","response_time":101,"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":["ai-agents","claude-code","cli","codex","cost","devtools","hooks","observability"],"created_at":"2026-06-25T22:30:40.369Z","updated_at":"2026-06-25T22:30:41.049Z","avatar_url":"https://github.com/doramirdor.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# OpenBar\n\n[![CI](https://github.com/doramirdor/openbar/actions/workflows/ci.yml/badge.svg)](https://github.com/doramirdor/openbar/actions/workflows/ci.yml)\n[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)\n[![Node](https://img.shields.io/badge/node-%E2%89%A522.5-43853d.svg)](https://nodejs.org)\n\n**A spending tab for your coding agent.** Local-first cost + bloat receipts for Claude Code and Codex.\n\n🌐 [doramirdor.github.io/openbar](https://doramirdor.github.io/openbar/) · 📐 [Architecture](docs/ARCHITECTURE.md) · 🤝 [Contributing](CONTRIBUTING.md) · 🔒 [Security](SECURITY.md)\n\n```text\n  OpenBar  ·  Claude Code\n\n  $1.42 estimated run cost\n  213k input tokens  (claude-opus-4-8)\n  9.8k output tokens\n  18 files touched  +612 -83  5 new\n  27 commands run\n  5 retries\n\n  Bloat score: 87/100  █████████████████░░░\n\n  Biggest waste:\n  Re-read package-lock.json 7 times\n\n  Fix:\n  Add lockfiles to your agent ignore rules.\n```\n\nIt runs entirely on your machine. No account, no upload, no API key.\n\n## Quick start\n\n```bash\nnpm i -g @amirdor/openbar   # installs the `openbar` command\nopenbar install             # add Claude Code hooks to this project\n# ... use Claude Code as usual ...\nopenbar report              # print the receipt for the last run\nopenbar summary             # your weekly agent bill across runs\nopenbar fix                 # turn the biggest wastes into CLAUDE.md rules\nopenbar share --png         # render a shareable card\n```\n\nNo global install? `npx @amirdor/openbar install`. Using Codex too? add `--codex`.\n\n## How it works\n\n```text\nClaude Code / Codex\n   │  (lifecycle hooks: SessionStart, PreToolUse, PostToolUse, Stop, …)\n   ▼\nopenbar hook  ──►  .openbar/runs/\u003csession\u003e.jsonl   (append-only event log)\n   │\n   ▼\nanalyzer  ──►  transcript/rollout token usage + git diff + waste detectors\n   │\n   ├─►  receipt (terminal)             openbar report\n   ├─►  weekly bill (terminal)         openbar summary\n   ├─►  shareable card (SVG/PNG/HTML)  openbar share\n   ├─►  agent rules (CLAUDE.md)        openbar fix\n   └─►  history (SQLite)               openbar report --history\n```\n\n- **`install`** writes hooks into `.claude/settings.json` (or `--global` / `--local`). It's idempotent and reversible (`uninstall`).\n- **`hook`** is called by Claude Code at each lifecycle point. It reads the hook JSON from stdin and appends a compact event to the per-session log. It is wrapped to never block or slow down the agent.\n- **`report`** reconstructs the run: real token usage from the Claude Code transcript, file changes from `git diff` (or tool events when there's no repo), waste detectors, and a bloat score.\n\n## Accurate cost, honestly labeled\n\nToken counts come from the real Claude Code transcript (`message.usage`), not estimates — including the 5-minute vs 1-hour cache-write split. Cost is computed per-model with Anthropic's cache multipliers (read ×0.10, write-5m ×1.25, write-1h ×2.0).\n\nIt's still labeled **estimated** because pricing for some legacy models is approximate and discount tiers can't be detected. We never show false precision. (Note: on a Claude subscription you don't pay per token — the figure is the API-rate equivalent, a \"what this would cost\" signal, not an invoice.)\n\nRates live in a built-in table. To set exact, negotiated, or Batch (50%-off) rates — or price a model OpenBar doesn't know — drop a `~/.openbar/pricing.json`:\n\n```json\n{ \"claude-opus-4-8\": { \"input\": 5, \"output\": 25 }, \"my-model\": { \"input\": 2, \"output\": 8 } }\n```\n\nYour file wins over the defaults, stays on your machine, and its rates are treated as exact.\n\n\u003e One subtlety handled correctly: a single API response is written to the transcript as multiple lines (one per content block) that all repeat the same `usage`. OpenBar dedupes by request id so tokens aren't counted 3–5× over.\n\n## Bloat score\n\nA transparent 0–100 score (higher = more wasteful), capped per dimension so nothing dominates:\n\n| Dimension | Max |\n|---|---|\n| files touched | 18 |\n| lines added | 14 |\n| repeated reads | 20 |\n| retries / failures | 16 |\n| dependency changes | 10 |\n| generated-file changes | 12 |\n| big diff for a tiny prompt | 10 |\n\n## Waste detectors\n\nRe-read files, lockfile reads, `node_modules`/`dist` reads, repeated commands, failing-test loops, dependency changes, edits to generated output, huge file reads, huge tool outputs, edit churn, output-heavy runs, file sprawl, and big-diff-for-small-prompt. Each finding carries a concrete fix.\n\n## Codex\n\nCodex has official hooks too, so the same flow works:\n\n```bash\nnpx openbar install --codex   # writes .codex/hooks.json (--global for ~/.codex)\n```\n\nTwo Codex specifics OpenBar handles for you:\n\n- **Tokens** come from Codex's on-disk rollout (`~/.codex/sessions/.../rollout-*.jsonl`, the `token_count` lines), normalized so the shared cost math applies. OpenAI pricing is approximate and the receipt says so.\n- **Trust model:** Codex skips a freshly-written command hook until you trust it — run `/hooks` inside Codex once after installing (or launch with `--dangerously-bypass-hook-trust`).\n\n## `openbar fix`\n\nWrites a managed block into `CLAUDE.md` (and `AGENTS.md` with `--all`), generated from what actually wasted money in your runs:\n\n```md\n\u003c!-- openbar:start --\u003e\n## Agent cost rules\n\n- Do not read lockfiles unless explicitly asked. Use the manifest for dependency questions.\n- If the same command fails twice for the same reason, stop and explain the blocker.\n- Prefer editing existing files over creating new ones.\n\u003c!-- openbar:end --\u003e\n```\n\nThe block is re-written in place on each run, so it stays current.\n\n## Commands\n\n| Command | Description |\n|---|---|\n| `openbar install [--codex] [--global\\|--local] [--print]` | Add hooks to Claude Code (or Codex) |\n| `openbar uninstall [--codex]` | Remove openbar hooks |\n| `openbar report [session] [--json] [--history] [--transcript path] [--no-save]` | Print a receipt |\n| `openbar summary [--days n\\|--all] [--json]` | Aggregate recent runs (weekly bill) |\n| `openbar share [session] [--png] [--html] [--out file]` | Render a shareable card |\n| `openbar fix [session] [--all] [--target file] [--print]` | Write rules into CLAUDE.md / AGENTS.md |\n\n## Requirements\n\n- Node ≥ 22.5 (uses the built-in `node:sqlite` for history; history degrades gracefully if unavailable).\n- Zero required runtime dependencies. PNG export uses the optional `@resvg/resvg-js`; without it, `share --png` writes a browser-based PNG exporter instead.\n\n## Development\n\n```bash\nnpm install      # builds via the prepare script\nnpm run build\nnpm test         # end-to-end smoke tests (Claude Code + Codex) against the compiled binary\n```\n\nSee [CONTRIBUTING.md](CONTRIBUTING.md) for the project layout and how to add a detector,\nand [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md) for the data flow.\n\n## Troubleshooting\n\nHooks are silent by design (agents can inject hook stdout into the model). If a run isn't\nshowing up, set `OPENBAR_DEBUG=1` and check `.openbar/openbar.log`. Confirm the\nhooks are registered with `openbar install --print`. On Codex, remember to trust the\nhook via `/hooks` after installing.\n\n## Status\n\nV0 — Claude Code + Codex, fully local. Done: receipts, accurate per-model cost, bloat score, waste detectors, `fix` rules, SVG/PNG/HTML share cards, local history + weekly summary.\n\nDeliberately deferred until the receipt is getting shared (per the original plan): cloud sync, team dashboard, PR comments, budget alerts, and billing. None of that is required to get value from the receipt.\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdoramirdor%2Fopenbar","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdoramirdor%2Fopenbar","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdoramirdor%2Fopenbar/lists"}