What is prompt engineering#
A prompt is the interface to a large language model. Prompt engineering designs that input so the model reliably produces high-quality output.
The four steps#
- Set the role: “You are a senior DBA”
- Provide context: background and constraints
- Specify format: “output as a table”, “answer in three steps”
- Give examples: one input-output pair (few-shot)
Comparison#
❌ “Write me a query”
✅ “You are a PostgreSQL expert. Table orders has user_id, amount, created_at. Write a SQL that sums spending per user last month, shown as a table.”
Common pitfalls#
- Overly long prompts dilute the key points
- Too many tasks in one request
- Ignoring output-format constraints
Summary#
Prompt engineering is not magic — it’s structured communication. State the requirement clearly and the model behaves far more consistently.

