Lesson 02 · Applied LLM Engineering
Prompting & Context Engineering
Beyond prompt tips: system prompts as specifications, structured outputs, the context window as a budget you spend — and the judgment call of when prompting beats fine-tuning.
Anthropic's FDE posting doesn't ask for "experience writing prompts" — it asks for production LLM experience including "advanced prompt engineering".6 The word doing the work is production. A prompt that works in a playground is a vibe; a prompt that runs ten thousand times a day against a customer's messy data, produces output their billing system can parse, and fails loudly instead of hallucinating quietly — that's an engineering artifact. This lesson gives you the two mental models behind that difference: the prompt as a specification, and the context window as a finite budget.
System prompts are specs, not vibes
Most engineers write system prompts the way they'd brief a smart intern in a hallway: "you're a helpful medical summarizer, be accurate and concise." That's a vibe. A specification, by contrast, defines the things you'd define in any API contract: the role and its boundaries, the exact input it will receive, the exact output shape it must produce, how to behave on malformed or missing input, and what it must never do. Anthropic's own prompt engineering guidance is a checklist of spec disciplines — be explicit and direct, use examples, give Claude a way out ("say you don't know"), structure with XML tags, define output format precisely.2 The techniques are public; what separates an FDE is treating them as contract-writing, not decoration.
The spec mindset extends to the output side as structured
outputs: instead of asking nicely for JSON and regex-ing the response, you define
a schema and the API constrains generation to it — the Claude API's
output_config.format accepts a JSON schema and guarantees parseable
output.2 For customer systems this is the
difference between a demo and an integration: downstream code can consume the model's
output like any other service response. OpenAI's guidance converges on the same
disciplines — clear instructions, reference text, structured decomposition — which tells
you this is engineering practice, not vendor folklore.4
| Vibes prompting | Spec prompting | |
|---|---|---|
| Role | "You are a helpful assistant" | Role + scope + explicit boundaries ("you summarize; you never diagnose") |
| Input | Assumed clean | Described precisely, incl. malformed/partial cases |
| Output | "Respond in JSON" | Schema-enforced structured output, every field defined |
| Uncertainty | Model improvises | Escape hatch: "if not stated in the transcript, write 'not documented'" |
| Verified by | Eyeballing one response | Checks that run on every change (evals, from Lesson 05) |
The context window is a budget, not a bucket
Current Claude models take up to a million tokens of context.3 The trap is treating that as a bucket to fill. Anthropic's engineering guidance is blunt: context is a finite resource with diminishing marginal returns, and the goal is to find the "smallest possible set of high-signal tokens that maximize the likelihood of some desired outcome."1 Every token you spend on boilerplate, stale history, or twelve tool definitions the task doesn't need is budget not available for the customer's actual data — and worse, it actively degrades the answer.
That degradation has a name: context rot. As the number of tokens in the window grows, the model's ability to accurately recall and use any given piece of it decreases — attention gets stretched thinner across more content.1 The practical countermeasures are budget management: compaction (summarize older history and continue with the summary), structured note-taking outside the window, and curating which tools and documents are in view at all — the Claude API now does compaction server-side when conversations approach the limit.13
This is why the field moved from prompt engineering to context engineering — not a rebrand, a superset. Prompt engineering asks "what do I say?"; context engineering asks "what is the full set of tokens the model sees — instructions, retrieved documents, tool definitions, history — and is every one of them earning its place?" Anthropic frames prompt engineering as a subset of this larger discipline, and it's the discipline that matters most for agents that loop over many turns.1 You'll feel this concretely in Lesson 03, where every tool definition you register is context you've spent.
When prompting beats fine-tuning
Customers ask for fine-tuning constantly — it sounds like "training the AI on our data," which sounds like moats. Your default answer should be the vendor's own: try prompting first. Prompt iteration is far faster than fine-tuning (minutes, not training runs plus data pipelines), needs a few dozen good examples instead of thousands of labeled ones, preserves the model's general knowledge instead of risking catastrophic forgetting, is transparent and debuggable in plain text, and survives model upgrades — you re-run your checks, not your training job.2 Fine-tuning earns its complexity in narrow cases: a style or format that survives every prompting attempt, or latency/cost floors that demand a smaller specialized model. Being the person who says "you don't need fine-tuning, and here's the eval that proves it" is the AI-judgment competency from Lesson 01 — cheaper, faster, and it builds the trust that wins the renewal.
🧪 Practical steps: clinical-note summarizer v1 (~60 min)
Meet the course's customer: a fictional Australian virtual-care
provider — telehealth consults, triage chat, clinical notes, claims. Over the next nine
lessons you'll build them a real system, culminating in the Lesson 11 capstone. Today:
a clinical-note summarizer whose system prompt is a spec and whose
output is schema-shaped. You'll also get a first taste of a real FDE skill —
synthetic data — because in a
regulated domain nobody hands you patient records in week one. Full instructions and a
starter script are in labs/0002-clinical-note-summarizer.md; the short
version:
- Set up — create
D:\Projects\FDE-Portfolio\l02-summarizer\;pip install anthropic;ANTHROPIC_API_KEYset. - Generate 3 synthetic telehealth transcripts with Claude — GP-style video consults with Australian texture (Medicare, GP referrals, local medication brands), each seeded with specific facts: medications with doses, symptoms, a follow-up plan.
- Write the system prompt as a spec — role and boundaries, input
description, SOAP-style sections (Subjective, Objective, Assessment, Plan) as a JSON
schema via structured outputs, and an explicit escape hatch:
"not documented"for anything the transcript doesn't state. - Write 5 hand-written checks per transcript in plain Python — must-include facts (the dose that was mentioned) and must-NOT-include facts (the diagnosis that never was). No frameworks yet.
- Run, fail, iterate the prompt until all checks pass on all three transcripts — and keep notes on which spec line fixed which failure.
- Save everything — code, prompt, checks, transcripts, and a short README with your failure notes — to the portfolio folder.
Feedback loop: your hand-written checks are a proto-eval — Lesson 05
upgrades this exact artifact into a proper eval harness, so keep it honest rather than
pretty. This artifact (key: l02-summarizer) feeds the Lesson 11 capstone
engagement and is tracked in the course's artifact tracker. Bring it to me in chat for a
rubric review, or use the box below.
No chat here — this box replaces it. Copy the prompt into any AI assistant (Claude, ChatGPT, Gemini…), then paste your system prompt, checks, and failure notes after it.
You are a senior Forward Deployed Engineer reviewing my work: a clinical-note summarizer v1 for a fictional Australian virtual-care provider. It includes a system prompt written as a specification, structured SOAP-style JSON output, 3 synthetic telehealth transcripts, 5 hand-written checks per transcript (must-include facts and must-not-include hallucinations), and notes on prompt iterations. Grade each criterion as Strong / Adequate / Missing, with one sentence of evidence: - Spec quality of the system prompt: it defines role AND boundaries, describes the input, specifies the exact output schema, and includes an explicit escape hatch for undocumented facts — not just "be accurate". - Check meaningfulness: the checks would actually catch a dangerous failure (a hallucinated dose, an invented diagnosis), not just confirm the output is valid JSON. - Honest failure notes: the iteration notes name real failures observed and which specific spec line fixed each — not a story where everything worked first try. Be skeptical — probe the weakest check first: describe one hallucination my checks would MISS. Then ask 2–3 questions a clinical-safety reviewer would ask. Finish with the single highest-leverage improvement before this gets an eval harness in Lesson 05. My work follows below.
- Rewrite one real work prompt as a spec. Take a prompt you (or a teammate) actually use at work and give it boundaries, an input description, an output schema, and an escape hatch. Diff the outputs before and after.
- Find one bloated context and trim it. Open any AI tool at work with a long accreted system prompt or over-stuffed context. Cut what isn't earning its tokens and note whether quality changes.
- Explain "context rot" to a colleague in one sentence. If you can't, you don't own the concept yet. (Try: "the more you stuff into the window, the worse the model gets at using any of it.")
Check yourself — think like an FDE
Scenarios, not recall. Diagnose from the mental models — spec vs vibes, budget vs bucket. Wrong picks stay live.
Scenario A
A customer's support assistant has degraded over two months. You inspect the pipeline: the system prompt has grown to 9,000 tokens of accumulated team instructions, every request injects the user's full 60-turn history, and all 40 internal tools are registered on every call. The model version never changed. What's your primary diagnosis?
Scenario B
A teammate demos a discharge-note generator. The system prompt: "You are an expert clinical scribe. Be thorough, accurate and professional. Output JSON." It worked beautifully on the three demo transcripts. The customer wants it in production next month, parsing notes into their patient record system. What do you flag first?
Scenario C
A customer's CTO insists on fine-tuning: "We want the model trained on OUR clinical terminology — we've budgeted for it." Their actual complaint is that summaries sometimes use generic terms instead of their in-house codes, of which there are about 200. What's the FDE move?
Recommended learning
Hand-picked follow-ups. None are required — the primary source above comes first.
- Article Context windows — Claude Docs The mechanics under this lesson: how the window fills, 1M-token context, context awareness, and server-side compaction.
- Article Prompt engineering guide — OpenAI The vendor contrast — read it to see the same spec disciplines emerge independently, which is how you know they're real.
- Article Prompt Engineering Interactive Tutorial — Anthropic (GitHub) Nine hands-on chapters with exercises — the deliberate-practice companion to this lesson's lab.
- YouTube Prompting 101 | Code w/ Claude — Anthropic Anthropic's own conference walkthrough of prompt structure — watch how they build a prompt up as a layered spec.
- YouTube Prompting for Agents | Code w/ Claude — Anthropic Where prompting meets context engineering for multi-turn agents — the bridge to Lesson 03.
References
- Anthropic Engineering, "Effective context engineering for AI agents" (Sep 2025) — context as a finite resource, "smallest possible set of high-signal tokens", context rot, compaction, note-taking, tool curation.
- Anthropic, Prompt engineering overview, Claude Docs (current) — try prompting before fine-tuning (speed, data efficiency, preserved general knowledge, transparency); clarity, examples, escape hatches, output-format control.
- Anthropic, Context windows, Claude Docs (current) — 1M-token context, context awareness, server-side compaction for long conversations.
- OpenAI, Prompt engineering guide (current) — clear instructions, reference text, task decomposition: the vendor-independent convergence on spec disciplines.
- Anthropic, Prompt Engineering Interactive Tutorial (GitHub) — hands-on exercises linked from the official docs.
- Anthropic, Forward Deployed Engineer, Applied AI — job posting (2026) — "Production experience with LLMs including advanced prompt engineering, agent development, evaluation frameworks".