Skip to main content
ClaudeWave
EN, English
Skill286 repo starsupdated 7mo ago

debug-mode

The debug-mode skill enables detailed logging of Claude Code agent sessions by capturing events like tool invocations, phase transitions, and skill activations to JSONL files. Use it when troubleshooting agent behavior, optimizing performance, or analyzing session workflows by enabling the feature through a configuration file stored in the project's `.claude/` directory with adjustable verbosity levels (minimal, standard, verbose).

Install in Claude Code
Copy
git clone --depth 1 https://github.com/MadAppGang/claude-code /tmp/debug-mode && cp -r /tmp/debug-mode/plugins/agentdev/skills/debug-mode ~/.claude/skills/debug-mode
Then start a new Claude Code session; the skill loads automatically.

SKILL.md

plugin: agentdev
updated: 2026-01-20

# AgentDev Debug Mode

Debug mode captures detailed session information for analysis, debugging, and optimization.
All events are recorded to a JSONL file in `claude-code-session-debug/`.

## Configuration

Debug mode uses **per-project configuration** stored in `.claude/agentdev-debug.json`.

### Config File Format

Location: `.claude/agentdev-debug.json` (in project root)

```json
{
  "enabled": true,
  "level": "standard",
  "created_at": "2026-01-09T07:00:00Z"
}
```

**Fields:**
- `enabled`: boolean - Whether debug mode is active
- `level`: string - Debug level (minimal, standard, verbose)
- `created_at`: string - ISO timestamp when config was created

## Enabling Debug Mode

Use the command to create the config file:

```
/agentdev:debug-enable
```

This creates `.claude/agentdev-debug.json` with `enabled: true`.

Or manually create the file:

```bash
mkdir -p .claude
cat > .claude/agentdev-debug.json << 'EOF'
{
  "enabled": true,
  "level": "standard",
  "created_at": "2026-01-09T07:00:00Z"
}
EOF
```

## Debug Levels

| Level | Captured Events |
|-------|-----------------|
| `minimal` | Phase transitions, errors, session start/end |
| `standard` | All of minimal + tool invocations, agent delegations |
| `verbose` | All of standard + skill activations, hook triggers, full parameters |

Default level is `standard`.

### Changing Debug Level

Using jq:
```bash
jq '.level = "verbose"' .claude/agentdev-debug.json > tmp.json && mv tmp.json .claude/agentdev-debug.json
```

## Output Location

Debug sessions are saved to:

```
claude-code-session-debug/agentdev-{slug}-{timestamp}-{id}.jsonl
```

Example:
```
claude-code-session-debug/agentdev-graphql-reviewer-20260109-063623-ba71.jsonl
```

## JSONL Format

Each line in the JSONL file is a complete JSON event object. This append-only format is:
- Crash-resilient (no data loss on unexpected termination)
- Easy to process with `jq`
- Streamable during the session

### Event Schema (v1.0.0)

```json
{
  "event_id": "550e8400-e29b-41d4-a716-446655440001",
  "correlation_id": null,
  "timestamp": "2026-01-09T06:40:00Z",
  "type": "tool_invocation",
  "data": { ... }
}
```

**Fields:**
- `event_id`: Unique UUID for this event
- `correlation_id`: Links related events (e.g., tool_invocation -> tool_result)
- `timestamp`: ISO 8601 timestamp
- `type`: Event type (see below)
- `data`: Type-specific payload

### Event Types

| Type | Description |
|------|-------------|
| `session_start` | Session initialization with metadata |
| `session_end` | Session completion |
| `tool_invocation` | Tool called with parameters |
| `tool_result` | Tool execution result |
| `skill_activation` | Skill loaded by agent |
| `hook_trigger` | PreToolUse/PostToolUse hook fired |
| `agent_delegation` | Task delegated to sub-agent |
| `agent_response` | Sub-agent returned result |
| `phase_transition` | Workflow phase changed |
| `user_interaction` | User approval/input requested |
| `proxy_mode_request` | External model request via Claudish |
| `proxy_mode_response` | External model response |
| `error` | Error occurred |

## What Gets Captured

### Session Metadata
- Session ID and path
- User request
- Environment (Claudish availability, plugin version)
- Start/end timestamps

### Tool Invocations
- Tool name
- Parameters (sanitized - credentials redacted)
- Execution context (phase, agent)
- Duration and result size

### Agent Delegations
- Target agent name
- Prompt preview (first 200 chars)
- Proxy mode model if used
- Session path

### Proxy Mode
- Model ID
- Request/response duration
- Success/failure status

