The short answer
Context engineering is deciding what a language model gets to see at each step. Not just your question, but everything in the context window: the instructions, the files it has read, the tools it can call, the results of earlier steps and whatever it remembers from previous work.
A model knows nothing outside that window. What isn’t in it doesn’t exist for the model. What is in it but isn’t relevant pulls its attention away. Context engineering is the craft of making that selection.
The term caught on in mid-2025, when Shopify CEO Tobi Lütke and AI researcher Andrej Karpathy, among others, used it as a better name for what prompt engineering had turned into in practice. It has since become the usual name for designing what an AI agent sees.
Why your prompt is no longer the main character
With a chatbot you ask one question and get one answer. The prompt is almost the entire context, so it pays to word it well. That’s what prompt engineering is about.
A coding agent like Claude Code or Codex works differently. It takes dozens of steps in a row: searching files, reading them, editing, running tests, reading errors, trying again. Every step adds text to the context window. Half an hour in, your original instruction is a small part of what the model sees.
Two things then go wrong:
The window fills up
Even a window of hundreds of thousands of tokens fills up on a large codebase. Something has to go, and when the agent drops things blindly, sometimes the one line that mattered goes with it.
More context doesn't make the model smarter
The more the window holds, the worse a model gets at finding the right details. Researchers call this context rot: old error messages, abandoned approaches and irrelevant files pull attention away from what counts now.
Context engineering tackles both. The goal isn’t as much context as possible, but the smallest set of information that lets the model take the next step well.
What sits in the context window
To design context, you need to know what it’s made of. For a coding agent there are roughly six layers.
System instructions
The tool's own fixed instructions: who the agent is, how it uses tools, what it may not do. As a user you have little say over these.
Project instructions
A file in your repo, such as CLAUDE.md or AGENTS.md, that loads into every session. It holds your conventions, your architecture and the commands to build and test.
The task and the conversation
What you ask and everything that goes back and forth after that. This grows fastest and gets cluttered first.
Files read and tool output
The code the agent opened, the output of tests and commands, search results. Often the largest part of the window.
Tools and their descriptions
Every available tool, MCP ones included, takes up space with its description. Twenty integrations you don't use are twenty sources of noise.
Retrieved knowledge and memory
Documentation pulled in through search or RAG, notes from earlier sessions, a summary of what's already done.
Only the first layer is fixed. You can steer the other five, and that’s where the work is. How tools come in through MCP and how knowledge gets retrieved with RAG each have their own explainer.
Four techniques that work in practice
Most approaches come down to four moves. Good agents do some of them on their own, but if you know them you can use them on purpose.
Select: only what's needed
Let the agent search and read selectively instead of loading whole folders. Keep the instructions file short and point to separate documents for detail. Switch off MCP integrations this task doesn't need.
Summarize: boil down old work
When a session runs long, summarize what was decided and done, then start clean. Claude Code does this with compaction. A fresh session with a good summary often beats a full session that keeps going.
Write down: memory outside the window
A plan, a task list or notes in a file survive every summary. The agent reads them back when it needs to, instead of holding everything in its head.
Isolate: hand off subtasks
A subagent investigates something in its own clean window and hands back only the conclusion. That way a search through a hundred files doesn't clutter your main session.
Prompt engineering, context engineering and harness engineering
The three terms often get mixed up. They describe layers that fit inside each other.
| Prompt engineering | Context engineering | Harness engineering | |
|---|---|---|---|
| What it's about | Wording one instruction well | Everything the model sees at each step | The whole environment around the agent |
| Unit | One question | One step in a session | Every session in a project |
| Typical work | Role, examples, desired format | Select, summarize, write down, isolate | Tests, checks, permissions, feedback loops |
| When it counts | One-off questions to a chatbot | Agents that work on their own for a long time | Teams that use agents every day |
Prompt engineering is part of context engineering: your prompt is one of the things in the window. Context engineering in turn is part of harness engineering, which also handles what happens when the agent gets something wrong. What a harness is exactly, you can read in what is an AI harness.
How a senior team approaches context engineering
Every client repo we work in runs with coding agents. What we’ve learned about context along the way comes down to a few fixed habits.
A short, honest instructions file
The instructions file in the repo describes how the project really works: which commands, which conventions, which pitfalls. Not a wish list. Whatever is wrong gets deleted, because an agent follows it to the letter.
Small tasks, fresh sessions
One task per session. An agent that fixes a bug, builds a feature and refactors at the same time drags the context of all three into every step.
The plan in writing
For bigger work the agent first writes a plan to a file. That plan becomes the task's memory, and a person reads it before any code gets written.
Tests as context
A failing test tells an agent exactly what's wrong, in a few lines. That's better context than an explanation in prose, and it works again in every session.
A model can only work with what’s on its workbench. Context engineering is clearing it before you start.
When you can worry about it less
Not every AI task needs this work. For a one-off question to ChatGPT, rewriting a text or explaining a function, the context is small and easy to oversee. A clear question is enough.
A short script of a few hundred lines doesn’t need much design either: the agent reads it all in one go and the window never fills up. Context engineering starts to pay off once an agent works on its own for longer, in a codebase bigger than one window can hold, or in a team where several people point the same agent at the same project.
Conclusion: context is the new programming work
AI agents shift what a developer does. Less typing yourself, more deciding what the agent knows at the moment it makes a call. That isn’t a trick for better prompts but design work: what must always be known, what do you fetch when it’s needed, and what do you clear away.
What it is
Deciding what a language model sees at each step: instructions, files, tools, earlier results and memory. As little as possible, as much as needed.
Why it matters
Agents work for a long time and read a lot. Without deliberate choices the window fills with noise, and the model wanders off or forgets what mattered.
What is context engineering, in short?
What's the difference between prompt engineering and context engineering?
What is a context window?
Isn't a bigger context window simply the answer?
What do CLAUDE.md and AGENTS.md have to do with context engineering?
How do RAG and MCP relate to context engineering?
Build faster with AI without lowering the bar?
Our senior developers work with coding agents every day. Bring them onto your project, or have your team learn to use them well in a workshop.