Prompt Engineering: How to Write Good Prompts
Briefly
Prompt engineering is the skill of formulating queries so that the model provides accurate, useful, and predictable responses.
What is It
A prompt is not a "question" but an instruction. A good prompt describes:
- who you are;
- what needs to be done;
- in what format;
- what should not be done.
Basic Formula
Role + Context + Task + Format + Constraints
Example:
You are a technical editor.
Write an explanation of the term 'token'.
Format: a short paragraph and one example.
Do not use complex formulas.
Main Principles
1. Give a Role
You are an experienced Python developer.
The role helps the model choose the right style.
2. Add Context
I am writing an article for beginners.
Without context, the model responds "on average".
3. Specify Format
Answer in a list of 5 points.
Or:
Provide the answer in JSON format.
4. Show Examples
Several examples work better than any explanation. More details in the article Few-shot prompting.
5. Limit Excess
Do not use water.
Do not make up facts.
Useful Techniques
- Chain-of-Thought — "think step by step";
- Few-shot — show 2–3 examples;
- System Prompt — set general rules;
- Temperature — control creativity.
How to Improve a Prompt
- Write the first version.
- Look at the response.
- Clarify the role, format, or constraints.
- Repeat.
A good prompt is the result of several iterations.