claude-session-introspect

Extract token usage, prompt counts, and compaction metrics from Claude Code session JSONL files.

154|9|Updated Mar 27, 2026
One-click install
npx skills add https://github.com/swyxio/skills --skill claude-session-introspect
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: claude-session-introspect
Source: https://github.com/swyxio/skills/tree/main/claude-session-introspect
Command: npx skills add https://github.com/swyxio/skills --skill claude-session-introspect

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires jq.

What problem does it solve?

Claude Code stores all conversation data as raw JSONL files on disk, but manually parsing these files to extract useful metrics like token usage, prompt counts, and compaction events is time-consuming and requires advanced command-line knowledge. This Skill eliminates that friction by providing a pre-built recipe and script to pull these metrics in seconds.

Core Features & Use Cases

  • Token Usage Tracking: Extract full session token counts including input, output, cache reads, and cache writes to audit context window usage.
  • Conversation Metrics: Count human prompts, assistant turns, and top tool calls to understand session activity patterns.
  • Compaction Analysis: Identify compaction boundaries, triggers, and surviving summary content to debug context loss in long-running sessions.
  • Use Case: A developer working on a long coding project can use this Skill to quickly check how many tokens their session has consumed, or identify which tool call caused unexpected context bloat.

Quick Start

Use the claude-session-introspect skill to pull full usage stats for your current Claude Code session, including token counts, prompt totals, and compaction events.

Frequently Asked Questions about claude-session-introspect

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I extract token usage metrics from Claude Code session files?

You can extract token usage metrics from Claude Code session files by parsing the on-disk JSONL data stored in the ~/.claude/projects directory. This Skill provides a pre-built script to pull input, output, and cache token counts in seconds.

What is the best way to count human prompts and tool calls in Claude Code?

Counting human prompts and tool calls in Claude Code involves parsing session JSONL files for conversation metrics. This Skill automates extracting assistant turns, human prompts, and top tool call frequency to understand session activity patterns.

How do I inspect compaction boundaries and summaries in long-running Claude Code sessions?

Inspecting compaction boundaries and summaries in long-running Claude Code sessions requires parsing the raw JSONL conversation data. This Skill identifies compaction triggers, boundaries, and surviving summary content to debug context loss.

Do I need jq installed to parse Claude Code JSONL session telemetry?

Yes, you need the jq command-line tool installed to parse Claude Code JSONL session telemetry. This Skill relies on jq as a dependency to extract structured metrics from the on-disk session files.

Why does my Claude Code session lose context during long coding projects?

Your Claude Code session loses context during long coding projects due to compaction events that summarize previous conversation history. You can use this Skill to identify compaction boundaries and triggers to debug the exact context loss.

Can I audit context window usage and token consumption for Claude Code?

Yes, you can audit context window usage and token consumption for Claude Code by extracting full session token counts from local JSONL files. This Skill retrieves input, output, cache read, and cache write metrics for session analysis.