Prompt Templates
You are about to implement a new API endpoint. You open Cursor and type: “Add a POST endpoint for creating orders.” Agent generates something, but it misses validation, uses the wrong error format, and does not follow your existing patterns. So you spend the next five messages correcting it: “add Zod validation,” “use our error format,” “follow the pattern in users.ts.” By message six, you have typed more corrective instructions than it would have taken to write the endpoint yourself.
The fix is not better prompting intuition. It is prompt templates — pre-built, tested prompts that you paste and customize in seconds. They front-load the instructions the AI needs so the first output is usable.
What You’ll Walk Away With
Section titled “What You’ll Walk Away With”- A library of copy-paste prompts for the most common development tasks
- A framework for building your own project-specific prompt templates
- Techniques for storing prompts as Cursor rules and custom commands
- Understanding of what makes a prompt effective versus wasteful
What Makes a Good Prompt Template
Section titled “What Makes a Good Prompt Template”An effective Cursor prompt has four elements:
- The task — What you want the AI to do
- The constraints — What patterns, files, or conventions to follow
- The boundaries — What NOT to do (prevents scope creep)
- The verification — How to confirm the output is correct
Feature Implementation Templates
Section titled “Feature Implementation Templates”New API Endpoint
Section titled “New API Endpoint”New React Component
Section titled “New React Component”Database Migration
Section titled “Database Migration”Debugging Templates
Section titled “Debugging Templates”General Bug Investigation
Section titled “General Bug Investigation”Performance Investigation
Section titled “Performance Investigation”Refactoring Templates
Section titled “Refactoring Templates”Extract and Restructure
Section titled “Extract and Restructure”Testing Templates
Section titled “Testing Templates”Test Suite Generation
Section titled “Test Suite Generation”Code Review Template
Section titled “Code Review Template”Storing Templates as Rules and Commands
Section titled “Storing Templates as Rules and Commands”As a Custom Command
Section titled “As a Custom Command”Save frequently used prompts as custom commands in .cursor/commands/:
---description: Generate a comprehensive test suite for a service---
Write a comprehensive test suite for the file I mention.
- Use Vitest- Mock external dependencies- Cover happy path, error cases, and edge cases- Use factory functions for test data- Run tests after writing themInvoke with /generate-tests @src/services/payment-service.ts in chat.
As a Rule
Section titled “As a Rule”For patterns that should always apply to certain file types:
---globs: "src/routes/**/*.ts"---
When creating or modifying API routes:- Always validate request bodies with Zod- Always use withAuth middleware unless the route is explicitly public- Always return errors using AppError from @src/lib/errors.ts- Always log the request and response using the loggerWhen This Breaks
Section titled “When This Breaks”Templates produce output that does not match your project. The template references patterns from a generic project. Update the @file references to point to your actual canonical examples.
Agent ignores parts of the template. Very long prompts (over 500 words) cause the agent to lose focus on later instructions. Move recurring constraints into rules so the prompt only contains task-specific information.
Templates feel rigid. They are starting points, not scripts. Delete the parts that do not apply and add context specific to the current task.
What’s Next
Section titled “What’s Next”- Context Patterns — How to provide the right
@filereferences in your prompts - Debugging Workflows — Systematic debugging beyond the template level
- Testing Patterns — Deep dive into AI-assisted testing strategies