Context Clean Up (audit-only)
This skill identifies what is bloating prompt context and turns it into a safe, reversible plan.
Contract
- - Audit-only by default.
- No automatic deletions.
- No unattended config edits.
- No silent cron/session pruning.
- If you ask for changes, the skill should propose:
1. exact change,
2. expected impact,
3. rollback plan,
4. verification steps.
Safety model
- - No
exec tool usage. - No
read tool usage. - If you want file-level analysis, run the bundled script manually and paste the JSON.
Quick start
- -
/context-clean-up → audit + actionable plan (no changes)
Optional manual report generation:
CODEBLOCK0
Windows variant:
CODEBLOCK1
What to measure (authoritative, not vibes)
When available, prefer fresh-session /context json receipts over subjective claims like “it feels leaner”.
High-signal fields:
- - INLINECODE4
- INLINECODE5
- INLINECODE6
- INLINECODE7
- INLINECODE8
If exact receipts are unavailable, fall back to ranked offenders + change scope, but label confidence lower.
Common offender classes
- 1. Tool result dumps
- oversized
exec output
- large
read output
- long
web_fetch payloads
- 2. Automation transcript noise
- cron jobs that say “OK” every run
- heartbeat messages that are not alert-only
- 3. Bootstrap reinjection bloat
- overgrown
AGENTS.md /
MEMORY.md /
SOUL.md /
USER.md
- long runbooks embedded directly in INLINECODE16
- 4. Ambient specialist surface
- too many always-visible specialist skills that should be on-demand workers/subagents instead
- 5. Summary accretion
- repeated summaries that keep historical detail instead of restart-critical facts only
Recommended trim ladder (lowest-risk first)
Phase 1 — Noise discipline
- - Make no-op automation truly silent (
NO_REPLY or nothing on success). - Keep alerts out-of-band when possible.
Phase 2 — Bootstrap slimming
- - Keep always-injected files short.
- Move long guidance to
references/, memory/, or external notes.
Phase 3 — Ambient surface reduction
- - Remove low-frequency specialist skills from always-on prompt surface.
- Prefer worker/subagent invocation for specialist flows.
Phase 4 — Higher-risk changes
- - Tool-surface or deeper runtime/config narrowing.
- Only propose with stronger rollback and explicit approval.
Workflow (audit → plan)
Step 0 — Determine scope
You need:
- - workspace dir
- state dir (
<OPENCLAW_STATE_DIR>)
Common defaults:
- - macOS/Linux: INLINECODE21
- Windows: INLINECODE22
Step 1 — Run the audit script
CODEBLOCK2
Interpretation cheatsheet:
- - huge tool outputs → transcript bloat
- many cron/system lines → automation bloat
- large bootstrap docs → reinjection bloat
Step 2 — Produce a fix plan
Include:
- - top offenders
- lowest-risk fixes first
- expected impact
- rollback notes
- verification plan
Step 3 — Verify
After changes:
- - confirm automation is silent on success
- check context growth flattens
- if possible, compare fresh-session
/context json before/after
Important caveat
Many OpenClaw runtimes snapshot skills/bootstrap per session.
So skill/config slimming often does not fully apply to the current session.
Use a new session for authoritative verification.
References
- - INLINECODE24
- INLINECODE25
上下文清理(仅审计)
此技能识别导致提示上下文臃肿的内容,并将其转化为安全、可逆的计划。
契约
- - 默认仅审计。
- 不自动删除。
- 不进行无人值守的配置编辑。
- 不进行静默的定时任务/会话修剪。
- 如果你要求更改,该技能应提出:
1. 确切的更改,
2. 预期影响,
3. 回滚计划,
4. 验证步骤。
安全模型
- - 不使用 exec 工具。
- 不使用 read 工具。
- 如需进行文件级分析,请手动运行捆绑脚本并粘贴 JSON。
快速开始
- - /context-clean-up → 审计 + 可操作计划(无更改)
可选的手动报告生成:
text
python3 scripts/contextcleanupaudit.py --out context-cleanup-audit.json
Windows 变体:
text
py -3 scripts/contextcleanupaudit.py --out context-cleanup-audit.json
衡量标准(权威,而非感觉)
在可用时,优先使用新会话 /context json 收据,而非主观说法如“感觉更精简了”。
高信号字段:
- - eligible skills
- skills.promptChars
- projectContextChars
- systemPrompt.chars
- promptTokens
如果无法获得确切的收据,则退而求其次,使用排名靠前的违规项 + 变更范围,但需标注置信度较低。
常见违规类别
- 1. 工具结果转储
- 过大的 exec 输出
- 大量的 read 输出
- 冗长的 web_fetch 负载
- 2. 自动化记录噪音
- 每次运行都说“OK”的定时任务
- 非仅告警的心跳消息
- 3. 引导注入膨胀
- 过度增长的 AGENTS.md / MEMORY.md / SOUL.md / USER.md
- 直接嵌入 SKILL.md 的长运行手册
- 4. 常驻专家表面
- 太多始终可见的专家技能,本应作为按需工作器/子代理
- 5. 摘要累积
- 重复的摘要保留了历史细节,而非仅保留重启关键事实
推荐修剪阶梯(风险最低优先)
阶段 1 — 噪音规范
- - 使无操作自动化真正静默(成功时返回 NO_REPLY 或不返回任何内容)。
- 尽可能将告警置于带外。
阶段 2 — 引导精简
- - 保持始终注入的文件简短。
- 将长指导移至 references/、memory/ 或外部笔记。
阶段 3 — 常驻表面缩减
- - 从始终开启的提示表面中移除低频专家技能。
- 对于专家流程,优先使用工作器/子代理调用。
阶段 4 — 高风险更改
- - 工具表面或更深的运行时/配置缩减。
- 仅在具有更强回滚和明确批准的情况下提出。
工作流程(审计 → 计划)
步骤 0 — 确定范围
你需要:
常见默认值:
- - macOS/Linux:~/.openclaw
- Windows:%USERPROFILE%\.openclaw
步骤 1 — 运行审计脚本
text
python3 scripts/contextcleanupaudit.py --workspace . --state-dir STATEDIR> --out context-cleanup-audit.json
解读速查表:
- - 巨大的工具输出 → 记录臃肿
- 许多定时任务/系统行 → 自动化臃肿
- 大型引导文档 → 注入臃肿
步骤 2 — 生成修复计划
包括:
- - 主要违规项
- 风险最低的修复优先
- 预期影响
- 回滚说明
- 验证计划
步骤 3 — 验证
更改后:
- - 确认自动化在成功时静默
- 检查上下文增长是否趋于平缓
- 如有可能,比较新会话 /context json 的前后差异
重要注意事项
许多 OpenClaw 运行时按会话快照技能/引导。
因此,技能/配置精简通常不会完全应用于当前会话。
请使用新会话进行权威验证。
参考资料
- - references/out-of-band-delivery.md
- references/cron-noise-checklist.md