Skip to main content

Cheat Sheet for Code Generation with Cursor AI


๐Ÿง  Cursor AI Prompt Cheat Sheetโ€‹

๐Ÿš€ Generate MVP Appโ€‹

- Generate a Next.js 14 app with TypeScript, Tailwind, and a login page.
- Create a SaaS dashboard layout with sidebar and top nav using ShadCN.
- Scaffold a CRUD interface for managing courses using Prisma and React.

โœจ Refactor Codeโ€‹

- Refactor this component to use custom hooks and make it cleaner.
- Split this file into smaller reusable components.
- Refactor this API route using async/await and proper error handling.

๐Ÿ› ๏ธ Fix Bugs / Debugโ€‹

- Why is this useEffect running infinitely?
- Fix this TypeScript error and explain why it happened.
- Debug this form validation issue.

๐Ÿงฑ Generate Components/UIโ€‹

- Create a reusable modal component with open/close logic.
- Generate a responsive card layout using Tailwind.
- Build a date picker with disabled past dates.

๐Ÿง  Understand / Learn Codeโ€‹

- Explain what this Zustand store does.
- Describe how this middleware handles authentication.
- What is the purpose of this Prisma query?

๐Ÿ“š Generate Documentationโ€‹

- Generate a README.md for this project.
- Add JSDoc comments to these functions.
- Document this API endpoint using OpenAPI format.

๐Ÿ” Auth & Role Managementโ€‹

- Add Firebase Auth with email/password and role-based access.
- Protect this API route so only admins can access it.

๐Ÿ“ฆ Backend / Databaseโ€‹

- Create Prisma models for students, tutors, and classes.
- Generate API routes for CRUD operations on courses.
- Write a seed script for this database.

๐Ÿงช Testingโ€‹

- Write a unit test for this function using Vitest.
- Generate integration tests for this login flow.
- Test this API route for error and success cases.

๐Ÿ“ˆ Optimization & Cleanupโ€‹

- Optimize this loop for performance.
- Clean up unused imports and variables.
- Convert this component to a server component (Next.js 14).