Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Enable an AI agent to iteratively improve its own skills and instructions based on task feedback.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
SKILL.md
1---2name: self-improvement3description: "Captures learnings, errors, and corrections to enable continuous improvement. Use when: (1) A command or operation fails unexpectedly, (2) User corrects Claude ('No, that's wrong...', 'Actually...'), (3) User requests a capability that doesn't exist, (4) An external API or tool fails, (5) Claude realizes its knowledge is outdated or incorrect, (6) A better approach is discovered for a recurring task. Also review learnings before major tasks."4metadata:5---67# Self-Improvement Skill89Log learnings and errors to markdown files for continuous improvement. Coding agents can later process these into fixes, and important learnings get promoted to project memory.1011## First-Use Initialisation1213Before logging anything, ensure the `.learnings/` directory and files exist in the project or workspace root. If any are missing, create them:1415```bash16mkdir -p .learnings17[ -f .learnings/LEARNINGS.md ] || printf "# Learnings\n\nCorrections, insights, and knowledge gaps captured during development.\n\n**Categories**: correction | insight | knowledge_gap | best_practice\n\n---\n" > .learnings/LEARNINGS.md18[ -f .learnings/ERRORS.md ] || printf "# Errors\n\nCommand failures and integration errors.\n\n---\n" > .learnings/ERRORS.md19[ -f .learnings/FEATURE_REQUESTS.md ] || printf "# Feature Requests\n\nCapabilities requested by the user.\n\n---\n" > .learnings/FEATURE_REQUESTS.md20```2122Never overwrite existing files. This is a no-op if `.learnings/` is already initialised.2324Do not log secrets, tokens, private keys, environment variables, or full source/config files unless the user explicitly asks for that level of detail. Prefer short summaries or redacted excerpts over raw command output or full transcripts.2526If you want automatic reminders or setup assistance, use the opt-in hook workflow described in [Hook Integration](#hook-integration).2728## Quick Reference2930| Situation | Action |31|-----------|--------|32| Command/operation fails | Log to `.learnings/ERRORS.md` |33| User corrects you | Log to `.learnings/LEARNINGS.md` with category `correction` |34| User wants missing feature | Log to `.learnings/FEATURE_REQUESTS.md` |35| API/external tool fails | Log to `.learnings/ERRORS.md` with integration details |36| Knowledge was outdated | Log to `.learnings/LEARNINGS.md` with category `knowledge_gap` |37| Found better approach | Log to `.learnings/LEARNINGS.md` with category `best_practice` |38| Simplify/Harden recurring patterns | Log/update `.learnings/LEARNINGS.md` with `Source: simplify-and-harden` and a stable `Pattern-Key` |39| Similar to existing entry | Link with `**See Also**`, consider priority bump |40| Broadly applicable learning | Promote to `CLAUDE.md`, `AGENTS.md`, and/or `.github/copilot-instructions.md` |41| Workflow improvements | Promote to `AGENTS.md` (OpenClaw workspace) |42| Tool gotchas | Promote to `TOOLS.md` (OpenClaw workspace) |43| Behavioral patterns | Promote to `SOUL.md` (OpenClaw workspace) |4445## OpenClaw Setup (Recommended)4647OpenClaw is the primary platform for this skill. It uses workspace-based prompt injection with automatic skill loading.4849### Installation5051**Via ClawdHub (recommended):**52```bash53clawdhub install self-improving-agent54```5556**Manual:**57```bash58git clone https://github.com/peterskoett/self-improving-agent.git ~/.openclaw/skills/self-improving-agent59```6061Remade for openclaw from original repo : https://github.com/pskoett/pskoett-ai-skills - https://github.com/pskoett/pskoett-ai-skills/tree/main/skills/self-improvement6263### Workspace Structure6465OpenClaw injects these files into every session:6667```68~/.openclaw/workspace/69├── AGENTS.md # Multi-agent workflows, delegation patterns70├── SOUL.md # Behavioral guidelines, personality, principles71├── TOOLS.md # Tool capabilities, integration gotchas72├── MEMORY.md # Long-term memory (main session only)73├── memory/ # Daily memory files74│ └── YYYY-MM-DD.md75└── .learnings/ # This skill's log files76├── LEARNINGS.md77├── ERRORS.md78└── FEATURE_REQUESTS.md79```8081### Create Learning Files8283```bash84mkdir -p ~/.openclaw/workspace/.learnings85```8687Then create the log files (or copy from `assets/`):88- `LEARNINGS.md` — corrections, knowledge gaps, best practices89- `ERRORS.md` — command failures, exceptions90- `FEATURE_REQUESTS.md` — user-requested capabilities9192### Promotion Targets9394When learnings prove broadly applicable, promote them to workspace files:9596| Learning Type | Promote To | Example |97|---------------|------------|---------|98| Behavioral patterns | `SOUL.md` | "Be concise, avoid disclaimers" |99| Workflow improvements | `AGENTS.md` | "Spawn sub-agents for long tasks" |100| Tool gotchas | `TOOLS.md` | "Git push needs auth configured first" |101102### Inter-Session Communication103104OpenClaw provides tools to share learnings across sessions:105106- **sessions_list** — View active/recent sessions107- **sessions_history** — Read another session's transcript108- **sessions_send** — Send a learning to another session109- **sessions_spawn** — Spawn a sub-agent for background work110111Use these only in trusted environments and only when the user explicitly wants cross-session sharing. Prefer sending a short sanitized summary and relevant file paths, not raw transcripts, secrets, or full command output.112113### Optional: Enable Hook114115For automatic reminders at session start:116117```bash118# Copy hook to OpenClaw hooks directory119cp -r hooks/openclaw ~/.openclaw/hooks/self-improvement120121# Enable it122openclaw hooks enable self-improvement123```124125See `references/openclaw-integration.md` for complete details.126127---128129## Generic Setup (Other Agents)130131For Claude Code, Codex, Copilot, or other agents, create `.learnings/` in the project or workspace root:132133```bash134mkdir -p .learnings135```136137Create the files inline using the headers shown above. Avoid reading templates from the current repo or workspace unless you explicitly trust that path.138139### Add reference to agent files AGENTS.md, CLAUDE.md, or .github/copilot-instructions.md to remind yourself to log learnings. (this is an alternative to hook-based reminders)140141#### Self-Improvement Workflow142143When errors or corrections occur:1441. Log to `.learnings/ERRORS.md`, `LEARNINGS.md`, or `FEATURE_REQUESTS.md`1452. Review and promote broadly applicable learnings to:146- `CLAUDE.md` - project facts and conventions147- `AGENTS.md` - workflows and automation148- `.github/copilot-instructions.md` - Copilot context149150## Logging Format151152### Learning Entry153154Append to `.learnings/LEARNINGS.md`:155156```markdown157## [LRN-YYYYMMDD-XXX] category158159**Logged**: ISO-8601 timestamp160**Priority**: low | medium | high | critical161**Status**: pending162**Area**: frontend | backend | infra | tests | docs | config163164### Summary165One-line description of what was learned166167### Details168Full context: what happened, what was wrong, what's correct169170### Suggested Action171Specific fix or improvement to make172173### Metadata174- Source: conversation | error | user_feedback175- Related Files: path/to/file.ext176- Tags: tag1, tag2177- See Also: LRN-20250110-001 (if related to existing entry)178- Pattern-Key: simplify.dead_code | harden.input_validation (optional, for recurring-pattern tracking)179- Recurrence-Count: 1 (optional)180- First-Seen: 2025-01-15 (optional)181- Last-Seen: 2025-01-15 (optional)182183---184```185186### Error Entry187188Append to `.learnings/ERRORS.md`:189190```markdown191## [ERR-YYYYMMDD-XXX] skill_or_command_name192193**Logged**: ISO-8601 timestamp194**Priority**: high195**Status**: pending196**Area**: frontend | backend | infra | tests | docs | config197198### Summary199Brief description of what failed200201### Error202```203Actual error message or output204```205206### Context207- Command/operation attempted208- Input or parameters used209- Environment details if relevant210- Summary or redacted excerpt of relevant output (avoid full transcripts and secret-bearing data by default)211212### Suggested Fix213If identifiable, what might resolve this214215### Metadata216- Reproducible: yes | no | unknown217- Related Files: path/to/file.ext218- See Also: ERR-20250110-001 (if recurring)219220---221```222223### Feature Request Entry224225Append to `.learnings/FEATURE_REQUESTS.md`:226227```markdown228## [FEAT-YYYYMMDD-XXX] capability_name229230**Logged**: ISO-8601 timestamp231**Priority**: medium232**Status**: pending233**Area**: frontend | backend | infra | tests | docs | config234235### Requested Capability236What the user wanted to do237238### User Context239Why they needed it, what problem they're solving240241### Complexity Estimate242simple | medium | complex243244### Suggested Implementation245How this could be built, what it might extend246247### Metadata248- Frequency: first_time | recurring249- Related Features: existing_feature_name250251---252```253254## ID Generation255256Format: `TYPE-YYYYMMDD-XXX`257- TYPE: `LRN` (learning), `ERR` (error), `FEAT` (feature)258- YYYYMMDD: Current date259- XXX: Sequential number or random 3 chars (e.g., `001`, `A7B`)260261Examples: `LRN-20250115-001`, `ERR-20250115-A3F`, `FEAT-20250115-002`262263## Resolving Entries264265When an issue is fixed, update the entry:2662671. Change `**Status**: pending` → `**Status**: resolved`2682. Add resolution block after Metadata:269270```markdown271### Resolution272- **Resolved**: 2025-01-16T09:00:00Z273- **Commit/PR**: abc123 or #42274- **Notes**: Brief description of what was done275```276277Other status values:278- `in_progress` - Actively being worked on279- `wont_fix` - Decided not to address (add reason in Resolution notes)280- `promoted` - Elevated to CLAUDE.md, AGENTS.md, or .github/copilot-instructions.md281282## Promoting to Project Memory283284When a learning is broadly applicable (not a one-off fix), promote it to permanent project memory.285286### When to Promote287288- Learning applies across multiple files/features289- Knowledge any contributor (human or AI) should know290- Prevents recurring mistakes291- Documents project-specific conventions292293### Promotion Targets294295| Target | What Belongs There |296|--------|-------------------|297| `CLAUDE.md` | Project facts, conventions, gotchas for all Claude interactions |298| `AGENTS.md` | Agent-specific workflows, tool usage patterns, automation rules |299| `.github/copilot-instructions.md` | Project context and conventions for GitHub Copilot |300| `SOUL.md` | Behavioral guidelines, communication style, principles (OpenClaw workspace) |301| `TOOLS.md` | Tool capabilities, usage patterns, integration gotchas (OpenClaw workspace) |302303### How to Promote3043051. **Distill** the learning into a concise rule or fact3062. **Add** to appropriate section in target file (create file if needed)3073. **Update** original entry:308- Change `**Status**: pending` → `**Status**: promoted`309- Add `**Promoted**: CLAUDE.md`, `AGENTS.md`, or `.github/copilot-instructions.md`310311### Promotion Examples312313**Learning** (verbose):314> Project uses pnpm workspaces. Attempted `npm install` but failed.315> Lock file is `pnpm-lock.yaml`. Must use `pnpm install`.316317**In CLAUDE.md** (concise):318```markdown319## Build & Dependencies320- Package manager: pnpm (not npm) - use `pnpm install`321```322323**Learning** (verbose):324> When modifying API endpoints, must regenerate TypeScript client.325> Forgetting this causes type mismatches at runtime.326327**In AGENTS.md** (actionable):328```markdown329## After API Changes3301. Regenerate client: `pnpm run generate:api`3312. Check for type errors: `pnpm tsc --noEmit`332```333334## Recurring Pattern Detection335336If logging something similar to an existing entry:3373381. **Search first**: `grep -r "keyword" .learnings/`3392. **Link entries**: Add `**See Also**: ERR-20250110-001` in Metadata3403. **Bump priority** if issue keeps recurring3414. **Consider systemic fix**: Recurring issues often indicate:342- Missing documentation (→ promote to CLAUDE.md or .github/copilot-instructions.md)343- Missing automation (→ add to AGENTS.md)344- Architectural problem (→ create tech debt ticket)345346## Simplify & Harden Feed347348Use this workflow to ingest recurring patterns from the `simplify-and-harden`349skill and turn them into durable prompt guidance.350351### Ingestion Workflow3523531. Read `simplify_and_harden.learning_loop.candidates` from the task summary.3542. For each candidate, use `pattern_key` as the stable dedupe key.3553. Search `.learnings/LEARNINGS.md` for an existing entry with that key:356- `grep -n "Pattern-Key: <pattern_key>" .learnings/LEARNINGS.md`3574. If found:358- Increment `Recurrence-Count`359- Update `Last-Seen`360- Add `See Also` links to related entries/tasks3615. If not found:362- Create a new `LRN-...` entry363- Set `Source: simplify-and-harden`364- Set `Pattern-Key`, `Recurrence-Count: 1`, and `First-Seen`/`Last-Seen`365366### Promotion Rule (System Prompt Feedback)367368Promote recurring patterns into agent context/system prompt files when all are true:369370- `Recurrence-Count >= 3`371- Seen across at least 2 distinct tasks372- Occurred within a 30-day window373374Promotion targets:375- `CLAUDE.md`376- `AGENTS.md`377- `.github/copilot-instructions.md`378- `SOUL.md` / `TOOLS.md` for OpenClaw workspace-level guidance when applicable379380Write promoted rules as short prevention rules (what to do before/while coding),381not long incident write-ups.382383## Periodic Review384385Review `.learnings/` at natural breakpoints:386387### When to Review388- Before starting a new major task389- After completing a feature390- When working in an area with past learnings391- Weekly during active development392393### Quick Status Check394```bash395# Count pending items396grep -h "Status\*\*: pending" .learnings/*.md | wc -l397398# List pending high-priority items399grep -B5 "Priority\*\*: high" .learnings/*.md | grep "^## \["400401# Find learnings for a specific area402grep -l "Area\*\*: backend" .learnings/*.md403```404405### Review Actions406- Resolve fixed items407- Promote applicable learnings408- Link related entries409- Escalate recurring issues410411## Detection Triggers412413Automatically log when you notice:414415**Corrections** (→ learning with `correction` category):416- "No, that's not right..."417- "Actually, it should be..."418- "You're wrong about..."419- "That's outdated..."420421**Feature Requests** (→ feature request):422- "Can you also..."423- "I wish you could..."424- "Is there a way to..."425- "Why can't you..."426427**Knowledge Gaps** (→ learning with `knowledge_gap` category):428- User provides information you didn't know429- Documentation you referenced is outdated430- API behavior differs from your understanding431432**Errors** (→ error entry):433- Command returns non-zero exit code434- Exception or stack trace435- Unexpected output or behavior436- Timeout or connection failure437438## Priority Guidelines439440| Priority | When to Use |441|----------|-------------|442| `critical` | Blocks core functionality, data loss risk, security issue |443| `high` | Significant impact, affects common workflows, recurring issue |444| `medium` | Moderate impact, workaround exists |445| `low` | Minor inconvenience, edge case, nice-to-have |446447## Area Tags448449Use to filter learnings by codebase region:450451| Area | Scope |452|------|-------|453| `frontend` | UI, components, client-side code |454| `backend` | API, services, server-side code |455| `infra` | CI/CD, deployment, Docker, cloud |456| `tests` | Test files, testing utilities, coverage |457| `docs` | Documentation, comments, READMEs |458| `config` | Configuration files, environment, settings |459460## Best Practices4614621. **Log immediately** - context is freshest right after the issue4632. **Be specific** - future agents need to understand quickly4643. **Include reproduction steps** - especially for errors4654. **Link related files** - makes fixes easier4665. **Suggest concrete fixes** - not just "investigate"4676. **Use consistent categories** - enables filtering4687. **Promote aggressively** - if in doubt, add to CLAUDE.md or .github/copilot-instructions.md4698. **Review regularly** - stale learnings lose value470471## Gitignore Options472473**Keep learnings local** (per-developer):474```gitignore475.learnings/476```477478This repo uses that default to avoid committing sensitive or noisy local logs by accident.479480**Track learnings in repo** (team-wide):481Don't add to .gitignore - learnings become shared knowledge.482483**Hybrid** (track templates, ignore entries):484```gitignore485.learnings/*.md486!.learnings/.gitkeep487```488489## Hook Integration490491Enable automatic reminders through agent hooks. This is **opt-in** - you must explicitly configure hooks.492493### Quick Setup (Claude Code / Codex)494495Create `.claude/settings.json` in your project:496497```json498{499"hooks": {500"UserPromptSubmit": [{501"matcher": "",502"hooks": [{503"type": "command",504"command": "./skills/self-improvement/scripts/activator.sh"505}]506}]507}508}509```510511This injects a learning evaluation reminder after each prompt (~50-100 tokens overhead).512513### Advanced Setup (With Error Detection)514515```json516{517"hooks": {518"UserPromptSubmit": [{519"matcher": "",520"hooks": [{521"type": "command",522"command": "./skills/self-improvement/scripts/activator.sh"523}]524}],525"PostToolUse": [{526"matcher": "Bash",527"hooks": [{528"type": "command",529"command": "./skills/self-improvement/scripts/error-detector.sh"530}]531}]532}533}534```535536This is optional. The recommended default is activator-only setup; enable `PostToolUse` only if you are comfortable with hook scripts inspecting command output for error patterns.537538### Available Hook Scripts539540| Script | Hook Type | Purpose |541|--------|-----------|---------|542| `scripts/activator.sh` | UserPromptSubmit | Reminds to evaluate learnings after tasks |543| `scripts/error-detector.sh` | PostToolUse (Bash) | Triggers on command errors |544545See `references/hooks-setup.md` for detailed configuration and troubleshooting.546547## Automatic Skill Extraction548549When a learning is valuable enough to become a reusable skill, extract it using the provided helper.550551### Skill Extraction Criteria552553A learning qualifies for skill extraction when ANY of these apply:554555| Criterion | Description |556|-----------|-------------|557| **Recurring** | Has `See Also` links to 2+ similar issues |558| **Verified** | Status is `resolved` with working fix |559| **Non-obvious** | Required actual debugging/investigation to discover |560| **Broadly applicable** | Not project-specific; useful across codebases |561| **User-flagged** | User says "save this as a skill" or similar |562563### Extraction Workflow5645651. **Identify candidate**: Learning meets extraction criteria5662. **Run helper** (or create manually):567```bash568./skills/self-improvement/scripts/extract-skill.sh skill-name --dry-run569./skills/self-improvement/scripts/extract-skill.sh skill-name570```5713. **Customize SKILL.md**: Fill in template with learning content5724. **Update learning**: Set status to `promoted_to_skill`, add `Skill-Path`5735. **Verify**: Read skill in fresh session to ensure it's self-contained574575### Manual Extraction576577If you prefer manual creation:5785791. Create `skills/<skill-name>/SKILL.md`5802. Use template from `assets/SKILL-TEMPLATE.md`5813. Follow [Agent Skills spec](https://agentskills.io/specification):582- YAML frontmatter with `name` and `description`583- Name must match folder name584- No README.md inside skill folder585586### Extraction Detection Triggers587588Watch for these signals that a learning should become a skill:589590**In conversation:**591- "Save this as a skill"592- "I keep running into this"593- "This would be useful for other projects"594- "Remember this pattern"595596**In learning entries:**597- Multiple `See Also` links (recurring issue)598- High priority + resolved status599- Category: `best_practice` with broad applicability600- User feedback praising the solution601602### Skill Quality Gates603604Before extraction, verify:605606- [ ] Solution is tested and working607- [ ] Description is clear without original context608- [ ] Code examples are self-contained609- [ ] No project-specific hardcoded values610- [ ] Follows skill naming conventions (lowercase, hyphens)611612## Multi-Agent Support613614This skill works across different AI coding agents with agent-specific activation.615616### Claude Code617618**Activation**: Hooks (UserPromptSubmit, PostToolUse)619**Setup**: `.claude/settings.json` with hook configuration620**Detection**: Automatic via hook scripts621622### Codex CLI623624**Activation**: Hooks (same pattern as Claude Code)625**Setup**: `.codex/settings.json` with hook configuration626**Detection**: Automatic via hook scripts627628### GitHub Copilot629630**Activation**: Manual (no hook support)631**Setup**: Add to `.github/copilot-instructions.md`:632633```markdown634## Self-Improvement635636After solving non-obvious issues, consider logging to `.learnings/`:6371. Use format from self-improvement skill6382. Link related entries with See Also6393. Promote high-value learnings to skills640641Ask in chat: "Should I log this as a learning?"642```643644**Detection**: Manual review at session end645