cat:learn-from-mistakes
Analyze mistakes with conversation length as potential cause (CAT-specific)
What this skill does
# Learn From Mistakes (CAT-Specific)
## Purpose
Analyze mistakes using 5-whys with CAT-specific consideration of conversation length and context
degradation. Integrates token tracking to identify context-related failures and recommend preventive
measures including earlier decomposition.
## When to Use
- Any mistake during CAT orchestration
- Subagent produces incorrect/incomplete results
- Task requires rework or correction
- Build/test/logical errors
- Repeated attempts at same operation
- Quality degradation over time
## Workflow
### 1. Verify Event Sequence (MANDATORY)
**CRITICAL: Do NOT rely on memory for root cause analysis.**
Verify actual event sequence using get-history:
```bash
/cat:get-history
# Look for: When stated? Action order? User corrections? Actual trigger?
```
**Anti-Pattern (M037):** Root cause analysis based on memory without get-history verification.
Memory is unreliable for causation, timing, attribution.
**If get-history unavailable:** Document analysis based on current context only, may be incomplete.
### 2. Document the Mistake
```yaml
mistake:
timestamp: 2026-01-10T16:30:00Z
type: incorrect_implementation
description: |
Subagent implemented parser with wrong precedence rules.
Expressions like "a + b * c" parsed as "(a + b) * c" instead of "a + (b * c)".
impact: |
All tests using operator precedence failing. Required complete rewrite.
```
### 3. Gather Context Metrics
**CAT-specific: Always collect token data**
```bash
SESSION_ID="${SUBAGENT_SESSION}"
SESSION_FILE="/home/node/.config/claude/projects/-workspace/${SESSION_ID}.jsonl"
TOKENS_AT_ERROR=$(jq -s 'map(select(.type == "assistant")) |
map(.message.usage | .input_tokens + .output_tokens) | add' "${SESSION_FILE}")
COMPACTIONS=$(jq -s '[.[] | select(.type == "summary")] | length' "${SESSION_FILE}")
MESSAGE_COUNT=$(jq -s '[.[] | select(.type == "assistant")] | length' "${SESSION_FILE}")
SESSION_DURATION=$(calculate_duration "${SESSION_FILE}")
```
### 4. Perform Root Cause Analysis
**A/B TEST IN PROGRESS** - See [RCA-AB-TEST.md](RCA-AB-TEST.md) for full specification.
**Method Assignment Rule:** Use mistake ID modulo 3:
- IDs ending in 6,9,2,5,8 (mod 3 = 0) → Method A (5-Whys)
- IDs ending in 7,0,3 (mod 3 = 1) → Method B (Taxonomy)
- IDs ending in 8,1,4 (mod 3 = 2) → Method C (Causal Barrier)
---
#### Method A: 5-Whys (Control)
Ask "why" iteratively until reaching fundamental cause (typically 5 levels):
```yaml
five_whys:
- why: "Why did this happen?"
answer: "Immediate cause of the mistake"
- why: "Why [previous answer]?"
answer: "Deeper contributing factor"
- why: "Why [previous answer]?"
answer: "Organizational or process factor"
- why: "Why [previous answer]?"
answer: "Systemic or environmental factor"
- why: "Why [previous answer]?"
answer: "Root cause - fundamental issue"
root_cause: "The fundamental issue identified at deepest 'why'"
category: "Select from category reference"
rca_method: "A"
```
**Example:**
```yaml
five_whys:
- why: "Why was precedence implemented incorrectly?"
answer: "Subagent confused multiplication and addition handling"
- why: "Why was the subagent confused?"
answer: "Earlier context about precedence rules was not referenced"
- why: "Why wasn't earlier context referenced?"
answer: "Session had 95K tokens, approaching context limit"
- why: "Why were there 95K tokens in the session?"
answer: "Task scope was too large for single context window"
- why: "Why wasn't the task decomposed earlier?"
answer: "Token monitoring wasn't triggering at 40% threshold"
root_cause: "Task exceeded safe context bounds without decomposition"
category: "context_degradation"
rca_method: "A"
```
**Check against common root cause patterns:**
- Assumption without verification?
- Completion bias (rationalized ignoring rules)?
- Memory reliance (didn't re-verify)?
- Environment state mismatch?
- Documentation ignored (rule existed)?
---
#### Method B: Modular Error Taxonomy
Based on [AgentErrorTaxonomy](https://arxiv.org/abs/2509.25370) (24% accuracy improvement).
```yaml
taxonomy_analysis:
# Step 1: Classify into module
module: MEMORY | PLANNING | ACTION | REFLECTION | SYSTEM
module_definitions:
MEMORY: "Failed to retain/recall earlier context"
PLANNING: "Poor task decomposition or sequencing"
ACTION: "Incorrect tool use or execution"
REFLECTION: "Failed to detect/correct own error"
SYSTEM: "Environment, tooling, or integration failure"
# Step 2: Identify failure mode within module
failure_mode: "What specific capability failed?"
failure_type: FALSE_POSITIVE | FALSE_NEGATIVE
# FALSE_POSITIVE = did something wrong
# FALSE_NEGATIVE = missed something
# Step 3: Check for cascading
cascading:
caused_downstream: true | false
is_symptom_of: null | "earlier failure description"
# Step 4: Corrective feedback
corrective_feedback: "What specific guidance would have prevented this?"
intervention_point: "At what step should intervention have occurred?"
root_cause: "..."
category: "..."
rca_method: "B"
```
---
#### Method C: Causal Barrier Analysis
Based on [causal reasoning research](https://www.infoq.com/articles/causal-reasoning-observability/).
```yaml
causal_barrier_analysis:
# Step 1: List ALL candidate causes
candidates:
- cause: "Knowledge gap - didn't know correct approach"
expected_symptoms: ["asked questions", "explored alternatives"]
observed: false
likelihood: LOW
- cause: "Compliance failure - knew rule, didn't follow"
expected_symptoms: ["rule exists in docs", "no confusion expressed"]
observed: true
likelihood: HIGH
- cause: "Tool limitation - tool couldn't do what was needed"
expected_symptoms: ["error messages", "tried alternatives"]
observed: false
likelihood: LOW
# Step 2: Select most likely cause
selected_cause: "Compliance failure"
confidence: HIGH | MEDIUM | LOW
evidence: "Rule documented in X, no exploration attempts observed"
# Step 3: Verify cause vs symptom
verification:
question: "If we fixed this, would the problem definitely not recur?"
answer: "Yes, if enforcement hook blocks the incorrect behavior"
is_root_cause: true # If uncertain, this may be a symptom
# Step 4: Barrier analysis
barriers:
- barrier: "Documentation in CLAUDE.md"
existed: true
why_failed: "Agent did not read/follow it"
- barrier: "PreToolUse hook"
existed: false
should_exist: true
strength_if_added: "Would block incorrect behavior"
minimum_effective_barrier: "hook (level 2)"
root_cause: "..."
category: "..."
rca_method: "C"
```
---
**Record the method used** in the final JSON entry:
```json
{
"rca_method": "A|B|C",
"rca_method_name": "5-whys|taxonomy|causal-barrier"
}
```
### 5. Check for Context Degradation Patterns
**CAT-specific analysis checklist:**
Reference: agent-architecture.md § Context Limit Constants
```yaml
context_degradation_analysis:
tokens_at_error: 95000
threshold_exceeded: true
threshold_exceeded_by: 15000
compaction_events: 2
errors_after_compaction: true
session_duration: 4.5 hours
messages_before_error: 127
early_session_quality: high
late_session_quality: degraded
quality_degradation_detected: true
context_related: LIKELY
confidence: 0.85
```
### 6. Identify Prevention Level
**Choose the strongest prevention level that addresses the root cause:**
```yaml
prevention_hierarchy:
- level: 1
type: code_fix
description: "Make incorrect behavior impossible in code"
examples: ["compile-time check", "type system enforcement", "API design"]
- level: 2
type: hook
description: "Automated enforcement via PreToolUse/PostToolUse hooks"
examples: ["block dangerous commands", "require confirmation", "validate state"]
- level: 3
type: validation
description: "Automated checks that caRelated in General
modeling-omnistudio-epc-catalog
IncludedSalesforce Industries CME EPC product-modeling skill for Product2-based catalog creation. Use when creating EPC products, configuring product attributes, building offer bundles with Product Child Items, or reviewing EPC DataPack JSON metadata for product catalog changes. TRIGGER when: user creates or updates Product2 EPC records, AttributeAssignment payloads, AttributeMetadata/AttributeDefaultValues, Offer bundles, or ProductChildItem relationships. DO NOT TRIGGER when: designing OmniScripts/FlexCards/Integration Procedures (use building-omnistudio-omniscript, building-omnistudio-flexcard, or building-omnistudio-integration-procedure), implementing Apex business logic (use generating-apex), or troubleshooting deployment pipelines (use deploying-metadata).
relationship-science-coach
IncludedUse this skill for direct, practical adult relationship coaching: couples conflict, repair, trust, marriage, dating, flirting, attachment patterns, emotional connection, sex, desire differences, eroticism, kink negotiation, affection, love languages, breakups, and long-term passion. Draw on Gottman, EFT and Hold Me Tight, attachment science, modern sex research, Perel, Nagoski, Kerner, Schnarch, Love and Stosny, and flexible love-language tools. Be concrete and low-hedge. Redirect only for imminent danger, abuse, coercive control, minors, non-consent, self-harm, stalking, or medical/legal/psychiatric decisions.
building-sf-integrations
IncludedSalesforce integration architecture and runtime plumbing with 120-point scoring. Use this skill to set up Named Credentials, External Credentials, External Services, REST/SOAP callout patterns, Platform Events, and Change Data Capture. TRIGGER when: user sets up Named Credentials, External Services, REST/SOAP callouts, Platform Events, CDC, or touches .namedCredential-meta.xml files. DO NOT TRIGGER when: Connected App/OAuth config (use configuring-connected-apps), Apex-only logic (use generating-apex), or data import/export (use handling-sf-data).
venue-templates
IncludedAccess comprehensive LaTeX templates, formatting requirements, and submission guidelines for major scientific publication venues (Nature, Science, PLOS, IEEE, ACM), academic conferences (NeurIPS, ICML, CVPR, CHI), research posters, and grant proposals (NSF, NIH, DOE, DARPA). This skill should be used when preparing manuscripts for journal submission, conference papers, research posters, or grant proposals and need venue-specific formatting requirements and templates.
let-fate-decide
IncludedDraws the 12 Houses of the Zodiac Tarot spread to inject entropy into planning when prompts are vague, ambiguous, or casually delegated. Interprets the spread to guide next steps. Use when the user says 'let fate decide', 'YOLO', 'whatever', 'idk', or other nonchalant phrases, makes Yu-Gi-Oh references, or when you are about to arbitrarily pick between multiple reasonable approaches. Prefer over ask-questions-if-underspecified when the user's tone is casual or playful rather than precision-seeking.
net-ops
IncludedCross-platform network troubleshooting (Windows, macOS, Linux) via local or remote shell. Use for: DNS broken, can't resolve hostnames, nslookup/dig works but apps fail, NRPT, WFP, scutil, /etc/resolver, systemd-resolved, /etc/resolv.conf, NetworkManager, VPN DNS leak residue (ProtonVPN/Mullvad/WireGuard/AnyConnect), AV/firewall blocking DNS or DoH, Tailscale DNS interaction, intermittent connectivity, remote diagnostics over SSH.