Skip to content
Agent Builder
Module 3Intermediate

Prompting & Context Engineering

Give agents exactly what they need — nothing more

Move beyond clever prompts to deliberate context design: system prompts, specs, examples, long-context management, memory, and reusable skills.

Lessons
6
Reading time
56 min
Level
Intermediate
Access
Full course

Lessons in this module

  1. 3.1

    From Prompt Engineering to Context Engineering

    Why the best results come from curating everything the model sees — not from magic phrases — and a framework for doing it.

    9 min
  2. 3.2

    Writing System Prompts That Hold Up

    Structure, tone, priorities, and edge cases: how to write system prompts that behave consistently over thousands of runs.

    10 min
  3. 3.3

    Specs, Examples, and Constraints

    Turn fuzzy requests into precise specs. When to use examples, how to phrase constraints, and how to get structured output reliably.

    10 min
  4. 3.4

    Managing Long Context

    Compaction, summaries, scratchpads, and just-in-time retrieval: techniques that keep long-running agents focused and accurate.

    9 min
  5. 3.5

    Giving Agents Memory

    Short-term vs. long-term memory, file-based memory, retrieval, and how to design memory that helps instead of polluting context.

    9 min
  6. 3.6

    Skills and Reusable Instructions

    Package your best workflows into skills, commands, and templates that any agent can load on demand.

    9 min

About this module

Context engineering is the practice of deciding everything a language model sees while it works: the system prompt, the task instructions, examples, retrieved documents, tool results, memory, and the conversation so far. Prompt engineering focuses on how a request is phrased. Context engineering takes a wider view, because for capable modern models, which information is present usually matters more than the exact wording of the ask.

This matters most for agents. An agent's context grows with every file it reads and every tool it calls, and more context is not automatically better: irrelevant material dilutes attention, stale facts mislead, and long sessions drift. Many failures that look like an unreliable model turn out to be context problems, such as a missing file, an outdated assumption from earlier in the session, or a pile of noisy search results. Fixing the context usually fixes the behavior.

This part teaches context engineering as a practical skill. You will learn to diagnose failures as context problems, write system prompts that behave consistently across thousands of runs, and turn fuzzy requests into precise specs, with examples that show what words can't, constraints that models actually follow, and reliable structured output.

You will then tackle the problems of long-running agents: fresh starts, compaction, scratchpad and progress files, just-in-time retrieval, lean tool output, and handing heavy reading to subagents. Finally, you will design agent memory that helps rather than pollutes, using file-based and retrieval-based approaches, and package your best workflows as skills, commands, and templates that agents load only when they need them.

Questions about Prompting & Context Engineering

What is context engineering?

Context engineering is the practice of curating everything a model sees when it works, including instructions, examples, documents, tool results, memory, and history. The goal is to give the model exactly the information it needs for the current step and leave out what would distract it.

What is the difference between prompt engineering and context engineering?

Prompt engineering is about how you phrase a request to a model. Context engineering covers the whole information environment around that request, including what gets retrieved, remembered, summarized, or left out. For agents that run many steps, context engineering usually has the bigger effect on results.

How do you write a good system prompt?

State the agent's goal and the situation it works in, give it the knowledge it can't infer, rank its priorities so conflicts resolve predictably, and describe how to handle tricky situations. Aim for clear principles rather than a long list of rigid rules, and test changes against a set of real inputs before shipping them.

How do AI agents remember things between sessions?

Models don't remember anything between calls on their own. Agents get memory by saving information outside the model, such as notes in files or entries in a database, and loading the relevant parts back into context later. Instruction files like CLAUDE.md are a simple form of long-term memory.

What are agent skills?

A skill is a packaged set of instructions, optionally with scripts or reference files, that an agent loads only when a task calls for it. A short description is always visible to the agent, and the full instructions load on demand, which keeps context lean while making specialized workflows reusable.

How do you get structured output from an LLM?

Describe the exact format you need, ideally as a JSON schema, and show an example. Where the API supports it, use a structured output or tool-based mode that enforces the schema, and always validate the result in code before using it.