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
EditingAdd proper TypeScript types to untyped code
Add TypeScript types to this code. Infer types from usage patterns. Use interfaces for object shapes.
Add Documentation Comments
EditingAdd JSDoc comments to functions and classes
Add JSDoc comments to all functions and classes. Include @param, @returns, and @example where appropriate.
Add Input Validation
EditingAdd validation to function inputs
Add input validation to this function. Check for null/undefined, validate types, throw descriptive errors for invalid inputs.
Add Error Handling
EditingWrap code in proper error handling
Add try-catch error handling. Log errors with context. Rethrow or return appropriate error responses.
Feature Development
Prompts for implementing new features with Cursor Chat
Create React Component
FeatureGenerate 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.
Create API Endpoint
FeatureGenerate 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
Create Custom Hook
FeatureGenerate 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.
Refactoring
Prompts for improving existing code
Extract to Function
RefactoringExtract logic into a reusable function
Extract the selected code into a well-named function. Add proper types, handle edge cases, and document with JSDoc.
Split Large Component
RefactoringBreak 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
Modernize Code
RefactoringUpdate 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
Debugging
Prompts for finding and fixing bugs
Fix This Error
DebuggingDebug 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
Trace Bug
DebuggingFind 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
Need custom Cursor prompts?
One Shotr generates personalized prompts optimized for your specific use case.
Try One Shotr Free3 free prompts - No credit card required