Prompt Engineering Lab
Build better prompts with the interactive builder, browse ready-to-use templates, and study before/after transformations that show what makes a great prompt.
Prompt Builder
Great prompts follow a layered structure. The 6-layer framework helps you write prompts that get consistent, high-quality results from Claude every time.
Build Your Prompt
Who should the AI act as? (e.g., 'You are an expert Python developer')
What background information does the AI need?
What specific task should the AI perform?
What rules or limitations should the AI follow?
How should the output be structured?
Provide example input/output pairs to guide the AI.
Live Preview
Template Library
Ready-to-use prompt templates. Click any template to copy it, then customize the bracketed placeholders for your use case.
Debug This Error
DebuggingIdentify root cause, explain why it happens, and provide the fix.
Code Review
CodingReview code for security, performance, style, and edge cases.
Write Tests
CodingWrite comprehensive tests covering happy path, edge cases, and errors.
Explain This Code
CodingBreak down complex code with line-by-line explanation.
Refactor for Readability
CodingImprove code structure while maintaining functionality.
Design a REST API
CodingDesign RESTful API endpoints with request/response schemas.
Write a Blog Post
WritingStructured blog post with hook, sections, and actionable conclusion.
Write Technical Documentation
WritingClear technical docs with examples, parameters, and edge cases.
Draft a Professional Email
WritingCraft a clear, professional email with the right tone.
Write Commit Messages
WritingGenerate conventional commit messages from a diff.
Analyze This Data
AnalysisExtract insights, patterns, and actionable recommendations from data.
Compare Technical Options
AnalysisSide-by-side comparison of technical choices with recommendation.
Architecture Review
AnalysisEvaluate system architecture for scalability and reliability.
Root Cause Analysis
DebuggingSystematic investigation to find the real source of a bug.
Performance Debugging
DebuggingIdentify and fix performance bottlenecks in code.
Fix This Regex
DebuggingDebug and explain regex patterns with test cases.
Claude Code Task Prompt
Claude CodeStructure a complex task for Claude Code to execute.
Write a CLAUDE.md
Claude CodeGenerate a project-specific CLAUDE.md for Claude Code.
PR Review Assistant
Claude CodeUse Claude Code to review a pull request thoroughly.
Create Migration Guide
Claude CodePlan and execute a codebase migration step by step.
Security Audit
AnalysisScan code for common security vulnerabilities.
Convert Between Languages
CodingTranslate code from one language to another idiomatically.
Before / After Gallery
See how vague prompts become powerful ones. Each pair shows the transformation with an explanation of what makes the improved version work.
fix my code
Debug this Python function that should return the sum of even numbers in a list but returns 0 for [2, 4, 6]. Here's the code:
def sum_evens(nums):
total = 0
for n in nums:
if n % 2 == 0:
total += n
return totalThe good prompt specifies the language, the expected vs actual behavior, provides a concrete failing input, and includes the code. Claude can immediately identify that the return is inside the loop.
write a blog post
Write a 1200-word blog post about React Server Components for mid-level frontend developers. Tone: conversational but technical. Structure: intro hook with a pain point, 3 sections with descriptive subheadings, 2 code examples showing before/after, actionable conclusion with next steps.
The good prompt defines topic, audience, length, tone, structure, and concrete deliverables. This eliminates multiple rounds of revision.
explain kubernetes
Explain Kubernetes to a backend developer who uses Docker but hasn't worked with orchestration. Cover: what problems it solves, core concepts (pods, services, deployments), and a minimal example of deploying a Node.js app. Skip the history and comparison with Docker Swarm.
The good prompt establishes the reader's existing knowledge, scopes what to cover AND what to skip, and asks for a practical example. This avoids a generic Wikipedia-style answer.
write tests for my function
Write Jest tests for this TypeScript function that validates email addresses. Cover: valid emails (user@domain.com), edge cases (plus addressing, subdomains), and invalid inputs (missing @, spaces, empty string). Use describe/it blocks with clear test names.
export function isValidEmail(email: string): boolean { ... }The good prompt specifies the testing framework, language, types of test cases, and preferred test structure. It also provides the function signature for context.
review this code
Review this Express.js authentication middleware for: 1) Security vulnerabilities (especially JWT handling) 2) Error cases that return 500 instead of proper status codes 3) Race conditions with the database call. The code handles ~10K requests/minute in production.
The good prompt focuses the review on specific concerns, mentions the technology stack, and provides production context (scale) that affects the recommendations.
write me a SQL query
Write a PostgreSQL query to find the top 10 customers by total order value in the last 30 days. Tables: customers (id, name, email), orders (id, customer_id, total, created_at). Include customers with no orders as $0. Format the output as: name, email, total_spent (descending).
The good prompt specifies the database, the exact result needed, provides the schema, handles the edge case (no orders), and defines the output format and sort order.
make this code better
Refactor this React component to: 1) Extract the fetch logic into a custom hook 2) Replace the nested ternaries with early returns 3) Add proper TypeScript types (currently using 'any' in 4 places) 4) Memoize the expensive filter operation. Keep the component's behavior identical.
The good prompt lists specific refactoring targets, explains what to preserve, and calls out exact issues. 'Make it better' could mean anything; this is actionable.
help me deploy my app
Create a GitHub Actions workflow to deploy a Next.js 14 app to AWS EC2. Requirements: run on push to main, build with Node 20, run tests first, SSH deploy to ec2-user@my-server, use PM2 for process management, send Slack notification on success/failure. Our secrets are in GitHub Secrets.
The good prompt specifies the CI/CD platform, framework, infrastructure, Node version, deployment method, process manager, and notification requirements. Every choice is made explicit.
write a regex for phone numbers
Write a JavaScript regex to validate US phone numbers. Must accept: (123) 456-7890, 123-456-7890, 123.456.7890, 1234567890, +1 123 456 7890. Must reject: 123-45-6789 (too few digits), letters, numbers with country codes other than +1. Return named capture groups for area code, prefix, and line number.
The good prompt lists exact formats to match and reject, specifies the language (JS regex flavor matters), and asks for capture groups. This eliminates guesswork about edge cases.