Workspace Search and Replace

Developer Toolsgithub-copilot-vs-cursorsearch_patternreplacement_patternfile_glob_pattern

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.

Prompt
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

{{search_pattern}}{{replacement_pattern}}{{file_glob_pattern}}

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.

What you get when you save this prompt

Your workspace unlocks powerful tools to iterate and improve.

AI OPTIMIZE

AI Optimization

One-click improvement with structure analysis and pattern suggestions.

VERSION DIFF

Version History

Track every edit. Compare versions side-by-side with word-level diffs.

ORGANIZE
Development
Code Review
Testing
Marketing

Folders & Tags

Organize your library with nested folders, tags, and drag-and-drop.

MCP
$ npm i -g @promptingbox/mcp
Claude · Cursor · ChatGPT

Use Everywhere

Access prompts from Claude, Cursor, ChatGPT & more via MCP integration.

Your prompts, organized

Save, version, and access your best prompts across ChatGPT, Claude, Cursor, and more.