text_editor_20250728
text_editor_20250124
text_editor_20241022
computer-use-2024-10-22
beta header when using the text editor tool.The text editor tool is generally available in Claude 4 and Sonnet 3.7.text_editor_20250728
tool for Claude 4 models does not include the undo_edit
command. If you require this functionality, you’ll need to use Claude 3.7 or Sonnet 3.5 with their respective tool versions.str_replace_based_edit_tool
) to Claude using the Messages API.You can optionally specify a max_characters
parameter to control truncation when viewing large files.max_characters
is only compatible with text_editor_20250728
and later versions of the text editor tool.Provide Claude with the text editor tool and a user prompt
Claude uses the tool to examine files or directories
view
command to examine file contents or list directory contentstool_use
content block with the view
commandExecute the view command and return results
max_characters
parameter was specified in the tool configuration, truncate the file contents to that lengthuser
message containing a tool_result
content blockClaude uses the tool to modify files
str_replace
to make changes or insert
to add text at a specific line number.str_replace
command, Claude constructs a properly formatted tool use request with the old text and new text to replace it withExecute the edit and return results
Claude provides its analysis and explanation
view
command allows Claude to examine the contents of a file or list the contents of a directory. It can read the entire file or a specific range of lines.
Parameters:
command
: Must be “view”path
: The path to the file or directory to viewview_range
(optional): An array of two integers specifying the start and end line numbers to view. Line numbers are 1-indexed, and -1 for the end line means read to the end of the file. This parameter only applies when viewing files, not directories.Example view commands
str_replace
command allows Claude to replace a specific string in a file with a new string. This is used for making precise edits.
Parameters:
command
: Must be “str_replace”path
: The path to the file to modifyold_str
: The text to replace (must match exactly, including whitespace and indentation)new_str
: The new text to insert in place of the old textExample str_replace command
create
command allows Claude to create a new file with specified content.
Parameters:
command
: Must be “create”path
: The path where the new file should be createdfile_text
: The content to write to the new fileExample create command
insert
command allows Claude to insert text at a specific location in a file.
Parameters:
command
: Must be “insert”path
: The path to the file to modifyinsert_line
: The line number after which to insert the text (0 for beginning of file)new_str
: The text to insertExample insert command
undo_edit
command allows Claude to revert the last edit made to a file.
text_editor_20250728
.command
: Must be “undo_edit”path
: The path to the file whose last edit should be undoneExample undo_edit command
view
tool result includes file contents with line numbers prepended to each line (e.g., “1: def is_prime(n):”). Line numbers are not required, but they are essential for successfully using the view_range
parameter to examine specific sections of files and the insert_line
parameter to add content at precise locations.str_replace
command to fix it:type: "text_editor_20250728"
type: "text_editor_20250124"
type: "text_editor_20241022"
Initialize your editor implementation
Handle editor tool calls
Implement security measures
Process Claude's responses
File not found
tool_result
:Multiple matches for replacement
str_replace
command matches multiple locations in the file, return an appropriate error message:No matches for replacement
str_replace
command doesn’t match any text in the file, return an appropriate error message:Permission errors
Provide clear context
Be explicit about file paths
Create backups before editing
Handle unique text replacement carefully
str_replace
command requires an exact match for the text to be replaced. Your application should ensure that there is exactly one match for the old text or provide appropriate error messages.Verify changes
Tool | Additional input tokens |
---|---|
text_editor_20250429 (Claude 4) | 700 tokens |
text_editor_20250124 (Claude Sonnet 3.7) | 700 tokens |
text_editor_20241022 (Claude Sonnet 3.5) | 700 tokens |
Date | Version | Changes |
---|---|---|
July 28, 2025 | text_editor_20250728 | Release of an updated text editor Tool that fixes some issues and adds an optional max_characters parameter. It is otherwise identical to text_editor_20250429 . |
April 29, 2025 | text_editor_20250429 | Release of the text editor Tool for Claude 4. This version removes the undo_edit command but maintains all other capabilities. The tool name has been updated to reflect its str_replace-based architecture. |
March 13, 2025 | text_editor_20250124 | Introduction of standalone text editor Tool documentation. This version is optimized for Claude Sonnet 3.7 but has identical capabilities to the previous version. |
October 22, 2024 | text_editor_20241022 | Initial release of the text editor Tool with Claude Sonnet 3.5. Provides capabilities for viewing, creating, and editing files through the view , create , str_replace , insert , and undo_edit commands. |