- Updated system and tool prompts to present dedicated tools as preferred defaults rather than absolute prohibitions. - Relaxed the hard-forbidding of shell equivalents for file operations, searching, and editing. - Retained guidance on prioritizing tools for their gitignore semantics, structure, and line-anchoring capabilities.
1.2 KiB
1.2 KiB
Performs string replacements in files with fuzzy whitespace matching.
- You MUST use the smallest `old_text` that uniquely identifies the change - If `old_text` is not unique, you MUST expand it with more context or use `all: true` to replace all occurrences - You SHOULD prefer editing existing files over creating new ones Returns success/failure status. On success, file modified in place with replacement applied. On failure (e.g., `old_text` not found or matches multiple locations without `all: true`), returns error describing issue. - You MUST read the file at least once in the conversation before editing. Tool errors if you attempt edit without reading file first. Replace is content-addressed — you identify *what* to change by its text.For pattern-addressed bulk changes, bash is more efficient:
| Operation | Command |
|---|---|
| Regex replace | sd 'pattern' 'replacement' file |
| Bulk replace across files | sd 'pattern' 'replacement' **/*.ts |
Use Replace when content itself identifies location; use ast_edit for structure-aware codemods.
For in-place edits prefer this tool or write — you get a diff preview and fuzzy matching.