session-debug
The session-debug skill queries Claude Code Agent Monitor data to inspect and analyze Claude Code sessions by session ID, recency, or error status. It retrieves comprehensive session metadata, event timelines, agent hierarchies, and tool execution traces from a local API, then produces a color-coded debug report identifying bottlenecks, failures, anomalies, and root causes with remediation suggestions.
git clone --depth 1 https://github.com/hoangsonww/Claude-Code-Agent-Monitor /tmp/session-debug && cp -r /tmp/session-debug/plugins/ccam-devtools/skills/session-debug ~/.claude/skills/session-debugSKILL.md
# 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 findingsOperate and maintain the local MCP server for this repository. Use for MCP tool updates, policy-guard changes, host configuration, and MCP runtime troubleshooting.
Run release-readiness checks for this repository. Use when validating docs, scripts, verification coverage, and operational safety before merge or release.
Understand this repository quickly before making changes. Use for architecture discovery, ownership mapping, command selection, and initial implementation planning.
Review backend route and hook logic for regressions, data integrity risks, and missing tests.
Review React UI changes for behavior regressions, state consistency, and UX breakage.
Review MCP server changes for tool safety, schema quality, and host integration correctness.
Debug production-like issues in this repository with disciplined evidence gathering. Use when fixing failing workflows, regressions, flaky behavior, or data inconsistencies across hooks, API, DB, websocket, and UI.
Operate and maintain the local MCP server for this project. Use when creating MCP host config, troubleshooting tool connectivity, modifying tool domains, or adjusting safety policy flags.