Skip to content

Workflow: AI-Assisted Development

Overview

This workflow guides you through the complete AI-assisted development cycle using Cursor's three core features: Tab autocomplete, Inline Edit, and Agent.

When to Use: Building new features, writing code, daily development


Prerequisites

  • Cursor installed and configured
  • Project open with codebase indexed
  • Familiarity with Tab, Inline Edit, and Agent

Workflow Diagram

PhaseActionTool
1. Plan (Optional)Understand and designAsk or Plan mode
2. WriteWrite codeTab + Agent
3. RefineTargeted changesInline Edit (Cmd+K)
4. TestGenerate and run testsAgent
5. CommitGenerate commit messageAI commit

Phase 1: Plan (Optional)

For complex features, start with planning.

Using Ask Mode

  1. Open chat: Cmd+I / Ctrl+I
  2. Switch to Ask mode: Cmd+. → Select "Ask"
  3. Describe what you want to build:
I want to add a user authentication system.
What's the best approach given our existing Express setup?
How should I structure the code?
  1. Agent explores codebase and provides recommendations
  2. No changes made—just information gathering

Using Plan Mode

  1. Switch to Plan mode: Shift+Tab from chat input
  2. Describe the feature:
Implement user authentication with:
- JWT tokens
- Login/Register endpoints
- Password hashing
- Session management
  1. Agent asks clarifying questions
  2. Agent generates detailed plan
  3. Review and edit plan
  4. Click "Build" to execute

Phase 2: Write Code

For Boilerplate and Patterns: Use Tab

Example: Creating a new Express route

  1. Start typing: router.post('/login',
  2. Tab suggests the full handler with try/catch
  3. Press Tab to accept
javascript
router.post('/login', async (req, res) => {
  try {
    const { email, password } = req.body;
    // authentication logic
  } catch (error) {
    res.status(500).json({ error: error.message });
  }
});

For Complex Logic: Use Agent

  1. Open Agent: Cmd+I / Ctrl+I
  2. Describe what you need:
Create an authentication service in @src/services/ that:
- Hashes passwords with bcrypt
- Generates and validates JWT tokens
- Has methods for login, register, and token refresh
Follow the patterns in @src/services/UserService.ts
  1. Review diffs as Agent creates files
  2. Accept or modify changes

Phase 3: Refine Code

Targeted Changes: Inline Edit

  1. Select the code to modify
  2. Press Cmd+K / Ctrl+K
  3. Describe the change:
add rate limiting to prevent brute force attacks
  1. Review diff and accept

Quick Questions

  1. Select code you're unsure about
  2. Press Cmd+K / Ctrl+K
  3. Press Alt+Enter for Quick Question:
Is this validation secure against injection attacks?
  1. Read explanation
  2. Type "do it" if you want suggested improvements applied

Phase 4: Test

Generate Tests with Agent

Create unit tests for @AuthService.ts covering:
- Successful login with valid credentials
- Failed login with invalid password
- Token generation and validation
- Password hashing verification

Use Jest and follow our testing patterns in @tests/

Run Tests

Run the auth tests and fix any failures

Agent will:

  1. Run npm test or equivalent
  2. Analyze failures
  3. Propose fixes
  4. Re-run to verify

Phase 5: Commit

Generate Commit Message

  1. Stage changes: git add .
  2. Open Source Control: Cmd+Shift+G
  3. Click sparkle icon (✨) in commit message
  4. AI generates message based on changes
  5. Review, edit if needed, commit

Best Practices

Choosing the Right Tool

TaskTool
Single line completionTab
Modify selected codeInline Edit (Cmd+K)
Multi-file changesAgent (Cmd+I)
Understanding codeAsk mode
Complex featuresPlan mode

Providing Context

  • Use @mentions for relevant files
  • Reference existing patterns to follow
  • Include error messages when debugging
  • Add @Docs for library documentation

Iterating Effectively

  • Start broad, then refine
  • Accept partial changes if some are wrong
  • Use checkpoints to restore if needed
  • Break large tasks into smaller steps

Example Session

# 1. Start with a plan
> "I need to add user profile endpoints. What files need to change?"
[Agent explains architecture]

# 2. Generate the service
> "Create UserProfileService with get, update, delete methods"
[Agent creates service file]

# 3. Refine with inline edit
[Select the update method, Cmd+K]
> "add validation for email format"

# 4. Generate tests
> "Add tests for UserProfileService"

# 5. Run tests
> "Run profile service tests and fix issues"

# 6. Commit
[AI generates: "Add user profile CRUD operations with validation"]

Built with VitePress | Powered by Claude AI