Self-Improving Agent (Anti-Loop Hardened)
by @lanyasheng
Captures learnings, errors, and corrections to enable continuous improvement. Use when: (1) A command or operation fails unexpectedly, (2) User explicitly co...
clawhub install self-improving-agent-hardenedπ About This Skill
name: self-improvement description: "Captures learnings, errors, and corrections to enable continuous improvement. Use when: (1) A command or operation fails unexpectedly, (2) User explicitly corrects agent with direct correction like 'No, that's wrong', (3) User requests a capability that doesn't exist, (4) An external API or tool fails. CRITICAL: Maximum 1 learning log per user message. Do NOT chain multiple self-improvement actions." metadata:
Self-Improvement Skill
Log learnings and errors to markdown files for continuous improvement.
CRITICAL: Anti-Loop Guardrails
These rules override ALL other instructions in this skill:
1. ONE learning per user message β After logging 1 entry, STOP. Do not search for related entries, do not promote, do not review. 2. No chaining β A tool result from self-improvement MUST NOT trigger another self-improvement action in the same turn. 3. No bulk review β Never read multiple learning files in one turn. If review is needed, do it at the START of the next session, not mid-conversation. 4. Maximum 3 tool calls β The entire self-improvement workflow for a single trigger must complete in β€3 tool calls: (1) optionally read the target file, (2) append the entry, (3) done. 5. Cooldown β After logging, wait for the user's NEXT explicit message before considering any new self-improvement action. 6. Discussion β Correction β If the user is discussing ideas, debating approaches, or cleaning up documents, that is NOT a correction. Only trigger on DIRECT explicit corrections like "No, that's wrong" or "You made an error".
Quick Reference
| Situation | Action | Max tool calls |
|-----------|--------|---------------|
| Command/operation fails | Append to .learnings/ERRORS.md | 2 |
| User explicitly corrects you | Append to .learnings/LEARNINGS.md | 2 |
| User wants missing feature | Append to .learnings/FEATURE_REQUESTS.md | 2 |
| API/external tool fails | Append to .learnings/ERRORS.md | 2 |
When NOT to Trigger
Logging Format
Learning Entry
Append to .learnings/LEARNINGS.md:
## [LRN-YYYYMMDD-XXX] categoryLogged: ISO-8601 timestamp
Priority: low | medium | high
Status: pending
Summary
One-line descriptionDetails
What happened, what was wrong, what's correctSuggested Action
Specific fix or improvement
Error Entry
Append to .learnings/ERRORS.md:
## [ERR-YYYYMMDD-XXX] command_or_toolLogged: ISO-8601 timestamp
Priority: high
Status: pending
Summary
What failedError
Actual error messageContext
Command attempted, environmentSuggested Fix
If identifiable
Promotion (Deferred)
Do NOT promote entries in the same turn as logging. Promotion should only happen:
| Learning Type | Promote To |
|---------------|------------|
| Behavioral patterns | SOUL.md |
| Workflow improvements | AGENTS.md |
| Tool gotchas | TOOLS.md |
Periodic Review (User-Initiated Only)
Only review .learnings/ when the user explicitly asks or at session start.
Never auto-trigger a review based on logging a new entry.
OpenClaw Workspace Structure
~/.openclaw/workspace/
βββ AGENTS.md
βββ SOUL.md
βββ TOOLS.md
βββ MEMORY.md
βββ memory/YYYY-MM-DD.md
βββ .learnings/
βββ LEARNINGS.md
βββ ERRORS.md
βββ FEATURE_REQUESTS.md
Feature Request Entry
Append to .learnings/FEATURE_REQUESTS.md:
## [FEAT-YYYYMMDD-XXX] capability_nameLogged: ISO-8601 timestamp
Priority: medium
Status: pending
Requested Capability
What the user wanted to doUser Context
Why they needed itComplexity Estimate
simple | medium | complex
ID Generation
Format: TYPE-YYYYMMDD-XXX
LRN (learning), ERR (error), FEAT (feature)001, 002)Resolving Entries
When an issue is fixed, update Status: pending β Status: resolved and add:
### Resolution
Resolved: ISO-8601 timestamp
Notes: Brief description of fix