Skip to content

2.2 — Context Engineering

Context engineering — deliberately shaping what information is available to the AI so it produces better results. This includes files, conversation history, system instructions, and documentation.

Most people focus on what they say to the AI. Context engineering focuses on what the AI can see when it answers. These are different problems with different solutions.

ToolWhat It DoesWhen To Use It
CLAUDE.mdA file in your project root that Claude Code reads automatically on every session. Contains project-specific instructions, conventions, and context.Every project should have one. It’s your AI’s briefing document.
System promptInstructions that shape the AI’s behavior for the entire conversation.When you need consistent behavior across many interactions.
File referencesPointing the AI at specific files so it reads them before acting.When the AI needs to understand existing code before making changes.
/compactCompress conversation history to free up context window space.When conversations get long and the AI starts “forgetting” earlier context.

Think of context like a desk. Everything the AI “knows” right now is on the desk. The desk has a fixed size — the context window. If you pile too much on it, things fall off the edges.

Context engineering is choosing what’s on the desk at any given moment.

Put on the desk: the specific files related to your current task, clear instructions, relevant examples.

Keep off the desk: unrelated files, previous conversation about different topics, noise.

When the desk gets crowded, use /compact to clear old history while preserving the important bits. This is not losing information — it’s making room for what matters now.

When AI gives you a bad answer, the problem is usually context (what it could see), not capability (what it can do).

Before blaming the model or rewriting your prompt, ask: what was the AI actually seeing when it answered? Add the right files, remove the noise, and try again. The answer often changes dramatically.


Next: 2.3 — Engineering Principles | Phase overview: Phase 2