Skip to main content

AI Prompts That Actually Work

Prompts I use regularly with Cursor, Claude, and ChatGPT. Organized by task type.


Starting a project

Build a Next.js 14 app with TypeScript, Tailwind, and Shadcn.
Include: auth with NextAuth, Prisma + PostgreSQL, basic CRUD for [entity].
Start with the folder structure and schema, then implement step by step.
Scaffold a SaaS dashboard with sidebar nav and top bar using ShadCN components.
Pages needed: dashboard overview, [feature 1], [feature 2], settings.

Refactoring

Refactor this component to be cleaner.
Constraints: no new dependencies, keep the same interface, preserve all existing behavior.
Explain each change you make.
Split this file into smaller, reusable pieces.
Tell me what you'd separate and why before doing it.
This is getting complex. What's the simplest way to restructure this?

Debugging

Why is this useEffect running infinitely? Walk me through the dependency array.
Fix this TypeScript error: [paste error]
Explain what caused it and how to prevent it next time.
This component re-renders too often. Help me profile it and fix the cause.

Understanding unfamiliar code

Explain what this code does in plain language.
Then explain: what problem does it solve, what are its edge cases, what would break it.
I inherited this codebase. Walk me through the data flow from [entry point] to [output].

Code generation

Create a [component name] component.
Requirements: [list]
Props: [list]
Use TypeScript, Tailwind, and follow the existing patterns in [file path].
Write a Prisma schema for [domain].
Entities: [list with relationships].
Include: created_at, updated_at on all models. Use UUIDs for primary keys.

Testing

Write unit tests for this function using Vitest.
Cover: happy path, edge cases (null, empty, boundary values), and error cases.
Generate integration tests for this API endpoint.
Test: successful response, auth failure, validation error, not found.

My rules for prompting

  1. Give constraints upfront. "No new dependencies", "keep the same interface", "TypeScript strict mode" — saves back-and-forth.
  2. Ask for explanation alongside code. "Explain each change" produces better output and helps you review it.
  3. Start broad, then drill down. Ask for structure first, then implementation.
  4. Paste the actual error message. Not a paraphrase — the exact text.
  5. Specify the stack. Claude doesn't know you're using Tailwind v4 unless you say so.