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:
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 - 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]
// 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
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.
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.
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
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
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 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
2. Overloading a Single Prompt
3. Not Providing Examples
4. Ignoring Context
5. Not Iterating
Prompt Templates
Here are reusable templates for common tasks:
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).
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]
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.
Lilly Tech Systems