Install
openclaw skills install oc-doctorRuns a comprehensive 11-section health check on local OpenClaw installations. Diagnoses configuration errors, session bloat, model drift, cron issues, securi...
Security findings on these releases were reviewed by staff and cleared for public use.
VirusTotalClearedClawScanClearedStatic analysisClearedopenclaw skills install oc-doctorComprehensive health check for OpenClaw installations. Outputs a structured diagnostic report with severity levels and actionable fixes.
Respond in the same language the user used to invoke this skill. If invoked via slash command with no additional text, infer the preferred language from context: check recent conversation history, workspace file content (e.g., CJK content in AGENTS.md or cron job payloads), and system locale. Fall back to English only if no language signal is found.
command -v openclaw >/dev/null || echo "CRITICAL: openclaw not found in PATH"
command -v jq >/dev/null || echo "CRITICAL: jq not found — install with: brew install jq (macOS) or apt install jq (Linux)"
Auto-detect all paths at runtime. Do NOT hardcode platform-specific locations.
OPENCLAW_HOME="${OPENCLAW_HOME:-$HOME/.openclaw}"
OPENCLAW_CONFIG="$OPENCLAW_HOME/openclaw.json"
OPENCLAW_DIST=""
if command -v openclaw &>/dev/null; then
OPENCLAW_DIST="$(dirname "$(readlink -f "$(command -v openclaw)")")/../lib/node_modules/openclaw/dist"
[ -d "$OPENCLAW_DIST" ] || OPENCLAW_DIST=""
fi
SESSIONS_DIR="$OPENCLAW_HOME/agents/main/sessions"
SESSIONS_INDEX="$SESSIONS_DIR/sessions.json"
MODELS_JSON="$OPENCLAW_HOME/agents/main/agent/models.json"
WORKSPACE_GLOB="$OPENCLAW_HOME/workspace-*"
LOGS_DIR="$OPENCLAW_HOME/logs"
BROWSER_CACHE="$OPENCLAW_HOME/browser"
CRON_DIR="$OPENCLAW_HOME/cron"
If any path doesn't exist, note it and skip that check section.
Run ALL sections below sequentially. For each finding, assign a severity:
CRITICAL — broken functionality, data loss riskWARNING — suboptimal config, potential issuesINFO — informational, optimization opportunityUse the built-in status command as the primary data source:
openclaw status --all 2>&1
openclaw --version 2>/dev/null
Report: version, gateway running status, LaunchAgent status, channel health.
Read $OPENCLAW_CONFIG and check:
agents.defaults.model.primary a known model? Cross-check with agents.defaults.models entries.agents.defaults.model.fallbacks defined in the models list?clawdbot.json or other legacy files exist in $OPENCLAW_HOME/.*.bak* files in $OPENCLAW_HOME/. More than 2 is WARNING.requireMention setting per group. false = WARNING (bot responds to all messages).groupPolicy. "open" = WARNING (any group can interact).Check openclaw.json for session.maintenance settings:
"warn" = WARNING (stale sessions accumulate without cleanup). Should be "enforce"."7d" to "14d"."100mb".Check agents.defaults.compaction in openclaw.json:
"safeguard" (default, safe). Note if missing.20000.8000.Use the built-in sessions list, then cross-reference with config:
openclaw sessions 2>&1
Also read sessions.json programmatically to check:
model field differs from the configured default. Particularly check channel sessions (telegram:, feishu:).contextTokens against its model's actual contextWindow (from models.json or built-in registry). Mismatch = WARNING (e.g., 272k contextTokens on a 200k model can cause overflow).XHIGH_MODEL_REFS or custom resolveForwardCompatModel additions) in $OPENCLAW_DIST/*.js.grep -rl "XHIGH_MODEL_REFS" $OPENCLAW_DIST/) and verify the current default model is included in XHIGH_MODEL_REFS if it should support xhigh thinking.$MODELS_JSON and check if inline model definitions are consistent with openclaw.json.Use the built-in cleanup dry-run as primary data source:
openclaw sessions cleanup --dry-run --fix-missing 2>&1
Then supplement with filesystem checks:
sessions.json. Calculate total size.sessions.json pointing to non-existent JSONL files.*.deleted.* files that can be cleaned up. Calculate total size.:cron: in their key. Separate parent jobs from :run: sub-sessions. Large numbers (>20) indicate cleanup isn't working.Read $CRON_DIR/jobs.json and check:
name + schedule + enabled: true. Flag as WARNING with dedup suggestion.enabled: false jobs. More than 10 = INFO (suggest cleanup if user confirms they're not needed).jobs.json.*.tmp files in $CRON_DIR. These are abandoned atomic-write artifacts. Any count > 0 with no process holding them open (lsof) = safe to delete.$CRON_DIR/runs/ for accumulated run logs. Count and total size.state.lastRunAtMs is older than expected based on their schedule (e.g., a daily job that hasn't run in 3+ days).Check openclaw.json for:
"open" means any Feishu group can interact = CRITICAL.["*"] means no restriction = WARNING.false on groups = WARNING (bot responds to every message).gateway.auth.mode from config. "token" is good, "none" = CRITICAL.$OPENCLAW_HOME/ contains any files that might be accidentally synced (e.g., check for .git directory in $OPENCLAW_HOME/).models.json (this is expected but worth noting).du -sh $OPENCLAW_HOME/browser/ 2>/dev/null # Browser cache
du -sh $OPENCLAW_HOME/logs/ 2>/dev/null # Logs
du -sh $SESSIONS_DIR/ 2>/dev/null # Sessions
du -sh $OPENCLAW_HOME/media/ 2>/dev/null # Media files
du -sh $OPENCLAW_HOME/memory/ 2>/dev/null # Memory files
du -sh $CRON_DIR/ 2>/dev/null # Cron data
du -sh $OPENCLAW_HOME/ 2>/dev/null # Total
# Log file sizes
ls -lhS $LOGS_DIR/ 2>/dev/null
# Large JSONL sessions (top 5)
ls -lhS $SESSIONS_DIR/*.jsonl 2>/dev/null | head -5
Flag:
$OPENCLAW_HOME/ > 1GB = WARNINGRead gateway.port from openclaw.json to determine the correct port (do NOT hardcode).
# Check for stuck/zombie openclaw processes
ps aux | grep -E "openclaw-gateway|openclaw " | grep -v grep
# Check gateway port binding (use port from config)
lsof -i :<port> 2>/dev/null | head -5
# Check gateway error log for recent errors
tail -20 $LOGS_DIR/gateway.err.log 2>/dev/null
Flag:
Measures static system instruction token footprint. Complements Section 5 (runtime session pressure) — together they form the Context Budget picture.
Locate and run the bundled collector script from the skill directory:
# Find the skill directory (works whether installed via skills.sh, clawhub, or manually)
SKILL_DIR="$(find ~/.claude/skills ~/.agents/skills -maxdepth 3 -name 'sysinstruction-check.sh' -path '*/oc-doctor/*' 2>/dev/null | head -1 | xargs dirname)"
bash "$SKILL_DIR/sysinstruction-check.sh"
The script auto-detects workspace directories and outputs structured JSON. See scripts/sysinstruction-check.sh for details.
Output schema:
{
"workspace_files": [
{"file": "workspace-name/FILE.md", "chars": 0, "lines": 0, "est_tokens": 0, "is_empty_template": false}
],
"total_est_tokens": 0,
"largest_file": "AGENTS.md",
"empty_template_files": [],
"tool_bloat_files": [],
"tool_bloat_est_tokens": 0,
"bootstrap_still_present": false,
"context_window": 200000,
"context_window_source": "models.json | default_fallback",
"pct_of_context": "0.0"
}
Analyze the JSON output along these dimensions:
Context budget ratio (complements Section 5's runtime check):
pct_of_context < 2% = INFO healthy2-5% = INFO acceptable but worth reviewing5-10% = WARNING consider trimming10-15% = WARNING (strong) actively optimize> 15% = CRITICAL only if paired with runtime truncation evidencecontext_window_source is "default_fallback", note that thresholds may be inaccurateTool description bloat:
tool_bloat_files non-empty = WARNING, list files and estimated token costReclaimable space (read empty_template_files and bootstrap_still_present):
bootstrap_still_present = true = INFO, can be deleted after initial setupempty_template_files non-empty = INFO, list files and estimated token savingsPer-file analysis:
WARNING, consider splittingWARNING, review individuallyBenchmarks (dynamic, based on actual context window):
Healthy: < 2% of context_window
Needs review: 2-5% of context_window
Needs optimization: > 5% of context_window
Cross-reference integrity:
.md filenames (e.g., HEARTBEAT.md, BOOTSTRAP.md, MEMORY.md).workspace-*/ directory and whether it is an empty template.WARNING — the agent has instructions that depend on a file that doesn't exist. Offer to generate a practical version based on the user's actual config (cron jobs, channels, heartbeat rules in AGENTS.md).WARNING — the file exists but has no real content, so the agent's instructions referencing it are ineffective. Offer to populate it with useful content or remove the dead reference.Add a System Instruction section to Findings:
### [SEVERITY] System Instruction Token Usage
| File | Lines | Chars | ~Tokens | % of Context |
|------|-------|-------|---------|--------------|
| AGENTS.md | N | N | N | N% |
| SOUL.md | N | N | N | N% |
| ... | ... | ... | ... | ... |
| **Total** | **N** | **N** | **N** | **N%** |
- Status: Healthy / Elevated / Needs Optimization
- Suggestions: (specific optimization actions, if any)
Present results as a structured diagnostic report:
# OpenClaw Doctor Report
## Summary
- Version: x.x.x
- Gateway: running/stopped
- Overall Health: HEALTHY / NEEDS ATTENTION / CRITICAL
## Findings
### [SEVERITY] Finding Title
- Description: ...
- Impact: ...
- Fix: (specific command or config change)
(repeat for each finding)
## Quick Stats
| Metric | Value |
|---|---|
| Active sessions | N |
| Cron jobs (enabled/disabled) | N / N |
| Orphan files | N (size) |
| Browser cache | size |
| Total disk usage | size |
## Recommended Actions
1. (prioritized list of suggested fixes)
After presenting the report, ask the user (in their language):
"Would you like me to fix these issues? I can address them one by one, or batch-fix all WARNING-level and below. CRITICAL issues will be confirmed individually."
For fixes:
.bak), clean empty template files, flag tool description injection.When displaying config excerpts in the report, always redact sensitive values:
... (e.g., 8263689670:A...)***REDACTED***This skill operates locally and makes no network requests. However, diagnostic output becomes part of the LLM conversation context.
Files read (read-only unless user approves a fix):
$OPENCLAW_HOME/openclaw.json — main config$OPENCLAW_HOME/agents/main/agent/models.json — model definitions$OPENCLAW_HOME/agents/main/sessions/sessions.json — session index$OPENCLAW_HOME/workspace-*/*.md — system instruction files$OPENCLAW_HOME/cron/jobs.json — cron job definitions$OPENCLAW_HOME/logs/gateway.err.log — recent gateway errors$OPENCLAW_DIST/*.js — installed dist files (for patch detection)Files modified (only with explicit user confirmation):
.md files (BOOTSTRAP.md archival)Environment variables read: OPENCLAW_HOME (optional override).
No secrets are transmitted or logged. The skill may display config excerpts in the diagnostic report shown to the user.