Expert Prompts

Expert Prompts

Real prompts from production development. Copy, adapt, and use.

These aren't templates—they're actual prompts that work. The key is understanding WHY they work so you can adapt them.

The Master Prompt

This single prompt sets up an entire development session:

🎯 Session Initialization
# Read and understand user rules, research each for complete understanding

# Ask me any clarifying questions (hallucination avoidance)

# Make todos of all tasks, use high IQ strategy for safety and 
# correctness as you create and order each, add todos for testing 
# of all code changes and additions, research documentation and 
# best practices online, don't start yet
Why it works: This prompt establishes context, prevents hallucination through clarifying questions, and creates a structured plan BEFORE any code is written.
🚀 Execution Prompt
# Continue todos, do each comprehensively and in highest IQ way possible

# Build test and write AND run test scripts then fix and repeat 
# process of writing tests and running them until all tests pass

# Short commit message once individual todos are complete and proceed
Why it works: This separates planning (above) from execution (this prompt). Forces test-driven approach and incremental commits.

Safe Refactoring Guide

When moving code between files, follow this exact sequence:

🔄 Safe Refactoring Steps
SAFE REFACTORING GUIDE:

0. Comment out code on original file first
1. Split large classes into smaller, focused class files
2. Copy code verbatim - Don't modify logic when moving to new files
3. Extract logical groups - Move related functions/components together
4. Use proper exports/imports - Maintain all references between files
5. Keep dependencies intact - Ensure imports are accessible to new files
6. Test frequently - Verify functionality after each extraction
Why it works: Step 0 (commenting first) is crucial—it lets you quickly restore if something breaks. Never delete until the refactor is proven.

Prompt Patterns by Task

Feature Development

New Feature Setup
I need to implement [FEATURE].

1. First, read these files to understand current implementation:
   - [file1]
   - [file2]

2. Research the documentation for [LIBRARY/API]

3. Create a plan with:
   - Files to create/modify
   - Tests to write
   - Edge cases to handle

4. Don't write code yet - just the plan.
Why it works: Separates planning from implementation. AI often rushes to code—this forces thinking first.
Implementation with Tests
Now implement [FEATURE] following the plan.

Requirements:
- Write the test file FIRST
- Then implement to make tests pass
- Each function should do ONE thing
- No external dependencies unless absolutely necessary
- Add error handling for: [list edge cases]

After each file, run: npm run test
Why it works: Enforces TDD and single responsibility. Explicit test running creates feedback loop.

Anti-Pattern Prompts

Things that DON'T work:

BadGood
"Add authentication" — No context about stack, existing patterns, or constraints"Add email/password auth using NextAuth.js to our Next.js 14 app. Use existing User model in schema.prisma."
"Build me a complete e-commerce site with cart, checkout, payments, and admin panel" — AI will make assumptions and miss details"Step 1: Create product schema. Step 2: Add cart API. Step 3: Build checkout flow..."
"Make this faster" — Faster how? At what cost?"Optimize this query. Target: < 100ms. Constraint: No schema changes. Current: 2s."

The Prompt Formula

Every effective prompt follows this structure:

[CONTEXT] + [TASK] + [CONSTRAINTS] + [OUTPUT FORMAT]

Example Breakdown

CONTEXT:     "We have a Next.js 14 app with Prisma and PostgreSQL."
TASK:        "Add rate limiting to the /api/auth endpoints."
CONSTRAINTS: "Use Redis. Max 5 attempts per minute per IP. No external libraries."
OUTPUT:      "Provide the middleware code and explain the implementation."

Quick Reference

SituationKey Phrase
Prevent hallucination"Ask me clarifying questions first"
Force planning"Don't write code yet - just the plan"
Ensure testing"Write the test FIRST, then implement"
Safe refactoring"Comment out before moving"
Root cause analysis"Explain WHY, don't just fix"
Current practices"Research best practices for 2024"

"A good prompt is worth a thousand iterations."