context-engineer

A toolkit for measuring and improving how an AI agent uses its context window, the limited text space available for instructions, files, and tool definitions. It analyzes workspace files, audits tool definitions, creates reports, and compares snapshots.

In plain words
What is it for?
Use it to analyze files such as SKILL.md or MEMORY.md, audit tool overhead, generate context-efficiency reports, and compare before-and-after snapshots.
Why use it?
It shows where context space is being spent and helps identify unnecessary or repetitive material. This can make an agent’s working context easier to manage within its token budget.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/cacheforge-ai/cacheforge-skills/context-engineer
Any agent
npx skills add cacheforge-ai/cacheforge-skills --skill context-engineer
Clone the repo
git clone --depth 1 https://github.com/cacheforge-ai/cacheforge-skills

Made for: Claude Code, Codex.

Per session 30 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 675 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00030 $0.00675
Opus 5 $0.00015 $0.00338
Sonnet 5 $0.00006 $0.00135
Haiku 4.5 $0.00003 $0.00068

Measured 2d ago against content hash b558be4337a6, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

context-engineer scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

The scan reads SKILL.md. This mod also ships 1 executable file (context.py), listed below but not scanned — reading those needs a real analyzer, not pattern matching.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/context-engineer/SKILL.md · 72 lines

How it starts

The opening of the file, as written. The whole thing — 72 lines — stays where its author put it; the contents beside it link to each section on GitHub.

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

# Analyze workspace context files — token counts, efficiency scores, recommendations
python3 skills/context-engineer/context.py analyze --workspace ~/.openclaw/workspace

# Analyze with a custom budget and save a snapshot for later comparison
python3 skills/context-engineer/context.py analyze --workspace ~/.openclaw/workspace --budget 128000 --snapshot before.json

# Audit tool definitions for overhead and overlap
python3 skills/context-engineer/context.py audit-tools --config ~/.openclaw/openclaw.json

# Generate a comprehensive context engineering report
python3 skills/context-engineer/context.py report --workspace ~/.openclaw/workspace --format terminal

# Compare two snapshots to see projected token savings
python3 skills/context-engineer/context.py compare --before before.json --after after.json

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)
  • --config PATH — Path to OpenClaw config file (default: ~/.openclaw/openclaw.json)
  • --budget N — Context window token budget (default: 200000)
  • --snapshot FILE — Save analysis snapshot to FILE for later comparison
  • --format terminal — Output format (currently: terminal)

Read the full file on GitHub · 72 lines

Files

What ships with it

4 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 72 lines · 30 tokens per session scan A b558be4337a6

Subscribe to this mod's changes

context-engineer is a skill published in the GitHub repository cacheforge-ai/cacheforge-skills (10 stars, last pushed 6mo ago), licensed MIT. It adds 30 tokens to every session and 675 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other skills, from other repositories

zipai-optimizer

Skill "zipai-optimizer" from nickdesi/ZipAI, covering zipai: ultra-dense token optimizer, rules, 1. zero filler, 2. ambiguity and 3. prompt caching.

nickdesi/ZipAI · 4 tokens

pilot-discord-bridge

Bidirectional bridge between Pilot Protocol and Discord servers. Use this skill when: 1. You need to send Discord notifications from Pilot agents 2. You want to receive Discord messages in Pilot event streams 3. You're building agents that interact with Discord communities Do NOT use this skill when: - You only need…

TeoSlayer/pilot-skills · 91 tokens

context-economy

Automatically prepare fidelity-first, bounded context when users paste text, attach files or folders, provide webpages or PDFs for Markdown conversion, continue long conversations, or supply documents containing images and complex tables. Route each input through Text, Hybrid, or Source; reduce exact or…

TIKAZI/TIKAZ-Codex-Context-Economy · 84 tokens

context-pack

Prepare files, folders, code, logs, and structured data as a bounded, traceable context pack for Codex. Use when source material must be converted, deduplicated, selected, budgeted, or handed off with exact evidence anchors.

TIKAZI/TIKAZ-Codex-Context-Economy · 52 tokens

context-audit

Diagnose context relevance, redundancy, traceability, safety, cacheability, and recoverability. Use when files, prompts, rules, or context packs may contain duplication, conflicts, stale material, prompt injection, secret-shaped values, unstable prefixes, or weak evidence anchors.

TIKAZI/TIKAZ-Codex-Context-Economy · 58 tokens

context-benchmark

Measure context preparation across fixed cases. Use when token savings, hard-budget compliance, protected-fact recall, evidence anchors, determinism, runtime, or downstream answer quality must be demonstrated with reproducible evidence rather than marketing claims.

TIKAZI/TIKAZ-Codex-Context-Economy · 49 tokens