Prompt Engineering Tutorial 0/120 lessons ~6 min read Lesson 23
Structured Prompts
A structured prompt uses clear sections (role, task, context, examples, format) separated by delimiters.
Course progress0%
Focus
6 guided sections
Practice signal
Examples included
Career prep
Foundation builder
Introduction
A structured prompt uses clear sections (role, task, context, examples, format) separated by delimiters. It's how you build prompts that are testable, editable and extensible.
Beginner analogy: Like a form with labelled fields vs a blank piece of paper. Forms are predictable, scalable and easy to edit.
Understanding the topic
Core concepts to understand:
- Sections: role, task, context, examples, constraints, format, query.
- Delimiters: XML tags, ###, triple backticks.
- Each section is editable without touching the others.
- Easier to A/B test — change one section, measure impact.
Syntax reference
Visual workflow / architecture:
bash
<role>You are a code reviewer.</role><task>Review this Python function.</task><context>{code}</context><format>JSON: [{line, severity, fix}]</format><query>Begin.</query>
Real-world use
Cursor, Claude Projects and OpenAI Assistants all internally use structured prompts to keep features stable as they evolve.
Best practices
- Use XML tags on Claude (it was trained to respect them).
- Keep section order consistent across a prompt library.
- Add a /* version */ comment to track changes.
Hands-on exercise
Interview preparation — practice these questions:
- Q1. Why use structured prompts?
- Q2. Why does Claude prefer XML delimiters?
- Q3. How does structure help A/B testing prompts?
- Q4. Where do you store structured prompt templates?
Ready to mark this lesson complete?Track your journey across the entire course.