Prompt Engineering
About 5 minutes
Prompt engineering is the practice of designing instructions for generative AI so it is more likely to produce the expected answer. OpenAI’s API documentation treats instructions, input messages, tools, and output formats as controllable parts of model interaction.[1]
Why Prompt Engineering Matters
Section titled “Why Prompt Engineering Matters”Generative AI decides what to return based on the text it receives. If the instruction is vague, the AI guesses the goal, audience, and assumptions. When that guess is wrong, the answer may be too long, too shallow, in the wrong format, or missing an important constraint.
A prompt is like a work request. Humans do better when a request includes the goal, deliverable format, and cautions. Generative AI behaves similarly.
Basic Elements of a Good Prompt
Section titled “Basic Elements of a Good Prompt”| Element | Explanation | Example |
|---|---|---|
| Role | The viewpoint expected from the AI | Explain as a beginner-friendly technical teacher |
| Goal | What should be achieved | Understand the overview of MCP |
| Audience | Who the answer is for | For someone without programming experience |
| Constraints | Conditions to follow | Explain every technical term |
| Materials | Information to reference | Summarize the meeting notes below |
| Output format | Shape of the answer | Compare in a table |
Bad Example and Better Example
Section titled “Bad Example and Better Example”Bad Example
Section titled “Bad Example”Tell me about AI agents.This can produce an answer, but the depth, length, reader level, and viewpoint are unclear.
Better Example
Section titled “Better Example”You are a beginner-friendly AI teacher.
Explain what an AI agent is for someone without programming experience.
Conditions:
- Start with a one-sentence definition
- Include an everyday analogy
- Compare it with a traditional chatbot in a table
- End with three key pointsThis prompt clarifies the role, audience, output format, and constraints. The AI has less to guess, so the answer becomes more stable.
Common Prompt Patterns
Section titled “Common Prompt Patterns”1. Specify a Role
Section titled “1. Specify a Role”You are a web engineer with security expertise.
Check whether the following code has XSS risk.A role helps the AI prioritize the right viewpoint.
2. Specify the Output Format
Section titled “2. Specify the Output Format”Compare the following three tools.
Use a table with "Use case / Strengths / Cautions".An output format makes the answer easier to read and reuse.
3. Provide an Example
Section titled “3. Provide an Example”Match the style of the following sentence and write a similar explanation.
Example:
"First grasp the big picture, then try a small example."An example shows the AI what kind of output is expected.
4. State Constraints
Section titled “4. State Constraints”Conditions:
- Do not state uncertain information as fact
- Mark places that need external confirmation as "Needs verification"
- Keep the answer within 300 charactersConstraints are quality guardrails.
Limits of Prompt Engineering
Section titled “Limits of Prompt Engineering”Some problems cannot be solved with prompts alone.
- The AI does not have the needed documents
- Long conversations cause important assumptions to be lost
- External tools are unavailable
- No system verifies whether the answer is correct
- Multi-step work state cannot be managed
These limits are why context engineering and harness engineering matter.
Summary
Section titled “Summary”- Prompt engineering designs instructions for AI
- Role, goal, audience, constraints, materials, and output format make answers more stable
- Prompts are important, but they do not manage documents, tools, or verification by themselves
- Practical AI work is moving from prompt-only design to context and harness design
Frequently Asked Questions
Section titled “Frequently Asked Questions”Q: Are longer prompts always better?
A: No. The important point is organized information. A long prompt with contradictions can reduce quality.
Q: Is “think step by step” still useful?
A: Sometimes. For complex tasks, it is usually better to state the goal, constraints, and expected output clearly than to rely on a single phrase.
Q: Are prompt templates enough?
A: They help with routine tasks, but tasks involving documents, tools, or verification need more than templates.
References
Section titled “References”- OpenAI, OpenAI API documentation