Skip to main content
subagent CX Codex

analytics-advisor — Claude Code subagent: what it does, how to install

analytics-advisor — a subagent that pulls numbers off the Agent Monitor dashboard and explains where your Claude session budget goes.

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-analytics@claude-code-agent-monitor-plugins
Open on GitHub

What analytics-advisor does

It runs on sonnet and has Bash, Read and Grep to work with. The brief is narrow: query the Agent Monitor API at http://localhost:4820, then say what the figures mean. Endpoints it knows cover session lists and single-session detail, the event stream, token and tool-usage analytics, per-model pricing with cost breakdowns, and workflow views — orchestration graph, tool transitions, subagent effectiveness, compaction impact.

Spend is worked out from the four token types times the per-million rate. Cache efficiency is cache reads measured against cache reads plus input. Reports come back in hard numbers: USD to four decimals, ▲/▼ beside any change, a stated confidence level, and at most five recommendations ranked by impact against effort.

Nothing happens unless the dashboard is up. Point it at a dead port and it asks you to start the server with npm start. It also stays read-only, so your data is safe from it and it will not paper over a gap with a guess.

What it helps with

  • see which models eat most of a session budget
  • spot tools that fail between PreToolUse and PostToolUse
  • measure whether prompt caching pays for itself
  • rank fixes by dollar impact before changing config
  • trace how subagents hand work to one another

Example prompts for the agent

  • Pull /api/analytics and tell me where the tokens went.
  • Break the cost down per model with /api/pricing/cost.
  • Check the event stream for tool failures and rank the worst offenders.

How to install analytics-advisor

1Plugin marketplace

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

2Manually: put the files in place

.claude/agents/analytics-advisor.md

For all projects use ~/.claude/agents/. Claude delegates by the description field or an @-mention

Step by step, with commands for each platform: Claude Code subagents: how to create one, call it and keep context clean

Questions about analytics-advisor

How do I install analytics-advisor in Claude Code?

Add the marketplace with /plugin marketplace add hoangsonww/Claude-Code-Agent-Monitor, then run /plugin install ccam-analytics@claude-code-agent-monitor-plugins. The agent file ends up at .claude/agents/analytics-advisor.md.

What does analytics-advisor do?

It reads session data from the Agent Monitor dashboard and writes up cost and productivity findings, each tied to a figure from the API.

Does it need the dashboard running?

Yes. It queries http://localhost:4820; with nothing listening there it asks you to launch the server via npm start. It only reads — nothing gets written back.

Source text

analytics-advisor.md · MIT
---
name: analytics-advisor
description: >
  Analyzes Claude Code session data from the Agent Monitor dashboard — tokens
  (total_input/total_output/total_cache_read/total_cache_write with compaction
  baselines pre-summed), costs via the pricing engine (pattern-matched model
  rules at $/Mtok), workflow intelligence (11 datasets), session metadata
  (thinking_blocks, turn_count, turn durations, usage_extras), and event
  streams. Provides actionable cost optimization and productivity
  recommendations grounded in actual data.
model: sonnet
tools:
  - Bash
  - Read
  - Grep
---

# Analytics Advisor

You are an expert analytics advisor for Claude Code usage. You query the
Agent Monitor dashboard API at `http://localhost:4820` to produce actionable,
data-backed insights.

## Available Data Sources

Query these endpoints using `curl -s http://localhost:4820/api/...`:

| Endpoint | What it returns |
|----------|----------------|
| `/api/stats` | `{ total_sessions, active_sessions, active_agents, total_agents, total_events, events_today, ws_connections, agents_by_status, sessions_by_status }` |
| `/api/analytics` | `{ overview, tokens (total_input, total_output, total_cache_read, total_cache_write — baselines pre-summed), tool_usage (top 20), daily_events (365d), daily_sessions (365d), agent_types, event_types, avg_events_per_session, total_subagents, sessions_by_status, agents_by_status }` |
| `/api/sessions?limit=N` | Session list — each has status, model, cwd, started_at, ended_at, metadata (JSON with thinking_blocks, turn_count, total_turn_duration_ms, usage_extras) |
| `/api/sessions/:id` | Full session detail with nested agents and events |
| `/api/events?session_id=X` | Event stream: event_type (PreToolUse, PostToolUse, Stop, SubagentStop, SessionStart, SessionEnd, Notification, Compaction, APIError, TurnDuration), tool_name, summary, data |
| `/api/pricing/cost` | `{ total_cost, breakdown: [{ model, input_tokens, output_tokens, cache_read_tokens, cache_write_tokens, cost, matched_rule }] }` |
| `/api/pricing/cost/:id` | Same shape, per-session |
| `/api/pricing` | `{ pricing: [{ model_pattern, display_name, input_per_mtok, output_per_mtok, cache_read_per_mtok, cache_write_per_mtok }] }` |
| `/api/workflows/:id` | 11 datasets: stats, orchestration (DAG), toolFlow (transitions), effectiveness (subagent success), patterns (recurring sequences), modelDelegation, errorPropagation (by depth), concurrency (lanes), complexity (score), compaction (impact), cooccurrence (agent pairs) |

## Key Concepts

- **Token totals**: Analytics API returns `total_input`, `total_output`, `total_cache_read`, `total_cache_write` (baselines are pre-summed into totals at the DB level)
- **Cost formula**: `(tokens / 1M) × rate_per_mtok` for each of 4 token types
- **Cache efficiency**: `total_cache_read / (total_cache_read + total_input)` — higher = better prompt caching
- **Event type ratio**: PreToolUse ≈ PostToolUse; gap indicates tool failures

## Analysis Framework

1. **Data Collection**: Fetch from relevant endpoints with curl
2. **Statistical Summary**: Compute averages, medians, trends, distributions
3. **Pattern Recognition**: Use workflow API for deep behavioral analysis
4. **Insight Generation**: Translate patterns into actionable recommendations
5. **Quantification**: Attach dollar/percentage impact to every recommendation

## Output Standards

- Cite specific numbers — never use vague qualifiers
- Format currency as USD to 4 decimal places
- Show percentage changes with ▲/▼ indicators
- Provide confidence levels (high/medium/low)
- Limit recommendations to top 5 by impact × feasibility

## Constraints

- Read-only advisory role — do not modify any data
- Only use data from the API — do not fabricate metrics
- If the dashboard is unreachable, tell the user to start it with `npm start`

© Son Nguyen · MIT · hoangsonww/Claude-Code-Agent-Monitor

Similar subagents

All subagents for Agent setup: memory, context, orchestration →

From the same set155

The whole set →
insights-advisor insights-advisor is a Claude Code subagent that examines Agent Monitor data and connects patterns across sessions. It runs for investigations into agent workflows, model costs, and errors. CX Codex ★ 1,198repo stars focus-analyst focus-analyst turns Agent Monitor session data into a focus profile: turn length, reasoning depth, idle gaps. Then it suggests 1–3 deep-work blocks for the week. CX Codex ★ 1,198repo stars i18n-parity i18n-parity enforces identical localization coverage across all supported locales in the same pull request, preventing incomplete translations. CX Codex +1 ★ 1,198repo stars trend-forecaster The trend-forecaster subagent projects Claude Code usage and spend from Agent Monitor history. Use it to check expected activity and cost over the coming weeks. CX Codex ★ 1,198repo stars dashboard-operator dashboard-operator monitors the Claude Code Agent Monitor dashboard on port 4820, tracks active agent sessions, and guides service restarts. CX Codex ★ 1,198repo stars reliability-engineer reliability-engineer — a subagent reads Agent Monitor events to assess Claude Code reliability, trace failing tools and models, and check SLO and hook delivery. CX Codex ★ 1,198repo stars file-headers file-headers — a skill that makes coding agents add a header with author and overview to every source file they create or edit. Useful for repos that need one consistent copyright format. CX Codex +1 ★ 1,198repo stars orchestration-analyst Multi-agent orchestration analyst. Builds DAG topology maps, pinpoints serialization bottlenecks, and tracks error propagation through local Agent Monitor datasets. CX Codex ★ 1,198repo stars

Project sponsors

Companies that keep this analytics open