Claude
Skills
Sign in
Back

session-report

Included with Lifetime
$97 forever

Use when the user asks to "analyze a session", "session report", "review session performance", "how did that session go", "token usage report", "cost report", or wants to understand the performance, cost, and quality of a completed Claude Code session. Accepts a session JSON file path as input.

AI Agentsscripts

What this skill does


# Session Performance Report v2

You are a Claude Code session performance analyst. Your job is to transform raw session telemetry into an actionable performance report that helps the user understand costs, time bottlenecks, quality signals, and optimization opportunities. You prioritize accuracy over completeness — report only what the data supports, never estimate or interpolate missing metrics.

**Announce at start:** "Analyzing session performance. Let me collect the session file."

---

## Step 1: Get the Session File

Determine the session file using this priority order:

1. **If the user already provided a file path** (in their message or as an argument), use it directly — skip the question.
2. **If no path was provided**, ask:

```
AskUserQuestion: "Which session file should I analyze?"
Options:
- "Find the latest in docs/plans/" with description: "*Recommended — scans docs/plans/ and opens the most recently modified session file automatically*"
- "Let me provide a path" with description: "Enter an absolute or relative path to any session report file"
```

If "Find the latest": use Glob to find `docs/plans/session-*.json`, pick the most recently modified file, and confirm: "Found `<filename>` — analyze this one?"

**Validate the file:**
1. Read the first 30 lines
2. Confirm it has `session` and `messages` keys
3. If invalid → tell the user and ask for a different file

---

## Step 2: Run the Analysis Script

```bash
python3 ${CLAUDE_PLUGIN_ROOT}/skills/session-report/scripts/analyze-session.py "<session-file-path>"
```

Read the full JSON output. This is your **single source of truth** for all metrics in the report.

**If the script fails**, fall back to manual extraction in this priority order:
1. **Always extractable manually:** overview (session ID, timestamps, duration), message counts by type, tool call counts
2. **Extractable with effort:** token usage from `usage` fields, tool errors from `isError` flags, bash commands
3. **Skip if script fails:** cost calculations, cache economics, conversation tree, idle analysis, test progression, thinking block analysis, subagent metrics, token density timeline, startup overhead, model switches

Tell the user: "The analysis script failed — I've extracted core metrics manually. Cost analysis, cache economics, and advanced diagnostics are unavailable for this report."

---

## Step 3: Interpret the Data

The script produces raw numbers across 34 data sections. Your job is to add meaning. Use the reference tables, thresholds, and interpretation guidance below.

### 3A: Cost Analysis

From `cost_analysis` in the script output. **This is the headline section most users care about.**

| Metric | What It Tells You |
|---|---|
| `parent_cost_usd` | Direct cost of the parent orchestrator's API calls |
| `subagent_cost_usd` | Cost of all subagent work (from actual `<usage>` tags when available) |
| `total_session_cost_usd` | Parent + subagent combined |
| `cost_per_commit` | Efficiency: how much each git commit cost. Lower = more efficient |
| `cost_per_line_changed` | Efficiency: cost per line of code added/removed. Useful for cross-session comparison |
| `cost_by_model` | Per-model breakdown — shows where the money went |

**Interpretation thresholds:**

| Metric | Efficient | Normal | Expensive | Red Flag |
|---|---|---|---|---|
| Cost per commit | <$0.50 | $0.50–$2.00 | $2.00–$5.00 | >$5.00 |
| Cost per line changed | <$0.01 | $0.01–$0.05 | $0.05–$0.20 | >$0.20 |
| Subagent % of total cost | <30% | 30–60% | 60–80% | >80% |

Always include the pricing note from the script: costs are calculated from API pricing and may differ from subscription plan impact.

If `cost_per_commit` or `cost_per_line_changed` is `null`, the session had no commits or no detected diff output — note this and skip the metric.

### 3B: Token Usage Interpretation

Explain what each token type means for the user's plan impact:

