Skip to main content
CONTEXT ENGINEERING

What is context engineering? And the business context your coding agent is missing

Updated · By Adam Polak, founder

Context engineering is deciding what an AI model or agent has in its context window at each step: instructions, tools, retrieved data, memory and history. It includes prompt engineering and extends it to agents, which work over many steps. For a coding agent the code is easy to retrieve, but the business rules behind it (thresholds, exceptions, who decides) often aren't written down: write them by hand into specs and docs, or capture them from the people who know with a tool like RuleFoundry, which serves them to the agent through MCP.

What context engineering means, from the posts that named it

Anthropic's engineering team, September 29, 2025: “Context engineering refers to the set of strategies for curating and maintaining the optimal set of tokens (information) during LLM inference, including all the other information that may land there outside of the prompts.”

  • Tobi Lütke, Shopify's CEO, on X, June 2025: “I really like the term ‘context engineering’ over prompt engineering. It describes the core skill better: the art of providing all the context for the task to be plausibly solvable by the LLM.”
  • Andrej Karpathy, on X, June 25, 2025: In every industrial-strength LLM app, context engineering is “the delicate art and science of filling the context window with just the right information for the next step.”
  • LangChain's Harrison Chase, June 23, 2025: “Context engineering is building dynamic systems to provide the right information and tools in the right format such that the LLM can plausibly accomplish the task.”

Sources, read on 2026-11-30: Anthropic, Effective context engineering for AI agents; LangChain, The rise of “context engineering” and Context Engineering; Cognition, Don't Build Multi-Agents; Lütke's post and Karpathy's post.

Context engineering vs prompt engineering

Anthropic calls context engineering “the natural progression of prompt engineering”; Harrison Chase calls prompt engineering “a subset of context engineering.”

Prompt engineeringContext engineering
The questionHow do I word this prompt?What should the model have in its window at this step?
What it shapesThe instructions and examples in one promptEverything in the window: instructions, tools, retrieved data, memory and history
When it happensOnce, when the prompt is writtenAt every step; Anthropic: “the curation phase happens each time we decide what to pass to the model”
Typical failureVague or ambiguous wordingInformation that is missing, stale, conflicting or too much

What's in an agent's context, and what goes wrong in a coding agent

Each part can hold too much, go stale, or be missing. Anthropic's guiding principle is “the smallest possible set of high-signal tokens that maximize the likelihood of some desired outcome.”

ComponentIn a coding agentWhat goes wrong
InstructionsThe agent's own system prompt; CLAUDE.md, AGENTS.md or rules files; skills (descriptions at start, full text when a task matches)Too much: CLAUDE.md loads every session, and Claude Code's docs say longer files “consume more context and reduce adherence.” Missing: the business rules.
ToolsRead, edit, search and shell tools, plus MCP serversToo many, overlapping: if a person can't say which tool fits, Anthropic notes, the agent can't either. Missing: no tool reaches where the rules are kept.
Retrieved knowledgeFiles found with grep and glob, docs, MCP resultsStale: a copied policy that has since changed. Missing: an exception in someone's head is in no file to retrieve.
MemoryCLAUDE.md; Claude Code's auto memory loads its first 200 lines or 25KB each sessionStale: a remembered limit that has since changed. Wrong: an error saved and referenced again and again, which Drew Breunig calls context poisoning.
ExamplesExisting code, tests, a sample specWrong: old code copied as a pattern brings its old rule. Too much: Anthropic advises “diverse, canonical examples,” not a “laundry list of edge cases.”
Conversation historyYour prompts, the files read, command outputToo much: as the window fills, recall falls, known as context rot. Lost: an instruction given only in conversation can disappear after compaction, Claude Code's docs say.

From Anthropic's post, Drew Breunig's "How Long Contexts Fail" (June 22, 2025) and Claude Code's docs, read on 2026-11-30. In Claude Code, /context shows what is in the window.

The business context: the part that's usually missing

A coding agent can read every file in the repo and still not know the rules the code must follow: thresholds, exceptions, who decides. Harrison Chase: “Models are not mind readers. If you do not give them the right context, they won't know it exists.” So the agent guesses. A made-up example: a quoting tool is adding discount approvals, and the prompt says “add approval for large discounts.”

