Skip to main content

Cursor Prompt Templates

Copy-paste ready prompts optimized for Cursor's AI code editor. Perfect for Cmd+K edits and Chat conversations.

Quick Edits (Cmd+K)

Focused prompts for Cursor's inline edit feature

Add TypeScript Types

Editing

Add proper TypeScript types to untyped code

Add TypeScript types to this code. Infer types from usage patterns. Use interfaces for object shapes.
typescripttypesquick

Add Documentation Comments

Editing

Add JSDoc comments to functions and classes

Add JSDoc comments to all functions and classes. Include @param, @returns, and @example where appropriate.
documentationjsdoccomments

Add Input Validation

Editing

Add validation to function inputs

Add input validation to this function. Check for null/undefined, validate types, throw descriptive errors for invalid inputs.
validationerror handlingsafety

Add Error Handling

Editing

Wrap code in proper error handling

Add try-catch error handling. Log errors with context. Rethrow or return appropriate error responses.
errorstry-catchsafety

Feature Development

Prompts for implementing new features with Cursor Chat

Create React Component

Feature

Generate a new React component with proper structure

Create a React component for [DESCRIBE COMPONENT].

Requirements:
- TypeScript with proper prop types
- Tailwind CSS for styling
- Handle loading and error states
- Include basic accessibility (ARIA labels, keyboard nav)
- Follow the existing component patterns in @components

Export both the component and its prop types.
reactcomponentnew

Create API Endpoint

Feature

Generate a complete API route

Create an API endpoint for [DESCRIBE ENDPOINT].

Use the patterns from @api for:
- Request validation
- Error handling
- Response formatting

Include:
- TypeScript types for request/response
- Input validation with appropriate library
- Error responses with proper status codes
- Success response structure
apibackendroute

Create Custom Hook

Feature

Generate a reusable React hook

Create a custom React hook for [DESCRIBE FUNCTIONALITY].

Requirements:
- TypeScript with proper generics if needed
- Handle loading, error, and success states
- Return a clean interface
- Include cleanup in useEffect if needed
- Follow patterns from @hooks

Provide example usage in a comment.
reacthooksreusable

Refactoring

Prompts for improving existing code

Extract to Function

Refactoring

Extract logic into a reusable function

Extract the selected code into a well-named function. Add proper types, handle edge cases, and document with JSDoc.
extractfunctionreuse

Split Large Component

Refactoring

Break a component into smaller pieces

This component is too large. Split it into smaller, focused components:
1. Identify logical sections
2. Extract each into its own component
3. Pass props appropriately
4. Keep state in the right place
5. Maintain the same visual behavior
componentssplitorganization

Modernize Code

Refactoring

Update code to use modern patterns

Modernize this code:
- Replace class components with functional ones
- Use hooks instead of lifecycle methods
- Apply modern JavaScript features (optional chaining, nullish coalescing)
- Use async/await instead of .then chains
- Keep the same behavior
modernupdatepatterns

Debugging

Prompts for finding and fixing bugs

Fix This Error

Debugging

Debug and fix a specific error

Fix this error: [PASTE ERROR MESSAGE]

1. Identify the root cause
2. Explain why it's happening
3. Implement the fix
4. Add a comment explaining the fix
errorfixdebug

Trace Bug

Debugging

Find the source of unexpected behavior

Help me find why [DESCRIBE UNEXPECTED BEHAVIOR].

Looking at @relevant-file and @another-file:
1. Trace the data flow
2. Identify where the bug might originate
3. Suggest debugging steps or console.logs to add
4. Propose a fix once identified
traceinvestigatedebug

Need custom Cursor prompts?

One Shotr generates personalized prompts optimized for your specific use case.

Try One Shotr Free

3 free prompts - No credit card required