Prompt Engineering Basics
Fundamentals of prompting
A prompt is a text instruction you send to a language model. The quality of the prompt directly affects the quality of the response. A good prompt clearly formulates the task, provides necessary context, and specifies the desired output format.
The more specific the prompt, the better the result. Instead of "write text" specify: topic, length, style, audience, format. The model can't read minds — everything important must be in the prompt.
It's rare to write a perfect prompt on the first try. Start with a simple version, evaluate the result, identify issues, and improve the prompt. Repeat until the result meets expectations.
Test prompts on different inputs. A prompt that works for one example may give poor results for others. Create a set of test cases and verify against them.
Iterative Prompt Improvement
Good prompts are created through iterations
Write about dogs.
Quick Tips
Key Principles
- • Start simple, add complexity as needed
- • Test on different examples
- • Analyze errors and improve
- • Save prompts that work
- • Be specific about expectations
- ❌Too vague:"Help me with code"
- ❌No context:"What's wrong here?" (no code)
- ❌Contradicting instructions:"Be brief, but describe everything in detail"
- ❌Expecting mind reading:No requirements for format, style, length
- ✓Specify role:"You are an experienced Python developer..."
- ✓Provide context:"In the context of a React web application..."
- ✓Specify format:"Respond in bullet point format"
- ✓Give examples:"For example: input → output"
[ROLE] — Who the model should be You are a [role] with expertise in [domain]. [CONTEXT] — Background information Context: [relevant information about the situation] [TASK] — What needs to be done Task: [clear task description] [FORMAT] — How the response should look Response format: - [requirement 1] - [requirement 2] [CONSTRAINTS] — What to avoid Constraints: - Don't [constraint 1] - Don't [constraint 2]
Try it yourself
Interactive demo of this technique
Get a dinner recipe
Here is a pancake recipe:
Ingredients: flour, eggs, milk, sugar, salt, oil.
Mix ingredients, fry in a pan.
Pasta Aglio e Olio (2 servings, 20 min)
Ingredients:
- Spaghetti — 200g
- Garlic — 4 cloves
- Olive oil — 60ml
- Chili pepper — 1 pc
- Parsley — 15g
- Salt — to taste
Steps:
- Cook spaghetti al dente (8 min).
- Slice garlic thinly.
- Sauté garlic and chili in olive oil on low heat (3 min).
- Add spaghetti + 50ml pasta water. Toss (2 min).
- Garnish with parsley. Serve immediately.
A one-word prompt is a lottery. Adding context (for whom), constraints (time, diet), and format (response structure), we get predictably useful results.
Lesson Quiz
1.Why is being specific and clear in prompts important for getting good results?
Create a free account to solve challenges
4 AI-verified challenges for this lesson
This lesson is part of a structured LLM course.
My Learning Path