Agent Health Optimizer
Diagnose, score, and continuously optimize your OpenClaw agent.
One command tells you exactly what's wrong and how to fix it. Set up a weekly cron and your agent gets better on its own.
Requirements
- python3 (3.8+)
- openclaw CLI (for cron job analysis)
Quick Start
# Full diagnostic suite — one command
python3 scripts/self_optimize.py
# Individual tools
python3 scripts/health_score.py # Health grade (A+ to F)
python3 scripts/memory_auditor.py # Memory hygiene check
python3 scripts/cron_optimizer.py # Cron job analysis
python3 scripts/cron_optimizer.py --fix # Auto-repair (backs up first)
python3 scripts/skill_comparator.py # Compare vs ClawHub catalog
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, error states, stagger configuration, time diversity, session isolation, delivery mode
- 📦 Skills (20pts): count, redundancy detection, ClawHub management ratio, essential skills
- 🔒 Security (15pts): safety rules, anti-poisoning policy, WAL protocol, external action controls
- 🔄 Continuity (15pts): SOUL.md, USER.md, HEARTBEAT.md, IDENTITY.md, git tracking
Letter grade from A+ (90+) to F (<50).
🔍 memory_auditor.py — Memory Hygiene
Detects:
- Imperative rules that should be declarative facts (anti-poisoning)
- Missing source tags on factual entries
- Stale entries >30 days with pending status
- External content stored as instructions (injection risk)
- 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/jitter (API stampede risk)
- Announce duplication (user gets message twice)
- Timeout mismatches (complex jobs with short timeouts)
- Session target recommendations (isolated vs main)
--fix mode: creates memory/cron-backup.json before any changes, then auto-applies stagger and disables duplicate announce.
📦 skill_comparator.py — Skill Quality Checker
Via ClawHub API (https://clawhub.ai/api/v1/):
- Fetches stars, downloads, installs for all installed skills
- Lists top ClawHub skills you're missing
- Finds upgrades: same-category skills with higher community rating
- Category coverage analysis (what domains are you missing?)
- Uses semantic categorization (15+ categories) with slug-weighted matching
🔄 self_optimize.py — Unified Runner
Runs all 4 tools, produces:
- Combined report with prioritized action items (HIGH/MED/LOW)
- Trend tracking: compares with last run, shows score change (📈/📉)
- All reports saved as JSON in
memory/ for historical analysis
What It Reads & Writes
Reads (non-destructive):
- Workspace files: MEMORY.md, AGENTS.md, SOUL.md, USER.md, HEARTBEAT.md, IDENTITY.md
- Daily logs:
memory/*.md
- Skill metadata:
skills/*/SKILL.md
- Cron config:
openclaw cron list --json
- ClawHub public API:
https://clawhub.ai/api/v1/skills/...
Writes (reports only):
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 (trend baseline)
Modifies (only with --fix):
cron_optimizer.py --fix edits cron jobs via openclaw cron edit
- Always backs up to
memory/cron-backup.json first
Periodic Self-Optimization
Set up a weekly cron (read-only, no --fix):
openclaw cron add \
--name "Agent Self-Optimize" \
--cron "0 11 * * 0" \
--tz "America/Los_Angeles" \
--session isolated \
--stagger 2m \
--no-deliver \
--message "Run agent self-optimization:
python3 ~/.openclaw/workspace/skills/agent-health-optimizer/scripts/self_optimize.py
Report results. If HIGH priority issues exist, list them. Compare health score trend. Keep it brief if everything is fine."
⚠️ Cron runs in read-only mode. Review suggested repairs before applying --fix.
Example Output
🏥 Agent Health Score: 81/100 (81%) — Grade: A
==================================================
🧠 Memory: 18/25 [███████░░░]
⏰ Cron: 18/25 [███████░░░]
📦 Skills: 15/20 [███████░░░]
🔒 Security: 15/15 [██████████]
🔄 Continuity: 15/15 [██████████]
🎯 PRIORITIZED ACTION ITEMS
🚨 HIGH: 2 cron jobs in error state
⚠️ MED: Time collision on 2 schedules
💡 LOW: No working-buffer.md
📈 Health trend: +13% since last run
Credits
Diagnostic patterns informed by:
- proactive-agent by halthelobster — WAL Protocol concepts
- self-improving-agent by pskoett — continuous improvement patterns
- Moltbook openclaw-explorers community — cron jitter pattern (thoth-ix), heartbeat batching (pinchy_mcpinchface)
1---
2name: agent-health-optimizer
3description: "Automated agent diagnostics and self-optimization toolkit for OpenClaw. Run one command to score your agent's health (0-100, grade A+ to F), audit memory hygiene, detect cron job issues, and compare installed skills against ClawHub. Set up a weekly cron for continuous self-improvement with trend tracking. Use when you want to diagnose agent problems, optimize your setup, check for better skills, or automate periodic health checks."
4metadata:
5 source: https://skillmd.com/skills/modbender/agent-health-optimizer
6 openclaw:
7 requires:
8 bins: ["openclaw", "python3"]
9---
10
11# Agent Health Optimizer
12
13**Diagnose, score, and continuously optimize your OpenClaw agent.**
14
15One command tells you exactly what's wrong and how to fix it. Set up a weekly cron and your agent gets better on its own.
16
17## Requirements
18
19- **python3** (3.8+)
20- **openclaw CLI** (for cron job analysis)
21
22## Quick Start
23
24```bash
25# Full diagnostic suite — one command
26python3 scripts/self_optimize.py
27
28# Individual tools
29python3 scripts/health_score.py # Health grade (A+ to F)
30python3 scripts/memory_auditor.py # Memory hygiene check
31python3 scripts/cron_optimizer.py # Cron job analysis
32python3 scripts/cron_optimizer.py --fix # Auto-repair (backs up first)
33python3 scripts/skill_comparator.py # Compare vs ClawHub catalog
34```
35
36## What It Does
37
38### 🏥 health_score.py — Agent Health Grade (0-100)
39
40Scores 5 dimensions:
41
42- **🧠 Memory (25pts)**: MEMORY.md completeness, daily log activity, working buffer, anti-poisoning hygiene, source tags
43- **⏰ Cron (25pts)**: job health, error states, stagger configuration, time diversity, session isolation, delivery mode
44- **📦 Skills (20pts)**: count, redundancy detection, ClawHub management ratio, essential skills
45- **🔒 Security (15pts)**: safety rules, anti-poisoning policy, WAL protocol, external action controls
46- **🔄 Continuity (15pts)**: SOUL.md, USER.md, HEARTBEAT.md, IDENTITY.md, git tracking
47
48Letter grade from A+ (90+) to F (<50).
49
50### 🔍 memory_auditor.py — Memory Hygiene
51
52Detects:
53- **Imperative rules** that should be declarative facts (anti-poisoning)
54- **Missing source tags** on factual entries
55- **Stale entries** >30 days with pending status
56- **External content** stored as instructions (injection risk)
57- **Oversized files** needing archival
58- **Daily log** gaps
59
60### ⏰ cron_optimizer.py — Cron Job Doctor
61
62Detects:
63- **Error states** with job names and error messages
64- **Time collisions** (multiple jobs on same schedule)
65- **Missing stagger/jitter** (API stampede risk)
66- **Announce duplication** (user gets message twice)
67- **Timeout mismatches** (complex jobs with short timeouts)
68- **Session target** recommendations (isolated vs main)
69
70`--fix` mode: creates `memory/cron-backup.json` before any changes, then auto-applies stagger and disables duplicate announce.
71
72### 📦 skill_comparator.py — Skill Quality Checker
73
74Via ClawHub API (`https://clawhub.ai/api/v1/`):
75- Fetches stars, downloads, installs for all installed skills
76- Lists top ClawHub skills you're missing
77- Finds upgrades: same-category skills with higher community rating
78- Category coverage analysis (what domains are you missing?)
79- Uses semantic categorization (15+ categories) with slug-weighted matching
80
81### 🔄 self_optimize.py — Unified Runner
82
83Runs all 4 tools, produces:
84- Combined report with prioritized action items (HIGH/MED/LOW)
85- Trend tracking: compares with last run, shows score change (📈/📉)
86- All reports saved as JSON in `memory/` for historical analysis
87
88## What It Reads & Writes
89
90**Reads** (non-destructive):
91- Workspace files: MEMORY.md, AGENTS.md, SOUL.md, USER.md, HEARTBEAT.md, IDENTITY.md
92- Daily logs: `memory/*.md`
93- Skill metadata: `skills/*/SKILL.md`
94- Cron config: `openclaw cron list --json`
95- ClawHub public API: `https://clawhub.ai/api/v1/skills/...`
96
97**Writes** (reports only):
98- `memory/health-score.json`
99- `memory/memory-audit.json`
100- `memory/cron-optimizer.json`
101- `memory/skill-comparator.json`
102- `memory/self-optimize-report.json`
103- `memory/self-optimize-last.json` (trend baseline)
104
105**Modifies** (only with `--fix`):
106- `cron_optimizer.py --fix` edits cron jobs via `openclaw cron edit`
107- Always backs up to `memory/cron-backup.json` first
108
109## Periodic Self-Optimization
110
111Set up a weekly cron (read-only, no --fix):
112
113```bash
114openclaw cron add \
115 --name "Agent Self-Optimize" \
116 --cron "0 11 * * 0" \
117 --tz "America/Los_Angeles" \
118 --session isolated \
119 --stagger 2m \
120 --no-deliver \
121 --message "Run agent self-optimization:
122python3 ~/.openclaw/workspace/skills/agent-health-optimizer/scripts/self_optimize.py
123
124Report results. If HIGH priority issues exist, list them. Compare health score trend. Keep it brief if everything is fine."
125```
126
127⚠️ Cron runs in read-only mode. Review suggested repairs before applying `--fix`.
128
129## Example Output
130
131```
132🏥 Agent Health Score: 81/100 (81%) — Grade: A
133==================================================
134 🧠 Memory: 18/25 [███████░░░]
135 ⏰ Cron: 18/25 [███████░░░]
136 📦 Skills: 15/20 [███████░░░]
137 🔒 Security: 15/15 [██████████]
138 🔄 Continuity: 15/15 [██████████]
139
140🎯 PRIORITIZED ACTION ITEMS
141 🚨 HIGH: 2 cron jobs in error state
142 ⚠️ MED: Time collision on 2 schedules
143 💡 LOW: No working-buffer.md
144
145📈 Health trend: +13% since last run
146```
147
148## Credits
149
150Diagnostic patterns informed by:
151- **[proactive-agent](https://clawhub.ai/halthelobster/proactive-agent)** by halthelobster — WAL Protocol concepts
152- **[self-improving-agent](https://clawhub.ai/pskoett/self-improving-agent)** by pskoett — continuous improvement patterns
153- **Moltbook openclaw-explorers community** — cron jitter pattern (thoth-ix), heartbeat batching (pinchy_mcpinchface)