self-improving-agent

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Self-Improving Agent

自改进代理(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.
自动内存负责捕获,本插件负责整理。
Claude Code的自动内存(v2.1.32+)会自动在
MEMORY.md
中记录项目模式、调试见解和您的偏好。本插件增加了智能层:它会分析Claude的学习内容,将已验证的模式推广为项目规则,并将重复出现的解决方案提取为可复用的Skill。

Quick Reference

快速参考

CommandWhat it does
/si: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:status
Memory health dashboard — line counts, topic files, recommendations
/si:remember
Explicitly save important knowledge to auto-memory
命令功能
/si:review
分析MEMORY.md — 找出可推广候选条目、过时条目和可合并的内容
/si:promote
将模式从MEMORY.md升级至CLAUDE.md或
.claude/rules/
/si:extract
将已验证的模式转化为独立Skill
/si:status
内存健康仪表盘 — 行数统计、主题文件、优化建议
/si:remember
将重要知识明确保存至自动内存

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:review          │
│         Self-Improving Agent (this plugin)               │
│              ↓ /si:extract    ↓ /si:remember            │
├─────────────────────────────────────────────────────────┤
│  .claude/rules/    │    New Skills    │   Error Logs     │
│  (scoped rules)    │    (extracted)   │   (auto-captured)│
└─────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────┐
│                  Claude Code Memory Stack                │
├─────────────┬──────────────────┬────────────────────────┤
│  CLAUDE.md  │   Auto Memory    │   Session Memory       │
│  (你编写)│   (Claude编写)│   (Claude编写)      │
│  规则与    │   MEMORY.md      │   对话日志    │
│  标准  │   + 主题文件  │   + 会话连续性         │
│  完整加载  │   前200行│   上下文加载      │
├─────────────┴──────────────────┴────────────────────────┤
│              ↑ /si:promote        ↑ /si:review          │
│         Self-Improving Agent (本插件)               │
│              ↓ /si:extract    ↓ /si:remember            │
├─────────────────────────────────────────────────────────┤
│  .claude/rules/    │    New Skills    │   Error Logs     │
│  (范围规则)    │    (提取生成)   │   (自动捕获)│
└─────────────────────────────────────────────────────────┘

Installation

安装方法

Claude Code (Plugin)

Claude Code(插件)

/plugin marketplace add alirezarezvani/claude-skills
/plugin install self-improving-agent@claude-code-skills
/plugin marketplace add alirezarezvani/claude-skills
/plugin install self-improving-agent@claude-code-skills

OpenClaw

OpenClaw

bash
clawhub install self-improving-agent
bash
clawhub install self-improving-agent

Codex CLI

Codex CLI

bash
./scripts/codex-install.sh --skill self-improving-agent
bash
./scripts/codex-install.sh --skill self-improving-agent

Memory Architecture

内存架构

Where things live

文件存储位置

FileWho writesScopeLoaded
./CLAUDE.md
You (+
/si:promote
)
Project rulesFull file, every session
~/.claude/CLAUDE.md
YouGlobal preferencesFull file, every session
~/.claude/projects/<path>/memory/MEMORY.md
Claude (auto)Project learningsFirst 200 lines
~/.claude/projects/<path>/memory/*.md
Claude (overflow)Topic-specific notesOn demand
.claude/rules/*.md
You (+
/si:promote
)
Scoped rulesWhen matching files open
文件编写者范围加载方式
./CLAUDE.md
你(+
/si:promote
项目规则每次会话完整加载
~/.claude/CLAUDE.md
全局偏好每次会话完整加载
~/.claude/projects/<path>/memory/MEMORY.md
Claude(自动)项目学习内容加载前200行
~/.claude/projects/<path>/memory/*.md
Claude(溢出存储)主题特定笔记按需加载
.claude/rules/*.md
你(+
/si:promote
范围规则打开匹配文件时加载

The promotion lifecycle

推广生命周期

1. Claude discovers pattern → auto-memory (MEMORY.md)
2. Pattern recurs 2-3x → /si: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
1. Claude发现模式 → 自动内存(MEMORY.md)
2. 模式重复出现2-3次 → /si:review标记为可推广候选
3. 你确认批准 → /si:promote将其升级至CLAUDE.md或rules/
4. 模式成为强制执行的规则,而非仅笔记
5. MEMORY.md中对应条目移除 → 为新学习内容腾出空间

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.
自动内存擅长记录Claude的学习内容,但无法判断:
  • 哪些学习内容是临时的,哪些是永久的
  • 哪些模式应成为强制执行的规则
  • 200行限制下,过时条目是否占用空间
  • 哪些解决方案足够优秀,可成为可复用Skill
而这些正是本插件的功能。

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).
当您推广某一学习内容时,它会从Claude的草稿本(MEMORY.md)转移至项目的规则系统(CLAUDE.md或
.claude/rules/
)。二者差异显著:
  • MEMORY.md:“我注意到该项目使用pnpm”(背景上下文)
  • CLAUDE.md:“使用pnpm,而非npm”(强制执行指令)
已推广的规则优先级更高,且会完整加载(不会被截断为200行)。

Rules directory for scoped knowledge

规则目录用于范围化知识

Not everything belongs in CLAUDE.md. Use
.claude/rules/
for patterns that only apply to specific file types:
yaml
undefined
并非所有内容都适合放在CLAUDE.md中。对于仅适用于特定文件类型的模式,可使用
.claude/rules/
目录:
yaml
undefined

.claude/rules/api-testing.md

.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.

paths:
  • "src/api/**/*.test.ts"
  • "tests/api/**/*"

  • 使用supertest进行API端点测试
  • 使用msw模拟外部服务
  • 始终测试错误响应,而非仅测试正常路径

仅当Claude处理API测试文件时,该规则才会加载——其他场景无额外开销。

Agents

代理模块

memory-analyst

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
分析MEMORY.md和主题文件,识别:
  • 跨会话重复出现的条目(可推广候选)
  • 引用已删除文件或旧模式的过时条目
  • 可合并的相关条目
  • MEMORY.md记录内容与CLAUDE.md强制执行规则之间的差距

skill-extractor

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
将已验证的模式生成完整的Skill:
  • 包含正确前置内容的SKILL.md
  • 参考文档
  • 示例和边缘情况
  • 可直接用于
    /plugin install
    clawhub publish

Hooks

钩子函数

error-capture (PostToolUse → Bash)

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.
监控命令输出中的错误。检测到错误时,会向自动内存添加结构化条目,包含:
  • 执行失败的命令
  • 错误输出(已截断)
  • 时间戳和上下文
  • 建议分类
Token开销: 执行成功时为0。仅检测到错误时产生约30个Token的开销。

Platform Support

平台支持

PlatformMemory SystemPlugin Works?
Claude CodeAuto-memory (MEMORY.md)✅ Full support
OpenClawworkspace/MEMORY.md✅ Adapted (reads workspace memory)
Codex CLIAGENTS.md✅ Adapted (reads AGENTS.md patterns)
GitHub Copilot
.github/copilot-instructions.md
⚠️ Manual promotion only
平台内存系统插件是否可用
Claude Code自动内存(MEMORY.md)✅ 完全支持
OpenClawworkspace/MEMORY.md✅ 适配支持(读取工作区内存)
Codex CLIAGENTS.md✅ 适配支持(读取AGENTS.md中的模式)
GitHub Copilot
.github/copilot-instructions.md
⚠️ 仅支持手动推广

Related

相关资源