Back to blog
Attribution

How Dev Agencies Track AI Costs by Client Without Spreadsheets

Every dev agency using Claude Code and Cursor has the same problem at month end.

The Anthropic invoice arrives. The Cursor invoice arrives. Combined, somewhere between $800 and $3,000 depending on team size and project intensity. And then someone — usually the agency owner or ops lead — tries to figure out how much of that belongs to which client.

The current process at most agencies looks like one of these:

The spreadsheet. A shared doc where developers are supposed to log their AI usage by project. In theory: clean attribution. In practice: nobody fills it in consistently, the data is incomplete by the second week, and reconciling it at month end takes two hours and produces numbers nobody fully trusts.

The estimate. Divide total AI costs proportionally to developer hours per project. Simple, fast, and wrong — AI usage doesn't track linearly with hours. The most AI-intensive projects are the complex ones, not the ones with the most billable hours.

The absorption. Don't track it. Put the total bill in overhead, accept the margin hit, and move on. By far the most common approach.

None of these produce data you can attach to a client invoice. This article covers how to get there without a spreadsheet.


Why Manual Tracking Doesn't Work

The spreadsheet approach fails for a specific reason: it requires developers to change their workflow to generate management data.

Developers use Claude Code and Cursor in flow. They open a session, work on a problem, close it, move to the next task. Asking them to log which client they were working on — at the session level, consistently, across every session — is asking them to interrupt flow to maintain an accounting record.

Even developers who try to do this accurately can't. Sessions bleed across tasks. A developer opens Claude Code to debug a feature for Client A, the conversation drifts into a related component they last touched for Client B, they spend 40 minutes on a tangent that's genuinely split between the two. How does that get logged?

Manual tracking produces data that's approximately right in aggregate and wrong in detail. For a rough internal cost allocation, it's workable. For a client-facing billing conversation backed by verified numbers, it isn't.


What Automatic Attribution Requires

The right architecture doesn't touch the developer workflow at all. It captures attribution signals that already exist in the development environment.

Git remote URL is the project identifier. Every repository has a remote URL that maps to a specific client engagement. If you're working in the client-a/ecommerce-replatform repo, you're working on Client A's project. This mapping is deterministic and doesn't require any human input.

Git config identity is the developer identifier. git config user.email returns the developer's email address — consistent across sessions, unique per person, already set on every developer's machine.

Git branch is the feature identifier. The active branch at the time of a session provides feature-level context on top of project-level attribution.

These three signals — project, developer, feature — are available in the development environment without any additional tooling. The question is whether something is reading them at session time and connecting them to AI usage data.


Where the AI Usage Data Lives

Claude Code and Cursor both write detailed session data locally. You don't need API access or webhook integrations to read it.

Claude Code writes JSONL session files to ~/.claude/projects/. Each file contains session turns with token counts, model used, cost estimates, and timestamps. The project path is embedded in the file location.

Cursor stores session data in a SQLite database at:

macOS:   ~/Library/Application Support/Cursor/User/globalStorage/state.vscdb
Linux:   ~/.config/Cursor/User/globalStorage/state.vscdb
Windows: %APPDATA%/Cursor/User/globalStorage/state.vscdb

Each database entry under cursorDiskKV:bubbleId:* contains model, token counts, cost, and — where available — project path from session metadata.

The data is there. The gap is connecting it to developer identity and client project context, then shipping it somewhere central that an agency owner can actually use.


The Collection Architecture

The cleanest implementation is a lightweight agent on each developer's machine that:

  1. Reads local Claude Code JSONL files and Cursor SQLite entries
  2. Attaches git identity (user.email) and project context (git remote URL, active branch) to each session
  3. Ships usage metadata — not code, not prompt content, only token counts, costs, model, identity, and project — to a central backend
  4. Refreshes on a configurable interval

This runs silently in the background. Developers don't see it, don't interact with it, and don't change how they work. The data flows automatically.

The privacy boundary matters: the agent captures usage metadata only. Token counts, costs, model name, git remote URL, developer email, branch name. It does not capture code content, prompt text, file contents, or API keys. Nothing proprietary leaves the machine.


What the Dashboard Produces

With automatic attribution in place, the per-client cost report is a live view rather than a month-end reconstruction.

A typical agency dashboard shows:

By client: Total AI spend this billing period, broken down by Claude Code, Cursor, and Cline. Which clients are recoverable vs already billed.

By project: Spend per active project, with developer breakdown. Which projects are running above expected cost.

By developer: Individual spend across all tools and projects. Useful for identifying outliers and having coaching conversations about session hygiene.

Spike detection: Sessions running significantly above the developer's or project's baseline — flagged automatically before the billing cycle closes.

Export: Per-client cost summary as CSV or PDF, formatted for attachment to a client invoice or inclusion in a billing conversation.

The output of this system isn't a dashboard for developers to monitor. It's a billing report for the person who sends the invoices.


The Conversation With Your Team

Some agency owners worry about the developer reception to usage tracking. The framing matters.

This is not keystroke logging, screen recording, or performance surveillance. It captures the same information visible in the Anthropic console — token counts and costs — and adds project context that the console doesn't have.

The right framing for developers: "We're tracking AI costs by project so we can recover them from client invoices, which means we're not eating that cost out of the margins that fund your tools and salaries. The data we collect is usage metadata only — no code, no prompts, nothing proprietary."

Most developers understand this framing immediately. The ones who don't are worth having a direct conversation with about agency economics.


The Setup Reality

Setting this up from scratch — collection agent, backend, dashboard, billing export — is a meaningful engineering project. Weeks of work before you have production-quality attribution data.

The alternative is using tooling built for exactly this purpose. TokenWatch installs with one command per repository:

npx @tokenwatch/cli init

After that, every Claude Code, Cursor, and Cline session is attributed automatically. The dashboard is live. The billing report is available before the next invoice cycle.

The founding plan is $99/month per agency — designed to be recovered in the first month from AI costs you're currently absorbing on client work.


The Month-End Difference

Without attribution: one Anthropic invoice, one Cursor invoice, a team that can't reconstruct where the costs went, a spreadsheet that's 60% complete, and a best-guess allocation that nobody fully trusts.

With attribution: a per-client cost summary ready before invoices go out, verified numbers for billing conversations, a spike flag on the one project that ran 3× expected cost, and an export you can attach directly to the invoice.

The difference isn't the data — the data already exists in files on your developers' machines. The difference is whether anything is reading it, attributing it, and surfacing it at the right time.


TokenWatch
Stop absorbing AI costs your clients should be paying.
Automatic attribution across Claude Code, Cursor, and Cline. Per-client billing reports, no spreadsheets.
Get Early Access →