---
title: "How to track AI coding agent costs per developer and per repo · Cork"
description: "Track Claude Code, Cursor and Codex spend per developer and per repository: /usage, OpenTelemetry with repo attributes, admin APIs, and tagging scripted runs."
canonical: "https://corkcli.com/blog/track-ai-coding-agent-costs-per-developer-repo"
last_updated: "2026-10-03"
published: "2026-10-03"
author: "Kevin Vera"
---

# How to track AI coding agent costs per developer and per repo

Track Claude Code, Cursor and Codex spend per developer and per repository: /usage, OpenTelemetry with repo attributes, admin APIs, and tagging scripted runs.

By Kevin Vera · October 3, 2026 · [Guides](https://corkcli.com/blog/c/guides) · 6 min read

To track AI coding agent costs per developer, use your vendor's admin reporting (Claude's spend report or Analytics API, Cursor's Admin API, ChatGPT workspace analytics for Codex). To track cost per repository as well, export Claude Code's OpenTelemetry metrics with repository attributes turned on, and tag scripted runs yourself. Per developer is mostly built in; per repo takes one setting or a little plumbing. The sections below give the exact commands and settings, as documented in October 2026.

## Know what each number means

Before building a report, decide which number you are tracking, because tools report different things:

- **Estimated cost at list price.** Claude Code computes its dollar figures locally from token counts. Its docs call the session figure "an estimate" and point to the Console for authoritative billing.
- **Billed spend.** What the invoice says. On Claude Team and Enterprise plans, usage inside the seat allowance "isn't metered in dollars"; only usage credits beyond it show as spend.
- **Plan usage.** Share of a subscription limit, which is not a dollar figure at all.

For chargeback, use billed spend. For "which repo burns the most tokens," estimates at list price are fine and much easier to slice.

## Claude Code: per developer

**For one developer, right now.** Run `/usage` (`/cost` is an alias). The Session block shows total cost, API and wall-clock duration, lines changed, and usage by model. On subscription plans it also shows plan usage bars and a breakdown of what counts against your limits, including subagents and MCP servers.

**For a team.** The right report depends on how developers sign in. From Claude Code's cost guide:

| Setup | Per-user reporting |
|---|---|
| Claude for Teams or Enterprise | Spend report CSV in org analytics; Enterprise Analytics API on Enterprise |
| Claude Console (API) | Console dashboard (spend and accepted lines per member) and the Claude Code Analytics API |
| Bedrock, Google Cloud's Agent Platform, Microsoft Foundry | OpenTelemetry or an LLM gateway |

The docs add that OpenTelemetry export "works on every setup and is the only option that streams per-user token and cost metrics into your own observability stack in near real time."

For budgeting context, the same guide reports that across enterprise deployments the average is "around $13 per developer per active day and $150-250 per developer per month," with 90% of users below $30 per active day.

## Claude Code: per repository with OpenTelemetry

Turn on telemetry for every developer (through managed settings or a shared shell profile):

```bash
export CLAUDE_CODE_ENABLE_TELEMETRY=1
export OTEL_METRICS_EXPORTER=otlp
export OTEL_EXPORTER_OTLP_PROTOCOL=grpc
export OTEL_EXPORTER_OTLP_ENDPOINT=https://otel.example.com:4317
export OTEL_EXPORTER_OTLP_HEADERS="Authorization=Bearer your-token"

# Tag every metric with the repository (Claude Code v2.1.269 or later)
export OTEL_METRICS_INCLUDE_REPOSITORY=true

# Optional: your own dimensions
export OTEL_RESOURCE_ATTRIBUTES="department=engineering,team.id=platform,cost_center=eng-123"
```

The metrics you want are `claude_code.cost.usage` (USD) and `claude_code.token.usage`. Every metric carries `user.email`, `user.account_uuid`, and `session.id`; with the repository flag on, it also carries `vcs.repository.name`, `vcs.owner.name`, and `vcs.provider.name`, derived from the repo's `origin` remote. Group by `user.email` for per-developer cost and by `vcs.repository.name` for per-repo cost.

Two cautions. `OTEL_RESOURCE_ATTRIBUTES` values cannot contain spaces (use underscores or percent-encoding). And if your organization pays contracted rates, set the `modelPricing` managed setting so the exported cost figures match your rates rather than list price.

## Scripted and CI runs

For agents you run from scripts, `claude -p` can return cost directly:

```bash
repo=$(basename "$(git rev-parse --show-toplevel)")
claude -p "Fix the lint errors in src/" --output-format json \
  | jq -c --arg repo "$repo" '{repo: $repo, cost: .total_cost_usd, session: .session_id}' \
  >> agent-costs.jsonl
```

The docs say the JSON payload "includes `total_cost_usd` and a per-model cost breakdown," and that both are client-side estimates. Each run appends one line to `agent-costs.jsonl`; sum it by repo, or push the lines to your metrics store, and you have per-repo cost for automation without any dashboard. When you resume a conversation with `--continue` or `--resume`, the figure is the conversation's running total, so record the difference between runs, not the sum.

## Cursor and Codex

**Cursor.** The Admin API (base URL `https://api.cursor.com`, Basic Authentication with an admin API key) has a `POST /teams/spend` endpoint that returns per-member spend for the current billing cycle, including `spendCents` (on-demand spend) and `overallSpendCents` (on-demand plus included usage). `POST /teams/filtered-usage-events` returns individual usage events with `chargedCents`. We did not find a per-repository breakdown in the Admin API docs, so per-repo attribution for Cursor needs your own convention.

**Codex.** For ChatGPT workspaces, admins find Codex usage in the Admin Console under Analytics, with active users and share of credits per use case and task. An Analytics API reports daily usage across ChatGPT, Codex, and Work products and needs a workspace-scoped Admin key with the `enterprise.analytics.usage.read` scope. OpenAI's own docs warn that "Message count doesn't tell you how much work the team finished," which is good advice for every tool on this page.

## Make the numbers mean something

Raw spend per developer rewards whoever does the least. Three adjustments make the report useful:

1. **Normalize by output.** Divide cost by merged pull requests or accepted lines (Claude Code exports `claude_code.lines_of_code.count`), not by days.
2. **Separate parallel runs.** One developer running five agents in parallel costs roughly five times as much per hour. Claude Code's docs note that agent teams "use significantly more tokens than a single session." Tag those sessions so they are not compared with single-agent work.
3. **Look for waste, not just totals.** Duplicate work by two agents, agents re-reading the same files, and reruns after merge conflicts all show up as spend with nothing to show for it.

## How Cork helps

Measuring spend tells you where tokens go. Cork reduces the share that goes to agents searching for context or redoing each other's work. Cork is the [coordination layer](https://corkcli.com/blog/coordination-layer-ai-coding-agents) for multiplayer coding agents: it keeps Claude Code, Codex and Cursor agents, on one machine or across a team's machines, from overwriting each other on one codebase, and hands each agent what the others already learned.

For this problem specifically:

- **`recap`:** an MCP tool that reports what happened and what it cost.
- **Briefing:** each agent is handed the exact signatures, callers and recent changes of the code it is about to touch, so it searches less.
- **[Write gate](https://corkcli.com/blog/write-gate) and live awareness:** fewer collisions means fewer reruns and fewer conflict fixes billed to nobody's task.
- **Team dashboard** on cloud plans.

In Cork's benchmark (12 Claude Code agents at once on one repository, hard tasks), agents with Cork used 53% fewer tokens than the same agents without it. Install it once for every repo on the machine:

```bash
curl -fsSL https://corkcli.com/install.sh | sh
```

## Frequently asked questions

### How do I see Claude Code costs per user?

On Teams, export the spend report CSV from org analytics; on Enterprise, use the Enterprise Analytics API; on the Console, use the Claude Code dashboard or the Claude Code Analytics API. OpenTelemetry works on every setup.

### Can I track Claude Code cost by repository?

Yes. Set `OTEL_METRICS_INCLUDE_REPOSITORY=true` (v2.1.269 or later) and the cost and token metrics carry the repository name and owner from the `origin` remote.

### Is the cost in /usage what I will be billed?

No. It is computed locally at list price unless an admin configured `modelPricing`. Use the Console usage page or your plan's billing for the authoritative figure.

### How much does Claude Code cost per developer?

Anthropic reports an enterprise average of around $13 per developer per active day and $150 to $250 per month, varying with model choice, codebase size, and how many agents each developer runs.

## Sources

- <https://code.claude.com/docs/en/costs>
- <https://code.claude.com/docs/en/monitoring-usage>
- <https://code.claude.com/docs/en/headless>
- <https://code.claude.com/docs/en/commands>
- <https://cursor.com/docs/account/teams/admin-api>
- <https://learn.chatgpt.com/docs/enterprise/usage-insights>
- <https://learn.chatgpt.com/docs/enterprise/analytics-api>

## Related reading

- [How to reduce token usage when running several coding agents at once](https://corkcli.com/blog/reduce-token-usage-multiple-coding-agents): Several Claude Code, Codex or Cursor agents at once multiply token spend. Cut it with lean shared context, cheaper models, less rediscovery and less rework.
- [Cork vs Amp: one agent in many orbs, or many agents on one codebase](https://corkcli.com/blog/cork-vs-amp): Cork vs Amp: Amp runs its agent in cloud orbs you can share. Cork keeps Claude Code, Codex and Cursor agents from overwriting each other on one repo.
- [Setting up Cork for a team of five](https://corkcli.com/blog/cork-team-of-five-setup): Set up Cork for a five-person team running Claude Code, Codex and Cursor agents: install, login, agent hours, AGENTS.md, working habits, and what it costs.
- [Messaging between your coding agents with cork message](https://corkcli.com/blog/cork-message-coding-agents): Use cork message to reach every coding agent in a repo, one agent, or whoever is working on a function, across Claude Code, Codex and Cursor. With examples.

[All articles](https://corkcli.com/blog.md) · [Cork in Markdown](https://corkcli.com/index.md) · [llms.txt](https://corkcli.com/llms.txt)

This page in HTML: https://corkcli.com/blog/track-ai-coding-agent-costs-per-developer-repo