DecisionWhat the agent guessedWhat the rule owner said
Which discounts need approvalOver 15% needs a manager's approval.Over 10% and at most 20%, the sales manager approves. Over 20%, the deal desk approves as well.
How the discount is measuredLine by line.On the whole quote, against list price.
Who may approveAny manager, including on quotes they own.If the quote's owner would be an approver, the owner's manager approves in their place.

Illustration, made up. Each guess is plausible enough to pass a code review that never asked the person who decides.

How to engineer the business context for a coding agent

The right rules, from the right source, at the step that needs them. It works with a Markdown file and any coding agent.

  1. 1

    Inventory what the agent needs to know

    List the decisions the feature's code will make: thresholds, approvals, exceptions, and which rule wins when two apply. Code and docs answer some; the rest is business context you must supply.

  2. 2

    Separate stable rules from changing ones

    Rules your team changes through code review can live in a repo file, named by its path in CLAUDE.md or AGENTS.md so the agent can open it when a task needs it; an @import in CLAUDE.md would load the whole file along with CLAUDE.md, every session. Rules owned outside engineering, such as limits and approvers, change on the business's schedule; a copy of them goes stale silently.

  3. 3

    Capture the missing rules from their owner, with sources

    Ask whoever decides, on a real case, and follow each “usually” to its exceptions. Write one rule per sentence, with explicit numbers and its source; list what they can't settle as open questions. Run the interview yourself, or have RuleFoundry run it.

  4. 4

    Serve the rules through MCP rather than pasting them

    The agent reads them from where they are kept when a task needs them. Limits that change often belong in configuration the code reads at runtime.

Write, select, compress, isolate: the four strategies in a coding agent

LangChain groups context engineering into four strategies; Anthropic's post covers the same moves. Each one in Claude Code:

StrategyWhat it meansIn Claude Code
WriteSave context outside the window to use laterCLAUDE.md; auto memory, which Claude writes from your corrections; the plan file plan mode writes
SelectPull the relevant context in when a task needs itgrep, glob and @file mentions; skills, whose full text loads when invoked; MCP; rules with a paths field, which load with matching files
CompressKeep only the tokens the task needs/compact; auto-compaction near the limit; /clear between unrelated tasks
IsolateSplit context across separate windowsSubagents, which work in their own context window and return a summary

From LangChain's post and Claude Code's docs, checked on 2026-11-30.

What the business context looks like when it's supplied

The same feature with the rules supplied, as the agent would read them from a rules file or an MCP tool: IDs, explicit boundaries, sources, and open questions marked. All made up.

Example

==> What the agent reads: discount approval rules <==
DA-1  A quote with a total discount of 10% or less needs no approval.
      Source: Discount policy v4 (deal desk), section 1
DA-2  A quote with a total discount over 10% and at most 20% needs the sales manager's approval.
      Source: Priya (deal desk), interview 2026-11-18, 02:40
DA-3  A quote with a total discount over 20% needs the sales manager's approval and the deal desk's approval.
      Source: Discount policy v4 (deal desk), section 2
DA-4  The total discount is measured on the whole quote against list price, not line by line.
      Source: Priya, interview 2026-11-18, 05:15
DA-5  If the quote's owner would be an approver under DA-2 or DA-3, the owner's manager approves in their place.
      Source: Priya, interview 2026-11-18, 07:02
DA-6  A renewal of the same products, at no more than the current quantities and at the same or a lower
      discount than the current contract, needs no new approval.
      It takes precedence over DA-2 and DA-3.
      Source: Priya, interview 2026-11-18, 09:30
Open  Do one-time services count toward the total discount, or only subscription lines? Owner: Priya
Open  Does an approval still stand if the quote is edited after it is approved? Owner: Priya

==> CLAUDE.md or AGENTS.md (one line) <==
- Discount approval rules come from the deal-desk-rules MCP server, never from this repo. Cite the rule ID in code and tests. If a task depends on an open question, stop and ask.

