Advanced Prompting & Context Engineering

Beginner-Friendly Teaching Edition  ·  Speak plainly, feed the right context
What you will learn
How to communicate with Claude Code so it executes accurately: three principles for specific requests, why more context is not better context, how to let Claude interview you before a big build, how to use it as a codebase navigator, multi-turn conversation strategy, and why you should not lower the effort level.
Be specificPoint to examplesStay focusedRight context, not all context/clear between tasks

The Big Idea

The chapter opens with a story. The author once told Claude Code to "help me optimize the styles on this page," meaning a few spacing and font tweaks. Claude refactored the entire CSS file, added unrequested "improvements," and destroyed a layout that took an afternoon to build. Rolling it back took half an hour.

Rephrased: "Change the heading font-size from 16px to 18px, and paragraph spacing from 10px to 14px. Only these two changes — don't touch anything else." Claude finished in 30 seconds. Perfect.

Easy way to remember:
Claude did not get smarter — the human got clearer.
This chapter is about speaking plainly and feeding the right context, not about fancy prompts.

Why This Topic Matters

  • Claude Code is not a search engine — you do not craft keywords — but how you communicate still changes output quality a lot.
  • Vague requests force Claude to guess, and its guess is usually not what you had in mind.
  • Too much context actually degrades the model — it gets lost in noise and makes incoherent decisions.
  • A few repeatable habits (specific requests, /clear, interviews, high effort) remove most day-to-day friction.

Core Concepts

Be specific
Name files, paths, tech choices, and reference patterns. The more specific the instruction, the clearer Claude's direction.
Point to existing patterns
"Build it like src/components/UserWidget.tsx." A reference example beats ten lines of description.
Describe symptoms, not causes
Say what the user experiences and where to look. Let Claude locate the root cause — it can see all the code.
Context
Everything the model is working from: your message, CLAUDE.md, files it has read, screenshots, and the full conversation history.
Context engineering
Actively giving the right information for the current problem — not an encyclopedia of the whole project.
Let Claude interview you
Before a big build, have Claude ask you everything it needs, then compile the answers into a Spec.
Effort level
Low / Medium / High / Max — how much reasoning the model invests. High is the default; do not skimp.
/clear vs /compact
/clear wipes context for a clean restart. /compact auto-compresses and is opaque and error-prone — the chapter warns against relying on it.

Topic 1 — How to Talk So Claude Understands (three principles)

The book distils the official Best Practices into three principles.

1. Be specific: name files, context, and preferences

Do not say "add a login feature." Say:

Add Google OAuth login under src/auth/ using the Better Auth library,
following the pattern of the existing GitHub login implementation.

Why: file paths, tech choices, and reference patterns each remove a guess Claude would otherwise have to make.

2. Point to existing patterns: "Do it like this"

Look at how src/components/UserWidget.tsx is implemented,
then build a CalendarWidget the same way.

Why: Claude reads code exceptionally well. Handing it a good example in your own codebase is far more effective than describing the style in words.

3. Describe symptoms, don't diagnose causes

Users fail to log in after session timeout - please check the token refresh flow under src/auth/.

Why: unless you have confirmed the cause, your diagnosis ("there's a problem with the token refresh logic") can send Claude down the wrong path. Claude can see all the code; let it find the root cause.

Before / After comparisons (from the book)

Weak requestStrong request
Add a search featureAdd a search box to the navbar in src/components/Header.tsx, using Fuse.js for fuzzy search over the posts array, styled to match the existing FilterDropdown component
The API is throwing an error, take a lookPOST /api/orders returns 500 when quantity > 100 — check the input validation and database write logic in src/api/orders.ts
Optimize performanceThe homepage takes 4 seconds to load. The main bottleneck is the Dashboard component — it fetches all user data at once. Switch to pagination, 20 records per page
Remember: "Do it like that [example]" is roughly 100× more effective than "make it nice."

Topic 2 — Context Engineering: More Information Isn't Always Better

Your intuition might be "the more I tell Claude, the better." The book says the opposite is true. Anthropic's engineering team found that too much context degrades model performance — it gets lost in the noise and starts making incoherent decisions.

Core principle: don't give all the information — give the right information. Show Claude what it needs to solve the current problem, not an encyclopedia of the whole project.

Check your usage

Use the /context command to see how much of the context window is in use. In one monorepo test cited in the book, just loading the base configuration in a fresh session consumed roughly 20k tokens, leaving about 180k for actual work.

Ways to actively manage context

TechniqueHow / why
@ file references@src/utils/auth.ts points Claude at a specific file instead of making it search.
Paste screenshotsFor UI issues, a screenshot is "ten times more accurate" than a text description.
Pipe datacat error.log | claude feeds logs directly to Claude.
Share URLsClaude can fetch web content — linking to API docs beats copy-pasting them.

Topic 3 — Let Claude Interview You

