Install
openclaw skills install prompt-dietAnalyze and optimize OpenClaw system prompt token usage by compressing workspace files (AGENTS.md, SOUL.md, USER.md, TOOLS.md, IDENTITY.md, HEARTBEAT.md, MEMORY.md). Performance-first approach: only safe compressions that preserve agent behavior quality. Use when: (1) system prompt feels bloated or costs are high, (2) user wants to audit token usage of workspace files, (3) MEMORY.md has grown large with stale entries, (4) periodic prompt hygiene check. NOT for: modifying OpenClaw core system instructions, safety rules, or tool definitions.
openclaw skills install prompt-dietAudit → recommend → apply cycle for workspace file token optimization. Run scripts/token_count.py to measure, identify compression opportunities by safety tier, then apply only approved changes with backup.
Files analyzed by this skill (all relative to the workspace root):
| File | Purpose | Typical Size |
|---|---|---|
AGENTS.md | Agent capability declarations | Medium |
SOUL.md | Persona and behavioral directives | Small–Medium |
USER.md | User profile and preferences | Small–Medium |
TOOLS.md | Tool configurations | Medium–Large |
IDENTITY.md | Agent identity/role | Small |
HEARTBEAT.md | Periodic check logic | Small–Medium |
MEMORY.md | Memory index | Grows over time |
| Custom context files | Any user-added workspace .md files | Variable |
Changes that cannot affect agent behavior:
## Section\n\n## Next)--- separators between every item)[TODO: ...], [OPTIONAL], unused scaffolding)Changes that reduce information density:
Changes that could break agent behavior:
/home/aif/.openclaw/workspace/ or current working directory's .openclaw/workspace/).python3 skills/prompt-diet/scripts/token_count.py /home/aif/.openclaw/workspace/ --detail
For each file with compression opportunities, produce a recommendation table:
File: MEMORY.md (847 tokens, 34% of total)
┌─────────────────────────────────────────────────┬────────┬──────────┐
│ Opportunity │ Tier │ Savings │
├─────────────────────────────────────────────────┼────────┼──────────┤
│ 3 entries reference completed 2026-03 project │ 🟡 │ ~120 tok │
│ 2 near-duplicate feedback entries │ 🟡 │ ~60 tok │
│ 4 blank lines between entries │ 🟢 │ ~4 tok │
└─────────────────────────────────────────────────┴────────┴──────────┘
Ask the user: "Apply 🟢 safe changes automatically? Show me which 🟡 review items to approve?"
Do not apply any changes without explicit user confirmation.
Only after user approval:
Create backup before any edits:
<filename>.pre-diet (e.g., MEMORY.md.pre-diet)prompt-diet-backup/ directory with timestampApply changes using Edit tool, one file at a time.
Show diff summary: lines removed, tokens saved per file.
Report before/after:
Before: 2,481 tokens across 7 files
After: 1,934 tokens across 7 files
Saved: 547 tokens (22%)
Offer to clean up backup files after user confirms the result looks good.
MEMORY.md grows continuously and is the highest-yield target. Check for:
memory/ daily log files (cross-reference).For each candidate removal, show the full entry text and ask: "Archive to daily log, merge, or keep?"
Never silently remove MEMORY.md entries — always show the user what will be deleted.
This skill does NOT auto-register a cron job. To set up periodic audits yourself:
Weekly audit cron (example):
# Add via: /schedule OR CronCreate tool
# Schedule: 0 9 * * 1 (every Monday 9am)
# Command: /prompt-diet audit-only
HEARTBEAT.md addition template (copy-paste into your HEARTBEAT.md):
## Prompt Diet Check (Weekly)
- Run token audit on workspace files
- Flag if any file has grown >20% since last check
- Remind user if MEMORY.md exceeds 200 lines
Manual one-off audit:
python3 /home/aif/.openclaw/workspace/skills/prompt-diet/scripts/token_count.py \
/home/aif/.openclaw/workspace/ --format json | python3 -m json.tool
This skill does not touch:
Token counts are estimates (tiktoken cl100k_base encoding approximates Claude tokenization; actual Claude token counts may differ by ±5–10%).
token_count.py — Standalone token counter. Works with or without tiktoken installed.compression-rules.md — Detailed per-file compression rules and examples.