self-improving-agent
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseSelf-Improving Agent
自我改进Agent
Captures learnings, errors, and corrections to enable continuous improvement across sessions.
捕获学习内容、错误和纠正信息,实现跨会话的持续改进。
Activation Triggers
激活触发条件
This skill automatically activates when:
| Trigger | What Gets Logged | Location |
|---|---|---|
| Command fails | Error type, context, recovery suggestion | |
| User corrects | "No, that's wrong...", "Actually..." | |
| Missing capability | "Can you X?" where X isn't available | |
| API/tool fails | Failure pattern, suggested fix | |
| Better approach found | Optimization learned | |
本技能在以下场景自动激活:
| 触发条件 | 记录内容 | 存储位置 |
|---|---|---|
| 命令执行失败 | 错误类型、上下文、恢复建议 | |
| 用户给出纠正 | "No, that's wrong...", "Actually..."这类表述 | |
| 能力缺失 | 用户提出当前不支持的功能请求,如"你能做X吗?" | |
| API/工具调用失败 | 失败模式、建议修复方案 | |
| 发现更优方案 | 学习到的优化点 | |
How It Works
工作原理
1. Automatic Logging (via hooks)
1. 自动日志记录(通过钩子实现)
PostToolUse → enhanced-failure-logger.js → logs failures with context
UserMessage → correction-detector.js → detects "wrong/actually/try again"
Response → capability-tracker.js → detects unfulfilled requestsPostToolUse → enhanced-failure-logger.js → logs failures with context
UserMessage → correction-detector.js → detects "wrong/actually/try again"
Response → capability-tracker.js → detects unfulfilled requests2. Learning Aggregation
2. 学习聚合
All learnings flow to :
logs/learnings.jsonljson
{
"timestamp": "2026-01-26T12:00:00Z",
"type": "user_correction|tool_failure|missing_capability",
"category": "factual_error|command_failed|web_browsing",
"description": "what was learned",
"source": "which detector"
}所有学习内容都会流入:
logs/learnings.jsonljson
{
"timestamp": "2026-01-26T12:00:00Z",
"type": "user_correction|tool_failure|missing_capability",
"category": "factual_error|command_failed|web_browsing",
"description": "what was learned",
"source": "which detector"
}3. Session Start Review
3. 会话启动回顾
On each session start, recent learnings are shown:
=== Learning Review ===
[Learnings] 47 total entries
[Recent]
• [tool_failure] Bash failed: timeout - WebFetch to external API...
• [user_correction] User corrected: "No, use the other file..."
[Corrections] 12 user corrections logged
[Capability Gaps] Top requested:
• send emails (5x)
• browse web (3x)每次会话启动时,会展示近期的学习内容:
=== Learning Review ===
[Learnings] 47 total entries
[Recent]
• [tool_failure] Bash failed: timeout - WebFetch to external API...
• [user_correction] User corrected: "No, use the other file..."
[Corrections] 12 user corrections logged
[Capability Gaps] Top requested:
• send emails (5x)
• browse web (3x)4. QAVR Integration
4. QAVR集成
Successful learnings boost Q-values for related memories, improving future retrieval.
成功的学习内容会提升相关记忆的Q值,优化后续的检索效果。
Manual Commands
手动命令
Review Learnings
回顾学习内容
bash
undefinedbash
undefinedShow all learnings
Show all learnings
cat ~/.claude/logs/learnings.jsonl | tail -20
cat ~/.claude/logs/learnings.jsonl | tail -20
Show corrections only
Show corrections only
cat ~/.claude/logs/corrections.jsonl | jq -s 'group_by(.correction_type) | map({type: .[0].correction_type, count: length})'
cat ~/.claude/logs/corrections.jsonl | jq -s 'group_by(.correction_type) | map({type: .[0].correction_type, count: length})'
Show capability gaps report
Show capability gaps report
node ~/.claude/scripts/hooks/capability-tracker.js --report
undefinednode ~/.claude/scripts/hooks/capability-tracker.js --report
undefinedTest Detection
检测功能测试
bash
undefinedbash
undefinedTest correction detector
Test correction detector
node ~/.claude/scripts/hooks/correction-detector.js
node ~/.claude/scripts/hooks/correction-detector.js
Test failure logger
Test failure logger
node ~/.claude/scripts/hooks/enhanced-failure-logger.js
node ~/.claude/scripts/hooks/enhanced-failure-logger.js
Test capability tracker
Test capability tracker
node ~/.claude/scripts/hooks/capability-tracker.js
undefinednode ~/.claude/scripts/hooks/capability-tracker.js
undefinedLearning Categories
学习分类
Correction Types
纠正类型
- - Wrong information provided
factual_error - - User asked to try again
retry_request - - Misinterpreted the request
misunderstanding - - Solution didn't work
failed_solution
- - 提供了错误信息
factual_error - - 用户要求重试
retry_request - - 误解了用户请求
misunderstanding - - 提供的解决方案无效
failed_solution
Failure Types
失败类型
- - Access denied
permission_error - - File/resource missing
not_found - - Operation timed out
timeout - - Connection issues
network_error - - Invalid syntax
syntax_error - - External API failed
api_error - - Shell command failed
command_failed - - Subagent failed
agent_failed
- - 访问被拒绝
permission_error - - 文件/资源不存在
not_found - - 操作超时
timeout - - 连接问题
network_error - - 语法无效
syntax_error - - 外部API调用失败
api_error - - Shell命令执行失败
command_failed - - 子Agent运行失败
agent_failed
Capability Categories
能力分类
- - Internet access requests
web_browsing - - Image/photo handling
image_processing - - Email/messaging
communication - - SQL/database queries
database_access - - Third-party services
external_api - - Long-term memory
memory_persistence
- - 互联网访问请求
web_browsing - - 图片/照片处理
image_processing - - 邮件/消息发送
communication - - SQL/数据库查询
database_access - - 第三方服务调用
external_api - - 长期记忆存储
memory_persistence
Configuration
配置
In , these hooks enable self-improvement:
settings.jsonjson
{
"hooks": {
"SessionStart": [...], // Reviews learnings
"PostToolUse": [
{"matcher": "Bash", "hooks": [{"command": "enhanced-failure-logger.js"}]},
{"matcher": "Task", "hooks": [{"command": "enhanced-failure-logger.js"}]}
]
}
}在中,以下钩子会启用自我改进功能:
settings.jsonjson
{
"hooks": {
"SessionStart": [...], // Reviews learnings
"PostToolUse": [
{"matcher": "Bash", "hooks": [{"command": "enhanced-failure-logger.js"}]},
{"matcher": "Task", "hooks": [{"command": "enhanced-failure-logger.js"}]}
]
}
}Benefits
优势
- Learn from mistakes - Don't repeat the same errors
- Understand user preferences - Track what corrections mean
- Identify skill gaps - Know what features to build
- Improve over time - QAVR ranking gets better with feedback
- Context persistence - Learnings survive session restarts
- 从错误中学习 - 不会重复犯相同的错误
- 理解用户偏好 - 追踪用户纠正内容背后的偏好
- 识别能力缺口 - 明确需要开发的功能方向
- 持续优化 - QAVR排序会随着反馈不断优化
- 上下文持久化 - 学习内容不会随着会话重启丢失
Integration with Other Skills
与其他技能的集成
| Skill | Integration |
|---|---|
| QAVR | Successful learnings boost memory Q-values |
| Memory Consolidation | Periodic cleanup of old learnings |
| Confidence Check | Review learnings before major tasks |
| IR-v2 | Use learnings to inform pattern selection |
| 技能 | 集成逻辑 |
|---|---|
| QAVR | 成功的学习内容会提升记忆Q值 |
| Memory Consolidation | 定期清理过时的学习内容 |
| Confidence Check | 执行重要任务前回顾学习内容 |
| IR-v2 | 基于学习内容优化模式选择 |
Files
文件结构
~/.claude/
├── logs/
│ ├── learnings.jsonl # All learnings
│ ├── corrections.jsonl # User corrections
│ ├── failures_detailed.jsonl # Enhanced failure logs
│ ├── missing_capabilities.jsonl # Capability requests
│ └── capability_gaps.json # Aggregated gaps
└── scripts/hooks/
├── correction-detector.js
├── enhanced-failure-logger.js
├── capability-tracker.js
└── session-start.js (reviews learnings)~/.claude/
├── logs/
│ ├── learnings.jsonl # All learnings
│ ├── corrections.jsonl # User corrections
│ ├── failures_detailed.jsonl # Enhanced failure logs
│ ├── missing_capabilities.jsonl # Capability requests
│ └── capability_gaps.json # Aggregated gaps
└── scripts/hooks/
├── correction-detector.js
├── enhanced-failure-logger.js
├── capability-tracker.js
└── session-start.js (reviews learnings)