---
name: devxkit-usage-observability
description: Read local backend usage captured in agent runs without pricing or raw payloads.
scope: global
devxkit_commands:
  - devxkit agent usage history
  - devxkit agent usage totals
  - devxkit agent usage export
---

# devxkit usage observability

## When to use

- Inspect token/duration summaries from past agent runs under `.agent-runs/`
- Compare backends (`cursor`, `codex`, etc.) for a slice without re-running backends
- Export usage for offline analysis (JSON/CSV) — **read-only**

## Preconditions

- Agent runs exist with `logs/<backend>/agent-run.json` under `.agent-runs/<issue>/`
- No backend execution required; commands only read local files

## Commands

```bash
devxkit agent usage history
devxkit agent usage totals
devxkit agent usage export --format json
devxkit agent usage export --format csv
```

Filtered examples:

```bash
devxkit agent usage history --issue 117 --backend cursor
devxkit agent usage totals --issue 117 --last 7d
devxkit agent usage export --format json --issue 117 --since 2026-06-01
devxkit agent usage history --json | jq '.events[0]'
devxkit agent usage totals --json | jq '.grand_total'
```

## Validation

- Commands exit 0 even when no events match (empty list / null totals)
- JSON output includes `monetary_cost: null` — never a dollar amount
- `history --json` and `export --format json` share the same event payload shape (ADR 0013)
- No `raw_usage`, prompts, results, stdout, stderr, or secrets in output

## Common failures

- **Empty history** → no captured run yet; backend may not have executed or did not emit usage JSON
- **Expecting pricing** → not supported; do not infer cost from token counts
- **Wrong issue filter** → confirm `.agent-runs/<issue>/` exists and run completed

## Stop conditions

- Do **not** calculate or report monetary cost
- Do **not** print or persist `raw_usage`, prompts, results, or API keys
- Do **not** run backends just to populate usage — use `devxkit agent run` only with explicit authorization
- `export` is read-only; it never triggers backend execution

## Related skills

- `devxkit-cursor-cost-policy`, `devxkit-pr-reporting` (scorecard may reference latest usage summary)
