apps/docs/docs/advanced-usage/available-tools/search-replace.md
The search_replace tool performs a targeted search-and-replace operation on a file, replacing exactly one uniquely-identified occurrence of specified text. If the search string matches multiple locations, the tool returns an error—the search string must be specific enough to identify a single target location.
The tool accepts these parameters:
file_path (required): The path of the file to modify relative to the current working directory.old_string (required): The exact text to search for and replace.new_string (required): The replacement text.This tool searches for an exact string in a file and replaces exactly one occurrence with new text. The search string must uniquely identify the target location in the file. If multiple matches are found, the tool returns an error and requires a more specific search string to proceed. This is an intentional safety design to prevent unintended changes.
apply_diff for complex editsWhen the search_replace tool is invoked, it follows this process:
file_path, old_string, and new_string parameters.old_string in the file. If more than one match is found, returns an error asking for a more specific search string.new_string.search_replace: Replaces exactly one uniquely-identified occurrence (this tool)edit_file: Also replaces exactly one occurrence by default; also supports old_string="" for file creationedit: Replaces first occurrence by default (unless replace_all: true)apply_diff: Use for precise, context-aware edits with fuzzy matchingThese are different implementations of search-and-replace functionality with varying capabilities.