Claude-Code-Agent-Monitor session-report
git clone https://github.com/hoangsonww/Claude-Code-Agent-Monitor
T=$(mktemp -d) && git clone --depth=1 https://github.com/hoangsonww/Claude-Code-Agent-Monitor "$T" && mkdir -p ~/.claude/skills && cp -r "$T/plugins/ccam-analytics/skills/session-report" ~/.claude/skills/hoangsonww-claude-code-agent-monitor-session-report && rm -rf "$T"
plugins/ccam-analytics/skills/session-report/SKILL.mdSession Report
Generate a detailed session report from the Claude Code Agent Monitor.
Input
The user provides: $ARGUMENTS
This may be a session ID, "latest", or a date range like "last 24 hours".
Data Sources
All data comes from the Agent Monitor API at
http://localhost:4820:
| Endpoint | What it returns |
|---|---|
| Session with nested and |
| Session list with , , and inline per session (bulk pricing applied server-side) |
| |
| Event stream: each has , , , (JSON), |
Key data points available per session
- Status:
/active
/completed
/errorabandoned - Model: primary model (e.g.
)claude-sonnet-4-20250514 - Metadata (JSON):
count,thinking_blocks
,turn_count
,total_turn_duration_ms
(service_tier, speed, inference_geo)usage_extras - Token usage per model: Pricing breakdown reports
,input_tokens
,output_tokens
,cache_read_tokens
per model (baselines are pre-summed into these totals at the DB level)cache_write_tokens - Cost formula:
for each of 4 token types, using longest-match pricing rule(tokens / 1,000,000) × rate_per_mtok - Agent hierarchy: recursive parent_agent_id tree, subagent_type (e.g. "task", "explore", "code-review", "compaction")
- Event types:
,PreToolUse
,PostToolUse
,Stop
,SubagentStop
,SessionStart
,SessionEnd
,Notification
,Compaction
,APIErrorTurnDuration
Report Sections
1. Session Overview
- ID (first 16 chars), name, status, model, working directory
- Start → end time, total duration
- Turn count and avg turn duration (from metadata)
2. Token Usage (per model)
| Model | Input | Output | Cache Read | Cache Write | Total | Show effective totals (current + baseline) since baselines preserve tokens lost during compaction. Calculate cache hit rate:
cache_read / (cache_read + input) × 100.
3. Cost Breakdown
From
/api/pricing/cost/{id} — show each model's cost with the matched pricing rule. Note rates are per million tokens.
4. Agent Hierarchy
Render the agent tree (main → subagents, with nested children). For each agent: name, type, subagent_type, status, task (first 60 chars), duration.
5. Tool Activity
Count
PreToolUse events by tool_name. Flag tools that appear in error events. Note subagent spawns (tool_name = "Agent").
6. Compaction & Context Health
- Count of
events (each = context was compressed)Compaction - Baseline tokens recovered (sum of baseline_* columns)
- Thinking block count from metadata
7. API Errors
List any
APIError events with type (quota, rate_limit, overloaded) and message.
8. Timeline
Key lifecycle events: SessionStart → first tool → compactions → errors → Stop → SessionEnd. Include TurnDuration events.
Output Format
Clean Markdown: executive summary line, structured tables, agent tree, numbered timeline. Bold key metrics.