Learning Center

Master the craft

Go beyond copy-paste. Learn the principles, patterns, and pitfalls of prompt engineering — so you can write your own instead of searching for someone else's.

Quick wins — instant prompt upgrades

Be specific about format

Do this
"Return a JSON object with keys: name, type, description"
Not this
"Give me the details"

Assign a role

Do this
"You are a senior React developer reviewing code for production"
Not this
"Help me with code"

Include constraints

Do this
"Use only standard library. No external dependencies. Max 50 lines."
Not this
"Write some code for this"

Fundamentals

The anatomy of a great prompt

Every effective AI prompt has five building blocks. You don't always need all five, but knowing them lets you diagnose why a prompt isn't working and fix it.

anatomy — structured prompt
Role
You are a senior TypeScript developer with 10 years of experience in React and Next.js.
Context
I'm building an e-commerce checkout flow. The cart state is managed with Zustand. We use Stripe for payments.
Task
Create a checkout summary component that displays line items, calculates totals with tax, and triggers the Stripe payment intent on submit.
Format
Return the component as a single TypeScript file. Include the Props interface. Use Tailwind CSS for styling.
Constraints
No external UI libraries. Handle loading and error states. Ensure the component is accessible (ARIA labels, keyboard navigation).
Vague prompt
Make me a checkout component for my website. It should look good and handle payments.
No role. No stack context. No format. "Look good" is not a spec.
Structured prompt
[Role] You are a senior TypeScript developer. [Context] I'm building a checkout with Zustand + Stripe. [Task] Create a checkout summary component with line items, tax, and Stripe payment. [Format] Single .tsx file, Tailwind CSS. [Constraints] No UI libs. Handle loading/error. ARIA-accessible.
All 5 parts present. Specific, actionable, constrained.

Patterns

5 prompt patterns that actually work

These aren't abstract ideas — they're battle-tested patterns you can use right now. Each one targets a specific type of AI interaction.

01

Role Assignment

Give the AI an identity

Assigning a specific role and expertise level dramatically improves output quality. The AI adjusts its vocabulary, assumptions, and depth based on the persona you give it.

Example prompt

You are a staff-level backend engineer who specializes in PostgreSQL performance tuning. You've optimized databases handling 10M+ rows and know EXPLAIN ANALYZE output intimately. Analyze this query and suggest index improvements: [PASTE QUERY]

Why it works: The "staff-level" and "10M+ rows" details tell the AI to skip beginner explanations and go deep. Specificity in the role produces specificity in the output.

02

Chain of Thought

Force step-by-step reasoning

For complex problems, asking the AI to think through steps before answering prevents it from jumping to conclusions. This pattern is especially powerful for debugging, architecture decisions, and math.

Example prompt

I have a race condition in my Node.js application. Before suggesting a fix: 1. First, identify all shared mutable state in this code 2. Then, trace the execution order under concurrent requests 3. Next, identify the exact lines where the race occurs 4. Finally, propose a fix using the minimal change needed Code: [PASTE CODE]

Why it works: The numbered steps force sequential reasoning. "Before suggesting a fix" prevents the AI from jumping straight to a solution without understanding the problem.

03

Few-Shot Examples

Show, don't just tell

Providing 2-3 examples of desired input/output teaches the AI your exact expectations — formatting, tone, level of detail, and naming conventions — far better than describing them in words.

Example prompt

Convert these user stories into technical tickets. Follow this exact format: Example input: "Users should be able to reset their password" Example output: **Title:** Implement password reset flow **Type:** Feature **Points:** 5 **Acceptance criteria:** - [ ] User can request reset via email - [ ] Token expires after 1 hour - [ ] New password must meet strength requirements Now convert these stories: [PASTE USER STORIES]

Why it works: The example encodes everything: the title format, type labels, point scale, and the checkbox style for acceptance criteria. One example is worth 100 words of instruction.

04

Output Formatting

Specify the exact shape

Telling the AI exactly how to structure its response — JSON, markdown tables, code blocks with file paths — eliminates the guesswork and makes outputs immediately usable without reformatting.

Example prompt

Review this React component for performance issues. Return your findings as a markdown table with these exact columns: | Line | Issue | Severity | Fix | Where: - Line = the line number(s) affected - Issue = one-sentence description - Severity = "critical", "warning", or "info" - Fix = the corrected code snippet Component: [PASTE COMPONENT]

Why it works: Specifying the table structure means you get scannable, structured output instead of rambling paragraphs. The severity levels ("critical/warning/info") force prioritization.

05

Constraint Setting

Define the boundaries

Constraints are what separate generic AI output from production-ready code. They prevent over-engineering, enforce team standards, and keep the AI focused on your actual needs.

Example prompt

Build a rate limiter middleware for Express. Constraints: - Use only Node.js built-in modules (no Redis, no external packages) - Must work in a single-process environment - Sliding window algorithm, not fixed window - Max 100 requests per IP per 15-minute window - Return 429 with Retry-After header when limited - Memory cleanup: evict expired entries every 60 seconds - TypeScript, strict mode - Under 80 lines of code

Why it works: "No external packages" prevents over-engineering. "Under 80 lines" forces simplicity. The specific algorithm choice (sliding window) eliminates ambiguity. Every constraint narrows the solution space toward what you actually need.

Anti-Patterns

4 mistakes that kill your output

Knowing what to avoid is half the battle. These are the most common patterns we see that lead to mediocre AI output.

Vague task description

✗ Bad
"Make this code better"
✓ Better
"Reduce the time complexity of this function from O(n²) to O(n log n) while keeping the same public API"

"Better" means different things — faster, more readable, shorter, more testable. Be surgical about what you want improved.

Missing context about your stack

✗ Bad
"Add authentication to my app"
✓ Better
"Add JWT authentication to my Express 5 / TypeScript API. We use Prisma with PostgreSQL. Auth tokens should be sent via httpOnly cookies, not localStorage."

Without stack context, the AI guesses — and often guesses wrong. Specifying your exact tools prevents incompatible suggestions.

Asking for everything at once

✗ Bad
"Build me a complete e-commerce platform with auth, payments, inventory, shipping, and admin dashboard"
✓ Better
"Build the product listing page. It fetches from GET /api/products (paginated, 20 per page) and displays cards with image, title, price. Use Next.js Server Components and Tailwind."

Large prompts produce shallow results. Break big tasks into focused chunks — one component, one endpoint, one feature at a time.

Not specifying what to skip

✗ Bad
"Write a login form component"
✓ Better
"Write a login form component. Skip: installation steps, project setup, imports for React itself. Include: form validation with Zod, error display, loading state, TypeScript types."

Telling the AI what NOT to include is just as important as what to include. It saves tokens and keeps the output focused on what you actually need.

vault — claim free prompts

Get 25 free prompts in your inbox

Production-ready templates. No spam. Unsubscribe anytime.

$

Ready to apply what you learned?

See these patterns in action

Our prompt library is built on exactly these patterns. Every prompt uses role assignment, formatting, and constraints — ready to copy and customize for your project.