The boundaries leave no gap or overlap between DA-1, DA-2 and DA-3, and DA-6 keeps the control: a renewal skips approval only for no more of the same products at no higher a discount. The open questions tell the agent where to stop and ask. Test each rule at its boundaries: exactly 10% and just over, exactly 20% and just over.

Where RuleFoundry fits: capturing and serving the business context

RuleFoundry does step 3 and serves the result for step 4. It interviews the person who knows, by voice or text, or reads a screen recording, and writes business rules in plain language, each linked to the line where it was said.

  • Rules with their sources

    Each rule cites the transcript lines it came from, and RuleFoundry checks that those lines actually say it. Rules are tentative until the expert confirms them.

  • Open questions, listed rather than filled in

    Anything the expert didn't settle is listed as a question, not filled in.

  • Your coding agent reads the rules through MCP

    RuleFoundry's plugins connect Claude Code, Cowork, Cursor, Codex and GitHub Copilot, and its app runs in ChatGPT. An agent can use only the workspaces, Extractions and artifacts your RuleFoundry account can access, and the connection can be revoked.

The Logic Twin answers questions from the same rules and says when they don't cover one. The outputs page shows what a finished result looks like, and the integrations page has the setup for each agent. Review the rules before relying on them; the facts page lists the limits and prices.

See it run

Send an interview to whoever decides the rules, from the web app once you sign up or from ChatGPT (setup), with a line like this one. Once it's finished, have your coding agent pull the rules from RuleFoundry and write a test for each.

Use RuleFoundry to interview [email protected] about which quote discounts need approval, and who approves them.

When something else fits better

  • AGENTS.md or CLAUDE.md, for rules your team already knows: Markdown instruction files your coding agents read.
  • A spec in the repo, when the context is one feature's goal, scope, acceptance criteria and rules, written before any code.
  • Context7, when what's missing is current library documentation. Its README describes version-specific docs and code examples, served through MCP or a CLI.
  • Unblocked, when the context exists but is spread across code, conversations, issues and docs. Its site describes a context layer that reasons across them.
  • Trail, when the know-how is already written in your systems and documents. Its site describes one Brain of policies, procedures and know-how that AI agents read, each rule citing its source.
  • RuleFoundry, when the business rules, especially the exceptions, are still in someone's head, and your coding agent should read them through MCP, each linked to where it was said.

Descriptions of other products, formats and docs come from their own websites and documentation, checked on 2026-11-30.

Questions people ask

What's the difference between context engineering and prompt engineering?
Prompt engineering is wording the instructions; context engineering is choosing everything in the window (instructions, tools, retrieved data, memory and history) at every step of an agent's run. Anthropic and LangChain both treat prompt engineering as part of it.
What is context engineering for coding agents?
Setting up what a coding agent reads: CLAUDE.md or AGENTS.md, its tools and MCP servers, the files it searches, its memory and the session so far. Keep always-loaded files short, and supply the business rules the code can't tell it.
Is RAG context engineering?
RAG is one technique within it: retrieving documents into the window. LangChain says it “can be a central context engineering challenge.” It retrieves only what is written down, so it can't supply a rule that lives in someone's head.
Who came up with the term context engineering?
Nobody owns it. Cognition's Walden Yan wrote about it on June 12, 2025; Tobi Lütke and Andrej Karpathy made it popular on X later that month; LangChain's Harrison Chase wrote it up on June 23, crediting Lütke, Ankur Goyal and Yan; Anthropic followed in September.
Are our business rules private, and what does RuleFoundry cost?
RuleFoundry does not use customer content to train models; only members of your workspace can read a Project's knowledge base. Agents you connect get no more than your account can see. One Extraction is free; after that, Personal is $20 a month for unlimited Extractions, or Team at $20 per active member a month, two seats minimum.

Related: Agent Skills vs MCP: where the context lives, CLAUDE.md and AGENTS.md for business rules, spec-driven development, RuleFoundry facts.

What changed: 2026-12-01, a rules file is named by path, not imported with @, and why; 2026-11-30, GitHub Copilot named as on the integrations page; 2026-11-30, first version.

Try it on one process

Your first Extraction is free.