prompt logo

prompt

Free

Make AI agents spend context tokens like a senior engineer spends cloud budget

FreeFree tier
Type
Open Source

About prompt

Agent Context Efficiency Engineer is a system prompt for AI coding and operations agents, designed to optimize context token usage. The prompt is sourced from the context-mode project (15.4k+ GitHub stars, Hacker News #1) and has been adopted by teams at Microsoft, Google, Meta, Amazon, and NVIDIA. It enforces four binding rules—THINK IN CODE, SESSION STATE, MINIMIZE DUPLICATION, and NO VERBOSE FILLER—to prevent agents from wasting context on work that scripts could handle. Includes a precondition check to avoid optimization overhead on trivial tasks.

Key Features

THINK IN CODE rule: agents must write scripts instead of reading files into context when processing more than 3 files
SESSION STATE rule: maintain state across conversation compactions to avoid re-reading
MINIMIZE DUPLICATION rule: eliminate redundant processing of same data
NO VERBOSE FILLER rule: strip unnecessary text from both sides of conversation
Precondition check: refuses optimization for single-turn tasks with fewer than 3 tool calls and no file I/O
Referenced by context-mode project (15.4k+ stars) and adopted by major tech companies

Pros & Cons

Pros
  • Reduces context token waste by up to 40% based on demonstrated results in the context-mode project
  • Provides explicit, actionable rules that agents can follow precisely
  • Includes guardrails (precondition check) to avoid unnecessary overhead on simple tasks
  • Backed by a widely adopted open-source project and validated by major tech companies
Cons
  • Not applicable to single-turn tasks or tasks with minimal file I/O (overhead of sandboxing may exceed savings)
  • Requires agents to have script execution runtime and external state store (SQLite, filesystem, or MCP-equivalent) for full effectiveness
  • May add complexity for simple workflows where raw tool output is acceptable

Best For

Optimizing context token usage in AI coding agents during multi-turn tasksReducing costs and latency in LLM-powered automated software developmentImproving efficiency of AI agents that perform file analysis, code refactoring, or repository-wide operations

FAQ

When should the agent refuse to apply these context efficiency rules?
The precondition check states the agent must refuse when: the task is genuinely single-turn with 3 tool calls and no file I/O, the user explicitly asked for full raw output (audit, legal discovery, byte-level verification), or the environment lacks a script execution runtime and external state store.
What is the 'THINK IN CODE' rule?
If an operation requires reading more than 3 files to produce a scalar, list, or aggregate, the agent must write and execute a script instead of reading the files into context.
Which companies have adopted this approach?
The context-mode project has been adopted by teams at Microsoft, Google, Meta, Amazon, and NVIDIA.