Context engineering is the practice of deciding what information an AI model gets to see when it works on a task. A model only knows what is in its training and what is in its context window right now, so the result depends on what you put there: the instructions, the relevant files, earlier messages, tool results and examples. Context engineering means including what the task needs, leaving out what distracts, and ordering it sensibly. It is a broader idea than prompt writing, because most of the context in an agent session comes from files and tools, not from the words you type.
Why Does Context Engineering Matter?
Models do worse when the context is crowded with irrelevant material, and they cannot use facts that never made it in. For coding agents, the biggest levers are a concise instructions file, pointing the agent at the right files, and keeping long tool output out of the main conversation. Good context engineering usually saves money too, because every token in the context is paid for on every turn.
What Does Context Engineering Look Like in Practice?
Instead of pasting a whole 3,000-line log into a chat, you paste the 20 lines around the error and the function that threw it. In a repository, you keep the AGENTS.md file short and specific, and put rare details in separate documents the agent reads only when needed. The 2prompt linter flags files that are getting too long to load every session.
What Do People Get Wrong About Context Engineering?
Bigger context windows do not make context engineering unnecessary. A model with room for a million tokens still pays attention unevenly and still costs more per token read. Relevant and short beats complete and long.
Which Terms Are Related?
Context window: The maximum amount of text, measured in tokens, that a model can take into account in a single request.
System prompt: The standing instructions an application gives a model before the conversation, setting its role, rules and format.
RAG (retrieval-augmented generation): Looking up relevant documents first and giving them to the model, so its answer is grounded in real sources.
Agent instructions file: A Markdown file in your repository that tells coding agents your commands, conventions and rules.
Prompt caching: Reusing the already processed start of a prompt across requests so repeated context is cheaper and faster.
Is context engineering just prompt engineering with a new name?
Partly, but it is broader. Prompt engineering focuses on the wording of instructions. Context engineering covers everything the model sees, including files, retrieved documents, tool results and conversation history, which is most of the input in agent work.
How do I know what context a coding agent is using?
Many agents show loaded instruction files and let you inspect or clear the conversation. Check your agent documentation for commands that list memory files or show context usage, and keep instruction files short so they are easy to audit.
Does adding more examples always help?
Not always. A few well-chosen examples can help a lot, but many similar examples waste tokens and can make the model copy them too literally. Pick examples that show the edge cases you care about.