home / skills / yonatangross / orchestkit / errors

This skill analyzes error patterns from Claude Code sessions to deliver actionable fixes and root-cause insights.

npx playbooks add skill yonatangross/orchestkit --skill errors

Review the files below or copy the command above to add this skill to your agents.

Files (1)
SKILL.md
2.9 KB
---
name: errors
license: MIT
compatibility: "Claude Code 2.1.34+. Requires memory MCP server."
description: Error pattern analysis and troubleshooting for Claude Code sessions. Use when handling errors, fixing failures, troubleshooting issues.
context: inherit
agent: debug-investigator
version: 1.0.0
author: OrchestKit
tags: [errors, debugging, troubleshooting, patterns]
user-invocable: false
allowed-tools: [Read, Bash, Grep]
complexity: low
metadata:
  category: document-asset-creation
  mcp-server: memory
---

# Error Pattern Analysis

Analyze errors captured from Claude Code sessions to identify patterns and get actionable insights.

## Quick Start

```bash
/errors              # Batch analysis of historical error patterns
/debug               # CC 2.1.30 real-time debug for current session
```

### When to Use Which

| Command | Purpose | Scope |
|---------|---------|-------|
| `/errors` | Batch analysis of error patterns (last 24h/7d) | Historical patterns |
| `/debug` | Real-time debug of current session state | Current session |
| `/ork:fix-issue` | Full RCA workflow for specific bug | Single issue |

## Quick Analysis

```bash
# Run batch analysis on last 24h of errors
python .claude/scripts/analyze_errors.py

# Analyze last 7 days
python .claude/scripts/analyze_errors.py --days 7

# Generate markdown report
python .claude/scripts/analyze_errors.py --report
```

## What Gets Captured

The error collector hook captures:
- Tool name (Bash, mcp__memory__search_nodes, etc.)
- Error message (first 500 chars)
- Tool input (command/query that failed)
- Timestamp and session ID

**Location:** `.claude/logs/errors.jsonl`

## Current Error Rules

Check learned patterns that trigger warnings:

```bash
cat .claude/rules/error_rules.json | jq '.rules[] | {id, signature, count: .occurrence_count}'
```

## Files

| File | Purpose |
|------|---------|
| `.claude/hooks/posttool/error-collector.sh` | Captures errors to JSONL |
| `.claude/hooks/pretool/bash/error-pattern-warner.sh` | Warns before risky commands |
| `.claude/scripts/analyze_errors.py` | Batch pattern analysis |
| `.claude/rules/error_rules.json` | Learned error patterns |
| `.claude/logs/errors.jsonl` | Raw error log |

## Common Patterns

### PostgreSQL Connection Errors

```
pattern: role "X" does not exist
fix: Use Docker connection: docker exec -it orchestkit-postgres-dev psql -U orchestkit_user -d orchestkit_dev

pattern: relation "X" does not exist
fix: Check MCP postgres server connection string - may be connected to wrong database
```

## Related Skills
- fix-issue: Fix identified errors
- debug-investigator: Debug error root causes
## Adding New Rules

Rules are auto-generated by `analyze_errors.py` when patterns repeat 2+ times.
For manual rules, edit `.claude/rules/error_rules.json`:

```json
{
  "id": "custom-001",
  "pattern": "your regex pattern",
  "signature": "human readable signature",
  "tool": "Bash",
  "occurrence_count": 1,
  "fix_suggestion": "How to fix this"
}
```

Overview

This skill performs error pattern analysis and troubleshooting for Claude Code sessions, surfacing recurring failures and actionable fixes. It captures runtime errors, learns common signatures, and produces reports or real-time warnings to speed diagnosis and remediation.

How this skill works

An error-collector hook records tool name, truncated error message, input that triggered the failure, timestamp, and session ID into a JSONL log. Batch analysis scripts scan recent logs to cluster repeated patterns, auto-generate rules when patterns repeat, and emit human-friendly fix suggestions or warnings for risky commands. A real-time debug endpoint inspects the current session state and flags matching rules immediately.

When to use it

  • After noticing recurring failures across runs to identify systemic issues
  • During incident response to quickly find likely root causes and fixes
  • Before running risky shell or database commands to get warnings
  • When generating a postmortem or RCA for a single bug
  • To monitor error trends over the last 24 hours or 7 days

Best practices

  • Collect errors continuously and centralize logs in the errors.jsonl file for accurate pattern detection
  • Run batch analysis regularly (daily/weekly) to keep auto-generated rules current
  • Review auto-generated rules and add manual fixes for edge cases to improve future suggestions
  • Use the real-time /debug flow for interactive troubleshooting of a live session
  • Keep fix suggestions concise and reproducible (commands, connection hints, config keys)

Example use cases

  • Run a 24-hour batch to surface the top PostgreSQL connection errors and get immediate remediation steps
  • Attach the real-time debugger to a stuck Claude Code session to detect which tool is failing
  • Auto-generate an error rule after two or more identical failures to trigger future warnings
  • Produce a markdown report summarizing error counts, signatures, and recommended fixes for an incident review
  • Warn users when a risky bash command matches a known dangerous pattern before execution

FAQ

How are error patterns detected?

Patterns are identified by clustering repeated error signatures in the JSONL logs; scripts mark a pattern when it repeats two or more times and optionally add a fix suggestion.

Where are errors stored and how do I inspect them?

Errors are written to a centralized JSONL log (errors.jsonl) with tool, truncated message, input, timestamp, and session ID; you can query this file or run the batch analyzer to generate reports.