How I am using Cursor (the AI Code Editor) in my development

Jan 8, 2025

How I am using Cursor (the AI Code Editor) in my development

This post was inspired by this image shared by the Cursor team.

Lets talk about vibe coding with Cursor. Cursor is an AI-powered code editor. It lets you use models directly inside of your IDE. This leads to entirely new workflows, where you can let the AI drive entirely, or ask the AI to periodically help you when you are stuck. This lets you design, debug, refactor, and ship code faster, all without leaving your editor.

Here are some of the ways I have been using Cursor lately.

Spinning Up a New Feature

  1. Generate boilerplate using Ask Cursor

    • Prompt: "Add a new API route at /api/invite that uses existing auth middleware and sends an email using utils/sendEmail."
    • Cursor generates the route using your existing patterns, imports, and middleware.
  2. Establish development conventions with Cursor Rules

    • Example rules: "Always use zod for input validation in API routes." or "Prefer async/await syntax over .then chains."
    • These rules guide Cursor’s behavior across all suggestions and edits.
    • Here is a helpful set of cursorrules you can include in your project.
  3. Refine inline as you go

    • Highlight blocks and request improvements like: "Add error handling", "Simplify this logic", or "Use early returns."
  4. Generate tests based on your project style

    • Prompt: "Write unit tests using the same structure as tests/auth.test.ts."
  5. Use an Agent to standardize output

    • Example: "Ensure all new API routes follow the project's error response format."

Debugging a Production Issue

Diagnosing bugs involves piecing together symptoms, logs, and code relationships. Cursor reduces cognitive overhead here:

  1. Analyze stack traces directly in-editor

    • Prompt: "Why might this error happen: TypeError: Cannot read properties of undefined (reading 'user')?"
    • Cursor interprets the stack and suggests likely root causes.
  2. Perform semantic search

    • Ask: "Where is authToken created or mutated in this project?"
    • Cursor’s semantic understanding is more powerful than traditional text search.
  3. Trace function usage in context

    • In a file, ask: "Who calls this function?", "What happens if input is null?", or "What’s the expected execution path?"
  4. Set debugging-specific Cursor Rules

    • Example: "Flag any code accessing .user without checking for undefined."

Refactoring with Confidence

Refactoring is safer and faster when you can rely on AI to understand and enforce your architecture and style.

  1. Refactor through goal-oriented prompts

    • Example: "Reduce cognitive complexity by extracting helpers and improving variable names."
  2. Edit entire folders with AI

    • Use "Edit Folder with AI" for consistent, bulk changes like:
      • "Convert CommonJS files in /lib to ESModules."
      • "Rename all references to customerId as clientId."
  3. Define stylistic rules to maintain consistency

    • Examples:
      • "Use arrow functions instead of function declarations."
      • "Destructure props by default."
  4. Automate transformation with Agents

    • Example: "Update Redux slices to use Zustand with equivalent behavior."
    • Great for sweeping, opinionated architectural shifts.
  5. Validate changes by asking for rationale

    • Prompt: "Why did you refactor it this way?"

Understanding a New Codebase

When joining a new project or switching contexts, Cursor can act like an experienced teammate who knows the codebase.

  1. Summarize unfamiliar files

    • Ask: "What is the purpose of this file?", or "What problem does this class solve?"
  2. Follow data flow across layers

    • Prompt: "Trace the flow of data from the controller to the database in this module."
  3. Set learning-oriented Cursor Rules

    • Examples:
      • "Explain logic as if to a senior-level student."
      • "Write documentation in JSDoc format."

Final Thoughts

Cursor isn’t just a better autocomplete, it’s a collaborative development environment powered by AI. By embedding AI directly into your workflow, it can allow you to ship faster with more confidence and less friction.

I've also found that when I leverage Cursor with Github Copilot when issuing PRs, I get a second layer of sanity-checking which helps cleanliness. I feed the Copilot comments back into Cursor to iteratively improve the codebase.

Try it on your next project: download Cursor and see how it changes the way you build software.