When Cursor generates multiple overlapping suggestions for the same file, the results often conflict. This tutorial shows how to use Ask mode to review all suggestions first, then Composer to merge them into one coherent implementation. You will learn prompt techniques that produce unified output instead of fragmented alternatives.
Combining multiple Cursor suggestions into coherent code
During iterative development with Cursor, you often get multiple suggestions that each solve part of the problem but conflict with each other. Applying them sequentially can introduce bugs, duplicated logic, or broken imports. This tutorial teaches you how to evaluate, combine, and apply suggestions as a single unified change.
Prerequisites
- Cursor installed and a project open
- Multiple suggestions or chat messages with code for the same file
- Familiarity with Cursor Chat (Cmd+L) and Composer (Cmd+I)
Step-by-step guide
Collect all suggestions in Ask mode
Collect all suggestions in Ask mode
Before applying anything, switch to Ask mode (Cmd+L) and gather all the suggestions Cursor has given you. If they came from different chat sessions, start a new session and paste summaries of each approach. Ask Cursor to list the differences.
1// Cursor Chat prompt (Cmd+L, Ask mode):2// I have three different approaches for my UserService:3// 1. Version A uses fetch with manual error handling4// 2. Version B uses axios with interceptors5// 3. Version C uses a custom httpClient wrapper6//7// @src/services/UserService.ts8// Compare these approaches. Which one fits best with the9// existing patterns in this file? List the pros and cons10// of each without making any changes.Expected result: Cursor analyzes all three approaches and recommends the best fit based on your existing codebase patterns.
Write a unified prompt that combines the best parts
Write a unified prompt that combines the best parts
Based on the comparison, write a single comprehensive prompt that specifies exactly what you want from each approach. Reference the original file and explicitly state which elements to include and which to skip. This produces one coherent result instead of fragments.
1// Cursor Chat prompt (Cmd+L):2// @src/services/UserService.ts3// Rewrite UserService combining these elements:4// - Use the fetch-based approach from Version A for the5// HTTP layer (no external dependencies)6// - Add the retry logic from Version B's axios interceptors7// but implement it with native fetch8// - Use Version C's typed error classes for error handling9// - Keep all existing method signatures unchanged10// - Generate one complete file, not fragmentsPro tip: The phrase 'Generate one complete file, not fragments' prevents Cursor from showing partial snippets. It forces a single unified output.
Expected result: Cursor produces a single, complete UserService implementation combining the best elements of all three approaches.
Use Composer for the final merge
Use Composer for the final merge
Once you have the unified code from Chat, use Composer (Cmd+I) to apply it to your actual file. Composer handles the diff application, imports, and any necessary adjustments to related files. This is safer than manually copy-pasting from Chat.
1// Composer prompt (Cmd+I):2// @src/services/UserService.ts Replace the current3// UserService implementation with the unified version4// from our chat discussion. Keep all existing exports.5// Update any imports that changed. Do not modify any6// other files.7//8// The unified version should:9// - Use native fetch with retry logic10// - Use typed error classes (NotFoundError, ValidationError)11// - Keep method signatures identical to the current file12// - Add JSDoc comments to public methodsExpected result: Composer applies the unified code as a clean diff, preserving exports and updating imports automatically.
Verify the merged result compiles and passes tests
Verify the merged result compiles and passes tests
After applying the unified suggestion, verify that the code compiles and existing tests still pass. Use the terminal in Cursor to run your type checker and test suite. If there are issues, paste the errors back into Chat for quick fixes.
1// Terminal commands:2npx tsc --noEmit # Check TypeScript compilation3npm test -- --testPathPattern=UserService # Run relevant tests45// If errors occur, paste into Cmd+L:6// @src/services/UserService.ts TypeScript compilation error:7// 'Property retry does not exist on type RequestInit'8// Fix this error while keeping the retry logic intact.Expected result: Code compiles without errors and all existing tests pass with the unified implementation.
Document the decision for your team
Document the decision for your team
Use Cursor to generate a brief comment block at the top of the file explaining which approach was chosen and why. This helps teammates understand the design decision without needing to review the chat history.
1// Cmd+K at the top of the file:2// "Add a comment block explaining that this service uses3// native fetch with custom retry logic and typed error4// classes. Mention that axios was considered but rejected5// to avoid external dependencies."67/**8 * UserService — handles all user-related API operations.9 *10 * Architecture decisions:11 * - Uses native fetch (no axios dependency) with custom retry logic12 * - Typed error classes (NotFoundError, ValidationError) for13 * structured error handling across the application14 * - All methods return typed Promises for full type safety15 */Expected result: A clear documentation block at the top of the file explaining the implementation choices.
Complete working example
1/**2 * UserService — unified implementation combining:3 * - Native fetch with custom retry logic4 * - Typed error classes for structured error handling5 * - Consistent method signatures for API compatibility6 */78import { config } from '@/config/env';910class ApiError extends Error {11 constructor(public statusCode: number, message: string) {12 super(message);13 this.name = 'ApiError';14 }15}1617class NotFoundError extends ApiError {18 constructor(resource: string, id: string) {19 super(404, `${resource} not found: ${id}`);20 this.name = 'NotFoundError';21 }22}2324async function fetchWithRetry(25 url: string,26 options: RequestInit = {},27 retries = 328): Promise<Response> {29 for (let attempt = 1; attempt <= retries; attempt++) {30 try {31 const response = await fetch(url, options);32 if (response.status >= 500 && attempt < retries) {33 await new Promise((r) => setTimeout(r, attempt * 1000));34 continue;35 }36 return response;37 } catch (err) {38 if (attempt === retries) throw err;39 await new Promise((r) => setTimeout(r, attempt * 1000));40 }41 }42 throw new Error('Max retries exceeded');43}4445export class UserService {46 private baseUrl = `${config.apiBaseUrl}/users`;4748 async getById(id: string) {49 const res = await fetchWithRetry(`${this.baseUrl}/${id}`);50 if (res.status === 404) throw new NotFoundError('User', id);51 if (!res.ok) throw new ApiError(res.status, 'Failed to fetch user');52 return res.json();53 }5455 async update(id: string, data: Record<string, unknown>) {56 const res = await fetchWithRetry(`${this.baseUrl}/${id}`, {57 method: 'PUT',58 headers: { 'Content-Type': 'application/json' },59 body: JSON.stringify(data),60 });61 if (!res.ok) throw new ApiError(res.status, 'Failed to update user');62 return res.json();63 }64}Common mistakes when combining multiple Cursor suggestions
Why it's a problem: Applying multiple suggestions sequentially without reviewing conflicts
How to avoid: Use Ask mode to compare all suggestions first, then write one unified prompt that combines the best elements into a single generation.
Why it's a problem: Copy-pasting from Chat instead of using Composer
How to avoid: Use Composer (Cmd+I) to apply changes. It handles imports, formatting, and shows a reviewable diff.
Why it's a problem: Asking Cursor to 'merge these two versions' without specifics
How to avoid: Be explicit: 'Use Version A's error handling, Version B's retry logic, and Version C's type definitions.'
Best practices
- Use Ask mode (Cmd+L) to compare suggestions before applying any changes
- Write a single unified prompt specifying exactly which elements from each suggestion to include
- Include 'Generate one complete file, not fragments' in your prompt for comprehensive output
- Apply unified code through Composer (Cmd+I) rather than manual copy-paste
- Run type checking and tests immediately after applying merged suggestions
- Start a new Chat session for the merge to avoid context pollution from earlier attempts
- Document the chosen approach with comments for future maintainers
Still stuck?
Copy one of these prompts to get a personalized, step-by-step explanation.
I have three different implementations of a UserService class: one using fetch with manual error handling, one using axios with retry interceptors, and one with typed error classes. Combine them into a single implementation that uses native fetch with custom retry logic and typed error classes. Keep all method signatures identical. Generate one complete file.
In Cursor Chat (Cmd+L): @src/services/UserService.ts I have tried three approaches for this service. Combine them: use native fetch from approach 1, add retry logic like approach 2 but without axios, and use the typed error classes from approach 3. Generate one complete replacement file with all imports.
Frequently asked questions
Can I reference a previous Chat session when merging suggestions?
Yes. Use @Past Chats in your prompt to reference summarized previous sessions. However, for best results, copy the key code snippets into a new session rather than relying on summarized history.
How many suggestions can Cursor realistically merge?
Cursor handles merging 2-3 approaches well. Beyond that, the context becomes too large and results degrade. For 4+ approaches, narrow down to the best 2-3 first.
What if the merged code introduces new bugs?
Always run tests after merging. Cursor creates checkpoints before Composer operations, so you can restore the previous state if the merge fails. Use git diff to review all changes before committing.
Is it better to merge in Chat or Composer?
Use Chat (Ask mode) to evaluate and plan the merge, then Composer to apply the final result. Chat is better for reasoning, Composer is better for applying changes to actual files.
How do I prevent conflicting suggestions in the first place?
Be specific in your initial prompt. Include your project conventions, preferred libraries, and constraints. The more context you provide upfront, the more consistent Cursor's suggestions will be.
Talk to an Expert
Our team has built 600+ apps. Get personalized help with your project.
Book a free consultation