Common Workflows and Patterns
Cursor becomes truly powerful once you internalize a set of repeatable workflows. Rather than reaching for AI randomly, 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 scaffold a new feature using Chat and Agent mode together
- How to quickly understand unfamiliar code using
@codebasecontext - 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 insight is to break this into three phases: plan, generate, and refine.
Phase 1 — Plan in Chat
Before writing any code, open the Chat panel and describe the feature you want to build. Be specific: include what the feature does, which files or systems it touches, and any constraints or edge cases you're aware of.
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. What's the best architecture for this, and which files will I need to create or modify?
Cursor will outline an approach — perhaps a notifications table, a REST endpoint, a React context, and a badge component. This plan becomes your checklist. You can push back, ask for alternatives, or ask it to elaborate on any step before writing a single line of code.
Phase 2 — Generate with Agent
Once you're happy with the plan, switch to Agent mode and give it the go-ahead:
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 intervene if it goes off course.
Phase 3 — Refine with Cmd+K
After Agent mode 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 navigate a codebase they didn't write. Cursor makes this dramatically faster.
Open the File and Ask Chat to Explain
Open the file you're trying to understand, then open Chat 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 has context of the open file, it can give you a detailed, accurate explanation rather than a generic one. You can follow up with questions like "why would this throw an error?" or "what calls this function?"
Use @codebase for Architecture Questions
For bigger questions about how different parts of the system fit together, use the @codebase mention:
@codebase How does authentication work in this app? Which files handle token validation, and how does the session get passed to API routes?
This triggers a semantic search across your entire project, letting Cursor trace the flow through multiple files and give you a coherent overview. It's particularly useful when onboarding to a new project or investigating a system you've inherited.
Build a Mental Map Progressively
Don't try to understand everything at once. Start with one module, ask Chat to explain it, then ask what it depends on. Follow the thread. Within 20–30 minutes of focused Chat sessions, you can build a solid mental model of even a large, unfamiliar system.
Workflow 3: Writing Tests
Tests are notoriously tedious to write, and AI excels at generating them — especially for pure functions with clear inputs and outputs.
Select the Function and Ask Chat
Select the function you want to test, then open Chat and ask:
Write a comprehensive 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 semantically meaningful.
Iterate on Coverage
After reviewing the initial 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 typically produces better test coverage than asking for everything upfront, because you can review each batch and guide the AI toward the scenarios that matter most for your specific code.
Ask for Test Infrastructure Help
If you're setting up a new testing environment or need mocks for complex dependencies, Chat is helpful 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 serve as a first-pass code reviewer before your code goes to human reviewers.
Reference the Changed Files
If you're in the middle of a feature branch, you can open the relevant files and ask Chat to review them:
Review the changes in
src/api/payments.ts. Look for security issues, error handling gaps, performance problems, and anything that doesn't follow REST conventions.
Paste a Diff or PR Description
For a broader review, you can paste a git diff directly into Chat or reference a GitHub PR by describing the changes:
Here's my git diff: [paste diff]. Identify any potential bugs, missing null checks, or race conditions before I submit this for review.
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 will produce 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 significant time.
README and API Docs
For higher-level documentation:
Write a README section for the
NotificationServiceclass. Include what it does, how to instantiate it, 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, you can 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 — converting JavaScript to TypeScript, rewriting a class component to a functional one, moving from one library to another — are well-suited to AI assistance because they follow consistent, learnable 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 will handle the mechanical parts (adding : string, : number, etc.) and flag genuinely 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 maintain the same interface.
For larger migrations, break the work into chunks by file or module and use Agent mode to work through them systematically. Always review the diffs carefully — migrations that look mechanical often hide subtle behavioral differences.
Putting It Together: A Typical Development Session
A real development session might chain several of these workflows together:
- Start of feature — Use Chat to plan, Agent to scaffold
- Mid-feature — Use Cmd+K to refine functions as you go
- Before commit — Use Chat for a quick self-review
- After feature — Use Chat to generate tests and documentation
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 generate: Using Chat to think through a feature before involving Agent mode reduces wasted iteration and produces better code
- @codebase is your map: For unfamiliar codebases,
@codebasequestions are faster than manual file exploration - Tests and docs are AI strengths: These repetitive-but-precise tasks are where AI delivers outsized value
- Code review is complementary: AI review catches a different class of issues than human review — use both
- 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 throughout a session gives you leverage at every stage of development
Quiz
Discussion
Sign in to join the discussion.

