Context engineering

Definition
Deciding exactly what information a model sees before it acts, the right files, rules and examples, and nothing else.

Why it matters

A model's output cannot be better than what it is given. Hand a coding agent an entire codebase and it drowns. Hand it the two files that matter plus a short note on conventions and it does the job cleanly. Many answers that look like model failures are context failures: the right fact was missing, an old rule contradicted a new one, or a hundred irrelevant pages buried the one that counted.

How to apply it

  • Give the model only what the task needs. Fewer, better inputs beat more.
  • Write stable conventions down once, in a rules file or system prompt, and supply them every time.
  • Keep a short record of decisions already taken, so the model does not reopen them.
  • Retrieve reference material on demand instead of pasting everything in. Retrieval-Augmented Generation (RAG) does this.
  • When output drifts, inspect what the model was given before blaming the model.

What it is

An AI model only knows what sits in front of it when it answers. That material is its context: the instructions, the documents, the earlier conversation and the tools it can call. Context engineering is the work of choosing and arranging all of it so the model has what it needs and nothing that distracts it.

Prompt engineering is the narrower skill of wording one instruction well. Context engineering covers the whole package around that instruction, and it matters most when AI agents run many steps with no person watching.

Common mistakes

  • Treating a longer prompt as a better one.
  • Leaving outdated or contradictory rules in the supply.
  • Never checking what the model actually received.

The four parts

  • Instructions: what the model is asked to do and how.
  • Knowledge: the documents and records relevant to this task only.
  • Memory: decisions already made, so settled questions stay settled.
  • Tools: what it may look up or change, described clearly.
Worked example

Suppose a six-person agency asks an AI assistant to draft client reports from a shared folder. The first attempt pastes in the whole folder, forty documents, two of them outdated, and the drafts quote last year's rates. The team rebuilds the setup. It keeps one short rules file with the house style and current rates, one document per client, and a short note at the top of each request that lists the decisions already agreed with that client. On the next run, Claude receives only those three inputs and cites the current rate card, skipping the old one. Reviewer corrections drop from about ten per report to two. The model did not get smarter. It was given the material that mattered and nothing that contradicted it.

Tools in the example

Some links are affiliate links: we may earn a commission at no cost to you. It never decides a ranking. How we work with partners

  1. Article

    Context window

    The limit on how much context fits.

  2. Article

    Prompt engineering

    Wording the instruction itself.

  3. Article

    Hallucination

    What often follows missing context.