Beginner

Prompting Basics

A prompt is how you communicate with Claude. Learn to structure your prompts for clear, accurate, and useful responses every time.

What is a Prompt?

A prompt is the text you send to Claude — your question, instruction, or request. The quality of Claude's response is directly tied to the quality of your prompt. A well-structured prompt leads to a focused, relevant answer. A vague prompt leads to a generic one.

Prompt engineering is the practice of crafting prompts that consistently produce the results you want. It is not about tricks or hacks — it is about clear communication.

Prompt Structure

Effective prompts typically include some or all of these four components:

Prompt Anatomy
1. INSTRUCTION - What you want Claude to do
   "Summarize the following article..."
   "Write a Python function that..."
   "Analyze this data and identify..."

2. CONTEXT - Background information Claude needs
   "I'm building a React app for a restaurant..."
   "The audience is high school students..."
   "Here is the error log: [paste log]"

3. EXAMPLES - Show Claude the pattern you want
   "Input: 'hello' -> Output: 'HELLO'"
   "For example: ... "

4. OUTPUT FORMAT - How you want the response
   "Return as JSON"
   "Use bullet points"
   "Respond in exactly 3 sentences"

Not every prompt needs all four. A simple question might only need the instruction. A complex task benefits from all four.

Clear and Specific Instructions

The most important skill in prompting is being clear and specific. Compare these examples:

Vague vs. Specific
// VAGUE - Claude has to guess what you want
Help me with my essay.

// SPECIFIC - Claude knows exactly what to do
Review my essay introduction (pasted below) and:
1. Check for grammatical errors
2. Suggest ways to make the opening hook stronger
3. Evaluate whether the thesis statement is clear
4. Keep your feedback concise - use bullet points

Essay introduction:
[paste text here]
Another Comparison
// VAGUE
Write some code for a todo app.

// SPECIFIC
Write a REST API endpoint in Express.js that:
- Accepts POST requests to /api/todos
- Validates that "title" (string, required) and
  "priority" (number 1-5, optional, default 3)
  are present in the request body
- Returns 201 with the created todo object
- Returns 400 with error details for invalid input
- Use TypeScript types for the request and response
Rule of thumb: If another human would need to ask you clarifying questions to do the task, your prompt probably needs more detail. Imagine delegating the task to a capable colleague who has never seen your project.

Using Examples (Few-Shot Prompting)

Few-shot prompting means showing Claude a few examples of what you want before asking it to do the task. This is one of the most effective prompting techniques.

Few-Shot Example: Text Classification
Classify each customer review as positive, negative,
or neutral.

Examples:

Review: "This product changed my life! Absolutely love it."
Classification: positive

Review: "It arrived broken and customer support was unhelpful."
Classification: negative

Review: "It works fine. Nothing special but does the job."
Classification: neutral

Now classify this review:

Review: "Decent quality for the price. Shipping was slow
but the product itself is okay."
Classification:

Claude learns the pattern from your examples and applies it to new inputs. The more consistent your examples, the more consistent Claude's output.

Few-Shot Example: Data Transformation
Convert natural language dates to ISO 8601 format.

Examples:
"January 5th, 2024" -> "2024-01-05"
"Dec 25 2023" -> "2023-12-25"
"3/15/2024" -> "2024-03-15"

Now convert:
"February 28th, 2025" ->

Asking for Structured Output

Claude can produce output in virtually any format. You just need to ask clearly.

JSON Output

JSON Output Prompt
Extract the following information from this business
card text and return it as JSON:

Text: "Jane Smith, Senior Developer at TechCorp.
Email: jane@techcorp.com, Phone: (555) 123-4567
LinkedIn: linkedin.com/in/janesmith"

Return JSON with these fields:
name, title, company, email, phone, linkedin

Claude's response:
{
  "name": "Jane Smith",
  "title": "Senior Developer",
  "company": "TechCorp",
  "email": "jane@techcorp.com",
  "phone": "(555) 123-4567",
  "linkedin": "linkedin.com/in/janesmith"
}

Markdown Output

Markdown Output Prompt
Create a comparison of React vs Vue.js.
Format as a markdown table with these columns:
Feature | React | Vue.js

Include rows for:
- Learning curve
- Performance
- Community size
- TypeScript support
- State management

List Output

List Output Prompt
List 5 ways to improve website performance.
For each item, provide:
- A clear title
- A one-sentence explanation
- The expected impact (high/medium/low)

Format as a numbered list.

Common Beginner Mistakes

Avoid these common pitfalls when writing prompts:

1. Being Too Vague

Problem: "Write something about marketing." This gives Claude no direction on length, format, audience, or topic depth. You will get a generic response.

2. Overloading a Single Prompt

Problem: Asking Claude to do 10 different things in one message. Break complex tasks into smaller, focused prompts for better results.

3. Not Providing Examples

Problem: Expecting Claude to guess your preferred format. If you want output in a specific style, show one or two examples of what you expect.

4. Ignoring Context

Problem: "Fix this code" without explaining what it should do, what language it is in, or what the error is. Always provide enough context for Claude to understand the situation.

5. Not Iterating

💡
Solution: Your first prompt does not need to be perfect. Send it, evaluate the response, and refine. Tell Claude "Make it more concise" or "Focus on section 3" or "Add more technical detail." Iteration is normal and effective.

Prompt Templates

Here are reusable templates for common tasks:

Template: Code Review
Review the following [language] code for:
1. Bugs and potential errors
2. Performance issues
3. Security vulnerabilities
4. Code style and readability
5. Suggestions for improvement

Code:
[paste your code here]

Provide your review as a numbered list with
severity levels (critical/warning/suggestion).
Template: Content Writing
Write a [type of content] about [topic].

Audience: [who will read this]
Tone: [formal/casual/technical/friendly]
Length: [word count or section count]
Key points to cover:
- [point 1]
- [point 2]
- [point 3]

Format: [paragraphs/bullet points/sections with headers]
Template: Data Analysis
Analyze the following data:

[paste data here]

Please:
1. Summarize the key trends
2. Identify any anomalies or outliers
3. Provide 3 actionable insights
4. Suggest what additional data would be
   helpful for deeper analysis

Present findings in a clear, non-technical summary.

✎ Try It: Write a Structured Prompt

Practice writing a prompt that includes all four components: instruction, context, an example, and output format. Use the text area below.