Prompt Engineering

Get dramatically better results from AI tools — structured prompting, iteration techniques, and real workflows.

25 lessons

Estimated lesson study time: 366 minutes

Lesson estimates are a guide, not a deadline. Allow extra time for practice, projects, and review.

Learn AI & Technology Access gives you full access to all 19 tracks and 552 lessons after sign-up and onboarding. No time limit, paid subscription, or payment card required.

Start Learn AI & Technology Access

Includes three AI Tutor answers across these courses. AI-generated content remains subject to Learn’s monthly allowance.

Track overview

Progress from clear instructions and message roles to structured prompting, decomposition, retrieval, tools, and agents. Finish with evaluation, injection defenses, and cost–latency tradeoffs to make prompting a testable engineering practice.

Who this track is for

People who use language-model tools and builders designing reusable prompt-driven workflows.

Before you begin

Begin with a concrete task and examples of acceptable outputs. Prior coding experience can help with tools and structured outputs but is not needed for the opening concepts.

What you will work toward

Practice building reusable prompts, grounding answers, testing reliability and security, and balancing output quality with latency and cost.

Complete lesson outline

1. Prompt Fundamentals

4 lessons

  1. 1.1 Anatomy of a Prompt

    12 minutes
    • Identify the core parts of a prompt: instruction, context, input, and output format
    • Explain how each part shapes the model's response
    • Rewrite a vague prompt into a structured one
  2. 1.2 Writing Clear Instructions

    13 minutes
    • Apply specificity, constraints, and examples to reduce ambiguity
    • Use delimiters to separate instructions from user content
    • Avoid common vagueness that leads to unpredictable answers
  3. 1.3 Controlling Tone and Format

    13 minutes
    • Direct the model to adopt a specific tone and reading level
    • Specify output formats such as tables, lists, or markdown
    • Combine tone and format requirements without conflict
  4. 1.4 Temperature and Sampling Parameters

    14 minutes
    • Explain how temperature affects randomness in generated text
    • Describe top-p sampling and when to adjust it
    • Choose parameters for deterministic versus creative tasks

2. Roles and System Prompts

4 lessons

  1. 2.1 System, User, and Assistant Roles

    13 minutes
    • Distinguish the system, user, and assistant message roles
    • Explain how the system prompt sets persistent behavior
    • Structure a multi-message conversation correctly
  2. 2.2 Designing Effective System Prompts

    14 minutes
    • Write a system prompt that defines role, goals, and boundaries
    • Encode rules and refusal behavior into the system message
    • Balance detailed instructions against prompt length
  3. 2.3 Managing Conversation Context

    14 minutes
    • Explain how conversation history is passed on every request
    • Manage the context window as conversations grow
    • Summarize or trim history to stay within token limits
  4. 2.4 Reusable Prompt Templates

    14 minutes
    • Design prompts with variable placeholders for reuse
    • Separate static instructions from dynamic input safely
    • Version and organize a small library of templates

3. Advanced Prompting Techniques

4 lessons

  1. 3.1 Zero-Shot and Few-Shot Prompting

    14 minutes
    • Contrast zero-shot prompting with providing examples
    • Construct few-shot examples that demonstrate the desired pattern
    • Choose the number and diversity of examples for a task
  2. 3.2 Chain-of-Thought Reasoning

    15 minutes
    • Explain how prompting for step-by-step reasoning improves accuracy
    • Apply chain-of-thought to multi-step problems
    • Know when reasoning models make explicit chain-of-thought unnecessary
  3. 3.3 Structured Output and JSON Mode

    16 minutes
    • Request reliable JSON output using schemas
    • Use structured output features to enforce field types
    • Parse and validate model responses in code
  4. 3.4 Prompt Decomposition and Chaining

    15 minutes
    • Break a complex task into a sequence of focused prompts
    • Pass the output of one prompt as input to the next
    • Decide when chaining beats a single large prompt

4. Retrieval and Grounding

4 lessons

  1. 4.1 Retrieval-Augmented Generation Concepts

    14 minutes
    • Explain why RAG grounds responses in external knowledge
    • Describe the retrieve-then-generate pattern
    • Identify when RAG solves knowledge and freshness gaps
  2. 4.2 Chunking and Indexing Documents

    15 minutes
    • Explain why documents are split into chunks for retrieval
    • Choose chunk size and overlap for good recall
    • Embed and index chunks in a vector store
  3. 4.3 Building RAG Prompts

    15 minutes
    • Insert retrieved context into a prompt with clear boundaries
    • Instruct the model to answer only from provided context
    • Add citations so answers are traceable to sources
  4. 4.4 Evaluating Retrieval Quality

    15 minutes
    • Measure retrieval quality with recall and precision at k
    • Diagnose whether errors come from retrieval or generation
    • Iterate on chunking and query strategies to improve grounding

5. Tools and Agents

4 lessons

  1. 5.1 Introduction to Tool Calling

    14 minutes
    • Explain how models call external functions to take actions
    • Describe the request, tool call, and result cycle
    • Recognize tasks that require tools rather than pure generation
  2. 5.2 Defining Tool Schemas

    16 minutes
    • Write a JSON schema describing a tool's name, purpose, and parameters
    • Write descriptions that help the model choose tools correctly
    • Handle the tool result and return it to the model
  3. 5.3 Agentic Loops and Planning

    15 minutes
    • Explain how an agent plans, acts, observes, and repeats
    • Describe how multiple tools combine to complete a goal
    • Identify risks of loops such as runaway cost and errors
  4. 5.4 Model Context Protocol and Integrations

    15 minutes
    • Explain how the Model Context Protocol standardizes tool integrations
    • Describe connecting an assistant to external systems safely
    • Compare custom tools with standardized connectors

6. Evaluation and Security

5 lessons

  1. 6.1 Prompt Injection and Attacks

    15 minutes
    • Explain how prompt injection hijacks model instructions
    • Distinguish direct from indirect injection through retrieved content
    • Recognize data exfiltration and jailbreak patterns
  2. 6.2 Defending Against Injection

    16 minutes
    • Apply input separation and trust boundaries to reduce injection risk
    • Constrain tool permissions and validate model actions
    • Add output filtering and human confirmation for sensitive steps
  3. 6.3 Evaluating and Iterating on Prompts

    16 minutes
    • Build a test set of inputs with expected outputs
    • Compare prompt variants systematically instead of by intuition
    • Use automated evals to catch regressions
  4. 6.4 Building a Production Prompt System

    17 minutes
    • Combine templates, retrieval, tools, and evals into one system
    • Add logging, versioning, and monitoring for prompts in production
    • Design a feedback loop to improve prompts over time
  5. 6.5 Controlling Cost and Latency in Prompt Systems

    16 minutes
    • Estimate token cost for a prompt and its expected completion
    • Apply techniques like prompt compression, caching, and model routing to reduce cost
    • Balance quality, latency, and spend when choosing a model tier