I think the starting point using AI for most people is a chat-like conversation in natural language. This is called prompting. It works well for simple tasks, but it is not a very efficient way of working when tasks grow in complexity, because the model needs more information to produce the desired output. Context engineering picks up where prompting stops.
What is context?
Context is a way to provide the model with additional information besides a prompt. This can include information about the task, the desired output, and any constraints or requirements that should be followed. But it is a balancing act. If you provide too little context, the model may not have enough information to produce the desired output. If you provide too much context, the model may become overwhelmed and produce less accurate results.
Also, context is not free. The more context you provide, the more tokens are used which can increase cost. So think about what you put in the context. Let’s look at the different types of context.
Types of context
I see context being categorized into two types: static and dynamic. Static context is loaded on every session. Token cost is high, but because it is always there it is reliable, so only put things in it that are truly global and applicable to all tasks. Dynamic context is loaded when needed for a specific task. This makes it more cost efficient, as it only costs when used.
Context types compared
| Static Context | Dynamic Context |
|---|---|
| System instructions | Skill bodies |
| Instruction files (AGENTS.md) | Tool results (from execution) |
| Global memory | Retrieved documents (RAG) |
| Core guardrails | |
| MCP tool definitions | |
| Skill metadata |
Skills sit on both sides of that table, which is the point of them. See Instructions, Skills, Hooks, and MCP for what a skill is.
For practical guidance on writing prompts, instructions, and skills, see Guidelines for writing.
Context efficiency
To optimize the context I have found several suggestions and tools online. Although I have not tried all of them yet, I will list the ones I found interesting and will probably try to integrate in my workflow. I will come back to this in the future when I have tried them and can give my experience with them.
Suggestions for optimizing context
Think in code
Prefer creating scripts when possible. For example when analyzing files don’t let the AI read every file (that will all end up in context), instead write a script that reads the files (then only the script is in context).
Always determine if an MCP tool or a CLI command is more efficient for the specific task.
Visualize the context
Try to understand what is in the context. If the tools in the IDE or app are not clear enough to give insights, you can ask the model output in a more visual way. For example, ask the model: “Show me context usage as a battery indicator.”
Shorten the context
When context becomes too large, research shows that the model might forget parts of the conversation. You can shorten the context by summarizing it. When running
/compact, do not let the model guess. Command it to “lose all debug info” or “summarize current state to a .md file for future reference.”Be concise and clear
Be concise and strip context of more wording than needed (for instance, cut on courtesy like “Please”, “Thank you”, etc.). Avoid being vague, but be explicit about the scope, goal and output format. For instance tell it “When reporting information, be extremely concise” or provide a template of the desired output.
Monitor efficiency
To keep improving efficiency, you can use the results of the session. Examples are:
- Capture learnings: “Now that we fixed the issue, capture the learnings from this conversation to avoid mistakes in the future.”
- With Copilot use
/chronicleto evaluate the agent session history to identify improvements. - Hooks can be used to log through bash commands on
PreToolUseto collect traces and run evaluations. - You can even make a skill to look through agent sessions (like Anthropic’s
/insights) to improve skills or find other gaps.
This can help improve skills and instructions, or even justify creating a new skill for a recurring specific task.
Make use of tools
There are several tools available to help optimize context. See the table below for a list of tools and their use cases.
Tool Layer What it reduces Best for RTK CLI output Command output → model input Coding agents, devops loops, CI logs context-mode MCP MCP server output Heavy MCP workflows Caveman Conversation Model replies Chat-heavy workflows Ponytail Codebase Extra code, abstractions Large repos, architecture-heavy work copilot-codeact-plugin Commands Execution cycles Toolcalls cates-analyzer Conversation Input tokens Skills/instructions/prompts