Module 14

Best practices for context engineering

Developer Tools How Claude Code Works

Module 14 — Best practices for context engineering

← Module 13 | Index


Context engineering is the craft of deciding what goes into Claude’s window — and what stays out — so the right information is present at the right moment. If Module 13 was about fewer tokens, this is about the right tokens. It’s arguably the highest-skill part of working with an agent, and it’s what separates frustrating sessions from ones that feel effortless.

The core insight: Claude is only as good as what’s on its desk. It can’t act on what it can’t see, and it can get distracted by what it shouldn’t be looking at. Everything below is about curating that desk.

The four moves of context engineering

Think of managing context as four distinct actions. Good practitioners do all four deliberately.

1. Add the right things in. Give Claude what it genuinely needs to succeed: the relevant files, a clear statement of the goal, examples of the output you want, the constraints that matter. An example of a finished report teaches format better than three paragraphs describing it. Concrete beats abstract.

2. Keep noise out. Just as important as what you add. Unrelated files, dead conversation history, tangents, and half-finished earlier attempts all compete for attention and can pull Claude off course. A focused desk produces focused work. This is why /clear between unrelated tasks (Module 4) is a quality tool, not just a cost one.

3. Compress what’s gotten long. When useful history has piled up, distill it. /compact turns a sprawling session into a tight summary. You can also do this by hand: “summarize what we’ve decided so far,” then /clear and paste the summary into a fresh session. The decisions survive; the clutter doesn’t.

4. Isolate heavy or specialized work. Push big sub-jobs into their own context so they don’t contaminate the main one. Subagents (Module 8) are the primary tool: a research subagent reads a hundred documents on its own desk and hands back three bullet points. The main context stays clean and on-task.

Practical techniques that work

State the goal explicitly, up front. Don’t make Claude infer the destination from a trail of small requests. “We’re building X; the end goal is Y; here are the constraints” anchors everything that follows.

Front-load what matters; let detail load on demand. Standing, always-true facts go in CLAUDE.md (Module 3). Procedures Claude should follow when relevant go in skills (Module 5), which load only on a match. This layering means the always-on context stays small while deep knowledge is available the moment it’s needed.

Show, don’t just tell. Provide an example input and the matching desired output. Examples are dense, unambiguous context — they pin down format, tone, and edge cases that prose descriptions leave fuzzy.

Point precisely. “Look at auth/login.py” beats “look through the codebase.” Naming the relevant location is itself an act of context engineering — you’re curating what lands on the desk.

Refresh the goal in long sessions. Over a long task, the original objective drifts toward the back of the desk. Restating it (“remember, the goal is still X”) re-centers attention. A quick recap before a hard step is cheap insurance.

Start fresh for a fresh problem. Reusing a stale session for a new task imports all its baggage. A clean start with a crisp brief almost always outperforms continuing in a cluttered window.

Use memory for what must survive the wipe. Context is erased between sessions; memory files and CLAUDE.md are not. Decisions, conventions, and durable facts belong in memory so each new clean session starts already informed (Module 3, Module 4).

The mental model: you are the editor

Claude does the writing and the doing, but you decide what it gets to see. A great editor doesn’t hand a writer every document in the building — they hand over exactly the right brief, the right references, and a clear goal, then get out of the way. Context engineering is that editorial judgment applied to an agent.

Master this and everything else in the tutorial compounds: skills load at the right time, subagents protect the main desk, memory carries the essentials forward, and each session opens with precisely what it needs and nothing it doesn’t. That is what working with Claude looks like at mastery.


← Module 13 | Index

🎉 You've finished How Claude Code Works!