What is context engineering?
Context engineering is choosing what goes into an AI model’s context window at each step: instructions, files, tool results, history and notes.
Updated
Context engineering is the practice of choosing what goes into an AI model’s context window at each step: the instructions, files, tool results, history and notes it sees. For a coding agent, that means CLAUDE.md or AGENTS.md, which files it reads, what gets summarized or cleared, and what a subagent keeps out of the main session.
People also say “context management” for the same work. Prompt engineering is the older, narrower part of it: writing the one message you send.
As of November 2026, from Anthropic’s Effective context engineering for AI agents, LangChain’s The rise of “context engineering” and the Prompt Engineering Guide. The term is still settling, so those sources win if this page disagrees.
Good context keeps an agent on track, but it still stops to ask before it runs a command. Coral puts every agent waiting on you in your Mac’s notch, so you answer with one key. Download Coral for free
Where the term came from
June 2025: a new name for the real work. Builders started saying that most of the work in an agent wasn’t the prompt but everything around it. LangChain’s post of June 23, 2025, The rise of “context engineering”, built its definition on recent posts by Shopify’s Tobi Lütke, Ankur Goyal and Cognition’s Walden Yan: “building dynamic systems to provide the right information and tools in the right format such that the LLM can plausibly accomplish the task.” Andrej Karpathy’s post that month called it an “art and science”, the phrase Anthropic later linked.
September 2025: Anthropic writes it down for agents. Anthropic’s engineering post of September 29, 2025 defines it as “the set of strategies for curating and maintaining the optimal set of tokens (information) during LLM inference”. It explains why it matters with context rot: “as the number of tokens in the context window increases, the model’s ability to accurately recall information from that context decreases.” So context is “a finite resource with diminishing marginal returns”, and every token spends part of the model’s “attention budget”.
The Prompt Engineering Guide puts the two terms side by side: prompt engineering tunes the instructions, and context engineering also covers retrieval, tool definitions, memory and state.
What it looks like in practice
In a coding agent, context engineering is mostly a set of habits and files. Anthropic’s post names the long-task techniques; the agents expose them as commands.
| Lever | What it does | In Claude Code / Codex |
|---|---|---|
| An instructions file | Loads the project’s rules and commands at the start of every session | CLAUDE.md (Claude Code also reads AGENTS.md when there’s no CLAUDE.md), AGENTS.md for Codex |
| Just-in-time reads | Keeps file paths and queries, and loads data only when needed | Claude Code “can write targeted queries, store results, and leverage Bash commands like head and tail” instead of loading whole files (Anthropic) |
| Look at what’s loaded | Shows what fills the window | /context in Claude Code (usage limits guide) |
| Compaction | Summarizes the history so the session can continue | In Claude Code, “passing the message history to the model to summarize and compress the most critical details” (Anthropic); PreCompact hooks in both agents (Claude Code hooks, Codex hooks) |
| Structured notes | The agent writes progress to a file outside the window | A to-do list, or a NOTES.md the agent keeps up to date |
| Subagents | A helper explores in its own window and returns only a summary | Subagents “often 1,000-2,000 tokens” back (Anthropic); see Codex subagents |
| Clear between tasks | Starts the next task without the last one’s leftovers | /clear in Claude Code |
A short instructions file is part of it too: one of the fixes Claude Code’s /usage screen can apply is trimming a long CLAUDE.md (usage limits guide), since that file loads into every session.
A well-fed agent still waits for you at every prompt. Coral shows the moment one needs you in your Mac’s notch. Get Coral, free
Context engineering vs prompt engineering, RAG and harness engineering
| Term | What it shapes | When it happens |
|---|---|---|
| Prompt engineering | The words of one request or system prompt | Once, before you send it |
| Context engineering | Everything in the window: instructions, files, tool results, history, notes | At every step of the agent loop (Anthropic) |
| RAG (retrieval-augmented generation) | The documents pulled in to answer a question | When a question needs outside knowledge; one technique inside context engineering (IBM) |
| Harness engineering | The environment around the agent: tools, tests, docs and checks it can run | When you build the setup the agent works in |
Anthropic’s line: in contrast to “the discrete task of writing a prompt, context engineering is iterative and the curation phase happens each time we decide what to pass to the model.” Harness engineering is the next layer out: context engineering decides what the coding agent sees, the harness decides what it can do and check.
A worked example: a refactor that outgrows one session
You ask Claude Code to move a codebase from one date library to another. It touches 80 files, more than one session holds well. The context-engineering way to run it:
- Keep
CLAUDE.mdshort. The test command, the lint command and one line on the new library’s conventions. Nothing agrepcan find. - Search with a subagent. “Use a subagent to list every file that imports the old library, grouped by folder.” The search runs in the subagent’s window; the main session gets only the list.
- Work in batches with a notes file. Ask Claude to keep
MIGRATION.md: done folders, decisions (“keep UTC everywhere”), open questions. That’s Anthropic’s structured note-taking. - Check the window. Run
/contextbetween batches. When old tool output is most of it, that’s your cue. - Start fresh from the notes.
/clear, then “ReadMIGRATION.mdand continue with the next folder.” The new session starts with the decisions and none of the noise.
Compaction (/compact) would also continue the session, but it’s a summary the model writes. The notes file is one you can read and correct. Kept across projects, not just for one task, the same habit is what people now call an AI second brain.
Where it stops
Context engineering decides what the agent knows. It doesn’t decide what the agent may do or when it needs you:
- The prompts stay. A perfectly fed agent still stops before an edit or a command your permission settings don’t allow. Better context can mean fewer wrong turns, not fewer approvals.
- Long tasks still need a handover. Compaction and notes stretch a session, but at some point a fresh session with a good note beats a stuffed window. Writing that note well, every time, is work.
- It’s per agent. Run several agents at once and each has its own window to manage, and its own moment to ask you something.
Where Coral fits
Coral doesn’t manage what’s in your agent’s context window. It helps in three places:
- Instructions files. The free CLAUDE.md builder and AGENTS.md builder write the file every session loads.
- Hand off. When a session has grown too long, select the agent in Coral and press ⇧H. The agent writes a short note (a title, then done, decisions, open issues, next step); you check it, pick Claude Code, Codex or OpenCode, and the new session starts in the same terminal and folder with the note as its first message. It also gets the old conversation as a file it can search. Free on your Mac; on your iPhone it’s Pro (features).
- The prompts that remain. Every Claude Code, Codex, Copilot CLI, OpenCode and Grok session that stops for a permission, a question or a plan shows up in your Mac’s notch. Press 1, 2 or 3 to answer.
Questions
What is context engineering in simple terms?
Deciding what an AI model sees at each step. For a coding agent: which instructions it loads, which files and tool results it reads, what old history gets summarized or cleared, and what a helper agent sums up instead of passing along in full.
What is the difference between prompt engineering and context engineering?
Prompt engineering writes one request. Context engineering manages everything in the model’s window, at every step: instructions, files, tool output, history and notes. Anthropic calls prompt writing a discrete task and context engineering an iterative one.
Who coined the term context engineering?
No single person. It spread in June 2025: LangChain’s post of June 23 built on posts by Tobi Lütke, Ankur Goyal and Walden Yan, and Andrej Karpathy called it an “art and science”. Anthropic’s September 2025 post defined it for agents.
What is context rot?
Anthropic’s name for a model recalling information less accurately as its context window fills up. It’s why a long agent session gets worse, and why compaction, notes, subagents and fresh sessions help.
How do I do context engineering in Claude Code?
Keep CLAUDE.md short, let subagents do broad searches, check /context, keep a notes file for long tasks, and use /clear or /compact when the window is mostly old output. Hooks on SessionStart can add context back after a compaction.