Skip to main content
skill CX Codex

session-report · hoangsonww — Claude Code skill: session reports

Builds a Markdown report for a session or date range, covering model usage, costs, agents, and events. Useful when you need to inspect what happened during a run.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add hoangsonww/Claude-Code-Agent-Monitor --skill session-report -a claude-code
Open on GitHub

What session-report does

The skill creates a report for a session ID, the latest session, or a date range. It breaks token usage down by model, includes baseline totals preserved through compaction, and shows pricing, the agent tree, tool calls, API errors, turn durations, and thinking-block counts.

The output combines a summary, tables, an agent tree, and an event timeline. Data comes from the Agent Monitor API at http://localhost:4820, so that API must be reachable for the skill to retrieve session details. Install it in Claude Code with npx skills add hoangsonww/Claude-Code-Agent-Monitor --skill session-report -a claude-code.

Costs use the pricing rule matched to each model. Check that rule before comparing the report total with an external bill; the calculation depends on the rates it applies.

What it helps with

  • compare token use across models in a session
  • break down session cost by pricing rule
  • locate API errors and tools involved in error events
  • trace subagent relationships and compaction events

Example prompts for the agent

  • Create a report for the latest session.
  • Summarize token usage and cost for last 24 hours.
  • Inspect session <session-id> and include API errors and the event timeline.

How to install session-report

1Skills CLI (Vercel)

npx skills add hoangsonww/Claude-Code-Agent-Monitor --skill session-report -a claude-code

2Manually: put the files in place

~/.claude/skills/session-report/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/session-report/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about session-report

How do I install session-report in Claude Code?

Run npx skills add hoangsonww/Claude-Code-Agent-Monitor --skill session-report -a claude-code. The skill file is at ~/.claude/skills/session-report/SKILL.md.

What does session-report do?

It builds a Markdown report for a session or date range, with token totals, costs, agent activity, tool calls, API errors, and a timeline.

Where does session-report get its data?

It reads session and event data from the Agent Monitor API at http://localhost:4820. The API needs to be reachable for the report to include that data.

Source text

SKILL.md · MIT
---
name: session-report
description: >
  Generate a comprehensive session report with per-model token usage
  (input, output, cache_read, cache_write including compaction baselines),
  cost breakdown via the pricing engine, tool invocations, agent hierarchy,
  compaction events, API errors, turn durations, and thinking block counts.
  Use when reviewing a specific session or summarizing activity over a date range.
---

# Session 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 |
|----------|----------------|
| `GET /api/sessions/{id}` | Session with nested `.agents[]` and `.events[]` |
| `GET /api/sessions?limit=50` | Session list with `agent_count`, `last_activity`, and **inline `cost`** per session (bulk pricing applied server-side) |
| `GET /api/pricing/cost/{sessionId}` | `{ total_cost, breakdown: [{ model, input_tokens, output_tokens, cache_read_tokens, cache_write_tokens, cost, matched_rule }] }` |
| `GET /api/events?session_id={id}` | Event stream: each has `event_type`, `tool_name`, `summary`, `data` (JSON), `created_at` |

### Key data points available per session

- **Status**: `active` / `completed` / `error` / `abandoned`
- **Model**: primary model (e.g. `claude-sonnet-4-20250514`)
- **Metadata (JSON)**: `thinking_blocks` count, `turn_count`, `total_turn_duration_ms`, `usage_extras` (service_tier, speed, inference_geo)
- **Token usage per model**: Pricing breakdown reports `input_tokens`, `output_tokens`, `cache_read_tokens`, `cache_write_tokens` per model (baselines are pre-summed into these totals at the DB level)
- **Cost formula**: `(tokens / 1,000,000) × rate_per_mtok` for each of 4 token types, using longest-match pricing rule
- **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`, `APIError`, `TurnDuration`

## 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)
Include these columns: Model, Input, Output, Cache Read, Cache Write, and 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 `Compaction` events (each = context was compressed)
- 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.

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

Similar skills

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

session-report by other authors comes first.

From the same set60

mcp-audit Audits user- and project-scoped MCP servers via the Agent Monitor API. Identifies transport issues, duplicate configurations, and external HTTP endpoints. CX Codex +1 ★ 1,121repo stars hook-inventory Inventories configured hooks and scripts in ~/.claude/hooks, then flags network activity and risky commands. Use it to review hook safety. CX Codex +1 ★ 1,121repo stars config-audit Walks your ~/.claude setup and reports what has piled up: skills, subagents, hooks, duplicates and risky shell commands. CX Codex +1 ★ 1,121repo stars usage-trends Tracks Claude Code session history, token consumption, and tool frequency through Agent Monitor API endpoints. Useful for diagnosing agent errors and checking cache efficiency over 365 days. CX Codex +1 ★ 1,121repo stars productivity-score Turns Agent Monitor metrics into a 0–100 productivity scorecard: session completion, cache efficiency, turn speed, tool success and cost. CX Codex +1 ★ 1,121repo stars model-mix Breaks down Claude Code token usage and spend across Opus, Sonnet, and Haiku via Agent Monitor to spot expensive models doing low-complexity tasks. CX Codex +1 ★ 1,121repo stars cost-breakdown This skill reports model and session costs, daily spending trends, and token efficiency. Use it to compare model pricing or plan a budget. CX Codex +1 ★ 1,121repo stars cache-efficiency The skill works out whether prompt caching pays off: hit rate, write-versus-read reuse, and what each side costs in dollars. CX Codex +1 ★ 1,121repo stars

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor