Agent Health Optimizer
Diagnose, score, and steadily improve your OpenClaw setup.
This skill is an audit toolkit, not a magic self-healing system. It is good at surfacing likely problems, weak spots, and opportunities. Its --fix mode is intentionally conservative.
Requirements
- - python3 (3.8+)
- openclaw CLI
Quick Start
CODEBLOCK0
What It Does
🏥 health_score.py — Agent Health Grade (0-100)
Scores 5 dimensions:
- - 🧠 Memory (25pts): MEMORY.md completeness, daily log activity, working buffer, anti-poisoning hygiene, source tags
- ⏰ Cron (25pts): job health, schedule diversity, use of isolated sessions, suspicious delivery setups, selective stagger usage
- 📦 Skills (20pts): count, overlap hints, ClawHub management ratio, metadata completeness
- 🔒 Security (15pts): safety rules, anti-poisoning policy, WAL protocol, external action controls
- 🔄 Continuity (15pts): SOUL.md, USER.md, HEARTBEAT.md, IDENTITY.md, git tracking
🔍 memory_auditor.py — Memory Hygiene
Detects:
- - Imperative rules that should be declarative facts
- Missing source tags on factual entries
- Stale entries >30 days with pending status
- External content stored as instructions
- Oversized files needing archival
- Daily log gaps
⏰ cron_optimizer.py — Cron Job Doctor
Detects:
- - Error states with job names and error messages
- Time collisions (multiple jobs on same schedule)
- Missing stagger on burst-prone recurring schedules
- Suspicious announce setups (for example explicit channel without explicit
to) - Timeout mismatches
- Session target recommendations (isolated vs main)
INLINECODE2 mode:
- - creates
memory/cron-backup.json before changes - only auto-adds stagger to recurring top-of-hour stampede-prone jobs
- does not force delivery on jobs using INLINECODE4
- does not modify exact-time jobs just because they lack stagger
📦 skill_comparator.py — Skill Landscape Checker
Via ClawHub API (https://clawhub.ai/api/v1/):
- - Fetches stars, downloads, installs for installed skills
- Lists top ClawHub skills you're missing
- Finds adjacent / overlapping skills with stronger community signals
- Category coverage analysis (what domains are missing?)
Important: these are comparison hints, not authoritative replacements.
🔄 self_optimize.py — Unified Runner
Runs all 4 tools and produces:
- - Combined report with prioritized action items (HIGH/MED/LOW)
- Trend tracking vs prior run (📈/📉)
- JSON reports in
memory/ for historical review
What It Reads & Writes
Reads (non-destructive):
- - Workspace files: MEMORY.md, AGENTS.md, SOUL.md, USER.md, HEARTBEAT.md, IDENTITY.md
- Daily logs: INLINECODE7
- Skill metadata: INLINECODE8
- Cron config: INLINECODE9
- ClawHub public API: INLINECODE10
Writes (reports only):
- - INLINECODE11
- INLINECODE12
- INLINECODE13
- INLINECODE14
- INLINECODE15
- INLINECODE16
Modifies (only with --fix):
- -
cron_optimizer.py --fix edits cron jobs via INLINECODE19 - Always backs up to
memory/cron-backup.json first
Periodic Self-Optimization
Set up a weekly cron (read-only, no --fix):
CODEBLOCK1
Positioning
Use this skill when you want:
- - a periodic audit
- a sanity check before changing agent architecture
- conservative recommendations
- a historical trend of agent health
Do not treat it as a substitute for human review on destructive or far-reaching changes.
Credits
Diagnostic patterns informed by:
- - proactive-agent by halthelobster
- self-improving-agent by pskoett
- Moltbook openclaw-explorers community — cron jitter pattern (thoth-ix), heartbeat batching (pinchy_mcpinchface)
License
This work is licensed under CC BY-SA 4.0. You are free to share and adapt, with attribution and same-license requirement.
Agent Health Optimizer
诊断、评分并稳步改进你的 OpenClaw 配置。
此技能是一个审计工具包,而非神奇的自我修复系统。它擅长发现潜在问题、薄弱环节和优化机会。其 --fix 模式有意保持保守。
要求
- - python3 (3.8+)
- openclaw CLI
快速开始
bash
完整诊断套件——一条命令
python3 scripts/self_optimize.py
独立工具
python3 scripts/health_score.py # 健康等级(A+ 到 F)
python3 scripts/memory_auditor.py # 内存卫生检查
python3 scripts/cron_optimizer.py # Cron 分析
python3 scripts/cron_optimizer.py --fix # 保守自动修复(先备份)
python3 scripts/skill_comparator.py # 相邻/重叠的 ClawHub 技能
功能说明
🏥 health_score.py — Agent 健康等级(0-100)
对 5 个维度进行评分:
- - 🧠 内存(25分):MEMORY.md 完整性、每日日志活动、工作缓冲区、防污染卫生、来源标签
- ⏰ Cron(25分):任务健康度、调度多样性、隔离会话使用、可疑投递设置、选择性错峰使用
- 📦 技能(20分):数量、重叠提示、ClawHub 管理比例、元数据完整性
- 🔒 安全(15分):安全规则、防污染策略、WAL 协议、外部操作控制
- 🔄 连续性(15分):SOUL.md、USER.md、HEARTBEAT.md、IDENTITY.md、git 追踪
🔍 memory_auditor.py — 内存卫生
检测:
- - 应改为声明性事实的命令式规则
- 事实条目缺少来源标签
- 超过 30 天且状态待定的过时条目
- 存储为指令的外部内容
- 需要归档的超大文件
- 每日日志缺失
⏰ cron_optimizer.py — Cron 任务医生
检测:
- - 包含任务名称和错误信息的错误状态
- 时间冲突(多个任务在同一调度上)
- 易爆发重复调度缺少错峰
- 可疑的公告设置(例如显式通道但没有显式 to)
- 超时不匹配
- 会话目标建议(隔离 vs 主会话)
--fix 模式:
- - 在更改前创建 memory/cron-backup.json
- 仅自动为重复的整点易爆发任务添加错峰
- 不强制投递使用 delivery=none 的任务
- 不因缺少错峰而修改精确时间任务
📦 skill_comparator.py — 技能格局检查器
通过 ClawHub API(https://clawhub.ai/api/v1/):
- - 获取已安装技能的星标数、下载量、安装量
- 列出你缺少的热门 ClawHub 技能
- 发现具有更强社区信号的相邻/重叠技能
- 类别覆盖分析(哪些领域缺失?)
重要提示:这些是比较提示,而非权威替代方案。
🔄 self_optimize.py — 统一运行器
运行所有 4 个工具并生成:
- - 带有优先级操作项(高/中/低)的综合报告
- 与上次运行的趋势对比(📈/📉)
- memory/ 中的 JSON 报告,用于历史回顾
读取与写入内容
读取(非破坏性):
- - 工作区文件:MEMORY.md、AGENTS.md、SOUL.md、USER.md、HEARTBEAT.md、IDENTITY.md
- 每日日志:memory/.md
- 技能元数据:skills//SKILL.md
- Cron 配置:openclaw cron list --json
- ClawHub 公共 API:https://clawhub.ai/api/v1/skills/...
写入(仅报告):
- - memory/health-score.json
- memory/memory-audit.json
- memory/cron-optimizer.json
- memory/skill-comparator.json
- memory/self-optimize-report.json
- memory/self-optimize-last.json
修改(仅使用 --fix):
- - cron_optimizer.py --fix 通过 openclaw cron edit 编辑 cron 任务
- 始终先备份到 memory/cron-backup.json
定期自我优化
设置每周 cron(只读,无 --fix):
bash
openclaw cron add \
--name Agent 自我优化 \
--cron 0 11 0 \
--tz America/Los_Angeles \
--session isolated \
--stagger 2m \
--no-deliver \
--message 运行 agent 自我优化:
python3 ~/.openclaw/workspace/skills/agent-health-optimizer/scripts/self_optimize.py
报告结果。首先列出高优先级问题。如果一切正常,保持简洁。
定位
在以下情况下使用此技能:
- - 需要定期审计
- 在更改 agent 架构前进行合理性检查
- 需要保守建议
- 需要 agent 健康的历史趋势
不要将其视为对破坏性或影响深远的变更的人工审查替代品。
致谢
诊断模式灵感来源于:
许可证
本作品采用 CC BY-SA 4.0 许可。你可以自由分享和改编,但需注明出处并采用相同许可。