Analyze Claude Code session logs to find recurring fail-then-fix patterns and propose CLAUDE.md rules to prevent them. Use when the user says "analyze errors", "find error patterns", "the same errors over and over", "what errors does Claude keep making", "what errors do you keep making", "what errors do I keep making", "what mistakes does Claude keep making", "what mistakes do you keep making", "what mistakes do I keep making", or wants to improve CLAUDE.md based on session history.
How this skill is triggered — by the user, by Claude, or both
Slash command
/claude-error-patterns:error-patternsThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Scan Claude Code session logs, find recurring fail-then-fix patterns, and help the user add preventive rules to CLAUDE.md.
Scan Claude Code session logs, find recurring fail-then-fix patterns, and help the user add preventive rules to CLAUDE.md.
Execute these 3 steps in order:
Run the analysis script:
python3 ${CLAUDE_SKILL_DIR}/scripts/error_patterns_cli.py --json --days 14
Adjust --days if the user specifies a different time range. Capture stdout (JSON) for parsing in Step 2.
If the user wants to exclude noisy categories (like generic_exit_code or generic_error), add --exclude generic_exit_code,generic_error.
Project filtering: If the user provides keywords after /error-patterns (e.g. /error-patterns code assistant), scope the analysis to a specific project:
~/.claude/projects/- as separators (e.g. -Users-<username>-code-assistant).--projects-dir ~/.claude/projects/<match>/ to the command.Parse the JSON output. Present two sections:
A. Fail-then-fix patterns (from the patterns array): recurring mistakes that Claude corrected.
B. Wheel-spinning patterns (from the wheel_spinning_patterns array): cases where Claude retried the same failing command 3+ times. Show the command pattern, average loop length, and whether it was eventually resolved.
For each section, show a numbered list (count >= 2):
Fail-then-fix patterns in the last 14 days (N files analyzed):
# | Count | Pattern | Category
----|-------|------------------------------------------------------|------------------
1 | 4 | Edit CLAUDE_HISTORY... — file modified since read | tool_error_unknown
2 | 4 | curl → AttributeError: 'NoneType'... | python_attribute
...
Wheel-spinning patterns (repeated failing attempts):
# | Count | Avg Length | Resolved? | Command Pattern
----|-------|-----------|-----------|----------------
1 | 2 | 5 attempts | 50% yes | gzcat cacna1...
...
Then ask the user:
Which pattern(s) would you like to add as CLAUDE.md rules? Enter numbers (e.g. "1,3,5"), "all", or "none".
For each selected pattern:
Check for suggested rule: The JSON output includes suggested_rule and suggested_section fields for well-known patterns. Use these when available.
Generate rule for unknown patterns: If no suggested_rule exists, derive one from the fail-then-fix example. Format: "When doing X, use Y instead of Z" or "Before doing X, always do Y first".
Check for duplicates: Read ~/.claude/CLAUDE.md and search for key terms from the proposed rule. If a similar rule already exists, tell the user and skip it.
Insert the rule: Find the appropriate section in CLAUDE.md (using suggested_section or inferring from context). Add the rule as a new bullet point (- ...) in that section.
Confirm: Show the user what was added and where.
--days 30).python3 ${CLAUDE_SKILL_DIR}/scripts/error_patterns_cli.py --list-categoriesnpx claudepluginhub bw2/claude-error-patternsAnalyzes and categorizes errors from Claude Code sessions with known resolution patterns. Searches memory for prior occurrences and delegates to debug-investigator for complex root cause analysis.
Analyzes Claude Code session transcripts for behavioral anti-patterns like edit thrashing, error loops, and correction-heavy interactions, then generates CLAUDE.md rules to prevent them.
Captures tool failures via PostToolUseFailure, detects error patterns in lessons-learned.md, promotes to permanent rules, and rotates files for Claude Code self-healing.