clawdoc
Diagnose OpenClaw agent failures, cost spikes, and performance issues with 14 pattern detectors. Use when: task failed unexpectedly, costs seem high, agent burned tokens, debugging session problems, want a health check, reviewing agent performance, agent forgot context, agent kept retrying, agent said commands but didn't execute them, cron jobs getting expensive, heartbeat costs too high, agent drifted off task after compaction, agent stuck reading without editing, agent running find/grep on entire filesystem, agent re-reading same file repeatedly.
Install via CLI (Recommended)
clawhub install openclaw/skills/skills/ashishjaingithub/clawdocclawdoc
Examine agent sessions. Diagnose failures. Prescribe fixes.
Invocation modes
/clawdoc (slash command ā default: headline mode)
Produces a compact, tweetable health check:
š©» clawdoc ā 3 findings across 12 sessions (last 7 days)
šø $47.20 spent ā $31.60 was waste (67% recoverable)
š“ Retry loop on exec burned $18.40 in one session
š” Opus running 34 heartbeats ($8.20 ā $0.12 on Haiku)
š” SOUL.md is 9,200 tokens ā 14% of your context window
Run: bash {baseDir}/scripts/headline.sh ~/.openclaw/agents/main/sessions
/clawdoc full or "give me a full diagnosis"
Runs all 14 pattern detectors and produces the complete diagnosis report with evidence and prescriptions.
/clawdoc brief or "clawdoc one-liner for daily brief"
Single-line summary for morning cron integration:
Yesterday: 8 sessions, $3.40, 1 warning (cron context growth on daily-report)
Run: bash {baseDir}/scripts/headline.sh --brief ~/.openclaw/agents/main/sessions
Natural language triggers
Also activates when user says: "what went wrong", "why did that fail", "debug", "diagnose", "why was that so expensive", "where are my tokens going", "cost breakdown", "health check", "check my agent", "what's wrong", "examine"
Quick examination ā most recent session
Find the most recent session file and run:
bash {baseDir}/scripts/examine.sh <session.jsonl>
This outputs a JSON summary with turns, cost, token counts, tool call frequency, and error count.
Single-session diagnosis
Run all 14 pattern detectors against a specific session file:
bash {baseDir}/scripts/diagnose.sh <session.jsonl> | jq .
Diagnosis with prescriptions
Pipe diagnose output into prescribe for a formatted report with fix recommendations:
bash {baseDir}/scripts/diagnose.sh <session.jsonl> | bash {baseDir}/scripts/prescribe.sh
Cost breakdown
Show per-turn cost waterfall for a session:
bash {baseDir}/scripts/cost-waterfall.sh <session.jsonl> | jq '.[0:5]'
Cross-session pattern recurrence
Analyze pattern recurrence across multiple sessions in a directory:
bash {baseDir}/scripts/history.sh <sessions-dir> | jq .
Full diagnosis
When the user wants a comprehensive diagnosis, run the scripts above and synthesize findings into this report format:
Diagnosis report format
## š©» Diagnosis ā [date]
### Patient summary
- Sessions examined: N
- Period: [date range]
- Total spend: $X.XX
- Total tokens: XXk in / XXk out
### Findings
#### š“ Critical
[Infinite retry loops, context exhaustion, tool-as-text failures]
Each finding includes: what happened, evidence, estimated cost impact, and specific prescription.
#### š” Warning
[Cost spikes, model routing waste, cron accumulation, compaction damage, workspace overhead]
#### š¢ Healthy
[What's working well ā efficient sessions, good model routing]
Metadata
Not sure this is the right skill?
Describe what you want to build ā we'll match you to the best skill from 16,000+ options.
Find the right skillPaste this into your clawhub.json to enable this plugin.
{
"plugins": {
"official-ashishjaingithub-clawdoc": {
"enabled": true,
"auto_update": true
}
}
}