beginner15 min read· Module 7, Lesson 1
📐Prompt Engineering Fundamentals
Write clear, effective prompts that get great results
Prompt Engineering — The Art of Asking
The quality of Claude's response depends entirely on how well you write your prompt. This is called prompt engineering.
The Golden Rules
- Be specific — Don't say "write code", say "write a TypeScript function that validates email addresses using regex"
- Give context — Tell Claude who it's helping and why
- Show examples — Give input/output examples of what you want
- Set constraints — Specify length, format, tone
- One task at a time — Break complex tasks into steps
Bad vs. Good Prompts
| Bad Prompt ❌ | Good Prompt ✅ |
|---|---|
| "Write a function" | "Write a TypeScript function called validateEmail that takes a string and returns a boolean" |
| "Summarize this" | "Summarize this article in exactly 3 bullet points, each under 20 words" |
| "Fix my code" | "This code throws 'TypeError: Cannot read property of undefined' on line 15. Here's the code: [paste code]" |
| "Write a blog post" | "Write a 500-word blog post about remote work tips. Tone: professional but friendly. Audience: young professionals." |
The CLEAR Framework
| Step | What to Do | Example |
|---|---|---|
| Context | Set the scene | "You are an expert Python developer..." |
| Length | Specify format/length | "...respond in exactly 5 bullet points..." |
| Examples | Show what you want | "...like this: Input: X → Output: Y..." |
| Ask clearly | State the exact task | "...now extract all email addresses from this text" |
| Refine | Add constraints | "...only include corporate emails, not personal ones" |
XML Tags for Structure
Claude works especially well with XML tags to organize your prompt:
<context>
You are a code reviewer for a TypeScript project.
</context>
<task>
Review the following code for:
1. Bugs and logic errors
2. Security vulnerabilities
3. Performance issues
</task>
<code>
function getUser(id) {
return db.query("SELECT * FROM users WHERE id = " + id);
}
</code>
<output_format>
For each issue, provide:
- Line number
- Issue type (bug/security/performance)
- Description
- Suggested fix
</output_format>
Few-Shot Prompting
Give Claude examples of what you want:
Convert these sentences to formal English:
Input: "gonna grab some food brb"
Output: "I am going to get something to eat. I will return shortly."
Input: "lol that's so funny ngl"
Output: "That is quite amusing, I must admit."
Input: "hey can u help me w this thing"
Output:
Chain of Thought
Ask Claude to think step by step:
Solve this problem step by step. Show your reasoning.
A store has a 30% off sale. An item originally costs $80.
If you also have a $10 coupon, what's the final price?
Prompt Chaining
Break complex tasks into a pipeline of simpler prompts:
Step 1: "Extract all company names from this article: [article]"
Step 2: "For each company, find their industry: [company list]"
Step 3: "Create a summary table: [company + industry data]"
Next up: Advanced prompt techniques and model-specific tips.