top-spenders — Claude Code command: what it does, how to install
top-spenders sorts Claude Code sessions by cost and lists the most expensive ones. Use it to inspect session spending and compare the top entries with the total.
MIT ★ 1,198 updated 2026-10-23
/plugin marketplace add hoangsonww/Claude-Code-Agent-Monitor
/plugin install ccam-analytics@claude-code-agent-monitor-pluginsWhat top-spenders does
The command gets sessions from the Agent Monitor dashboard, then sorts them by the inline cost value in descending order. For each of the requested entries, it prints the USD cost, model, working-directory name or ID, and start time. If you omit N, it uses 10.
It also adds up the listed sessions and reports their share of the cost across all returned sessions. Currency values use four decimal places. The Agent Monitor dashboard must be reachable at localhost:4820; if it is down, start it with npm start from the repository root.
For Claude Code, install the command through the plugin marketplace. The repository also provides install paths for Codex, GitHub Copilot, and Gemini CLI.
What it helps with
- rank Claude Code sessions by cost
- compare spending across models and working directories
- calculate the top sessions' share of total cost
- inspect session start times alongside costs
Example prompts for the agent
- List the five most expensive Claude Code sessions:
/ccam-analytics:top-spenders 5. - Show the default number of highest-cost sessions:
/ccam-analytics:top-spenders. - Calculate the share for the three costliest sessions:
/ccam-analytics:top-spenders 3.
How to install top-spenders
1Plugin marketplace
/plugin marketplace add hoangsonww/Claude-Code-Agent-Monitor/plugin install ccam-analytics@claude-code-agent-monitor-plugins2Manually: put the files in place
.claude/commands/top-spenders.mdCall it with /top-spenders. For all projects use ~/.claude/commands/
Manually: put the files in place
~/.codex/prompts/top-spenders.mdCall it with /prompts:top-spenders. Codex marks this format deprecated in favour of skills
Manually: put the files in place
.github/prompts/top-spenders.prompt.mdManually: put the files in place
.gemini/commands/top-spenders.tomlGemini stores commands as TOML: the prompt text goes into the prompt field
Questions about top-spenders
How do I install top-spenders in Claude Code?
Run /plugin marketplace add hoangsonww/Claude-Code-Agent-Monitor, then run /plugin install ccam-analytics@claude-code-agent-monitor-plugins.
What does top-spenders do?
It orders Agent Monitor sessions by cost and lists the most expensive entries. It then reports their combined cost and its share of the total cost for all returned sessions.
What does top-spenders need to run?
The Agent Monitor dashboard must be available at localhost:4820. If it cannot be reached, start the dashboard with npm start from the repository root.
Source text
top-spenders.md · MIT
--- description: List the top N most expensive Claude Code sessions by inline cost. argument-hint: "[N]" --- List the most expensive Claude Code sessions from the Agent Monitor dashboard. `N` = **$ARGUMENTS** (default `10` if empty). Fetch the session list (each session carries an inline `cost` field from bulk pricing): ``` curl -s "http://localhost:4820/api/sessions?limit=200" ``` Then: 1. Sort sessions by `cost` descending. 2. Print the top `N` as a numbered list, one line each: `<rank>. $<cost to 4dp> — <model> — <cwd basename or id> — <started_at>` 3. After the list, print the **summed cost of the top N** and what percent that is of the summed cost of all returned sessions. Currency as USD to 4 decimal places. Skip sessions with no/zero cost only if it would otherwise pad the list past meaningful entries — otherwise include them. Keep it terse, no extra commentary. If the dashboard is unreachable, tell the user to start it with `npm start` from the repo root.
© Son Nguyen · MIT · hoangsonww/Claude-Code-Agent-Monitor