# Context Engineering vs Prompt Engineering for Coding Agents

> Prompt engineering optimizes one instruction. Context engineering designs what the agent knows across every session. Where each one pays off, and where it stops.

**Prompt engineering** optimizes the instruction you hand a model for one turn. **Context engineering** designs what the model knows across every turn and every session, and builds the system that delivers it.

Both are real. The reason to be precise about the difference is that on a coding agent, most of the turns are not written by you.

## The core difference

| | Prompt engineering | Context engineering |
| --- | --- | --- |
| **Designs** | The instruction for one request | What the agent knows, and when |
| **Scope** | A single turn | Every turn, every session |
| **Who authors it** | The person typing | The team, in review |
| **Where it lives** | The message, or a prompt library | The repository |
| **Improves** | The response you asked for | The responses you never read |
| **Cannot** | Survive the end of the conversation | Verify what the agent produced |

The row that decides it for coding agents is the fifth one. When an agent runs a multi-step task, you write the first message and it takes twenty actions. Prompt engineering reaches the first one.

## Why prompt engineering felt sufficient, and stopped

In a chat-shaped interaction, the prompt *is* the interface. You ask, it answers, you refine. Improving the ask improves the result almost immediately, which is why prompt engineering became a discipline with real techniques behind it.

Coding agents changed the shape. The agent reads files, runs commands, edits code, reads the result, and continues. Between your message and the finished change there are many decisions you did not phrase. Those decisions are made from whatever the agent knows, and what it knows about your project is whatever reached it.

That is not an argument that prompts stopped mattering. It is an argument that the leverage moved.

## What each one actually fixes

Both address failures, and the failures are different.

**A prompt problem** looks like: the agent misunderstood the task, produced the wrong shape of answer, or went too broad. You rephrase, and it gets better. Signal: rewording fixes it.

**A context problem** looks like: the code is correct in general and wrong for this repository. It uses a library you rejected, puts a handler where your architecture does not, reinvents a pattern that exists, or reopens a settled decision. Signal: rewording does not fix it, and you find yourself explaining the same background again.

The test is simple. **If you have explained the same thing to the agent more than twice, it is a context problem, and no prompt will close it.**

## Both, in the right order

The two compose, and there is a sensible sequence.

1. **Frame the task clearly.** Prompt engineering, and it is still the cheapest improvement available.
2. **Make the project's rules available.** Context engineering: the architecture, decisions, rules, and specs the agent needs but cannot derive.
3. **Deliver them selectively.** Not everything on every turn; what applies to the file in front of it.
4. **Check the result.** Review against the documents the change claims to satisfy.

Step 3 is the one people skip, and it is where a lot of context efforts quietly fail. A large instruction file is explicit and versioned and still poor context, because everything in it arrives every time and competes with the task for attention.

## The neighbouring terms

Two more terms circulate, and both get placed wrongly.

**RAG is not context engineering.** Retrieval over your codebase answers "where is this mentioned". It cannot answer "what did we decide and why", because that was never in the code to retrieve.

**Harness engineering nests inside context engineering.** A harness is everything in an agent except the model: its tools, the guides it gets before acting, and the sensors that verify it after. [Building one is a specific form of context engineering](/learn/harness-engineering/), which is what the canonical source says. The "prompt to context to harness" progression that circulates in vendor posts is not in the material it cites.

## A worked comparison

The task: add rate limiting to the auth endpoints.

**Prompt-engineered.** "Add rate limiting to the auth endpoints. Use the existing middleware pattern, follow our error conventions, and reuse the Redis client rather than adding a dependency." That is a good prompt, and it works. You will write it again next week, and a teammate who does not know these constraints will not write it at all.

**Context-engineered.** You ask for rate limiting. The agent receives the decision recording Redis token buckets and why, the rule for error shapes under `src/auth/`, and the spec for the session API, because those documents are scoped to the code it is about to touch. The constraints arrive whether or not the person asking knew them.

The second one is more work once and no work afterwards. That is the whole trade.

## Where to start

Not with a prompt library.

1. **Write the decision you are tired of re-explaining**, with its rationale and the alternative you rejected.
2. **Scope one rule to one directory**, the convention your agent breaks most often.
3. **Let the delivery be automatic**, so it arrives at the edit rather than at the top of a conversation.

[Archcore](https://archcore.ai/) does this part, and yes, it is our tool: typed Markdown documents in a `.archcore/` directory, versioned with the code, injected by session hooks and served to any MCP-aware agent. [Context engineering for AI coding agents](https://archcore.ai/context-engineering/) covers the five properties in full.

Keep writing good prompts. They just stopped being the part that scales.