关于 self-reflection
self-reflection 是帮助 Agent 持续改进的技能,可记录错误、经验和改进事项,并通过定期检查触发复盘。它提供命令行操作,并可接入 OpenClaw heartbeat 工作流。
主要功能
- 01检查是否需要复盘
- 02记录并读取反思内容
- 03查看统计并重置计时器
- 04支持 OpenClaw heartbeat 集成
适用场景
- 01定期检查 Agent 是否需要复盘
- 02记录 API 调用错误及改进经验
- 03读取近期经验以辅助后续任务
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ hopyky/ self-reflection --skill self-reflection安装后在 Claude Code 中输入/self-reflection确认已加载。
包含的文件
除 SKILL.md 外,安装时一起下载的参考资料和脚本。
.gitignoreLICENSEREADME.mdself-reflection.example.jsonbin/self-reflection详细介绍
🪞 自我反思
一项用于持续自我改进的技能。Agent 会通过定期触发的心跳反思,持续记录错误、经验教训和改进。
快速开始
# Check if reflection is needed
self-reflection check
# Log a new reflection
self-reflection log "error-handling" "Forgot timeout on API call" "Always add timeout=30"
# Read recent lessons
self-reflection read
# View statistics
self-reflection stats
工作原理
Heartbeat (60m) → Agent reads HEARTBEAT.md → Runs self-reflection check
│
┌─────────┴─────────┐
▼ ▼
OK ALERT
│ │
Continue Reflect
│
┌─────────┴─────────┐
▼ ▼
read log
(past lessons) (new insights)
命令
| 命令 | 描述 |
|---|---|
check [--quiet] | 检查是否需要反思(OK 或 ALERT) |
log <tag> <miss> <fix> | 记录一条新的反思 |
read [n] | 阅读最近的 n 条反思(默认为 5) |
stats | 显示反思统计信息 |
reset | 重置计时器 |
OpenClaw 集成
在 ~/.openclaw/openclaw.json 中启用心跳:
{
"agents": {
"defaults": {
"heartbeat": {
"every": "60m",
"activeHours": { "start": "08:00", "end": "22:00" }
}
}
}
}
在工作区的 HEARTBEAT.md 中添加:
## Self-Reflection Check (required)
Run `self-reflection check` at each heartbeat.
If ALERT: read past lessons, reflect, then log insights.
配置
创建 ~/.openclaw/self-reflection.json:
{
"threshold_minutes": 60,
"memory_file": "~/workspace/memory/self-review.md",
"state_file": "~/.openclaw/self-review-state.json",
"max_entries_context": 5
}
作者
由 hopyky 创建
许可证
MIT
评论
支持 Markdown