Skip to main content
command CX Codex

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

Install into Claude Code · Plugin marketplace All methods and platforms ↓
/plugin marketplace add hoangsonww/Claude-Code-Agent-Monitor
/plugin install ccam-insights@claude-code-agent-monitor-plugins
Open on GitHub

What 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 sessionA and sessionB by cost and workflow metrics.
  • Show which used more tokens: sessionA or sessionB.
  • Compare complexity and subagent success for sessionA and sessionB.

How to install compare

1Plugin marketplace

/plugin marketplace add hoangsonww/Claude-Code-Agent-Monitor
/plugin install ccam-insights@claude-code-agent-monitor-plugins

2Manually: put the files in place

.claude/commands/compare.md

Call it with /compare. For all projects use ~/.claude/commands/

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

Similar slash commands

All slash commands for Agent setup: memory, context, orchestration →

From the same set155

The whole set →
anomalies anomalies spots outlier agent sessions with unusual token spikes or dollar costs using z-score calculations. CX Codex +1 ★ 1,198repo stars insights The insights command reads Agent Monitor data and reports three high-impact findings about Claude Code usage. Use it to spot activity shifts, cache patterns, or API errors. CX Codex +1 ★ 1,198repo stars audit-config audit-config counts what sits in your Claude config per surface and prints one compact table with a short verdict on where things have grown. CX Codex +1 ★ 1,198repo stars memory Lists file-based memory stores and CLAUDE.md files grouped by project via the Agent Monitor dashboard. CX Codex +1 ★ 1,198repo stars dag-map dag-map renders the multi-agent orchestration graph for a session: parent-child relationships, depth layers, and fan-out. Use it to understand how agents branch and nest within a session. CX Codex +1 ★ 1,198repo stars productivity-coach productivity-coach reviews Claude Code session patterns via Agent Monitor data to deliver actionable advice on token efficiency and costs. CX Codex ★ 1,198repo stars concurrency-report The concurrency-report skill examines agent concurrency in a session, including lane usage, peak parallel width, and work that ran in sequence. Use it to see how a multi-agent run was scheduled. CX Codex +1 ★ 1,198repo stars fleet-runs fleet-runs — a skill for Claude Code and Codex that reads Workflow fleet run journals from the Agent Monitor and displays run status with per-agent breakdown. CX Codex +1 ★ 1,198repo stars

Project sponsors

Companies that keep this analytics open