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.
npx skills add hoangsonww/Claude-Code-Agent-Monitor --skill session-debug -a claude-codeWhat 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
latestsession 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-code2Manually: put the files in place
~/.claude/skills/session-debug/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/session-debug/
1Skills CLI (Vercel)
npx skills add hoangsonww/Claude-Code-Agent-Monitor --skill session-debug -a codex2Manually: put the files in place
.agents/skills/session-debug/SKILL.mdFor all projects use ~/.agents/skills/
1Skills CLI (Vercel)
npx skills add hoangsonww/Claude-Code-Agent-Monitor --skill session-debug -a cursor2Manually: put the files in place
.cursor/skills/session-debug/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install hoangsonww/Claude-Code-Agent-Monitor session-debug2Manually: put the files in place
.github/skills/session-debug/SKILL.md1Skills CLI (Vercel)
npx skills add hoangsonww/Claude-Code-Agent-Monitor --skill session-debug -a gemini-cli2Platform CLI
gemini skills install https://github.com/hoangsonww/Claude-Code-Agent-Monitor --path plugins/ccam-devtools/skills/session-debugManually: put the files in place
.devin/skills/session-debug/SKILL.mdThe legacy .windsurf/skills/ path still works
Skills CLI (Vercel)
npx skills add hoangsonww/Claude-Code-Agent-Monitor --skill session-debug -a opencodeClaude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
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