self-improvement by pskoett/self-improving-agent
npx skills add https://github.com/pskoett/self-improving-agent --skill self-improvement将学习和错误记录到 Markdown 文件中,以实现持续改进。编码代理稍后可以将这些处理成修复方案,重要的学习内容会被提升到项目记忆中。
| 情境 | 操作 |
|---|---|
| 命令/操作失败 | 记录到 .learnings/ERRORS.md |
| 用户纠正你 | 记录到 .learnings/LEARNINGS.md,类别为 correction |
| 用户需要缺失的功能 | 记录到 .learnings/FEATURE_REQUESTS.md |
| API/外部工具失败 | 记录到 .learnings/ERRORS.md,包含集成详细信息 |
| 知识已过时 |
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
记录到 .learnings/LEARNINGS.md,类别为 knowledge_gap |
| 找到更好的方法 | 记录到 .learnings/LEARNINGS.md,类别为 best_practice |
| 与现有条目相似 | 使用 **See Also** 链接,考虑提升优先级 |
| 广泛适用的学习内容 | 提升到 CLAUDE.md、AGENTS.md 和/或 .github/copilot-instructions.md |
| 工作流程改进 | 提升到 AGENTS.md(OpenClaw 工作区) |
| 工具注意事项 | 提升到 TOOLS.md(OpenClaw 工作区) |
| 行为模式 | 提升到 SOUL.md(OpenClaw 工作区) |
OpenClaw 是此技能的主要平台。它使用基于工作区的提示注入,并自动加载技能。
通过 ClawdHub(推荐):
clawdhub install self-improving-agent
手动安装:
git clone https://github.com/peterskoett/self-improving-agent.git ~/.openclaw/skills/self-improving-agent
OpenClaw 将以下文件注入到每个会话中:
~/.openclaw/workspace/
├── AGENTS.md # 多代理工作流程、委托模式
├── SOUL.md # 行为准则、个性、原则
├── TOOLS.md # 工具能力、集成注意事项
├── MEMORY.md # 长期记忆(仅主会话)
├── memory/ # 每日记忆文件
│ └── YYYY-MM-DD.md
└── .learnings/ # 此技能的日志文件
├── LEARNINGS.md
├── ERRORS.md
└── FEATURE_REQUESTS.md
mkdir -p ~/.openclaw/workspace/.learnings
然后创建日志文件(或从 assets/ 复制):
LEARNINGS.md — 纠正、知识差距、最佳实践ERRORS.md — 命令失败、异常FEATURE_REQUESTS.md — 用户请求的功能当学习内容被证明广泛适用时,将其提升到工作区文件:
| 学习类型 | 提升到 | 示例 |
|---|---|---|
| 行为模式 | SOUL.md | "保持简洁,避免免责声明" |
| 工作流程改进 | AGENTS.md | "为长任务生成子代理" |
| 工具注意事项 | TOOLS.md | "Git push 需要先配置认证" |
OpenClaw 提供工具在会话间共享学习内容:
在会话开始时自动提醒:
# 将钩子复制到 OpenClaw 钩子目录
cp -r hooks/openclaw ~/.openclaw/hooks/self-improvement
# 启用它
openclaw hooks enable self-improvement
完整详细信息请参阅 references/openclaw-integration.md。
对于 Claude Code、Codex、Copilot 或其他代理,在项目中创建 .learnings/:
mkdir -p .learnings
从 assets/ 复制模板或创建带标题的文件。
追加到 .learnings/LEARNINGS.md:
## [LRN-YYYYMMDD-XXX] category
**Logged**: ISO-8601 timestamp
**Priority**: low | medium | high | critical
**Status**: pending
**Area**: frontend | backend | infra | tests | docs | config
### Summary
One-line description of what was learned
### Details
Full context: what happened, what was wrong, what's correct
### Suggested Action
Specific fix or improvement to make
### Metadata
- Source: conversation | error | user_feedback
- Related Files: path/to/file.ext
- Tags: tag1, tag2
- See Also: LRN-20250110-001 (if related to existing entry)
---
追加到 .learnings/ERRORS.md:
## [ERR-YYYYMMDD-XXX] skill_or_command_name
**Logged**: ISO-8601 timestamp
**Priority**: high
**Status**: pending
**Area**: frontend | backend | infra | tests | docs | config
### Summary
Brief description of what failed
### Error
Actual error message or output
### Context
- Command/operation attempted
- Input or parameters used
- Environment details if relevant
### Suggested Fix
If identifiable, what might resolve this
### Metadata
- Reproducible: yes | no | unknown
- Related Files: path/to/file.ext
- See Also: ERR-20250110-001 (if recurring)
---
追加到 .learnings/FEATURE_REQUESTS.md:
## [FEAT-YYYYMMDD-XXX] capability_name
**Logged**: ISO-8601 timestamp
**Priority**: medium
**Status**: pending
**Area**: frontend | backend | infra | tests | docs | config
### Requested Capability
What the user wanted to do
### User Context
Why they needed it, what problem they're solving
### Complexity Estimate
simple | medium | complex
### Suggested Implementation
How this could be built, what it might extend
### Metadata
- Frequency: first_time | recurring
- Related Features: existing_feature_name
---
格式:TYPE-YYYYMMDD-XXX
LRN(学习)、ERR(错误)、FEAT(功能)001、A7B)示例:LRN-20250115-001、ERR-20250115-A3F、FEAT-20250115-002
当问题被修复时,更新条目:
**Status**: pending 改为 **Status**: resolved### Resolution
- **Resolved**: 2025-01-16T09:00:00Z
- **Commit/PR**: abc123 or #42
- **Notes**: Brief description of what was done
其他状态值:
in_progress - 正在积极处理中wont_fix - 决定不解决(在解决说明中添加原因)promoted - 已提升到 CLAUDE.md、AGENTS.md 或 .github/copilot-instructions.md当学习内容广泛适用(不是一次性修复)时,将其提升到永久的项目记忆中。
| 目标 | 应包含的内容 |
|---|---|
CLAUDE.md | 项目事实、约定、所有 Claude 交互的注意事项 |
AGENTS.md | 代理特定的工作流程、工具使用模式、自动化规则 |
.github/copilot-instructions.md | GitHub Copilot 的项目上下文和约定 |
SOUL.md | 行为准则、沟通风格、原则(OpenClaw 工作区) |
TOOLS.md | 工具能力、使用模式、集成注意事项(OpenClaw 工作区) |
**Status**: pending 改为 **Status**: promoted**Promoted**: CLAUDE.md、AGENTS.md 或 .github/copilot-instructions.md学习内容(详细):
项目使用 pnpm 工作区。尝试了
npm install但失败了。锁文件是pnpm-lock.yaml。必须使用pnpm install。
在 CLAUDE.md 中(简洁):
## Build & Dependencies
- Package manager: pnpm (not npm) - use `pnpm install`
学习内容(详细):
修改 API 端点时,必须重新生成 TypeScript 客户端。忘记这一点会导致运行时的类型不匹配。
在 AGENTS.md 中(可操作):
## After API Changes
1. Regenerate client: `pnpm run generate:api`
2. Check for type errors: `pnpm tsc --noEmit`
如果记录的内容与现有条目类似:
grep -r "keyword" .learnings/**See Also**: ERR-20250110-001在自然的断点处审查 .learnings/:
# Count pending items
grep -h "Status\*\*: pending" .learnings/*.md | wc -l
# List pending high-priority items
grep -B5 "Priority\*\*: high" .learnings/*.md | grep "^## \["
# Find learnings for a specific area
grep -l "Area\*\*: backend" .learnings/*.md
当你注意到以下情况时自动记录:
纠正(→ 类别为 correction 的学习):
功能请求(→ 功能请求):
知识差距(→ 类别为 knowledge_gap 的学习):
错误(→ 错误条目):
| 优先级 | 何时使用 |
|---|---|
critical | 阻塞核心功能、数据丢失风险、安全问题 |
high | 重大影响、影响常见工作流程、重复出现的问题 |
medium | 中等影响、存在变通方法 |
low | 轻微不便、边缘情况、锦上添花 |
用于按代码库区域筛选学习内容:
| 区域 | 范围 |
|---|---|
frontend | UI、组件、客户端代码 |
backend | API、服务、服务器端代码 |
infra | CI/CD、部署、Docker、云 |
tests | 测试文件、测试工具、覆盖率 |
docs | 文档、注释、README |
config | 配置文件、环境、设置 |
保持学习内容本地化(每个开发者):
.learnings/
在仓库中跟踪学习内容(团队范围):不要添加到 .gitignore - 学习内容成为共享知识。
混合模式(跟踪模板,忽略条目):
.learnings/*.md
!.learnings/.gitkeep
通过代理钩子启用自动提醒。这是选择加入的 - 你必须明确配置钩子。
在项目中创建 .claude/settings.json:
{
"hooks": {
"UserPromptSubmit": [{
"matcher": "",
"hooks": [{
"type": "command",
"command": "./skills/self-improvement/scripts/activator.sh"
}]
}]
}
}
这会在每个提示后注入学习评估提醒(约 50-100 个令牌的开销)。
{
"hooks": {
"UserPromptSubmit": [{
"matcher": "",
"hooks": [{
"type": "command",
"command": "./skills/self-improvement/scripts/activator.sh"
}]
}],
"PostToolUse": [{
"matcher": "Bash",
"hooks": [{
"type": "command",
"command": "./skills/self-improvement/scripts/error-detector.sh"
}]
}]
}
}
| 脚本 | 钩子类型 | 目的 |
|---|---|---|
scripts/activator.sh | UserPromptSubmit | 提醒在任务后评估学习内容 |
scripts/error-detector.sh | PostToolUse (Bash) | 在命令错误时触发 |
详细配置和故障排除请参阅 references/hooks-setup.md。
当学习内容足够有价值,可以成为可重用技能时,使用提供的助手进行提取。
当满足以下任何条件时,学习内容有资格进行技能提取:
| 标准 | 描述 |
|---|---|
| 重复出现 | 有 See Also 链接指向 2 个以上类似问题 |
| 已验证 | 状态为 resolved 且有有效的修复方案 |
| 非显而易见 | 需要实际调试/调查才能发现 |
| 广泛适用 | 不特定于项目;跨代码库有用 |
| 用户标记 | 用户说"将此保存为技能"或类似内容 |
识别候选:学习内容满足提取标准
运行助手(或手动创建):
./skills/self-improvement/scripts/extract-skill.sh skill-name --dry-run
./skills/self-improvement/scripts/extract-skill.sh skill-name
自定义 SKILL.md:用学习内容填充模板
更新学习内容:将状态设置为 promoted_to_skill,添加 Skill-Path
验证:在新会话中阅读技能以确保其自包含
如果你更喜欢手动创建:
skills/<skill-name>/SKILL.mdassets/SKILL-TEMPLATE.md 中的模板name 和 description 的 YAML 前置元数据注意这些信号,表明学习内容应该成为技能:
在对话中:
在学习条目中:
See Also 链接(重复出现的问题)best_practice在提取之前,验证:
此技能通过代理特定的激活方式,在不同的 AI 编码代理中工作。
激活:钩子(UserPromptSubmit、PostToolUse) 设置:带有钩子配置的 .claude/settings.json 检测:通过钩子脚本自动
激活:钩子(与 Claude Code 相同的模式) 设置:带有钩子配置的 .codex/settings.json 检测:通过钩子脚本自动
激活:手动(不支持钩子) 设置:添加到 .github/copilot-instructions.md:
## Self-Improvement
After solving non-obvious issues, consider logging to `.learnings/`:
1. Use format from self-improvement skill
2. Link related entries with See Also
3. Promote high-value learnings to skills
Ask in chat: "Should I log this as a learning?"
检测:会话结束时手动审查
激活:工作区注入 + 代理间消息传递 设置:参见上面的"OpenClaw 设置"部分 检测:通过会话工具和工作区文件
无论使用何种代理,在以下情况下应用自我提升:
对于 Copilot 用户,在相关时将此添加到你的提示中:
完成此任务后,评估是否有任何学习内容应使用自我提升技能格式记录到
.learnings/。
或使用快速提示:
每周安装
5.8K
仓库
GitHub 星标
7
首次出现
2026年2月20日
安全审计
安装于
opencode5.7K
codex5.7K
gemini-cli5.7K
github-copilot5.7K
cursor5.7K
kimi-cli5.7K
Log 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.
| Situation | Action |
|---|---|
| Command/operation fails | Log to .learnings/ERRORS.md |
| User corrects you | Log to .learnings/LEARNINGS.md with category correction |
| User wants missing feature | Log to .learnings/FEATURE_REQUESTS.md |
| API/external tool fails | Log to .learnings/ERRORS.md with integration details |
| Knowledge was outdated | Log to .learnings/LEARNINGS.md with category knowledge_gap |
| Found better approach | Log to .learnings/LEARNINGS.md with category best_practice |
| Similar to existing entry | Link with **See Also**, consider priority bump |
| Broadly applicable learning | Promote to CLAUDE.md, AGENTS.md, and/or .github/copilot-instructions.md |
| Workflow improvements | Promote to AGENTS.md (OpenClaw workspace) |
| Tool gotchas | Promote to TOOLS.md (OpenClaw workspace) |
| Behavioral patterns | Promote to SOUL.md (OpenClaw workspace) |
OpenClaw is the primary platform for this skill. It uses workspace-based prompt injection with automatic skill loading.
Via ClawdHub (recommended):
clawdhub install self-improving-agent
Manual:
git clone https://github.com/peterskoett/self-improving-agent.git ~/.openclaw/skills/self-improving-agent
OpenClaw injects these files into every session:
~/.openclaw/workspace/
├── AGENTS.md # Multi-agent workflows, delegation patterns
├── SOUL.md # Behavioral guidelines, personality, principles
├── TOOLS.md # Tool capabilities, integration gotchas
├── MEMORY.md # Long-term memory (main session only)
├── memory/ # Daily memory files
│ └── YYYY-MM-DD.md
└── .learnings/ # This skill's log files
├── LEARNINGS.md
├── ERRORS.md
└── FEATURE_REQUESTS.md
mkdir -p ~/.openclaw/workspace/.learnings
Then create the log files (or copy from assets/):
LEARNINGS.md — corrections, knowledge gaps, best practicesERRORS.md — command failures, exceptionsFEATURE_REQUESTS.md — user-requested capabilitiesWhen learnings prove broadly applicable, promote them to workspace files:
| Learning Type | Promote To | Example |
|---|---|---|
| Behavioral patterns | SOUL.md | "Be concise, avoid disclaimers" |
| Workflow improvements | AGENTS.md | "Spawn sub-agents for long tasks" |
| Tool gotchas | TOOLS.md | "Git push needs auth configured first" |
OpenClaw provides tools to share learnings across sessions:
For automatic reminders at session start:
# Copy hook to OpenClaw hooks directory
cp -r hooks/openclaw ~/.openclaw/hooks/self-improvement
# Enable it
openclaw hooks enable self-improvement
See references/openclaw-integration.md for complete details.
For Claude Code, Codex, Copilot, or other agents, create .learnings/ in your project:
mkdir -p .learnings
Copy templates from assets/ or create files with headers.
Append to .learnings/LEARNINGS.md:
## [LRN-YYYYMMDD-XXX] category
**Logged**: ISO-8601 timestamp
**Priority**: low | medium | high | critical
**Status**: pending
**Area**: frontend | backend | infra | tests | docs | config
### Summary
One-line description of what was learned
### Details
Full context: what happened, what was wrong, what's correct
### Suggested Action
Specific fix or improvement to make
### Metadata
- Source: conversation | error | user_feedback
- Related Files: path/to/file.ext
- Tags: tag1, tag2
- See Also: LRN-20250110-001 (if related to existing entry)
---
Append to .learnings/ERRORS.md:
## [ERR-YYYYMMDD-XXX] skill_or_command_name
**Logged**: ISO-8601 timestamp
**Priority**: high
**Status**: pending
**Area**: frontend | backend | infra | tests | docs | config
### Summary
Brief description of what failed
### Error
Actual error message or output
### Context
- Command/operation attempted
- Input or parameters used
- Environment details if relevant
### Suggested Fix
If identifiable, what might resolve this
### Metadata
- Reproducible: yes | no | unknown
- Related Files: path/to/file.ext
- See Also: ERR-20250110-001 (if recurring)
---
Append to .learnings/FEATURE_REQUESTS.md:
## [FEAT-YYYYMMDD-XXX] capability_name
**Logged**: ISO-8601 timestamp
**Priority**: medium
**Status**: pending
**Area**: frontend | backend | infra | tests | docs | config
### Requested Capability
What the user wanted to do
### User Context
Why they needed it, what problem they're solving
### Complexity Estimate
simple | medium | complex
### Suggested Implementation
How this could be built, what it might extend
### Metadata
- Frequency: first_time | recurring
- Related Features: existing_feature_name
---
Format: TYPE-YYYYMMDD-XXX
LRN (learning), ERR (error), FEAT (feature)001, A7B)Examples: LRN-20250115-001, ERR-20250115-A3F, FEAT-20250115-002
When an issue is fixed, update the entry:
**Status**: pending → **Status**: resolved### Resolution
- **Resolved**: 2025-01-16T09:00:00Z
- **Commit/PR**: abc123 or #42
- **Notes**: Brief description of what was done
Other status values:
in_progress - Actively being worked onwont_fix - Decided not to address (add reason in Resolution notes)promoted - Elevated to CLAUDE.md, AGENTS.md, or .github/copilot-instructions.mdWhen a learning is broadly applicable (not a one-off fix), promote it to permanent project memory.
| Target | What Belongs There |
|---|---|
CLAUDE.md | Project facts, conventions, gotchas for all Claude interactions |
AGENTS.md | Agent-specific workflows, tool usage patterns, automation rules |
.github/copilot-instructions.md | Project context and conventions for GitHub Copilot |
SOUL.md | Behavioral guidelines, communication style, principles (OpenClaw workspace) |
TOOLS.md | Tool capabilities, usage patterns, integration gotchas (OpenClaw workspace) |
**Status**: pending → **Status**: promoted**Promoted**: CLAUDE.md, AGENTS.md, or .github/copilot-instructions.mdLearning (verbose):
Project uses pnpm workspaces. Attempted
npm installbut failed. Lock file ispnpm-lock.yaml. Must usepnpm install.
In CLAUDE.md (concise):
## Build & Dependencies
- Package manager: pnpm (not npm) - use `pnpm install`
Learning (verbose):
When modifying API endpoints, must regenerate TypeScript client. Forgetting this causes type mismatches at runtime.
In AGENTS.md (actionable):
## After API Changes
1. Regenerate client: `pnpm run generate:api`
2. Check for type errors: `pnpm tsc --noEmit`
If logging something similar to an existing entry:
grep -r "keyword" .learnings/**See Also**: ERR-20250110-001 in MetadataReview .learnings/ at natural breakpoints:
# Count pending items
grep -h "Status\*\*: pending" .learnings/*.md | wc -l
# List pending high-priority items
grep -B5 "Priority\*\*: high" .learnings/*.md | grep "^## \["
# Find learnings for a specific area
grep -l "Area\*\*: backend" .learnings/*.md
Automatically log when you notice:
Corrections (→ learning with correction category):
Feature Requests (→ feature request):
Knowledge Gaps (→ learning with knowledge_gap category):
Errors (→ error entry):
| Priority | When to Use |
|---|---|
critical | Blocks core functionality, data loss risk, security issue |
high | Significant impact, affects common workflows, recurring issue |
medium | Moderate impact, workaround exists |
low | Minor inconvenience, edge case, nice-to-have |
Use to filter learnings by codebase region:
| Area | Scope |
|---|---|
frontend | UI, components, client-side code |
backend | API, services, server-side code |
infra | CI/CD, deployment, Docker, cloud |
tests | Test files, testing utilities, coverage |
docs | Documentation, comments, READMEs |
config | Configuration files, environment, settings |
Keep learnings local (per-developer):
.learnings/
Track learnings in repo (team-wide): Don't add to .gitignore - learnings become shared knowledge.
Hybrid (track templates, ignore entries):
.learnings/*.md
!.learnings/.gitkeep
Enable automatic reminders through agent hooks. This is opt-in - you must explicitly configure hooks.
Create .claude/settings.json in your project:
{
"hooks": {
"UserPromptSubmit": [{
"matcher": "",
"hooks": [{
"type": "command",
"command": "./skills/self-improvement/scripts/activator.sh"
}]
}]
}
}
This injects a learning evaluation reminder after each prompt (~50-100 tokens overhead).
{
"hooks": {
"UserPromptSubmit": [{
"matcher": "",
"hooks": [{
"type": "command",
"command": "./skills/self-improvement/scripts/activator.sh"
}]
}],
"PostToolUse": [{
"matcher": "Bash",
"hooks": [{
"type": "command",
"command": "./skills/self-improvement/scripts/error-detector.sh"
}]
}]
}
}
| Script | Hook Type | Purpose |
|---|---|---|
scripts/activator.sh | UserPromptSubmit | Reminds to evaluate learnings after tasks |
scripts/error-detector.sh | PostToolUse (Bash) | Triggers on command errors |
See references/hooks-setup.md for detailed configuration and troubleshooting.
When a learning is valuable enough to become a reusable skill, extract it using the provided helper.
A learning qualifies for skill extraction when ANY of these apply:
| Criterion | Description |
|---|---|
| Recurring | Has See Also links to 2+ similar issues |
| Verified | Status is resolved with working fix |
| Non-obvious | Required actual debugging/investigation to discover |
| Broadly applicable | Not project-specific; useful across codebases |
| User-flagged | User says "save this as a skill" or similar |
Identify candidate : Learning meets extraction criteria
Run helper (or create manually):
./skills/self-improvement/scripts/extract-skill.sh skill-name --dry-run
./skills/self-improvement/scripts/extract-skill.sh skill-name
Customize SKILL.md : Fill in template with learning content
Update learning : Set status to promoted_to_skill, add Skill-Path
Verify : Read skill in fresh session to ensure it's self-contained
If you prefer manual creation:
skills/<skill-name>/SKILL.mdassets/SKILL-TEMPLATE.mdname and descriptionWatch for these signals that a learning should become a skill:
In conversation:
In learning entries:
See Also links (recurring issue)best_practice with broad applicabilityBefore extraction, verify:
This skill works across different AI coding agents with agent-specific activation.
Activation : Hooks (UserPromptSubmit, PostToolUse) Setup : .claude/settings.json with hook configuration Detection : Automatic via hook scripts
Activation : Hooks (same pattern as Claude Code) Setup : .codex/settings.json with hook configuration Detection : Automatic via hook scripts
Activation : Manual (no hook support) Setup : Add to .github/copilot-instructions.md:
## Self-Improvement
After solving non-obvious issues, consider logging to `.learnings/`:
1. Use format from self-improvement skill
2. Link related entries with See Also
3. Promote high-value learnings to skills
Ask in chat: "Should I log this as a learning?"
Detection : Manual review at session end
Activation : Workspace injection + inter-agent messaging Setup : See "OpenClaw Setup" section above Detection : Via session tools and workspace files
Regardless of agent, apply self-improvement when you:
For Copilot users, add this to your prompts when relevant:
After completing this task, evaluate if any learnings should be logged to
.learnings/using the self-improvement skill format.
Or use quick prompts:
Weekly Installs
5.8K
Repository
GitHub Stars
7
First Seen
Feb 20, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
opencode5.7K
codex5.7K
gemini-cli5.7K
github-copilot5.7K
cursor5.7K
kimi-cli5.7K
99,500 周安装