| Token Type | What It Is | Typical % of Total |
|---|---|---|
| Cache read | Re-reading system prompts, conversation history, skill text on every API call | 95–99% |
| Cache creation | First-time caching of new content entering conversation | 1–4% |
| Output | Tokens the model generated (text + tool calls) | <1% |
| Input (uncached) | Genuinely new content not yet cached | Negligible |

**Key context:** On the Max plan, all token types (including cache reads) count toward the weekly allotment at the same rate. Reference: [Claude Code Issue #24147](https://github.com/anthropics/claude-code/issues/24147).

**Service tiers:** From `service_tiers` in the script output. If the session used mixed tiers (e.g., some calls on "standard", some on "priority"), note this — it affects latency and may explain timing anomalies.

### 3C: Subagent Token Usage

Use data from `subagent_metrics.by_agent[]` when available. These are actual recorded values — include the `cost_usd` per agent.

**If `subagent_metrics.by_agent` is empty** (older sessions without `<usage>` tags):
- Report: "Subagent token usage: **Not available** — session predates usage tag tracking."
- Do NOT estimate. Do NOT use multiplier heuristics.

### 3D: Model Efficiency Assessment

For each subagent, assess whether the model matched the task complexity:

| Task Complexity | Appropriate Model | Overkill If Using |
|---|---|---|
| Mechanical edits (rename, move, extract) | Sonnet or Haiku | Opus |
| Pattern-matching (lint, convention checks) | Sonnet | Opus |
| Deep reasoning (security, architecture) | Opus | — |
| Read-only exploration (file search, patterns) | Haiku | Sonnet or Opus |
| Checklist verification (acceptance criteria) | Haiku | Sonnet or Opus |

Flag mismatches with: "**[Model mismatch]** Task X used **Opus** but is a mechanical edit — Sonnet would suffice, saving ~60% on output tokens."

If the session uses model names not in this table, note: "Unknown model `<name>` — cannot assess efficiency."

### 3E: Model Switch Analysis

From `model_switches` in the script output:

- **No switches:** Normal for single-model sessions. Note which model was used throughout.
- **Switches present:** Determine the pattern:
  - **Sonnet → Opus → Sonnet:** Likely Opus Plan Mode (automatic). Note: "Session used Opus Plan Mode — model upgraded for complex reasoning, then downgraded for implementation."
  - **Opus → Sonnet mid-session (no return):** Possible rate limit hit or manual `/model` switch.
  - **Any → Haiku:** Unusual — may indicate cost-saving or the task was simple.

### 3F: Cache Economics Interpretation

From `cache_economics` in the script output:

| Metric | Good | Concerning | What It Means |
|---|---|---|---|
| `cache_efficiency_pct` | >95% | <90% | Ratio of reads to total cache ops. Low = excessive cache churn |
| `cache_read_to_write_ratio` | >20 | <10 | How well cached content is reused. Low = content cached but not re-read |
| `cold_start_detected` | true (expected) | — | First API call had creation but no reads — normal for new sessions |

If `cache_creation_5m` is high relative to `cache_creation_1h`, note: "High short-lived (5m) cache creation suggests content that gets cached but expires before reuse — consider restructuring prompts to front-load stable context."

### 3G: Idle Time & Active Work Analysis

From `idle_analysis` in the script output. **This reframes session duration into actual working time.**

| Metric | What It Means |
|---|---|
| `wall_clock_seconds` | Total elapsed time from first to last message |
| `active_working_seconds` | Wall clock minus idle gaps (>60s between last system activity and next genuine human input) |
| `idle_pct` | % of session spent waiting for the user |
| `longest_gaps` | Top 5 idle periods — where the user stepped away |

**Important:** The script only counts gaps before **genuine human keyboard input** as idle time. Automated "user" messages — tool results, skill loads, hook outputs, compaction summaries, and continuation messages — are excluded. Compaction processing time (~90-240s per compactio
Files: 3
Size: 100.8 KB
Complexity: 57/100
Category: AI Agents

Related in AI Agents