Teach Your AI to Learn from Mistakes with the Self-Improving-Agent Skill
Have you ever wished your AI coding agent could actually learn from its mistakes? Not just apologize and move on, but genuinely remember what went wrong and avoid repeating the same errors?
The self-improving-agent skill by @pskoett does exactly that—and it's quickly become one of ClawdHub's most popular skills with over 24,000 downloads and 210 stars.
The Problem: AI Amnesia
Every time you start a new session with your AI coding assistant, you're starting fresh. That brilliant debugging insight from yesterday? Gone. The quirky project convention you explained three times? Forgotten. The API gotcha that cost you an hour? Ready to bite you again.
The self-improving-agent skill creates a persistent learning system that captures these moments and makes them available to future sessions.
Installation
Getting started is simple:
clawdhub install self-improving-agentFor OpenClaw users, that's it—the skill integrates automatically with your workspace. For other agents like Claude Code or Codex CLI, you'll want to set up the hooks (more on that below).
How It Works
The skill creates a .learnings/ directory with three key files:
- LEARNINGS.md — Corrections, knowledge gaps, and best practices
- ERRORS.md — Command failures, exceptions, and integration issues
- FEATURE_REQUESTS.md — User-requested capabilities that don't exist yet
Whenever your agent encounters a triggering situation, it logs a structured entry. Here's what triggers automatic logging:
| Situation | What Gets Logged |
|---|---|
| Command fails unexpectedly | Error entry with reproduction steps |
| User says "No, that's wrong..." | Correction learning |
| User asks for missing feature | Feature request |
| API behaves differently than expected | Knowledge gap learning |
| Better approach discovered | Best practice learning |
Example: Capturing a Learning
When your agent makes a mistake and you correct it, it logs something like:
## [LRN-20260218-001] correction
**Logged**: 2026-02-18T06:15:00Z
**Priority**: medium
**Status**: pending
**Area**: config
### Summary
Project uses pnpm, not npm
### Details
Attempted `npm install` but lock file is pnpm-lock.yaml.
User corrected: must use `pnpm install`.
### Suggested Action
Check for pnpm-lock.yaml before running npm commands.
### Metadata
- Source: user_feedback
- Tags: package-manager, pnpm
---The Promotion System
The real power comes from promoting valuable learnings to permanent project memory. When a learning proves broadly applicable, the skill promotes it to:
| Learning Type | Promotes To | Example |
|---|---|---|
| Behavioral patterns | SOUL.md | "Be concise, avoid disclaimers" |
| Workflow improvements | AGENTS.md | "Spawn sub-agents for long tasks" |
| Tool gotchas | TOOLS.md | "Git push needs auth configured first" |
| Project conventions | CLAUDE.md | "Use pnpm, not npm" |
This creates a virtuous cycle: mistakes become learnings, learnings become permanent knowledge, and future sessions start smarter.
Setting Up Hooks (Optional but Recommended)
For automatic reminders and error detection, add hooks to your agent config:
For Claude Code (.claude/settings.json):
{
"hooks": {
"UserPromptSubmit": [{
"matcher": "",
"hooks": [{
"type": "command",
"command": "./skills/self-improvement/scripts/activator.sh"
}]
}]
}
}For OpenClaw, copy the hook to your hooks directory:
cp -r hooks/openclaw ~/.openclaw/hooks/self-improvement
openclaw hooks enable self-improvementPro Tips
-
Log immediately — Context is freshest right after an issue occurs. Don't wait until the end of the session.
-
Search before logging — Check for related entries with
grep -r "keyword" .learnings/to avoid duplicates and link related issues. -
Promote aggressively — If a learning would help future sessions, add it to CLAUDE.md or AGENTS.md. Don't let valuable insights languish in the backlog.
-
Review regularly — Before major tasks, scan
.learnings/for relevant context. A quickgrep -B5 "Priority**: high" .learnings/*.mdshows pending high-priority items. -
Extract to skills — When a learning is valuable enough to share, the skill includes an extraction script:
./scripts/extract-skill.sh skill-name
Why This Matters
The self-improving-agent skill transforms your AI assistant from a stateless tool into something that genuinely grows more capable over time. Every correction teaches it something. Every error becomes documented knowledge. Every "actually, you should..." becomes a permanent improvement.
After a few weeks of use, you'll have a personalized knowledge base of your project's quirks, conventions, and gotchas—all automatically captured and ready to inform every future session.
Links:
Comments (0)
No comments yet. Be the first to comment!