compare — Claude Code command for comparing sessions
Compare two sessions by cost and workflow metrics. Use the command to find differences in token use, tool activity, and subagent results.
MIT ★ 1,198 updated 2026-10-23
/plugin marketplace add hoangsonww/Claude-Code-Agent-Monitor
/plugin install ccam-insights@claude-code-agent-monitor-pluginsWhat compare does
Give the command two session IDs. It fetches cost and workflow data for both, then builds a side-by-side table with deltas. The comparison covers token totals, cache hit rate, tool and event counts, agent counts, complexity, subagent success, and compactions.
The final line identifies which session cost less or ran leaner and points to the main driver. Data comes from the Agent Monitor dashboard API at http://localhost:4820, so the dashboard must be running for the comparison to work. Start it with npm start from the repository root.
What it helps with
- compare the cost of two sessions
- spot differences in input and output token use
- check which session generated more tool activity
- compare subagent success rates
- identify compaction differences between sessions
Example prompts for the agent
- Compare sessions
sessionAandsessionBby cost and workflow metrics. - Show which used more tokens:
sessionAorsessionB. - Compare complexity and subagent success for
sessionAandsessionB.
How to install compare
1Plugin marketplace
/plugin marketplace add hoangsonww/Claude-Code-Agent-Monitor/plugin install ccam-insights@claude-code-agent-monitor-plugins2Manually: put the files in place
.claude/commands/compare.mdCall it with /compare. For all projects use ~/.claude/commands/
Manually: put the files in place
~/.codex/prompts/compare.mdCall it with /prompts:compare. Codex marks this format deprecated in favour of skills
Manually: put the files in place
.github/prompts/compare.prompt.mdManually: put the files in place
.gemini/commands/compare.tomlGemini stores commands as TOML: the prompt text goes into the prompt field
Questions about compare
How do I install compare in Claude Code?
Run /plugin marketplace add hoangsonww/Claude-Code-Agent-Monitor, then /plugin install ccam-insights@claude-code-agent-monitor-plugins. The Claude Code command file is .claude/commands/compare.md.
What does the compare command do?
It compares two sessions across cost, token use, and workflow metrics, then presents the differences in a table. The agent ends with a brief verdict on which session cost less or was leaner.
Does the Agent Monitor dashboard need to be running?
Yes. The command gets its data from the dashboard at http://localhost:4820. Start it with npm start from the repository root.
Source text
compare.md · MIT
---
description: Compare two sessions side-by-side with cost and workflow deltas
argument-hint: "[sessionA] [sessionB]"
---
Compare the two sessions in **$ARGUMENTS** (first id = Session A, second id = Session B) side-by-side using the Agent Monitor dashboard. If fewer than two ids are given, ask for both.
1. Fetch cost for each, in parallel:
- `curl -s http://localhost:4820/api/pricing/cost/<sessionA>`
- `curl -s http://localhost:4820/api/pricing/cost/<sessionB>`
Each returns `{ total_cost, breakdown:[{ model, input_tokens, output_tokens, cache_read_tokens, cache_write_tokens, cost, matched_rule }] }`.
2. Fetch workflow intelligence for each:
- `curl -s http://localhost:4820/api/workflows/<sessionA>`
- `curl -s http://localhost:4820/api/workflows/<sessionB>`
Use `stats` (tool/event/agent counts), `complexity` (score), `effectiveness` (subagent success), `compaction` (impact), and `errorPropagation`.
3. Print a side-by-side comparison table with a delta column (B − A):
- Total cost (USD, 4 decimals) and Δ% .
- Tokens: input, output, cache_read, cache_write (sum the breakdown per session).
- Cache hit rate = `cache_read / (cache_read + input)`.
- Tool count, event count, agent count (from `stats`).
- Complexity score (from `complexity`).
- Subagent success rate (from `effectiveness`) and compaction count (from `compaction`).
Output rules: one row per metric with columns Session A | Session B | Δ; use ▲ when B is higher and ▼ when lower; currency in USD to 4 decimals; rates as percentages to 2 decimals. End with a one-line verdict on which session was cheaper/leaner and the main driver. Cite only fields the API returned — never fabricate. If a session id is unknown or the dashboard is unreachable at `http://localhost:4820`, say so and tell the user to start it with `npm start` from the repo root.
© Son Nguyen · MIT · hoangsonww/Claude-Code-Agent-Monitor