self-improving-agent
Curate what the agent has learned into durable project knowledge. Reviews Claude Code auto-memory (MEMORY.md and its topic files) for learnings worth keeping, promotes proven ones into CLAUDE.md or .claude/rules/, records a correction as a lesson that persists across sessions, prunes stale or duplicate entries, and turns a recurring fix into a reusable skill. Use whenever the user asks what you ha
Install
Copy this folder into your Claude Code project (needs Node.js):
npx degit alirezarezvani/claude-skills/engineering-team/self-improving-agent/skills/self-improving-agent .claude/skills/self-improving-agentOr install it for every project:
npx degit alirezarezvani/claude-skills/engineering-team/self-improving-agent/skills/self-improving-agent ~/.claude/skills/self-improving-agentFile content
Made by its original authors and shared under MIT. We show it unchanged, with credit and a link to the source. Source β
--- name: "self-improving-agent" description: "Curate what the agent has learned into durable project knowledge. Reviews Claude Code auto-memory (MEMORY.md and its topic files) for learnings worth keeping, promotes proven ones into CLAUDE.md or .claude/rules/, records a correction as a lesson that persists across sessions, prunes stale or duplicate entries, and turns a recurring fix into a reusable skill. Use whenever the user asks what you have learned or saved about the project, which memories should become permanent rules, to remember a lesson or stop repeating a mistake, or to clean up, audit or check memory health." --- # Self-Improving Agent > Auto-memory captures. This plugin curates. Claude Code's auto-memory (v2.1.32+) automatically records project patterns, debugging insights, and your preferences in `MEMORY.md`. This plugin adds the intelligence layer: it analyzes what Claude has learned, promotes proven patterns into project rules, and extracts recurring solutions into reusable skills. ## Quick Reference | Command | What it does | |---------|-------------| | `/si:memory-review` | Analyze MEMORY.md β find promotion candidates, stale entries, consolidation opportunities | | `/si:promote` | Graduate a pattern from MEMORY.md β CLAUDE.md or `.claude/rules/` | | `/si:extract` | Turn a proven pattern into a standalone skill | | `/si:memory-status` | Memory health dashboard β line counts, topic files, recommendations | | `/si:remember` | Explicitly save important knowledge to auto-memory | ## How It Fits Together ``` βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β Claude Code Memory Stack β βββββββββββββββ¬βββββββββββββββββββ¬βββββββββββββββββββββββββ€ β CLAUDE.md β Auto Memory β Session Memory β β (you write)β (Claude writes)β (Claude writes) β β Rules & β MEMORY.md β Conversation logs β β standards β + topic files β + continuity β β Full load β First 200 linesβ Contextual load β βββββββββββββββ΄βββββββββββββββββββ΄βββββββββββββββββββββββββ€ β β /si:promote β /si:memory-review β β Self-Improving Agent (this plugin) β β β /si:extract β /si:remember β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€ β .claude/rules/ β New Skills β Error Logs β β (scoped rules) β (extracted) β (auto-captured)β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ ``` ## Installation ### Claude Code (Plugin) ``` /plugin marketplace add alirezarezvani/claude-skills /plugin install self-improving-agent@claude-code-skills ``` ### OpenClaw ```bash clawhub install self-improving-agent ``` ### Codex CLI ```bash ./scripts/codex-install.sh --skill self-improving-agent ``` ## Memory Architecture ### Where things live | File | Who writes | Scope | Loaded | |------|-----------|-------|--------| | `./CLAUDE.md` | You (+ `/si:promote`) | Project rules | Full file, every session | | `~/.claude/CLAUDE.md` | You | Global preferences | Full file, every session | | `~/.claude/projects/<path>/memory/MEMORY.md` | Claude (auto) | Project learnings | First 200 lines | | `~/.claude/projects/<path>/memory/*.md` | Claude (overflow) | Topic-specific notes | On demand | | `.claude/rules/*.md` | You (+ `/si:promote`) | Scoped rules | When matching files open | ### The promotion lifecycle ``` 1. Claude discovers pattern β auto-memory (MEMORY.md) 2. Pattern recurs 2-3x β /si:memory-review flags it as promotion candidate 3. You approve β /si:promote graduates it to CLAUDE.md or rules/ 4. Pattern becomes an enforced rule, not just a note 5. MEMORY.md entry removed β frees space for new learnings ``` ## Core Concepts ### Auto-memory is capture, not curation Auto-memory is excellent at recording what Claude learns. But it has no judgment about: - Which learnings are temporary vs. permanent - Which patterns should become enforced rules - When the 200-line limit is wasting space on stale entries - Which solutions are good enough to become reusable skills That's what this plugin does. ### Promotion = graduation When you promote a learning, it moves from Claude's scratchpad (MEMORY.md) to your project's rule system (CLAUDE.md or `.claude/rules/`). The difference matters: - **MEMORY.md**: "I noticed this project uses pnpm" (background context) - **CLAUDE.md**: "Use pnpm, not npm" (enforced instruction) Promoted rules have higher priority and load in full (not truncated at 200 lines). ### Rules directory for scoped knowledge Not everything belongs in CLAUDE.md. Use `.claude/rules/` for patterns that only apply to specific file types: ```yaml # .claude/rules/api-testing.md --- paths: - "src/api/**/*.test.ts" - "tests/api/**/*" --- - Use supertest for API endpoint testing - Mock external services with msw - Always test error responses, not just happy paths ``` This loads only when Claude works with API test files β zero overhead otherwise. ## Agents ### memory-analyst Analyzes MEMORY.md and topic files to identify: - Entries that recur across sessions (promotion candidates) - Stale entries referencing deleted files or old patterns - Related entries that should be consolidated - Gaps between what MEMORY.md knows and what CLAUDE.md enforces ### skill-extractor Takes a proven pattern and generates a complete skill: - SKILL.md with proper frontmatter - Reference documentation - Examples and edge cases - Ready for `/plugin install` or `clawhub publish` ## Hooks ### error-capture (PostToolUse β Bash) Monitors command output for errors. When detected, appends a structured entry to auto-memory with: - The command that failed - Error output (truncated) - Timestamp and context - Suggested category **Token overhead:** Zero on success. ~30 tokens only when an error is detected. ## Platform Support | Platform | Memory System | Plugin Works? | |----------|--------------|---------------| | Claude Code | Auto-memory (MEMORY.md) | β Full support | | OpenClaw | workspace/MEMORY.md | β Adapted (reads workspace memory) | | Codex CLI | AGENTS.md | β Adapted (reads AGENTS.md patterns) | | GitHub Copilot | `.github/copilot-instructions.md` | β οΈ Manual promotion only | ## Related - [Claude Code Memory Docs](https://code.claude.com/docs/en/memory) - [pskoett/self-improving-agent](https://clawhub.ai/pskoett/self-improving-agent) β inspiration - `playwright-pro` β sister plugin in this repo