The Problem

Developers using AI‑assisted coding tools have no easy way to see how many tokens each model consumes per project, nor the resulting cost. Without visibility they can overspend on expensive models (Claude, Gemini, etc.) or miss opportunities to optimise prompts.

What This Does

codeburn is a local desktop app that proxies calls to 37 supported AI coding agents, records token counts, and aggregates spend by model, project and task. The UI lives in app/renderer/ (React/TSX components such as App.tsx, Sidebar.tsx, Spend.tsx). Core bookkeeping lives in src/ – e.g. src/parser.ts parses provider responses, src/models.ts defines the spend model, and src/providers/ contains per‑agent adapters. The Electron entry points (app/electron/cli.ts, app/electron/main.ts) start the process, load the quota manager (app/electron/quota/), and expose an IPC layer used by the renderer.

How It Is Wired

Execution begins at app/electron/cli.ts (the packaged CLI). It parses command‑line arguments, then creates the Electron main window via app/electron/main.ts. The main process loads the quota manager (app/electron/quota/index.ts) which registers each provider’s token‑tracking hook (e.g. app/electron/quota/claude.ts, codex.ts).

Renderer code (app/renderer/main.tsx) boots React, importing the UI library app/renderer/lib/ (formatters, IPC wrappers). UI actions (e.g. opening the “Spend” view) call ipc.invoke('track-token', payload) which is handled in app/electron/quota/index.ts. That module forwards to the appropriate provider adapter in src/providers/ – each adapter ultimately calls the external AI endpoint and returns the token usage.

All token records are persisted via SQLite (src/sqlite/), accessed by src/main.ts (the high‑level orchestrator) which writes rows to usage tables. The central type hub src/types.ts (imported by 102 other modules) defines the data contracts used throughout the stack.

The import graph shows 476 internal modules with 1 250 edges; src/parser.ts sits in a small cycle with src/providers/index.ts and src/optimize.ts, giving those files a high blast radius. src/main.ts has the highest instability (imports 37 modules, imports none) and acts as the final sink before data is written.

How To Use It

# Clone the repo
git clone https://github.com/moses-y/codeburn
cd codeburn

# Install dependencies (npm is inferred from package.json)
npm ci

# Build the Electron app (vite config present)
npm run build   # script defined in app/package.json

# Run the CLI (entry point)
node ./app/electron/cli.js   # or npx codeburn after global install

Configuration lives in app/electron/quota/ – each provider expects an API key in the environment (e.g. CLAUDE_API_KEY, GEMINI_API_KEY). No explicit config file is shipped; the README points to the README.md for key names.

Real‑World Use

A CI pipeline can wrap npx codeburn around any npm run lint step. After each AI‑generated patch, the tool logs a row like:

{
  "model": "claude-2.1",
  "project": "frontend",
  "tokens": 124,
  "cost_usd": 0.0012
}

Teams can query the SQLite DB to enforce per‑project budgets or to surface the most expensive prompts in a dashboard.

Code Health & Issues

  • HIGH – Pin GitHub Action versions to commit SHA (.github/workflows/*).
  • HIGH – CI does not run the test suite (.github/workflows/*).
  • MEDIUM – No least‑privilege GITHUB_TOKEN permissions (ci.yml).
  • MEDIUM – Dependabot / Renovate missing (package*.json).
  • MEDIUM – No dependency‑vulnerability scan in CI.
  • MEDIUM – Generated build output committed (app/), should be ignored.
  • MEDIUM – Checkout step keeps token (build-snap.yml); set persist-credentials: false.
  • LOW – No job timeouts in several workflows (build-snap.yml).
  • LOW – Repository lacks convention files (.editorconfig, formatter config).

Additional static findings:

  • HIGH – Oversized files (src/parser.ts, src/models.ts, src/optimize.ts > 3 k lines).
  • HIGH – Import cycles involving src/parser.ts, src/providers/index.ts, src/optimize.ts.
  • HIGH – Hub module src/types.ts (102 dependents) makes any change high‑risk.
  • MEDIUM – High branching density in src/parser.ts and related utilities.

The Bottom Line

codeburn delivers a functional, locally‑run dashboard for AI token accounting, with a clear Electron‑React stack and a well‑scoped SQLite backend. The codebase is usable but suffers from large, tightly‑coupled modules, import cycles, and several CI hygiene gaps that should be addressed before heavy production reliance. Teams that need immediate visibility into AI spend can adopt it, provided they allocate effort to refactor the hub files and tighten the CI pipeline.