Prompt Engineering Basics: Write Instructions That Work
A practical five-part prompt framework—role, task, context, format, constraints—with templates, failure patterns, and reusable scenarios.

What “prompt engineering” actually means
A prompt is the instruction and context you send to ChatGPT. Engineering it means making the request executable: clear goal, explicit constraints, and a checkable output. On ChatGPT or via the OpenAI API, better prompts often beat blindly switching models.
The five-part framework
- Role — who should the model act as?
- Task — what verb: summarize, rewrite, compare, generate?
- Context — audience, background, source material, business rules
- Format — Markdown, table, JSON, numbered steps
- Constraints — length, tone, bans, required coverage
Template
You are a science writer for non-technical readers.
Task: Explain what a vector database is and how it differs from a regular database.
Audience: junior product managers.
Format: 80-word summary, then three short sections, then one everyday analogy.
Constraints: Avoid jargon piles; when a term is required, define it in parentheses; do not invent market-share numbers.
Advanced techniques
Few-shot examples
Show 1–3 input/output pairs before the real task—great for titles, support macros, or extraction.
Stepwise reasoning for hard problems
Ask for steps before the final answer to reduce skipped logic. Still verify; steps are not a correctness guarantee.
Structured outputs
Return JSON only with fields title, summary, tags (array), risk_level (low|mid|high). No extra prose.
Iterate on purpose
Skeleton → details → tone pass. Treat the model as a co-editor, not a one-click oracle.
Weak vs strong prompts
| Weak prompt | Problem | Fix |
|---|---|---|
| “Write something” | No goal | Specify genre, length, use |
| “Make it more professional” | Vague bar | Define reader and jargon level |
| “Use the latest online news” | Hallucination risk | Paste verified sources; mark uncertainty |
| “Think with the strongest model” | Empty instruction | Provide scoring criteria and must-cover points |
Reusable scenarios
- Meeting notes → table of decisions / owners / due dates
- Code review → correctness, readability, performance, security
- Learning plan → level, weekly hours, 4-week milestones and acceptance checks
API connection
The web UI is for exploration; production pipelines belong on platform.openai.com with Docs. Freeze winning prompts as system + user templates with version control.
Practice
Upgrade “Please improve this product blurb” into a five-part prompt that returns: diagnosis, three rewrites (formal / friendly / concise), and a recommendation with reasons.
Takeaway
A good prompt is a mini specification. Write the five parts, iterate on evidence, and verify facts yourself. Continue with Effective Asking and the Latest Model Guide.
Related
GPT-4 / Latest Model Guide: How to Choose and Use
A durable framework for picking ChatGPT and API models by task difficulty, format needs, latency, and cost—not by marketing names alone.
Effective Asking: Get Better Answers in Fewer Turns
Goal framing, follow-up tactics, and a quality checklist to raise ChatGPT hit rate and cut wasted conversation loops.