Mulch Self Improver — Let your agents grow 🌱
Structured expertise that accumulates over time, lives in git, and works with any agent. Agents start each session from zero; the pattern discovered yesterday is forgotten today. This skill uses Mulch: agents call mulch record to write learnings and mulch query to read them. Expertise compounds across sessions, domains, and teammates. Mulch is a passive layer — it does not contain an LLM. Agents use Mulch; Mulch does not use agents.
Benefits: Better and more consistent coding · Improved experience · Less hallucination (grounding in project expertise)
When to use: Command/tool fails, user corrects you, user wants a missing feature, your knowledge was wrong, or you found a better approach — record with Mulch and promote proven patterns to project memory. Auto-detection: The hook now detects errors and corrections automatically and prompts to record.
Mechanics: One learning store — .mulch/ (append-only JSONL, git-tracked, queryable). Session start: mulch prime. Recording: mulch record <domain> --type <type> .... No .learnings/ markdown files.
Qualification (features, benefits, pain points): See QUALIFICATION.md. Benchmark (token efficiency, troubleshooting skill improvement): See BENCHMARK.md — e.g. ~54% fewer chars to get same resolutions; find rate same or better; less context → fewer tokens, less noise, lower risk of wrong fix.
New Features (v1.1)
Auto-Detection
The hook now automatically detects learning moments:
- - Errors/failures — When commands fail or return errors
- Corrections — When you say "no", "actually", "wrong", etc.
- Retries — When you ask to try again
The agent will prompt: "Want me to record this for next time?"
Pre-loaded Domains
24 preset domains included in
config/domains.json:
CODEBLOCK0
Notifications
When a learning is recorded, you're notified via Telegram.
Quick Reference
| Situation | Action |
|---|
| Command/operation or API fails | INLINECODE7 |
| User corrects you / knowledge was wrong |
mulch record <domain> --type convention "..." or
--type pattern --name "..." --description "..." |
| Found better approach, best practice |
mulch record <domain> --type convention "..." or
--type guide --name "..." --description "..." |
| Architectural or tech decision |
mulch record <domain> --type decision --title "..." --rationale "..." |
| Feature request (tracking) |
mulch record <domain> --type decision --title "..." --rationale "..." |
| Key file/endpoint to remember |
mulch record <domain> --type reference --name "..." --description "..." |
| Similar to existing record | Use
--relates-to <domain>:<id> or
--supersedes; run
mulch search "..." first |
| Broadly applicable pattern | Promote to
CLAUDE.md,
AGENTS.md, SOUL.md, TOOLS.md; use
mulch onboard for snippets |
| Session start (project has .mulch/) | Run
mulch prime to load expertise into context |
Mulch Setup
Install (optional; npx works without install):
CODEBLOCK1
Initialize in project:
CODEBLOCK2
Provider hooks (remind agent to record):
CODEBLOCK3
Onboarding snippet for AGENTS.md/CLAUDE.md:
CODEBLOCK4
Record Types (Mulch)
| Type | Required | Use Case |
|---|
| INLINECODE22 | description, resolution | What went wrong and how to avoid it |
| INLINECODE23 |
content | "Use pnpm not npm"; "Always WAL mode for SQLite" |
|
pattern | name, description | Named patterns, optional
--file |
|
decision | title, rationale | Architecture, tech choices, feature tracking |
|
reference | name, description | Key files, endpoints, resources |
|
guide | name, description | Step-by-step procedures |
Optional on any record: --classification (foundational | tactical | observational), --tags, --relates-to, --supersedes, --evidence-commit, --evidence-file, --outcome-status (success | failure).
Workflow
- 1. Session start: If
.mulch/ exists, run mulch prime (or mulch prime <domain> for focus). - During work: When something fails or you learn something, run
mulch record <domain> --type <type> .... - Before finishing: Review; record any remaining insights with
mulch record. - Promote: When a pattern is proven and broadly applicable, add to CLAUDE.md / AGENTS.md / SOUL.md / TOOLS.md; use
mulch onboard to generate snippets.
Finding Domain
- - Use existing domains from
mulch status or mulch query --all. - Run
mulch learn to get domain suggestions from changed files. - Common domains:
api, database, testing, frontend, backend, infra, docs, config.
Recurring Patterns and Linking
- - Search first:
mulch search "keyword" or mulch query <domain>. - Link records:
mulch record ... --relates-to <domain>:<id> or --supersedes <domain>:<id>. - Recurring issues → promote to CLAUDE.md/AGENTS.md or add to TOOLS.md/SOUL.md so all agents see them.
Simplify & Harden Feed
For candidates from the simplify-and-harden skill:
- 1. Use
pattern_key as a stable tag: mulch record <domain> --type pattern --name "<pattern_key>" --description "..." --tags "simplify-and-harden". - Search first:
mulch search "<pattern_key>"; if found, use --relates-to or add to existing via mulch edit if needed. - When recurrence is high, promote to CLAUDE.md/AGENTS.md/SOUL.md/TOOLS.md as short prevention rules.
Periodic Review
- - When: Before major tasks, after features, weekly.
- Commands:
mulch status, mulch ready --since 7d, mulch query --all. - Actions: Promote high-value records to project memory; run
mulch prune for stale tactical/observational entries if desired; mulch doctor --fix for health.
Promotion Targets
| Learning Type | Promote To |
|---|
| Behavioral patterns | INLINECODE67 (OpenClaw workspace) |
| Workflow improvements |
AGENTS.md |
| Tool gotchas |
TOOLS.md (OpenClaw workspace) |
| Project facts, conventions |
CLAUDE.md |
| Copilot context |
.github/copilot-instructions.md |
Use mulch onboard to generate AGENTS.md/CLAUDE.md snippets.
Detection Triggers
Record when you notice:
- - User corrects you ("No, that's not right...", "Actually...") → convention or pattern
- Command/API/tool fails → failure (description + resolution)
- User wants missing capability → decision (title + rationale)
- Your knowledge was wrong or outdated → convention
- You found a better approach → convention or guide
OpenClaw Setup
OpenClaw injects workspace files; use Mulch for learnings.
Installation
CODEBLOCK5
Workspace and Mulch
- - Session start: Run
mulch prime when the project (or workspace) has .mulch/. Optionally add mulch prime output to workspace context if your setup supports it. - Recording: Use
mulch record from the project or workspace directory that contains .mulch/. - Promotion: SOUL.md, AGENTS.md, TOOLS.md live in
~/.openclaw/workspace/; add promoted rules there.
Enable Hook (reminder at bootstrap)
CODEBLOCK6
See references/openclaw-integration.md.
Generic Setup (Other Agents)
- 1. In project:
mulch init and mulch add <domain> as needed. - Use
mulch setup <provider> (cursor, claude, codex, etc.) for hooks. - Add to CLAUDE.md/AGENTS.md: "Run mulch prime at session start. Record learnings with mulch record --type failure|convention|decision|pattern|guide|reference."
- Run
mulch onboard and paste the snippet into your agent docs.
Multi-Agent Safety
Mulch is safe for concurrent use: advisory file locking, atomic writes, and merge=union in .gitattributes for JSONL. Multiple agents can run mulch prime and mulch record in parallel; locks serialize writes per domain.
Skill Extraction
When a Mulch record is valuable as a reusable skill:
- 1. Get content from
mulch query <domain> or mulch search "...". - Create
skills/<skill-name>/SKILL.md (template in assets/SKILL-TEMPLATE.md). - Optionally note in the record (e.g. via
mulch edit) that it was promoted to a skill.
Best Practices
- 1. Record immediately — context is freshest after the issue.
- Pick the right type — failure (description+resolution), convention (short rule), decision (title+rationale), etc.
- Use domains consistently — e.g. same
api domain for all API-related learnings. - Link related records —
--relates-to, --supersedes. - Run mulch prime at session start — so the agent is grounded in existing expertise.
- Promote when proven — move broadly applicable rules to CLAUDE.md, AGENTS.md, SOUL.md, TOOLS.md.
No .learnings/
This skill does not use .learnings/ or markdown log files. All learnings live in .mulch/ and are recorded via the Mulch CLI. If you see references to .learnings/ in older docs, treat them as superseded by Mulch.
自我改进 — 让你的智能体不断成长 🌱
结构化专业知识随时间积累,存在于git中,可与任何智能体配合使用。智能体每次会话从零开始;昨天发现的模式今天就被遗忘。本技能使用Mulch:智能体调用mulch record记录学习内容,调用mulch query读取学习内容。专业知识跨会话、跨领域、跨团队成员不断累积。Mulch是一个被动层——它不包含大语言模型。智能体使用Mulch;Mulch不使用智能体。
优势: 更好且更一致的编码 · 改进的体验 · 更少的幻觉(基于项目专业知识)
使用时机: 命令/工具失败、用户纠正你、用户想要缺失功能、你的知识有误、或你找到了更好的方法——用Mulch记录并将经过验证的模式提升到项目记忆中。自动检测: 钩子现在自动检测错误和纠正,并提示记录。
机制: 一个学习存储——.mulch/(仅追加JSONL,git跟踪,可查询)。会话开始:mulch prime。记录:mulch record <领域> --type <类型> ...。没有.learnings/ markdown文件。
资质(功能、优势、痛点): 参见QUALIFICATION.md。基准测试(token效率、故障排除技能提升): 参见BENCHMARK.md——例如,达到相同解决方案约减少54%字符;发现率相同或更好;更少上下文→更少token、更少噪音、更低错误修复风险。
新功能(v1.1)
自动检测
钩子现在自动检测学习时刻:
- - 错误/失败 — 当命令失败或返回错误时
- 纠正 — 当你说不、实际上、错了等时
- 重试 — 当你要求重试时
智能体会提示:想让我记录这个以备下次使用吗?
预加载领域
config/domains.json中包含24个预设领域:
api, database, testing, frontend, backend, infra, docs, config,
security, performance, deployment, auth, errors, debugging,
workflow, customer, system, marketing, sales, content,
competitors, crypto, automation, openclaw
通知
当记录学习内容时,通过Telegram通知你。
快速参考
| 情况 | 操作 |
|---|
| 命令/操作或API失败 | mulch record <领域> --type failure --description ... --resolution ... |
| 用户纠正你/知识有误 |
mulch record <领域> --type convention ... 或 --type pattern --name ... --description ... |
| 找到更好的方法、最佳实践 | mulch record <领域> --type convention ... 或 --type guide --name ... --description ... |
| 架构或技术决策 | mulch record <领域> --type decision --title ... --rationale ... |
| 功能请求(跟踪) | mulch record <领域> --type decision --title ... --rationale ... |
| 需要记住的关键文件/端点 | mulch record <领域> --type reference --name ... --description ... |
| 与现有记录相似 | 使用--relates-to <领域>:
或--supersedes;先运行mulch search ... |
| 广泛适用的模式 | 提升到CLAUDE.md、AGENTS.md、SOUL.md、TOOLS.md;使用mulch onboard生成代码片段 |
| 会话开始(项目有.mulch/) | 运行mulch prime将专业知识加载到上下文中 |
Mulch设置
安装(可选;npx无需安装即可使用):
bash
npm install -g mulch-cli
或:npx mulch-cli <命令>
在项目中初始化:
bash
mulch init
快速:一次性添加所有预设领域
cat config/domains.json | jq -r .domains[].name | xargs -I {} mulch add {}
或逐个添加:
mulch add api
mulch add database
mulch add testing
添加与你领域匹配的:frontend, backend, infra, docs, config
提供者钩子(提醒智能体记录):
bash
mulch setup cursor # 或:claude, codex, gemini, windsurf, aider
AGENTS.md/CLAUDE.md的入职代码片段:
bash
mulch onboard
记录类型(Mulch)
| 类型 | 必需 | 使用场景 |
|---|
| failure | description, resolution | 出了什么问题以及如何避免 |
| convention |
content | 使用pnpm而非npm;SQLite始终使用WAL模式 |
| pattern | name, description | 命名模式,可选--file |
| decision | title, rationale | 架构、技术选择、功能跟踪 |
| reference | name, description | 关键文件、端点、资源 |
| guide | name, description | 分步流程 |
任何记录的可选项:--classification(基础 | 战术 | 观察),--tags,--relates-to,--supersedes,--evidence-commit,--evidence-file,--outcome-status(成功 | 失败)。
工作流程
- 1. 会话开始: 如果.mulch/存在,运行mulch prime(或mulch prime <领域>聚焦)。
- 工作期间: 当某事失败或你学到新东西时,运行mulch record <领域> --type <类型> ...。
- 结束前: 审查;使用mulch record记录任何剩余见解。
- 提升: 当模式经过验证且广泛适用时,添加到CLAUDE.md / AGENTS.md / SOUL.md / TOOLS.md;使用mulch onboard生成代码片段。
查找领域
- - 使用mulch status或mulch query --all中的现有领域。
- 运行mulch learn从更改的文件获取领域建议。
- 常见领域:api,database,testing,frontend,backend,infra,docs,config。
重复模式与链接
- - 先搜索: mulch search 关键词或mulch query <领域>。
- 链接记录: mulch record ... --relates-to <领域>:或--supersedes <领域>:。
- 重复问题→提升到CLAUDE.md/AGENTS.md或添加到TOOLS.md/SOUL.md,以便所有智能体都能看到。
简化与强化反馈
对于来自简化与强化技能的候选:
- 1. 使用patternkey作为稳定标签:mulch record <领域> --type pattern --name key> --description ... --tags simplify-and-harden。
- 先搜索:mulch search ;如果找到,使用--relates-to或通过mulch edit添加到现有记录(如果需要)。
- 当重复率高时,提升到CLAUDE.md/AGENTS.md/SOUL.md/TOOLS.md作为简短的预防规则。
定期审查
- - 时间: 重大任务前、功能完成后、每周。
- 命令: mulch status,mulch ready --since 7d,mulch query --all。
- 操作: 将高价值记录提升到项目记忆;如需可运行mulch prune清理过时的战术/观察条目;mulch doctor --fix进行健康检查。
提升目标
| 学习类型 | 提升到 |
|---|
| 行为模式 | SOUL.md(OpenClaw工作空间) |
| 工作流程改进 |
AGENTS.md |
| 工具陷阱 | TOOLS.md(OpenClaw工作空间) |
| 项目事实、约定 | CLAUDE.md |
| Copilot上下文 | .github/copilot-instructions.md |
使用mulch onboard生成AGENTS.md/CLAUDE.md代码片段。
检测触发条件
在以下情况记录:
- - 用户纠正你(不,那不对...,实际上...)→ convention或pattern
- 命令/API/工具失败 → failure(description + resolution)
- 用户想要缺失功能 → decision(title + rationale)
- 你的知识有误或过时 → convention
- 你找到了更好的方法 → convention或guide
OpenClaw设置
OpenClaw注入工作空间文件;使用Mulch记录学习内容。
安装