### Phase Transitions
- From/to phase numbers and names
- Transition reason (completed, skipped, failed)
- Quality gate results

### Errors
- Error type (tool_error, hook_error, agent_error, etc.)
- Message and stack trace
- Context (phase, agent, tool)
- Recoverability

## Sensitive Data Protection

Debug mode automatically sanitizes sensitive data:

**Redacted Patterns:**
- API keys (`sk-*`, `ghp_*`, `AKIA*`, etc.)
- Tokens (bearer, access, auth)
- Passwords and secrets
- AWS credentials
- Slack tokens (`xox*`)
- Google API keys (`AIza*`)

## Analyzing Debug Output

### Prerequisites

Install `jq` for JSON processing:
```bash
# macOS
brew install jq

# Linux
apt-get install jq
```

### Quick Statistics

```bash
# Count events by type
cat session.jsonl | jq -s 'group_by(.type) | map({type: .[0].type, count: length})'
```

### Tool Usage Analysis

```bash
# Tool invocation counts
cat session.jsonl | jq -s '
  [.[] | select(.type == "tool_invocation") | .data.tool_name]
  | group_by(.)
  | map({tool: .[0], count: length})
  | sort_by(-.count)'
```

### Failed Operations

```bash
# Find all errors and failed tool results
cat session.jsonl | jq 'select(.type == "error" or (.type == "tool_result" and .data.success == false))'
```

### Timeline View

```bash
# Chronological event summary
cat session.jsonl | jq '"\(.timestamp) [\(.type)] \(.data | keys | join(", "))"'
```

### Event Correlation

```bash
# Find tool invocation and its result
INVOCATION_ID="550e8400-e29b-41d4-a716-446655440001"
cat session.jsonl | jq "select(.event_id == \"$INVOCATION_ID\" or .correlation_id == \"$INVOCATION_ID\")"
```

### Phase Duration Analysis

```bash
# Calculate time between phase transitions
cat session.jsonl | jq -s '
  [.[] | select(.type == "phase_transition")]
  | sort_by(.timestamp)
  | .[]
  | {phase: .data.to_name, timestamp: .timestamp}'
```

### Agent Delegation Timing

```bash
# Find slowest agent delegations
cat session.jsonl | jq -s '
  [.[] | select(.type == "agent_response")]
  | sort_by(-.data.duration_ms)
  | .[:5]
  | .[]
  | {agent: .data.agent, duration_sec: (.data.duration_ms / 1000)}'
```

### Proxy Mode Performance

```bash
# External model response times
cat session.jsonl | jq -s '
  [.[] | select(.type == "proxy_mode_response")]
  | .[]
  | {model: .data.model_id, success: .data.success, duration_sec: (.data.duration_
adr-documentationSkill

Architecture Decision Records (ADR) documentation practice. Use when documenting architectural decisions, recording technical trade-offs, creating decision logs, or establishing architectural patterns. Trigger keywords - "ADR", "architecture decision", "decision record", "trade-offs", "architectural decision", "decision log".

agent-coordination-disciplineSkill

Use when deciding whether to launch an agent, selecting which agent to use, or coordinating multiple agents. Covers delegation criteria, external-model patterns, task isolation, and agent selection strategies.

api-designSkill

Use when designing REST or GraphQL APIs, defining endpoints, implementing pagination/filtering, handling API versioning, or establishing API documentation with OpenAPI/Swagger.

api-integrationSkill

Use when integrating Apidog + OpenAPI specifications with your React app. Covers MCP server setup, type generation, and query layer integration. Use when setting up API clients, generating types from OpenAPI, or integrating with Apidog MCP.

api-spec-analyzerSkill

Analyzes API documentation from OpenAPI specs to provide TypeScript interfaces, request/response formats, and implementation guidance. Use when implementing API integrations, debugging API errors (400, 401, 404), replacing mock APIs, verifying data types, or when user mentions endpoints, API calls, or backend integration.

architect-detectiveSkill

Use when analyzing architecture and system design. Find design patterns, map layers, identify core abstractions via PageRank. Uses claudemem AST structural analysis for efficient architecture investigation.

auditSkill

On-demand security and code quality audit. Use when checking for vulnerabilities, security issues, code smells, or compliance problems. Trigger keywords - "audit", "security check", "vulnerability scan", "code quality", "compliance", "security audit".

auth-patternsSkill

Use when implementing authentication (JWT, sessions, OAuth), authorization (RBAC, ABAC), password hashing, MFA, or security best practices for backend services.