When to use this skill
Use this skill when the user wants to:
- - Understand where their context window tokens are going
- Analyze workspace files (SKILL.md, SOUL.md, MEMORY.md, etc.) for bloat
- Audit tool definitions for redundancy and overhead
- Get a comprehensive context efficiency report
- Compare before/after snapshots to measure optimization progress
- Optimize system prompts for token efficiency
Commands
CODEBLOCK0
What It Analyzes
- - System prompt efficiency — Length, redundancy detection, compression potential
- Tool definition overhead — Count tools, per-tool token cost, identify unused/overlapping
- Memory file bloat — MEMORY.md size, stale entries, optimization suggestions
- Skill overhead — Installed skills contributing to context, per-skill token cost
- Context budget — What % of model context window is consumed by static content vs available for conversation
Options
- -
--workspace PATH — Path to workspace directory (default: ~/.openclaw/workspace) - INLINECODE2 — Path to OpenClaw config file (default:
~/.openclaw/openclaw.json) - INLINECODE4 — Context window token budget (default: 200000)
- INLINECODE5 — Save analysis snapshot to FILE for later comparison
- INLINECODE6 — Output format (currently: terminal)
Notes
- - Token estimates are approximate (~4 characters per token). For precise counts, use a model-specific tokenizer.
- No external dependencies required — runs with Python 3 stdlib only.
- Built by Anvil AI — context engineering experts. https://anvil-ai.io
何时使用该技能
当用户希望以下操作时,可使用此技能:
- - 了解上下文窗口的令牌流向
- 分析工作区文件(SKILL.md、SOUL.md、MEMORY.md 等)是否存在冗余
- 审计工具定义中的重复和开销
- 获取全面的上下文效率报告
- 对比优化前后的快照以衡量优化进展
- 优化系统提示词的令牌效率
命令
bash
分析工作区上下文文件——令牌数量、效率评分、优化建议
python3 skills/context-engineer/context.py analyze --workspace ~/.openclaw/workspace
使用自定义预算进行分析,并保存快照供后续对比
python3 skills/context-engineer/context.py analyze --workspace ~/.openclaw/workspace --budget 128000 --snapshot before.json
审计工具定义中的开销和重叠
python3 skills/context-engineer/context.py audit-tools --config ~/.openclaw/openclaw.json
生成全面的上下文工程报告
python3 skills/context-engineer/context.py report --workspace ~/.openclaw/workspace --format terminal
对比两个快照以查看预计节省的令牌数
python3 skills/context-engineer/context.py compare --before before.json --after after.json
分析内容
- - 系统提示词效率 — 长度、冗余检测、压缩潜力
- 工具定义开销 — 工具数量、每个工具的令牌成本、识别未使用/重叠的工具
- 记忆文件冗余 — MEMORY.md 大小、过期条目、优化建议
- 技能开销 — 已安装技能对上下文的贡献、每个技能的令牌成本
- 上下文预算 — 静态内容占模型上下文窗口的百分比,以及可用于对话的百分比
选项
- - --workspace PATH — 工作区目录路径(默认:~/.openclaw/workspace)
- --config PATH — OpenClaw 配置文件路径(默认:~/.openclaw/openclaw.json)
- --budget N — 上下文窗口令牌预算(默认:200000)
- --snapshot FILE — 将分析快照保存至 FILE 供后续对比
- --format terminal — 输出格式(当前仅支持:terminal)
备注
- - 令牌估算为近似值(约每令牌4个字符)。如需精确计数,请使用模型专用分词器。
- 无需外部依赖——仅使用 Python 3 标准库即可运行。
- 由 Anvil AI(上下文工程专家)构建。https://anvil-ai.io