Workspace Search and Replace
Cursor's Agent mode and Copilot Chat both handle multi-file operations, but both default to naive find-replace. This prompt forces contextual analysis of each occurrence. The classification step catches the edge cases that break codebases.
Perform a codebase-wide search and replace with intelligence: Find: {{search_pattern}} Replace with: {{replacement_pattern}} Scope: {{file_glob_pattern}} But this isn't a simple find-replace. For each occurrence: 1. **Read the surrounding context** (10 lines before and after) 2. **Classify** the usage: - Direct usage: Replace straightforwardly - Aliased: Update the alias/import too - Inside a string/comment: May need different handling - In a test: Update test expectations to match - In a type definition: Update the type and all references 3. **Apply the appropriate replacement** for each category 4. **Update imports** if the replacement changes the import source 5. **Check for TypeScript errors** after the replacement Provide a summary: - Total occurrences found: X - Replaced: Y - Skipped (with reason): Z - Files modified: (list) - New TypeScript errors introduced: (list with fixes) If any replacement is ambiguous, show the context and ask rather than guessing.
Variables to customize
Why this prompt works
Cursor's Agent mode and Copilot Chat both handle multi-file operations, but both default to naive find-replace. This prompt forces contextual analysis of each occurrence. The classification step catches the edge cases that break codebases.
Save this prompt to your library
Organize, version, and access your best prompts across ChatGPT, Claude, and Cursor.
Related prompts
Get thorough code reviews with actionable feedback tailored to your language, framework, and standards.
Context-Aware Code CompletionProviding the surrounding code and project context lets the model match existing patterns exactly. The constraint against modifying existing code prevents unwanted side effects.
Inline Code SuggestionConstraining suggestions to match existing style and scope produces insertions that feel native to the codebase. The 'no explanation' rule mimics real inline completion behavior.
Code ExplanationThe audience level parameter adjusts complexity automatically. Requiring a usage example ensures the explanation is practical, not just theoretical.