Common Workflows and Patterns
Cursor becomes truly powerful once you build a set of repeatable workflows. Rather than reaching for AI at random, experienced developers build habits around specific patterns that match common development tasks. In this lesson, we'll walk through six high-value workflows you can start using today.
What You'll Learn
- How to plan and build a new feature using Plan mode and Agent mode together
- How to quickly understand unfamiliar code by letting Ask mode search your codebase
- How to generate and iterate on tests with AI assistance
- How to use Cursor for code review, documentation, and migration tasks
Workflow 1: Starting a New Feature
One of the highest-leverage things you can do with Cursor is use it to kick off a new feature from scratch. The key is to break the work into three phases: plan, build, and refine.
Phase 1: Plan with Plan Mode
Before writing any code, open the Agent side panel (Cmd+I or Cmd+L) and cycle to Plan mode with Shift+Tab or pick it from the mode menu. Describe the feature you want to build. Be specific: include what the feature does, which systems it touches, and any constraints or edge cases you know about.
Example prompt:
I need to add a user notification system to this app. Users should receive an in-app notification when someone comments on their post. We're using React on the frontend and Express with PostgreSQL on the backend. The
usersandpoststables already exist. Plan the architecture and list the files I'll need to create or change.
In Plan mode, the agent researches your codebase, may ask you a few clarifying questions, and then writes an editable plan. It might propose a notifications table, a REST endpoint, a React context, and a badge component. This plan becomes your checklist. Edit it directly, remove steps you don't want, or ask for alternatives before any code is written.
If you only want to talk the idea through without a formal plan, Ask mode works too. It is read-only, so nothing in your project changes while you think.
Phase 2: Build with Agent
Once you're happy with the plan, build from it. You can tell the agent to carry out the whole plan, or go one step at a time in Agent mode:
Now implement step 1: create the notifications table migration and the Express endpoint for fetching a user's notifications.
Agent mode will create or edit multiple files, run terminal commands if needed, and work through the task step by step. Watch what it does and step in if it goes off course. If you think of something while it works, type it and press Enter to queue the message for when it finishes the current step.
Phase 3: Refine with Cmd+K
After the agent produces a draft, use Cmd+K inline editing to polish individual sections. Select a function and ask it to add error handling, tighten a type definition, or rename a variable for clarity. Cmd+K is surgical. Use it when you know exactly what needs changing in a specific block of code.
Workflow 2: Understanding Unfamiliar Code
Every developer eventually has to work in a codebase they didn't write. Cursor makes this much faster.
Open the File and Ask
Open the file you're trying to understand, switch the side panel to Ask mode, and ask a direct question:
Can you explain what this file does? Specifically, what is the
reconcileQueuefunction responsible for, and what are its inputs and outputs?
Because Cursor can see the open file, it gives you a detailed, accurate explanation rather than a generic one. Follow up with questions like "why would this throw an error?" or "what calls this function?"
Ask Architecture Questions Directly
For bigger questions about how parts of the system fit together, just ask. You don't need a special keyword. The agent runs its own semantic search across your project to find the relevant files:
How does authentication work in this app? Which files handle token validation, and how does the session get passed to API routes?
The agent traces the flow through multiple files and gives you a coherent overview. This is especially useful when you join a new project or inherit a system. If you already know which files matter, @-mention them (for example @src/auth/ or @middleware.ts) to point the agent straight at them.
Build a Mental Map Step by Step
Don't try to understand everything at once. Start with one module, ask for an explanation, then ask what it depends on. Follow the thread. Within 20 to 30 minutes of focused questions, you can build a solid mental model of even a large, unfamiliar system.
Workflow 3: Writing Tests
Tests are tedious to write, and AI is very good at generating them, especially for pure functions with clear inputs and outputs.
Select the Function and Ask
Select the function you want to test, press Cmd+Shift+L to add it to the chat, and ask:
Write a thorough test suite for this function using Jest. Cover the happy path, edge cases (empty input, null values, large numbers), and error conditions.
Cursor will generate a test file with multiple describe and it blocks. Because it can see the function's implementation, the tests will be accurate: not just syntactically valid but meaningful. In Agent mode, you can also ask it to run the tests and fix any that fail.
Iterate on Coverage
After reviewing the first tests, push for more:
Good. Now add tests for what happens when the database call throws an error. Also add a test for concurrent calls.
This iterative approach usually produces better coverage than asking for everything upfront, because you can review each batch and guide the AI toward the scenarios that matter most for your code.
Ask for Test Infrastructure Help
If you're setting up a new testing environment or need mocks for complex dependencies, the agent can help here too:
We're using Prisma as our ORM. How should I mock the Prisma client in these tests so they don't hit the real database?
Workflow 4: Code Review Assistance
Cursor can act as a first-pass code reviewer before your code goes to human reviewers.
Reference Your Changes
If you're in the middle of a feature branch, use @Branch to give the agent the diff between your branch and main, or @Commit for your current uncommitted changes:
@Branch Review these changes. Look for security issues, error handling gaps, performance problems, and anything that doesn't follow REST conventions.
You can also @-mention a single file, such as @src/api/payments.ts, for a focused review. Cursor also has a /review slash command that runs Bugbot and a security review on your local changes before you push.
Review on the Pull Request
Once you open a pull request, Cursor's Bugbot can review it on GitHub and leave comments about likely bugs. You will learn more about Bugbot in the lesson on parallel agents, cloud agents, and Bugbot.
Specific Review Lenses
Different reviews need different lenses. Some useful prompts:
- "Review this for security vulnerabilities, especially around user input handling."
- "Does this code have any memory leaks or missed cleanup in useEffect hooks?"
- "Is this TypeScript type-safe? Highlight any implicit
anyor unsafe casts." - "Would a junior developer understand this code? Suggest where comments would help."
AI code review isn't a replacement for human review. It catches different things. Use both.
Workflow 5: Documentation Generation
Keeping documentation in sync with code is painful. Cursor can help generate it on demand.
JSDoc and Inline Comments
Select a function or class and ask:
Add JSDoc comments to this function explaining the parameters, return value, and any thrown errors.
Cursor produces accurate documentation because it can read the implementation. You'll still need to review it, especially the description of edge-case behavior, but it's a strong starting point that saves a lot of time.
README and API Docs
For higher-level documentation:
Write a README section for the
NotificationServiceclass. Include what it does, how to create an instance, and a usage example.
Based on the route handlers in
src/api/, generate an API reference table showing each endpoint, its method, required parameters, and what it returns.
Keeping Docs Updated
When you change a function, select the outdated comment and use Cmd+K to update it:
Update this JSDoc to reflect the new
optionsparameter I just added.
Workflow 6: Converting and Migrating Code
Migration tasks, such as converting JavaScript to TypeScript, rewriting a class component as a functional one, or moving from one library to another, suit AI well because they follow consistent patterns.
JavaScript to TypeScript
Select a JavaScript file and ask:
Convert this file to TypeScript. Add proper type annotations, interfaces for all object shapes, and use strict null checks. Flag anything that's ambiguous and needs my review.
Cursor handles the mechanical parts (adding : string, : number, and so on) and flags truly ambiguous cases where it needs your input.
Class Components to React Hooks
Convert this React class component to a functional component using hooks. Use
useStatefor state,useEffectfor lifecycle methods, and preserve the exact same behavior.
Library Migrations
This code uses
axiosfor HTTP requests. Refactor it to use the nativefetchAPI instead. Handle errors the same way and keep the same interface.
For larger migrations, start in Plan mode to map out the work, then break it into chunks by file or module and let Agent mode work through them one at a time. Always review the diffs carefully. Migrations that look mechanical often hide subtle behavior changes.
Putting It Together: A Typical Development Session
A real development session might chain several of these workflows together:
- Start of feature: Use Plan mode to plan, then Agent mode to build
- Mid-feature: Use Cmd+K to refine functions as you go
- Before commit: Use
@Commitor/reviewfor a quick self-review - After feature: Ask the agent to generate tests and documentation, then let Bugbot review the PR
Over time, these patterns become second nature. The goal isn't to hand everything to AI. It's to use AI for the high-friction, repetitive, or error-prone parts while keeping your judgment and understanding firmly in the loop.
Key Takeaways
- Plan before you build: Plan mode researches your code and writes an editable plan, which cuts wasted iteration and produces better code
- Just ask about the codebase: The agent searches your project on its own; use @-mentions when you already know which files matter
- Tests and docs are AI strengths: These repetitive but precise tasks are where AI delivers outsized value
- Code review is complementary: Use
@Branch,@Commit,/review, and Bugbot, but keep human review too - Migrations are AI-friendly: Mechanical conversions (JS to TS, class to hooks) are good candidates for Agent mode, with careful diff review afterward
- Workflows compound: Chaining these patterns through a session gives you leverage at every stage of development

