learning-from-failures
Use when failures occur in agent systems, workflows, or validations to capture institutional knowledge and prevent recurring issues. Converts failure patterns into preventive warnings.
What this skill does
# Learning from Failures
## Overview
**Learning from failures IS converting failure patterns into institutional knowledge.**
When agent systems, workflows, or validations fail, this skill converts failure cases into reusable preventive knowledge. Systematically record failure patterns, extract common characteristics, establish preventive measures, and avoid the same problems from recurring.
**Core principle:** Every failure is a learning opportunity. Convert failure patterns into preventive warnings and build institutional memory.
**Feedback loop:** Failure case → pattern extraction → prevention measures → warning system → preventive execution
## Routing
**Pattern:** Utility
**Trigger:** Validation failures, workflow interruptions, agent system issues
**Mode:** Passive trigger, problem analysis
**Chain:** standalone
## Task Initialization (MANDATORY)
Before ANY action, create task list using TaskCreate:
```
TaskCreate for EACH task below:
- Subject: "[learning-from-failures] Task N: <action>"
- ActiveForm: "<doing action>"
```
**Tasks:**
1. Analyze failure context
2. Extract failure patterns
3. Generate prevention measures
4. Store institutional memory
5. Integrate learning warnings
Announce: "Created 5 tasks. Starting execution..."
**Execution rules:**
1. `TaskUpdate status="in_progress"` BEFORE starting each task
2. `TaskUpdate status="completed"` ONLY after verification passes
3. If task fails → stay in_progress, diagnose, retry
4. NEVER skip to next task until current is completed
5. At end, `TaskList` to confirm all completed
## Task 1: Analyze Failure Context
**Goal:** Analyze the failure context and identify key factors.
**Session type check (FIRST):**
| Session type | What to capture |
|--------------|-----------------|
| **Debug session** | TWO learning targets: (1) the bug itself — root cause, reproduction condition, prevention rule; (2) any model reasoning errors made during debugging |
| **Workflow failure** | The workflow gap or validation failure as a pattern |
| **Agent system issue** | Component misconfiguration, chain break, or bad architecture decision |
**If this is a debug session, capture the bug separately BEFORE analyzing model errors:**
- What is the bug? (exact behavior, not just symptoms)
- What condition triggers it?
- Why did it occur? (root cause, not just the fix)
- What prevention rule would have caught it early?
**Analysis dimensions:**
- **Failure type:** Code bug, code anti-pattern, workflow gap, security blind spot, integration missing, model reasoning error
- **Trigger condition:** When, where, how it was triggered
- **Impact scope:** Affected components, workflows, users
- **Root cause analysis:** Technical factors, process factors, knowledge gaps
**Data collection:**
- Error messages and stack traces
- Relevant code and configuration
- Workflow context
- Similar historical cases
**Verification:** Clear understanding of the complete failure context and root cause. Debug sessions have identified and separately documented the bug itself and model errors.
## Task 2: Extract Failure Patterns
**Goal:** Extract reusable pattern characteristics from failure cases.
**Important:** Read [references/memory-patterns.md](references/memory-patterns.md) for pattern classification and extraction strategies.
**For debug sessions — extract the bug as a separate pattern entry:**
```
Pattern type: code-bug
Context: [language/framework/component where bug lives]
Trigger: [exact condition that causes the bug]
Root cause: [why it happened]
Prevention rule: [what check would catch it before it reaches production]
```
This is distinct from model reasoning errors. A bug pattern prevents the same bug from being introduced again; a model error pattern prevents the same debugging mistake.
**Pattern extraction process:**
1. **Context matching:** Identify trigger conditions and environment characteristics
2. **Problem identification:** Specific failure pattern and mechanism
3. **Detection rules:** How to catch this type of problem early
4. **Prevention measures:** How to prevent recurrence
**Use memory-manager.py to extract patterns:**
```bash
python plugins/rcc/skills/learning-from-failures/scripts/memory-manager.py extract-pattern \
--failure-type "code-anti-pattern" \
--context "TypeScript interface definition" \
--problem "type mismatch causes runtime error"
```
**Verification:** Pattern is structurally documented with detection and prevention elements.
## Task 3: Generate Prevention Measures
**Goal:** Create concrete prevention measures for identified patterns.
**Prevention measure types:**
- **Code checks:** Static analysis rules, type checking
- **Workflow guards:** Process checkpoints, validation steps
- **Integration tests:** Automated test cases
- **Documentation standards:** Best practice guidelines
**Warning generation:**
- Warning messages targeting specific components
- Checklists for relevant contexts
- Concrete steps for preventive actions
**Verification:** Prevention measures are specific and actionable; warning messages are clear.
## Task 4: Store Institutional Memory
**Goal:** Store learning results in the memory system.
**Memory structure:**
```
.rcc/memory/
├── patterns/ # Learned pattern library
├── failures/ # Failure case records
└── preventions/ # Prevention measure list
```
**Use memory-manager.py to record:**
```bash
python plugins/rcc/skills/learning-from-failures/scripts/memory-manager.py record-failure \
--type "integration-missing" \
--component "agent-system" \
--description "agent communication lacks error handling"
```
**Memory format:**
```markdown
## Pattern: [Pattern Name]
**Context:** When [situation]
**Problem:** [specific failure mode]
**Detection:** [how to catch it early]
**Prevention:** [how to prevent it]
**Examples:** [real cases that triggered this learning]
```
**Verification:** Memory file created, structure complete, retrievable.
## Task 5: Integrate Learning Warnings
**Goal:** Integrate learning results into relevant skills and workflows.
**Integration points:**
- **planning-agent-systems:** Load warnings before architecture decisions
- **writing-* skills:** Apply prevention measures
- **hook scripts:** Check for known failure patterns
**Warning retrieval command:**
```bash
echo '{"component":"agent-system","context":"planning","type":"all"}' | \
python plugins/rcc/skills/learning-from-failures/scripts/memory-manager.py get-warnings
```
**Update relevant skills:** Add learning integration check in planning-agent-systems Task 2.
**Verification:** Warning system integrated and triggerable in relevant workflows.
## Red Flags - STOP
These thoughts mean you're rationalizing. STOP and reconsider:
- "Skip failure analysis"
- "Apply a generic solution directly"
- "Ignore the root cause"
- "Don't record the learning"
- "Simplify the prevention measures"
- "Skip the integration step"
- "Assume it won't happen again"
## Common Rationalizations
| Thought | Reality |
|---------|---------|
| "Skip failure analysis" | Unanalyzed failures recur |
| "Apply generic solution" | Generic solutions ignore specific context |
| "Ignore root cause" | Treating symptoms cannot prevent recurrence |
| "Don't record learning" | Knowledge lost; team cannot benefit |
| "Simplify prevention" | Simplified measures fail to prevent effectively |
| "Skip integration" | Learning cannot be applied to actual workflows |
| "Won't happen again" | Failure patterns recur in similar contexts |
## Flowchart: Learning from Failures
```dot
digraph learning_from_failures {
rankdir=TB;
start [label="Failure occurs", shape=doublecircle];
analyze [label="Task 1: Analyze\nfailure context", shape=box];
extract [label="Task 2: Extract\nfailure patterns", shape=box];
prevent [label="Task 3: Generate\nprevention measures", shape=box];
store [label="Task 4: Store\ninstitutional memory", shape=box];
integrate [label="Task 5: IntegRelated in AI Agents
skill-development
IncludedComprehensive meta-skill for creating, managing, validating, auditing, and distributing Claude Code skills and slash commands (unified in v2.1.3+). Provides skill templates, creation workflows, validation patterns, audit checklists, naming conventions, YAML frontmatter guidance, progressive disclosure examples, and best practices lookup. Use when creating new skills, validating existing skills, auditing skill quality, understanding skill architecture, needing skill templates, learning about YAML frontmatter requirements, progressive disclosure patterns, tool restrictions (allowed-tools), skill composition, skill naming conventions, troubleshooting skill activation issues, creating custom slash commands, configuring command frontmatter, using command arguments ($ARGUMENTS, $1, $2), bash execution in commands, file references in commands, command namespacing, plugin commands, MCP slash commands, Skill tool configuration, or deciding between skills vs slash commands. Delegates to docs-management skill for official documentation.
reprompter
IncludedTransform messy prompts into well-structured, effective prompts — single or multi-agent. Use when: "reprompt", "reprompt this", "clean up this prompt", "structure my prompt", rough text needing XML tags and best practices, "reprompter teams", "repromptception", "run with quality", "smart run", "smart agents", multi-agent tasks, audits, parallel work, anything going to agent teams. Don't use when: simple Q&A, pure chat, immediate execution-only tasks. See "Don't Use When" section for details. Outputs: Structured XML/Markdown prompt, quality score (before/after), optional team brief + per-agent sub-prompts, agent team output files. Success criteria: Single mode quality score ≥ 7/10; Repromptception per-agent prompt quality score 8+/10; all required sections present, actionable and specific.
adaptive-compaction
IncludedAdaptive add-on policy and recovery layer that decides WHEN to compact, prune, snapshot, or fork -- replacing fixed-percent auto-compaction across Claude Code, Codex, and MCP-capable hosts. Trigger on auto-compact timing or damage: "when should I compact", "is it safe to compact now or start a fresh session", "auto-compact fires too early/mid-task", "switching to an unrelated task but the window still has space", "context rot", "answers get worse the longer the session runs", "the agent forgot the plan or my decisions after it summarized", "add a layer on top that manages context without changing the agent", raising autoCompactWindow to give the policy room, or installing/tuning a cross-tool compaction policy or PreCompact hook -- even when "compaction" is never said but the problem is context-window pressure or post-summarization memory loss. Do NOT use to summarize a conversation, build RAG, write a summarization prompt (decides WHEN not HOW), or answer max-context-length trivia.
agent-skill-creator
IncludedCreate cross-platform agent skills from workflow descriptions. Activates when users ask to create an agent, automate a repetitive workflow, create a custom skill, or need advanced agent creation. Triggers on phrases like create agent for, automate workflow, create skill for, every day I have to, daily I need to, turn process into agent, need to automate, create a cross-platform skill, validate this skill, export this skill, migrate this skill. Supports single skills, multi-agent suites, transcript processing, template-based creation, interactive configuration, cross-platform export, and spec validation.
llm-wiki
IncludedUse when building or maintaining a persistent personal knowledge base (second brain) in Obsidian where an LLM incrementally ingests sources, updates entity/concept pages, maintains cross-references, and keeps a synthesis current. Triggers include "second brain", "Obsidian wiki", "personal knowledge management", "ingest this paper/article/book", "build a research wiki", "compound knowledge", "Memex", or whenever the user wants knowledge to accumulate across sessions instead of being re-derived by RAG on every query.
skill-master
IncludedAgent Skills authoring, evaluation, and optimization. Create, edit, validate, benchmark, and improve skills following the agentskills.io specification. Use when designing SKILL.md files, structuring skill folders (references, scripts, assets), ingesting external documentation into skills, running trigger evals, benchmarking skill quality, optimizing descriptions, or performing blind A/B comparisons. Keywords: agentskills.io, SKILL.md, skill authoring, eval, benchmark, trigger optimization.