learn-from-failure — Claude Code skill for recurring errors
The learn-from-failure Claude Code skill classifies failures and checks whether their causes have appeared before. Repeated problems lead to a durable artifact meant to prevent another recurrence.
MIT ★ 26 updated 2026-11-16
npx skills add wrg32786/aigent-os --skill learn-from-failure -a claude-codeWhat learn-from-failure does
The skill classifies a failure, searches $AIGENT_VAULT/memory/FAILURE_MODES.md for matching patterns, then adds an entry to the ledger. With 0–1 earlier occurrences, it logs and monitors the issue; at 2 or more, it requires an artifact. At 3 or more, it treats the earlier artifact as failed and calls for diagnosis and repair or replacement.
The failure category determines the artifact: routing problems change a skill description or add a hook, while verification problems add a runnable check to a doctrine note. Tool failures go into SKILL_GAPS.md; knowledge gaps become notes, and authority violations are surfaced to the operator. The skill needs $AIGENT_VAULT and its memory/FAILURE_MODES.md ledger.
Run /learn-from-failure with an optional failure description. If the command has no argument, the skill asks what went wrong.
What it helps with
- classify the cause of a failure
- find earlier instances of the same problem
- decide when a recurring issue needs a lasting fix
- record the cause, remedy, and affected system layer
Example prompts for the agent
- Analyze this recurring failure: the agent picked the wrong tool.
/learn-from-failureThe data verification error happened again./learn-from-failureLog the Gmail MCP authentication failure and check for earlier cases.
How to install learn-from-failure
1Skills CLI (Vercel)
npx skills add wrg32786/aigent-os --skill learn-from-failure -a claude-code2Manually: put the files in place
~/.claude/skills/learn-from-failure/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/learn-from-failure/
1Skills CLI (Vercel)
npx skills add wrg32786/aigent-os --skill learn-from-failure -a codex2Manually: put the files in place
.agents/skills/learn-from-failure/SKILL.mdFor all projects use ~/.agents/skills/
1Skills CLI (Vercel)
npx skills add wrg32786/aigent-os --skill learn-from-failure -a cursor2Manually: put the files in place
.cursor/skills/learn-from-failure/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install wrg32786/aigent-os skills/learn-from-failure2Manually: put the files in place
.github/skills/learn-from-failure/SKILL.md1Skills CLI (Vercel)
npx skills add wrg32786/aigent-os --skill learn-from-failure -a gemini-cli2Platform CLI
gemini skills install https://github.com/wrg32786/aigent-os --path skills/learn-from-failureManually: put the files in place
.devin/skills/learn-from-failure/SKILL.mdThe legacy .windsurf/skills/ path still works
Skills CLI (Vercel)
npx skills add wrg32786/aigent-os --skill learn-from-failure -a opencodeClaude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
Step by step, with commands for each platform: How to install skills in Claude Code: five ways
Questions about learn-from-failure
How do I install learn-from-failure in Claude Code?
Run npx skills add wrg32786/aigent-os --skill learn-from-failure -a claude-code. The skill file is installed at ~/.claude/skills/learn-from-failure/SKILL.md.
What does learn-from-failure do?
It classifies a failure, checks the ledger for matching causes, and selects an artifact to capture the remedy. Repeated failures trigger a lasting fix; after the third occurrence, the earlier artifact is diagnosed and repaired or replaced.
What does learn-from-failure need to run?
It needs $AIGENT_VAULT with the memory/FAILURE_MODES.md ledger. The skill searches that file for recurring patterns and appends new failure records.
Source text
SKILL.md · MIT
---
name: learn-from-failure
description: "Convert failures into reusable artifacts and check repetition. Use when analyzing a failure mode or a recurring failure."
---
# /learn-from-failure — Convert failure to reusable artifact
When a failure occurs, classify it, check for repetition, and produce a durable artifact that prevents recurrence.
## Trigger
`/learn-from-failure` or `/learn-from-failure <failure description>`
Use on: "same issue", "happened again", "recurring", "third time", "keeps happening"
## Flow
### 1. Identify failure
- If argument provided: use it
- If no argument: ask "What failed?"
### 2. Classify failure mode
| Mode | Description | Example |
|------|-------------|---------|
| `routing` | Task sent to wrong agent/model/tool | Opus used for a read-only task |
| `verification` | Output accepted without checking data flow | Video "looked fine" but spec was wrong |
| `tool` | Tool unavailable, broken API, wrong usage | Gmail MCP auth expired |
| `knowledge` | Agent lacked domain knowledge | Didn't know SDK v6 changed type strings |
| `authority` | Agent acted outside delegation zone | the AIgent made a Level 3 decision |
### 3. Check for repetition
Read `$AIGENT_VAULT/memory/FAILURE_MODES.md`. Search for Pattern lines matching the current failure's root cause.
- **0-1 prior occurrences:** Phase 1 — log and monitor
- **2+ occurrences:** Phase 2 — mandatory artifact. A log entry is not enough.
- **3+ occurrences:** The prior artifact failed. Diagnose why and fix or replace it.
### 4. Log to FAILURE_MODES.md
Append a new entry following the existing format:
```markdown
## {YYYY-MM-DD} — {short symptom name}
**Symptom:** {what went wrong, user-visible}
**Verified cause:** {exact mechanism}
**Fix:** {what was done}
**Layer:** {which system layer}
**Pattern:** {one-line category — this is the load-bearing piece for repetition detection}
```
### 5. Determine artifact type
| Failure mode | Artifact | Target |
|---|---|---|
| `routing` | Skill description or hook | the skill's `SKILL.md` description, or `.claude/hooks/` |
| `verification` | Checklist item in doctrine | Relevant doctrine note |
| `tool` | SKILL_GAPS entry + skill spec | `memory/SKILL_GAPS.md` |
| `knowledge` | Vault note or memory candidate | `concepts/` or `memory/` |
| `authority` | Flag to the operator | `aigent_authority_matrix.md` |
### 6. Create artifact
- For routing: add 3+ trigger phrases to the skill's `description` ("Use when ...")
- For verification: append a concrete, runnable check to the relevant doctrine
- For tool: log to SKILL_GAPS.md, suggest /skill-hunt if external capability needed
- For knowledge: write a memory candidate or vault note
- For authority: surface to the operator with recommendation
### 7. Output
```
Failure logged: {classification}
Pattern: {pattern line}
Repeated: {yes/no, count}
Artifact: {type} at {path}
```
## Boundary
Per [[Self-Learning Doctrine]]: a failure logged without an artifact is a false resolution. The ledger grows, the failure recurs, the system learns nothing.
## Bounded procedure experiment (fixture only)
A Finding is an observation, not a verified cause or authority to edit a procedure.
The [fixture mechanics](../../evals/procedure-experiment/README.md) use a declarative grammar and a pinned historical corpus.
Freeze the candidate, evidence, corpus, size budgets and rollback before evaluating.
Require a passing verdict and a caller-supplied approval bound to the candidate and base.
Distinct identity strings are not authenticated review.
This proves mechanics on a fixture, not natural-language procedure compliance or live behavior.
## Related
- [[concepts/Self-Learning Doctrine]] — the doctrine this skill implements
- [[memory/FAILURE_MODES.md]] — the ledger
- [[concepts/Capability Expansion Doctrine]] — tool failures feed the expansion loop
- [[Self-Improving CLAUDE.md]] — the broader self-improvement cycle
© wrg32786 · MIT · wrg32786/aigent-os