Composer - Multi-File AI Editing
Build features across multiple files with AI assistance
💡 What You'll Learn
- Use Composer for multi-file features and refactors
- When to use Composer vs. Chat vs. Cmd+K
- Write effective Composer prompts
- Review and accept changes across files
🎼 What is Composer?
Composer is Cursor's most powerful feature. It can create, modify, and delete files across your entire codebase in a single command.
🎯 Perfect For:
- ✨ Creating new features that span multiple files
- 🔄 Large refactors across the codebase
- 📦 Generating boilerplate (components, tests, configs)
- 🏗️ Scaffolding entire features or modules
- 🔗 Creating files that need to work together
⌨️ Opening Composer
| Method | Shortcut |
|---|---|
| Open Composer | Cmd+I (Mac) / Ctrl+I (Win) |
| Or click icon | Top-right toolbar (Composer icon) |
🎯 Real-World Examples
Example 1: Create a Complete Feature
- Login component (src/components/Login.tsx)
- Auth context (src/context/AuthContext.tsx)
- API routes (src/app/api/auth/route.ts)
- Types (src/types/auth.ts)
Use NextAuth.js and follow our project conventions
✅ Add proper imports between them
✅ Follow your codebase patterns
✅ Add TypeScript types
Example 2: Refactor Across Files
Update all imports, usages, and file names.
✅ Update class name and exports
✅ Fix all imports in other files
✅ Update all usages
Example 3: Generate Test Suite
Create tests/ directory with unit tests, integration tests, and mocks
Example 4: Add Feature to Existing Code
Update @src/app/layout.tsx, create @src/components/ThemeToggle.tsx,
and add theme context in @src/context/ThemeContext.tsx
✍️ Writing Great Composer Prompts
✅ Good Composer Prompts
- Specific file paths and names
- "Create X in src/path/to/file.ts"
- "Refactor X to use pattern Y"
- "Add feature Z to @existing/file.ts"
- Clear requirements and constraints
- Reference existing patterns with @
❌ Bad Composer Prompts
- "Make it better" (too vague)
- "Fix everything" (unclear scope)
- No file paths specified
- Asking questions (use Chat)
- Small single-file edits (use Cmd+K)
📋 The Composer Workflow
Open Composer (Cmd+I)
Press Cmd+I or click the Composer icon
Write Your Prompt
Be specific about files, features, and requirements
Add Context with @
Reference existing files, folders, or docs
Review Changes
Cursor shows a diff of all proposed changes
Accept or Modify
Accept all, accept some, or refine your prompt
🔄 Composer vs. Other Tools
| Task | Best Tool |
|---|---|
| Create multiple new files | Composer ⭐ |
| Refactor across files | Composer ⭐ |
| Edit single file | Cmd+K |
| Quick code completion | Tab |
| Ask questions | Chat (Cmd+L) |
| Scaffold entire feature | Composer ⭐ |
⚡ Pro Tips
💡 Tip 1: Start with small Composer tasks to understand how it works
💡 Tip 2: Always review diffs carefully before accepting changes
💡 Tip 3: Use @ to reference existing files/patterns you want to follow
💡 Tip 4: Break huge tasks into smaller Composer prompts
💡 Tip 5: You can iterate - accept changes, then run Composer again to refine
🎓 Practice Exercise
Try This Challenge:
- Open Composer (Cmd+I)
- Type: "Create a simple TODO feature with:
- TodoList component in src/components/TodoList.tsx
- TodoItem component in src/components/TodoItem.tsx
- useTodos hook in src/hooks/useTodos.ts
- Type definitions in src/types/todo.ts
- Review the generated files
- Accept the changes and test them
⚠️ Common Pitfalls
Composer creates too many files
Be more specific about scope. Say "only create" or "modify existing files only"
Changes don't match my coding style
Add @ references to existing files with your style, or add a .cursorrules file
Composer is too slow
Break large tasks into smaller prompts. Wait for codebase indexing to complete.
🎬 Composer Best Practices
- ✅ Be Explicit: Name files and paths clearly
- ✅ Provide Examples: Use @ to reference similar code
- ✅ Review Everything: Never blindly accept all changes
- ✅ Use Git: Commit before big Composer changes
- ✅ Iterate: Run Composer multiple times to refine
- ✅ Test: Always test generated code thoroughly
🔗 Next Steps
Master advanced context with the @ symbols deep dive: @ Symbols Tutorial →