When you are about to build something substantial (the book's example: a payment system from scratch), do not start by writing a requirements document. Instead:

I want to build a payment feature. Before you start,
interview me and ask everything you need to know.

Claude asks a series of questions: which payment methods? refunds? expected concurrency? webhook callbacks? which currencies? The book notes at least half of these will be things you had not considered — Claude just did the work of a requirements analyst.

The key move: fresh session for execution

Interview phaseGenerate SpecExecute in a NEW session

Why a fresh session? The interview conversation has already accumulated a lot of history, consuming a large chunk of context. A new session that starts from a clean Spec lets Claude focus entirely on execution, without the noise of everything discussed along the way.

Topic 4 — Treat Claude Like a Senior Engineer (codebase navigator)

Many people only use Claude Code to write code. It is equally valuable for understanding a codebase. You can ask it directly:

  • "How does logging work in this project?"
  • "What's the process for adding a new API endpoint?"
  • "What's the call chain for this useAuth hook?"
  • "What's the difference between src/lib/db.ts and src/utils/database.ts? Why do both exist?"

Claude reads the relevant code and gives a structured explanation — faster than reading docs, more convenient than asking a colleague. The book says this is exactly how the Claude Code team onboards new members: they ask Claude Code rather than reading a pile of wikis, and its understanding is often more accurate than the outdated docs.

Onboarding accelerator: when joining a new project, spend 10 minutes asking — "What's the architecture? What are the core modules? How does data flow through the system?" — and save at least half a day of digging.

Topic 5 — Multi-turn Conversation Strategy

StrategyWhat it means
Tight feedback loopsDo not wait for 500 lines before checking. Correcting after 10 lines costs almost nothing; tearing down a finished feature wastes tokens and time.
Two corrections and still off? Start overStop correcting. Use /clear to wipe context and restart with a better initial prompt. Untangling a derailed conversation usually makes it worse.
Switch tasks, clear contextFinished a component and moving to a schema change? /clear. Different tasks have different context needs; old history is just noise.
Use a /catchup after /clearShrivu's approach: a custom /catchup command tells Claude to read the current git branch's changes to restore relevant context.
Use subagents for researchDelegate "figure out how this library works" or "analyze how competitors implement this" to a subagent. Findings return to the main session without the intermediate reasoning polluting your context.
Warning from the book: do not rely on /compact (auto-compression). It is opaque and error-prone. When you need to reset, use /clear, not /compact.

Topic 6 — Effort Level: Don't Skimp Here

Claude Code has four effort levels, controlling how much reasoning the model invests.

LevelBest forCharacteristics
LowSimple formatting, renamingFast, but prone to careless mistakes
MediumRoutine development tasksLighter than the default
HighComplex features, debuggingDefault level — what Boris (Claude Code's creator) uses
MaxExtremely complex architectural decisionsUncapped reasoning tokens — slowest and deepest

High is already the default, and Boris never dials it down. The reasoning mirrors why he sticks with Opus: Claude thinks more deeply, needs fewer revisions, and ends up more efficient overall.

Remember: if Low makes a mistake, the time you spend fixing it will likely exceed what High would have taken to get it right the first time. Fixing low-effort mistakes always costs more than the few seconds you saved.

Simple Example: Same Task, Two Requests

Vague
"Help me optimize the styles on this page."

Result in the book: full CSS refactor, unrequested changes, broken layout, 30 minutes to roll back.
Precise
"Change the heading font-size from 16px to 18px, and paragraph spacing from 10px to 14px. Only these two changes — don't touch anything else."

Result: done correctly in 30 seconds.

Visual Mental Model: The Right-Sized Context

Context window (say ~200k tokens)
┌───────────────────────────────────────────────┐
│ base config / CLAUDE.md      ~20k             │
│ THE RIGHT FILES for this task                 │
│ THE RIGHT SCREENSHOT / LOG / URL              │
│ .................. free space for real work .. │
└───────────────────────────────────────────────┘
        vs.  cramming in the whole project
┌───────────────────────────────────────────────┐
│ every file, every doc, huge chat history      │
│ model gets lost in the noise -> worse output  │
└───────────────────────────────────────────────┘

Important Comparisons

Hand-managed context vs. auto-compression

/clear/compact
What it doesWipes context; you restart with a clean prompt (or /catchup)Automatically compresses conversation history
PredictabilityYou control exactly what goes back inOpaque — you cannot see what was kept or dropped
Book's adviceUse this to resetDo not rely on it

Where to fill in the blanks: you vs. Claude interviewing you

You write the requirements docClaude interviews you first
You only capture what you already thought ofClaude asks about refunds, concurrency, webhooks, currencies — things you missed
Blind spots stay blindBlind spots surface before any code is written
Execute in the same messy sessionCompile a Spec, then execute in a fresh, focused session

Real-World Use Cases

  • Precise edits: "change only these two values, touch nothing else" — safe refactors.
  • Feature by reference: "build CalendarWidget like UserWidget" — consistent style across a codebase.
  • Bug reports: "500 on POST /api/orders when quantity > 100" — Claude locates the cause.
  • Big new system: payment feature — interview → Spec → fresh session to build.
  • Onboarding: 10 minutes of architecture questions instead of half a day of wiki reading.
  • Research: delegate "how does this library work?" to a subagent so the main context stays clean.

Common Beginner Mistakes

  • Vague requests like "add a login feature" or "make it nice" — Claude has to guess.
  • Diagnosing the cause yourself when you have not confirmed it, sending Claude the wrong way.
  • Dumping the whole project into context, thinking more is better.
  • Never checking /context usage.
  • Carrying old conversation history into a completely different task.
  • Correcting a derailed conversation three, four, five times instead of /clear and restarting.
  • Relying on /compact to manage context.
  • Lowering the effort level "to save time" on a task you thought was simple.
  • Packing three unrelated requests into one message — Claude nails only one.

Best Practices

  • Be specific: file names, line numbers, function names, expected behaviour.
  • Point to examples in your own codebase: "do it like that."
  • Describe symptoms, let Claude diagnose.
  • Give the right context, not all of it; check with /context.
  • Use @file, screenshots, piped logs, and URLs to feed context efficiently.
  • Let Claude interview you before big builds; turn answers into a Spec; execute in a fresh session.
  • Use Claude as a codebase navigator when onboarding.
  • Tight feedback loops: correct early, when it is cheap.
  • Two failed corrections → /clear and start over.
  • /clear between tasks; use a /catchup to restore branch context.
  • Delegate research to subagents.
  • Keep effort on High (or Max); do not dial it down.
  • One thing at a time; for larger tasks, work in confirmed steps.

Interview / Revision Questions

  1. What are the three principles for talking to Claude Code?
  2. Why should you describe symptoms instead of diagnosing the cause?
  3. What counts as "context" beyond the message you type?
  4. Why can more context make output worse?
  5. What does the /context command do, and roughly how much did base config cost in the book's monorepo test?
  6. List four ways to actively feed context (hint: @, screenshots, pipes, URLs).
  7. What is the "let Claude interview you" workflow, and why execute in a fresh session?
  8. Give three questions you could ask Claude when onboarding to a new codebase.
  9. What should you do after two failed corrections?
  10. Why does the book warn against /compact, and what should you use instead?
  11. What are the four effort levels, and which is the default?
  12. Why is lowering the effort level usually a false economy?

Practice Exercises

Exercise 1: Take a vague request you have used before ("optimize this", "make it nicer") and rewrite it with a file path, a tech choice, and a reference pattern.
Exercise 2: Write a bug report in symptom form: what the user does, what they see, and where to look — without naming a cause.
Exercise 3: Run /context in a real project and note how much is used before you do anything.
Exercise 4: Pick a feature idea and ask Claude to interview you. Collect the answers into a short Spec, then open a fresh session and paste only the Spec.
Exercise 5: Onboard yourself to an unfamiliar repo with 10 minutes of architecture questions. Write down what you learned.
Exercise 6: During a task, deliberately practise a tight feedback loop: stop Claude after ~10 lines and redirect it.

Quick Memory Map

Advanced Prompting & Context Engineering
│
├── Three principles
│   ├── Be specific   (files, paths, tech, patterns)
│   ├── Point to examples ("do it like this")
│   └── Symptoms, not causes
│
├── Context engineering
│   ├── Context = message + CLAUDE.md + files + screenshots + history
│   ├── Too much context -> worse output
│   ├── Check with /context
│   └── Feed: @file, screenshots, cat log | claude, URLs
│
├── Big builds
│   └── Let Claude interview you -> Spec -> NEW session to execute
│
├── Codebase navigator
│   └── Ask architecture / call-chain / "why do both exist" questions
│
├── Multi-turn strategy
│   ├── Tight feedback loops (correct early)
│   ├── 2 fails -> /clear + restart
│   ├── /clear between tasks (+ /catchup)
│   ├── subagents for research
│   └── Don't trust /compact
│
└── Effort level
    Low / Medium / High(default) / Max  -> keep it High

Complete Chapter Revision

  1. Claude Code is not a search engine, but clear communication still drives output quality.
  2. Three principles: be specific, point to examples, describe symptoms not causes.
  3. Specific requests name files, paths, tech choices, and reference patterns.
  4. "Context" is the message plus CLAUDE.md, read files, screenshots, and full history.
  5. Too much context degrades performance; give the right information, not all of it.
  6. Check usage with /context; feed context with @file, screenshots, piped logs, and URLs.
  7. For big builds, let Claude interview you, compile a Spec, and execute in a fresh session.
  8. Use Claude as a codebase navigator to onboard fast.
  9. Multi-turn strategy: tight feedback loops, /clear after two fails, /clear between tasks, subagents for research.
  10. Do not rely on /compact; use /clear.
  11. Keep the effort level on High; fixing low-effort mistakes costs more than the seconds saved.
  12. The best progress comes from practice-built intuition, not more prompt tricks.

Final Takeaway

The chapter's central lesson:

Good conversations do not depend on elaborate prompts — they depend on precise context. Specify your needs clearly, let Claude interview you to fill your blind spots, keep sessions clean with /clear, and do not lower the effort level. The most effective advancement comes from building intuition through practice.

This teaching edition is based on the supplied April 2026, 2nd edition of Claude Code: The Complete Guide (§06, "Advanced Prompting & Context Engineering"). Command names, effort-level details and token figures reflect that edition and may change over time.