Header-Body-Footer Prompt Pattern
Consistent prompt structure that scales to complex multi-task prompts.
Prompts as Documents
Long-form documents — reports, articles, emails — use a Header/Body/Footer structure because it is cognitively easy to navigate. Readers know what to expect in each zone.
The same principle applies to prompts. When prompts grow beyond a few sentences, a Header/Body/Footer structure makes them scannable, maintainable, and consistent.
This pattern works across models and scales from simple to highly complex prompts.
The Header Section
The Header answers two questions: Who are you? and What is the task?
It sets the model's identity (persona or role) and states the primary goal of the prompt. Everything else builds on this foundation.
A strong header is concise — typically 2-4 sentences. It does not include examples, constraints, or output rules.
header = '''
<header>
You are an expert technical writer specializing in API documentation.
Your task is to write clear, developer-friendly documentation
for the API endpoint described in the body of this prompt.
</header>
'''
print(header)All lessons in this course
- Using XML Tags as Delimiters
- Modular Prompt Sections
- Header-Body-Footer Prompt Pattern
- Prompt Organization Best Practices