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
| Phase | Action | Tool |
|---|---|---|
| 1. Plan (Optional) | Understand and design | Ask or Plan mode |
| 2. Write | Write code | Tab + Agent |
| 3. Refine | Targeted changes | Inline Edit (Cmd+K) |
| 4. Test | Generate and run tests | Agent |
| 5. Commit | Generate commit message | AI commit |
Phase 1: Plan (Optional)
For complex features, start with planning.
Using Ask Mode
- Open chat:
Cmd+I/Ctrl+I - Switch to Ask mode:
Cmd+.→ Select "Ask" - 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?- Agent explores codebase and provides recommendations
- No changes made—just information gathering
Using Plan Mode
- Switch to Plan mode:
Shift+Tabfrom chat input - Describe the feature:
Implement user authentication with:
- JWT tokens
- Login/Register endpoints
- Password hashing
- Session management- Agent asks clarifying questions
- Agent generates detailed plan
- Review and edit plan
- Click "Build" to execute
Phase 2: Write Code
For Boilerplate and Patterns: Use Tab
Example: Creating a new Express route
- Start typing:
router.post('/login', - Tab suggests the full handler with try/catch
- 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
- Open Agent:
Cmd+I/Ctrl+I - 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- Review diffs as Agent creates files
- Accept or modify changes
Phase 3: Refine Code
Targeted Changes: Inline Edit
- Select the code to modify
- Press
Cmd+K/Ctrl+K - Describe the change:
add rate limiting to prevent brute force attacks- Review diff and accept
Quick Questions
- Select code you're unsure about
- Press
Cmd+K/Ctrl+K - Press
Alt+Enterfor Quick Question:
Is this validation secure against injection attacks?- Read explanation
- 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 failuresAgent will:
- Run
npm testor equivalent - Analyze failures
- Propose fixes
- Re-run to verify
Phase 5: Commit
Generate Commit Message
- Stage changes:
git add . - Open Source Control:
Cmd+Shift+G - Click sparkle icon (✨) in commit message
- AI generates message based on changes
- Review, edit if needed, commit
Best Practices
Choosing the Right Tool
| Task | Tool |
|---|---|
| Single line completion | Tab |
| Modify selected code | Inline Edit (Cmd+K) |
| Multi-file changes | Agent (Cmd+I) |
| Understanding code | Ask mode |
| Complex features | Plan 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"]