Prompt Engineering
Beginner
Anatomy of an Effective Prompt
Build prompts with identity, instructions, context, examples, constraints, and output contracts.
25 min
3 sections
structure
instructions
contracts
1
2
3
01. Use clear sections
Section 1 of 3
Models handle complex tasks better when logical boundaries are explicit. Use headings for major sections and tags for variable data such as files, tickets, logs, database rows, or user messages. This also makes prompts easier for humans to review.
markdown
# Identity
You are a senior frontend engineer reviewing React code.
# Task
Find correctness, accessibility, and maintainability issues.
# Rules
- Prioritize bugs over style.
- Cite exact files and lines when available.
- Do not suggest rewrites unless needed for correctness.
# Output
Return JSON with fields: summary, findings, test_gaps.
<pull_request>
...
</pull_request>Back to Course