Skip to main content
skill CX Codex

session-debug — Claude Code skill: inspect one agent session

Pulls a single Claude session out of Agent Monitor and reports its event chain, subagent tree, token spend and failures.

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

What session-debug does

The skill reads session data from the local Agent Monitor API at http://localhost:4820. You point it at a target three ways: a session ID through GET /api/sessions/{id}, the newest run through GET /api/sessions?limit=1, or the latest failed one through GET /api/sessions?limit=10&status=error. Events, agents and cost come next.

Then it walks the session from several angles. Events are laid out in order, the longest dependent chain gets marked, and slow steps stand out. Agent inspection covers the parent-child tree with subagent type and depth. Tool calls are traced in sequence, including repeats and failures. Anomaly checks look for out-of-order events, quiet stretches past 30 seconds and token spikes. The result is a debug report: a summary header, a colour-coded timeline, an agent tree diagram and numbered findings about what went wrong.

None of this works unless Agent Monitor is already running on http://localhost:4820. No server, no data to inspect. Pass a session ID, latest or errors as the argument.

What it helps with

  • trace why a session ended in an error
  • spot which subagent failed and where
  • catch the same tool being called over and over
  • find idle gaps and token spikes on the timeline
  • work out what one session cost

Example prompts for the agent

  • Debug the latest session and show me the slowest step
  • Find the most recent errored session and explain the failure
  • Draw the subagent tree for session abc123

How to install session-debug

1Skills CLI (Vercel)

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

2Manually: put the files in place

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

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

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

Questions about session-debug

How do I install session-debug in Claude Code?

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

What does session-debug do?

It gathers one session's data from Agent Monitor and produces a report: event chain, agent tree, tool trace, anomalies and a likely root cause for any error.

What does session-debug need to run?

A running Agent Monitor instance — every request goes to http://localhost:4820. Without it the skill has no events or agents to read.

Source text

SKILL.md · MIT
---
name: session-debug
description: >
  Debug a specific session by inspecting its full event chain (PreToolUse,
  PostToolUse, Stop, SubagentStop, Compaction, APIError, TurnDuration,
  Notification events), agent hierarchy (recursive parent/child tree with
  subagent_type and depth), token usage with compaction baselines, workflow
  intelligence data (orchestration DAG, error propagation by depth), and
  session metadata (thinking_blocks, turn_count, total_turn_duration_ms).
---

# Session Debug

Debug and inspect a Claude Code session from Agent Monitor data.

## Input

The user provides: **$ARGUMENTS**

This may be:
- A session ID to debug
- "latest" or "last" for the most recent session
- "errors" to find and debug the most recent errored session

## Procedure

1. **Identify the target session**:
   - If session ID given: `GET /api/sessions/{id}` from `http://localhost:4820`
   - If "latest": `GET /api/sessions?limit=1` (default sort: most recently updated first)
   - If "errors": `GET /api/sessions?limit=10&status=error`

2. **Collect full session data**:
   - Session metadata: status, model, cwd, timestamps, duration
   - Events: `GET /api/events?session_id={session_id}` — full event timeline
   - Agents: `GET /api/agents?session_id={session_id}` — all agents in session
   - Cost: `GET /api/pricing/cost/{session_id}`

3. **Analyze the session**:

   ### Session Lifecycle
   - Start time → first event → last event → end time
   - Status transitions (active → working → completed/error)
   - Total duration and active-vs-idle time

   ### Event Chain Analysis
   - Chronological event list with timestamps and durations
   - Identify the **critical path** (longest chain of dependent events)
   - Flag events that took unusually long
   - Highlight error events with full error context

   ### Agent Inspection
   - List all agents: type, task, status, duration
   - Subagent tree visualization (parent → children)
   - Agents that failed and their last known state
   - Agent switching patterns (when and why new agents spawned)

   ### Tool Execution Trace
   - Every tool invocation in order with: tool name, duration, success/failure
   - Failed tool calls with error messages
   - Tool retry patterns (same tool called multiple times)

   ### Anomaly Detection
   - Events out of expected order
   - Gaps in event timeline (>30s with no events)
   - Duplicate events or agent states
   - Token usage spikes (compaction indicators)

4. **Diagnosis**:
   - Root cause hypothesis (if errors present)
   - Contributing factors
   - Remediation suggestions

## Output Format

Present as a debug report with:
- Session summary header (ID, status, model, duration, cost)
- Color-coded timeline (✅ success, ❌ error, ⚠️ warning, ℹ️ info)
- Agent tree diagram
- Diagnosis section with numbered findings

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

Similar skills

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

From the same set20

history-portability Pulls in Claude or Claude history and shifts whole CCAM datasets between machines. Useful when you switch laptops or need a restore. CX Codex +1 ★ 1,114repo stars remote-collection A skill that walks the agent through CCAM remote data sources: connect machines over SSH and pull Claude and Codex history. Useful when sessions live beyond your laptop. CX Codex +1 ★ 1,114repo stars regression-watch Compares an older baseline window of session history with a recent one and reports which metrics got worse: errors, cache, compactions, cost per session. CX Codex +1 ★ 1,114repo stars benchmark The benchmark skill takes one session or a few recent ones and compares them with the rolling average from Agent Monitor data: cost, tokens, tool count and workflow complexity. Each metric comes back as a percentile of the population. CX Codex +1 ★ 1,114repo stars event-trace Turns one Claude session into an ordered timeline of its events, flagging gaps, failures and tool calls that never finished. CX Codex +1 ★ 1,114repo stars live-watch Polls the Agent Monitor /api/stats endpoint a few times in a row and reports how the counters shift across that window. Useful when you want motion, not a single snapshot. CX Codex +1 ★ 1,114repo stars spend-forecast Turns the daily session trend on the Agent Monitor dashboard into a spend projection for the end of the week or month. CX Codex +1 ★ 1,114repo stars cost-alert Walks through the budget rules configured in Agent Monitor and the alerts that already fired, with a plain explanation of what set each one off. CX Codex +1 ★ 1,114repo 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