Workspace Management
Learning Outcomes
- Organise large projects using Cursor's workspace features for AI-friendly navigation
- Use multiple cursors combined with AI assistance for bulk edits
- Perform intelligent search and replace operations using AI understanding
- Manage multiple open files effectively with AI context in mind
- Apply bulk operations across files while maintaining project coherence
Lesson Plan
| Segment | Duration | Topic |
|---|---|---|
| Intro | 4 min | Why workspace organisation matters for AI-assisted coding |
| Demo 1 | 8 min | Project organisation strategies for large codebases |
| Demo 2 | 8 min | Multiple cursors with AI — bulk editing patterns |
| Demo 3 | 8 min | AI-aware search and replace |
| Explain | 5 min | Managing context — what the AI sees from open files |
| Demo 4 | 7 min | Multi-file editing workflows |
| Wrap-up | 5 min | Best practices and key takeaways |
Before You Begin
Pre-work:
- Complete Lesson 7 — Agent Mode
- Have a project with at least 15-20 files open in Cursor
- Familiarise yourself with VS Code's multi-cursor feature (Alt+Click to add cursors)
- Know the basics of Find and Replace (Cmd+H / Ctrl+H)
Shopping List:
- A medium-to-large project open in Cursor (a real project you work on is ideal)
- Multiple files with similar patterns that could benefit from bulk edits
- The Explorer panel visible (Cmd+Shift+E / Ctrl+Shift+E)
A well-organised project makes AI assistance significantly more effective. When files are logically grouped and well-named, the AI can find relevant context faster and make better suggestions.
Project structure principles for AI-friendly codebases:
src/
├── features/ # Group by feature/domain
│ ├── auth/
│ │ ├── components/
│ │ ├── hooks/
│ │ ├── services/
│ │ └── types.ts
│ ├── users/
│ └── posts/
├── components/ # Shared/common components
│ ├── ui/ # Primitives (Button, Input, Modal)
│ └── layout/ # Layout components (Header, Sidebar)
├── lib/ # Utilities and helpers
├── hooks/ # Shared hooks
└── types/ # Global type definitions
Why this matters for AI:
- When you reference
@src/features/auth/, the AI gets a focused, relevant context - Co-located files (component + hook + test) mean the AI can understand a feature holistically
- Consistent naming lets the AI predict where things live
Using workspace folders effectively:
- Collapse irrelevant folders in the Explorer to reduce visual clutter
- Pin frequently used files by right-clicking a tab > "Pin Tab" (Cmd+K then Cmd+Enter)
- Use Split Editor (Cmd+) to view related files side by side
- Go to File with Cmd+P — type partial filenames to navigate quickly
- Collapse irrelevant folders in the Explorer to reduce visual clutter
- Pin frequently used files by right-clicking a tab > "Pin Tab" (Ctrl+K then Ctrl+Enter)
- Use Split Editor (Ctrl+) to view related files side by side
- Go to File with Ctrl+P — type partial filenames to navigate quickly
Workspaces for monorepos:
If you work in a monorepo, consider using VS Code Workspaces:
- File > Add Folder to Workspace
- Add only the folders you're actively working in
- This limits what the AI indexes and improves relevance
.cursorignore for AI indexing:
Create a .cursorignore file (similar to .gitignore) to exclude directories from AI indexing:
# .cursorignore
node_modules/
dist/
build/
.next/
coverage/
*.generated.ts
vendor/
This prevents the AI from wasting context on generated files, dependencies, or build artefacts.
Cursor inherits VS Code's powerful multi-cursor editing and enhances it with AI capabilities. Combining these features enables rapid bulk edits.
Basic multi-cursor shortcuts:
| Action | Shortcut |
|---|---|
| Add cursor at click position | Option+Click |
| Add cursor above/below | Cmd+Option+Up/Down |
| Select next occurrence of word | Cmd+D |
| Select all occurrences of word | Cmd+Shift+L |
| Add cursors to line ends of selection | Option+Shift+I |
| Undo last cursor/selection | Cmd+U |
| Action | Shortcut |
|---|---|
| Add cursor at click position | Alt+Click |
| Add cursor above/below | Ctrl+Alt+Up/Down |
| Select next occurrence of word | Ctrl+D |
| Select all occurrences of word | Ctrl+Shift+L |
| Add cursors to line ends of selection | Alt+Shift+I |
| Undo last cursor/selection | Ctrl+U |
Multi-cursor + AI workflow:
The power comes from selecting multiple locations and then applying AI edits across all of them simultaneously.
Example 1: Adding TypeScript types to multiple functions
- You have 10 functions that lack return types
- Use Cmd+D / Ctrl+D to select each function name (or use Find to locate them)
- Select all the relevant lines
- Press Cmd+K / Ctrl+K and say: "Add proper TypeScript return types to all these functions"
- Cursor applies types to each function based on its implementation
Example 2: Converting console.log to a logger
- Use Cmd+Shift+L / Ctrl+Shift+L to select all occurrences of
console.log - Instead of simple find-replace, press Cmd+K / Ctrl+K
- Say: "Replace each console.log with the appropriate logger level — logger.info for success messages, logger.error for errors, logger.debug for debug output"
- The AI understands the context of each console.log and chooses the right level
Example 3: Adding error handling to multiple API calls
- Select a block of code containing multiple fetch/axios calls
- Press Cmd+K / Ctrl+K
- Say: "Wrap each API call in try/catch with proper error handling that shows a toast notification"
- The AI wraps each call individually, preserving the specific error context
Standard find-and-replace is powerful but literal. Cursor's AI adds semantic understanding — it can replace patterns based on meaning, not just text matching.
Standard Find and Replace (still useful):
- Find in file: Cmd+F
- Replace in file: Cmd+H (with regex: click .* button)
- Find in all files: Cmd+Shift+F
- Replace in all files: Cmd+Shift+H
- Find in file: Ctrl+F
- Replace in file: Ctrl+H (with regex: click .* button)
- Find in all files: Ctrl+Shift+F
- Replace in all files: Ctrl+Shift+H
When standard replace works:
- Renaming a variable that's always spelled the same way
- Changing an import path across all files
- Updating a version number in configuration files
When you need AI-enhanced replace:
Standard replace fails when:
- The change is contextual (same text, different treatment based on context)
- The replacement isn't a direct text swap (restructuring code)
- You need to preserve meaning while changing form
AI-enhanced search and replace workflow:
- Use global search (Cmd+Shift+F / Ctrl+Shift+F) to find all instances
- Open each file from the search results
- Select the relevant code in each file
- Use Chat or Cmd+K to describe the semantic replacement
Example: Converting class components to functional components
Standard replace cannot do this — it requires understanding component structure.
- Search for
extends React.Componentacross the project - Open each result
- Select the entire class component
- Cmd+K: "Convert this class component to a functional component with hooks. Preserve all behaviour."
- The AI restructures lifecycle methods into useEffect, state into useState, etc.
Example: Updating API response handling
Your API changed from { data: [...] } to { results: [...], pagination: {...} }.
- Search for
.datain API response handling code - For each usage, select the surrounding context
- Cmd+K: "Update this to use the new API format where 'data' is now 'results' and pagination metadata is available at response.pagination"
- The AI updates each usage appropriately, including updating TypeScript types
Scoped search for targeted changes:
Use search filters to limit scope:
files to include:src/features/users/**— only search in user featuresfiles to exclude:*.test.ts, *.spec.ts— skip test files- Use glob patterns:
**/*.tsx— only TypeScript React files
Understanding what the AI can "see" at any given moment helps you work more effectively. Context management is a key skill for AI-assisted development.
What contributes to AI context in Cursor:
| Context Source | When It's Included | Your Control |
|---|---|---|
| Current file | Always (for inline edits) | Keep files focused and short |
| Selected text | When you select before Cmd+K/L | Select exactly what's relevant |
| @-mentioned files | When you explicitly reference | Choose the most relevant files |
| .cursor/rules | Always | Keep it concise |
| Open tabs | May be included as background context | Close irrelevant tabs |
| Codebase index | When AI searches for context | Configure .cursorignore |
Managing open files for optimal AI context:
Strategy 1: The "working set" approach
Keep only the files relevant to your current task open:
- Close files from previous tasks
- Open the 3-5 files directly related to what you're working on
- Pin files you reference constantly (types, utilities)
Strategy 2: Tab groups for different contexts
Use VS Code's tab groups to organise by concern:
- Group 1: Feature files you're building
- Group 2: Reference files (types, interfaces, examples)
- Group 3: Test files
Strategy 3: Split editor for reference
- Cmd+\ to split editor right
- Cmd+K then Cmd+\ to split editor down
- Keep reference files (types, interfaces) in one pane and working files in another
- Use Cmd+1, Cmd+2 to switch between editor groups
- Ctrl+\ to split editor right
- Ctrl+K then Ctrl+\ to split editor down
- Keep reference files (types, interfaces) in one pane and working files in another
- Use Ctrl+1, Ctrl+2 to switch between editor groups
Explicit context with @-mentions:
When the AI's automatic context isn't enough, be explicit:
@src/types/user.ts @src/services/userService.ts
Create a new hook that fetches user data with proper typing and error handling,
following the pattern in @src/hooks/useProductData.ts
This tells the AI exactly which files to consider, instead of hoping it finds the right context.
Context window limits:
The AI has a finite context window. If you include too many files, earlier context may be "pushed out":
- A Chat conversation with many back-and-forth messages loses early context
- References to 10+ large files may hit limits
- Keep conversations focused; start a new chat when switching topics
When you need to make similar changes across many files, Cursor offers several approaches ranging from manual multi-file editing to AI-automated bulk operations.
Approach 1: Agent mode for bulk changes
Best for: Semantic changes that require understanding (not simple text replacement).
Agent task: "Add JSDoc documentation to all exported functions in src/lib/.
Each function should have a @param tag for each parameter and a @returns tag.
Infer the descriptions from the function names and implementations."
The agent will read each file, understand the functions, and add appropriate documentation.
Approach 2: Multi-file inline edits
Best for: Similar but not identical changes across a few files (3-7 files).
- Open all the files that need changes
- In each file, select the relevant section
- Use Cmd+K / Ctrl+K with the same instruction
- The AI applies the instruction with file-specific context
Approach 3: Find across files + batch Cmd+K
Best for: Changes at consistent locations (e.g., all files have a similar structure).
- Cmd+Shift+F / Ctrl+Shift+F to find the pattern across files
- Click through results, opening each file
- In each file, select and apply the same Cmd+K instruction
- Accept or modify each result
Approach 4: Terminal scripts + AI generation
Best for: Mechanical, repetitive changes that follow a strict pattern.
Ask Chat: "Write a bash script that adds a copyright header to all .ts files in src/ that don't already have one."
Then run the generated script in the terminal.
Real-world bulk operation examples:
Example 1: Adding error boundaries to all page components
Agent: "For every file in src/app/ that exports a default page component,
create a corresponding error.tsx file that shows a user-friendly error
message with a retry button. Follow the pattern in src/app/dashboard/error.tsx."
Example 2: Migrating CSS-in-JS to Tailwind
This is too complex for a single agent task. Break it down:
- Agent task 1: "Convert styled-components in src/components/ui/ to Tailwind classes. Start with Button.tsx, Input.tsx, and Card.tsx."
- Agent task 2: "Continue the Tailwind migration for Modal.tsx, Dropdown.tsx, and Tabs.tsx."
- After each batch, review and test before continuing.
Example 3: Adding loading states to all data-fetching components
Agent: "For each component in src/features/ that uses useQuery hooks,
add a loading skeleton state. Use the LoadingSkeleton component from
src/components/ui/LoadingSkeleton.tsx. Show the skeleton when isLoading
is true. Reference src/features/users/UserList.tsx for the pattern."
Combine workspace management techniques into complete workflows for day-to-day development in large codebases.
Workflow: Starting a new feature
-
Prepare workspace:
- Close all unrelated tabs (Cmd+K Cmd+W / Ctrl+K Ctrl+W)
- Open the directory where your feature will live
- Open 2-3 reference files (existing features with similar patterns)
- Pin your types/interfaces file
-
Scaffold with Agent:
- Use Agent mode to create the initial file structure
- Reference the existing feature as a pattern
-
Iterate with Chat + Inline:
- Use Chat for design decisions
- Use Cmd+K for rapid edits within the generated files
-
Review and cleanup:
- Close reference files
- Open all new files and review
- Use multi-cursor for any consistent tweaks
Workflow: Investigating a bug in unfamiliar code
-
Find the entry point:
- Cmd+Shift+F / Ctrl+Shift+F to search for the error message or symptom
- Open the relevant file
-
Build context progressively:
- Open the file where the bug manifests
- Use "Go to Definition" (F12) to trace the call chain
- Open each file in the chain (usually 3-5 files)
- Keep these open as your working context
-
Ask AI with full context:
- Reference all relevant files with @-mentions
- Describe the symptom and ask for diagnosis
- The AI can now see the full chain of execution
Workflow: Code review with workspace setup
- Checkout the PR branch
- View changed files: Use
git diff --name-only mainin terminal - Open all changed files as your working set
- Use Chat: "Review these changes for potential issues. I have the changed files open: @file1.tsx @file2.tsx @file3.tsx"
- Navigate between issues using the AI's suggestions
Keyboard shortcuts for efficient navigation:
| Action | Shortcut |
|---|---|
| Go to file by name | Cmd+P |
| Go to symbol in workspace | Cmd+T |
| Go to definition | F12 |
| Peek definition (inline) | Option+F12 |
| Go back | Ctrl+- |
| Go forward | Ctrl+Shift+- |
| Switch between open files | Ctrl+Tab |
| Close current tab | Cmd+W |
| Action | Shortcut |
|---|---|
| Go to file by name | Ctrl+P |
| Go to symbol in workspace | Ctrl+T |
| Go to definition | F12 |
| Peek definition (inline) | Alt+F12 |
| Go back | Alt+Left |
| Go forward | Alt+Right |
| Switch between open files | Ctrl+Tab |
| Close current tab | Ctrl+W |
Questions & Answers
Key Takeaways
- Structure your project for AI — logical grouping and clear naming help the AI find relevant context
- Use .cursorignore to exclude generated files, dependencies, and build output from AI indexing
- Multi-cursor + AI enables semantic bulk edits that simple find-replace cannot achieve
- Manage your open tabs — 5 relevant files beats 50 random ones for AI context quality
- Break bulk operations into batches — commit between batches for safe rollback points
- Learn navigation shortcuts — speed between files compounds into significant productivity gains
Next Steps: In Lesson 9 — Extensions & Integrations, you'll learn how to extend Cursor's capabilities with VS Code extensions, Git integration, and external tool connections.