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 |
|---|
| INLINECODE1 | Analyze MEMORY.md — find promotion candidates, stale entries, consolidation opportunities |
| INLINECODE2 |
Graduate a pattern from MEMORY.md → CLAUDE.md or
.claude/rules/ |
|
/si:extract | Turn a proven pattern into a standalone skill |
|
/si:status | Memory health dashboard — line counts, topic files, recommendations |
|
/si:remember | Explicitly save important knowledge to auto-memory |
How It Fits Together
CODEBLOCK0
Installation
Claude Code (Plugin)
CODEBLOCK1
OpenClaw
CODEBLOCK2
Codex CLI
CODEBLOCK3
Memory Architecture
Where things live
| File | Who writes | Scope | Loaded |
|---|
| INLINECODE7 | You (+ /si:promote) | Project rules | Full file, every session |
| INLINECODE9 |
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
CODEBLOCK4
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:
CODEBLOCK5
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 INLINECODE17
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的自动记忆功能(v2.1.32+)会自动将项目模式、调试洞察和您的偏好记录在MEMORY.md中。本插件在此基础上增加了智能层:它分析Claude所学内容,将经过验证的模式提升为项目规则,并将可复用的解决方案提取为独立技能。
快速参考
| 命令 | 功能说明 |
|---|
| /si:review | 分析MEMORY.md — 查找可提升项、过期条目、合并机会 |
| /si:promote |
将模式从MEMORY.md升级到CLAUDE.md或.claude/rules/ |
| /si:extract | 将已验证的模式转化为独立技能 |
| /si:status | 记忆健康仪表盘 — 行数统计、主题文件、建议 |
| /si:remember | 将重要知识显式保存到自动记忆 |
整体架构
┌─────────────────────────────────────────────────────────┐
│ Claude Code 记忆栈 │
├─────────────┬──────────────────┬────────────────────────┤
│ CLAUDE.md │ 自动记忆 │ 会话记忆 │
│ (您编写) │ (Claude编写) │ (Claude编写) │
│ 规则与标准 │ MEMORY.md │ 对话日志 │
│ 完整加载 │ + 主题文件 │ + 连续性 │
│ │ 前200行 │ 上下文加载 │
├─────────────┴──────────────────┴────────────────────────┤
│ ↑ /si:promote ↑ /si:review │
│ 自我改进型代理(本插件) │
│ ↓ /si:extract ↓ /si:remember │
├─────────────────────────────────────────────────────────┤
│ .claude/rules/ │ 新技能 │ 错误日志 │
│ (作用域规则) │ (提取所得) │ (自动捕获) │
└─────────────────────────────────────────────────────────┘
安装
Claude Code(插件)
/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
记忆架构
文件存放位置
| 文件 | 编写者 | 作用域 | 加载方式 |
|---|
| ./CLAUDE.md | 您(+ /si:promote) | 项目规则 | 每次会话完整加载 |
| ~/.claude/CLAUDE.md |
您 | 全局偏好 | 每次会话完整加载 |
| ~/.claude/projects/
/memory/MEMORY.md | Claude(自动) | 项目学习记录 | 前200行 |
| ~/.claude/projects//memory/*.md | Claude(溢出) | 主题特定笔记 | 按需加载 |
| .claude/rules/*.md | 您(+ /si:promote) | 作用域规则 | 匹配文件打开时加载 |
提升生命周期
- 1. Claude发现模式 → 自动记忆(MEMORY.md)
- 模式重复出现2-3次 → /si:review标记为可提升项
- 您批准 → /si:promote将其升级到CLAUDE.md或rules/
- 模式成为强制规则,而不仅仅是笔记
- MEMORY.md中的条目被移除 → 为新学习内容腾出空间
核心概念
自动记忆是捕获,而非策管
自动记忆擅长记录Claude所学的内容。但它无法判断:
- - 哪些学习内容是临时的,哪些是永久的
- 哪些模式应该成为强制规则
- 何时200行限制因过期条目而浪费空间
- 哪些解决方案足够优秀,可以成为可复用技能
这正是本插件的职责所在。
提升即升级
当您提升一个学习内容时,它会从Claude的草稿本(MEMORY.md)转移到项目的规则系统(CLAUDE.md或.claude/rules/)。两者的区别至关重要:
- - MEMORY.md:我注意到这个项目使用pnpm(背景上下文)
- CLAUDE.md:使用pnpm,不要用npm(强制指令)
提升后的规则具有更高优先级,并且完整加载(不会被截断为200行)。
作用域知识的规则目录
并非所有内容都适合放在CLAUDE.md中。对于仅适用于特定文件类型的模式,请使用.claude/rules/:
yaml
.claude/rules/api-testing.md
paths:
- src/api//*.test.ts
- tests/api//*
- - 使用supertest进行API端点测试
- 使用msw模拟外部服务
- 始终测试错误响应,而不仅仅是正常路径
这仅在Claude处理API测试文件时加载——其他情况下零开销。
代理
记忆分析师
分析MEMORY.md和主题文件,识别:
- - 跨会话重复出现的条目(可提升候选)
- 引用已删除文件或旧模式的过期条目
- 应合并的相关条目
- MEMORY.md所知内容与CLAUDE.md强制规则之间的差距
技能提取器
将已验证的模式生成完整的技能:
- - 带有正确前置元数据的SKILL.md
- 参考文档
- 示例和边界情况
- 可直接用于/plugin install或clawhub publish
钩子
错误捕获(PostToolUse → Bash)
监控命令输出中的错误。检测到错误时,向自动记忆追加结构化条目,包含:
- - 失败的命令
- 错误输出(截断)
- 时间戳和上下文
- 建议的分类
令牌开销: 成功时为零。仅在检测到错误时约30个令牌。
平台支持
| 平台 | 记忆系统 | 插件是否可用? |
|---|
| Claude Code | 自动记忆(MEMORY.md) | ✅ 完全支持 |
| OpenClaw |
workspace/MEMORY.md | ✅ 已适配(读取工作区记忆) |
| Codex CLI | AGENTS.md | ✅ 已适配(读取AGENTS.md模式) |
| GitHub Copilot | .github/copilot-instructions.md | ⚠️ 仅支持手动提升 |
相关资源