errors

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Error Pattern Analysis

错误模式分析

Analyze errors captured from Claude Code sessions to identify patterns and get actionable insights.
分析从Claude Code会话中捕获的错误,识别模式并获取可执行的洞察。

Quick Start

快速开始

bash
/errors              # Batch analysis of historical error patterns
/debug               # CC 2.1.30 real-time debug for current session
bash
/errors              # 批量分析历史错误模式
/debug               # 当前会话的CC 2.1.30实时调试

When to Use Which

场景选择指南

CommandPurposeScope
/errors
Batch analysis of error patterns (last 24h/7d)Historical patterns
/debug
Real-time debug of current session stateCurrent session
/ork:fix-issue
Full RCA workflow for specific bugSingle issue
命令用途范围
/errors
批量分析错误模式(最近24小时/7天)历史模式
/debug
当前会话状态的实时调试当前会话
/ork:fix-issue
特定bug的完整RCA(根本原因分析)流程单个问题

Quick Analysis

快速分析

bash
undefined
bash
undefined

Run batch analysis on last 24h of errors

对最近24小时的错误进行批量分析

python .claude/scripts/analyze_errors.py
python .claude/scripts/analyze_errors.py

Analyze last 7 days

分析最近7天的错误

python .claude/scripts/analyze_errors.py --days 7
python .claude/scripts/analyze_errors.py --days 7

Generate markdown report

生成Markdown报告

python .claude/scripts/analyze_errors.py --report
undefined
python .claude/scripts/analyze_errors.py --report
undefined

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
错误收集钩子会捕获以下信息:
  • 工具名称(Bash、mcp__memory__search_nodes等)
  • 错误信息(前500个字符)
  • 工具输入(执行失败的命令/查询)
  • 时间戳和会话ID
存储位置:
.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}'
查看触发警告的已学习模式:
bash
cat .claude/rules/error_rules.json | jq '.rules[] | {id, signature, count: .occurrence_count}'

Files

文件说明

FilePurpose
.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
文件用途
.claude/hooks/posttool/error-collector.sh
将错误捕获至JSONL文件
.claude/hooks/pretool/bash/error-pattern-warner.sh
在执行高风险命令前发出警告
.claude/scripts/analyze_errors.py
批量模式分析
.claude/rules/error_rules.json
已学习的错误模式
.claude/logs/errors.jsonl
原始错误日志

Common Patterns

常见模式

PostgreSQL Connection Errors

PostgreSQL连接错误

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
模式:role "X" does not exist
修复方案:使用Docker连接:docker exec -it orchestkit-postgres-dev psql -U orchestkit_user -d orchestkit_dev

模式:relation "X" does not exist
修复方案:检查MCP PostgreSQL服务器连接字符串 - 可能连接到了错误的数据库

Related Skills

相关技能

  • fix-issue: Fix identified errors
  • debug-investigator: Debug error root causes
  • fix-issue:修复已识别的错误
  • debug-investigator:调试错误根本原因

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"
}
当错误模式重复出现2次及以上时,
analyze_errors.py
会自动生成规则。 如需手动添加规则,请编辑
.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"
}