text-editor-tool changedagents-and-tools/tool-use/text-editor-tool
Nearest release: v2.1.312, published under an hour before this site recorded the change. Shown because the two are within 24 hours of each other. Nothing here says the release caused the edit.
Recorded here
Lines+25added
Lines−25removed
From line
226
where the diff opens
First seen
14 Aug 2026
this site's first read of the page
Recorded edits12to this page, all time
The whole hunk
from line 226, old and new numbered
/
from line 226
226226<Steps>
227227 <Step title="Provide Claude with the text editor tool and a user prompt">
228228 * Include the text editor tool in your API request.
229 * Provide a user prompt that might require examining or modifying files, such as "Can you fix the syntax error in my code?"
229 * Provide a user prompt that might require examining or modifying files, such as “Can you fix the syntax error in my code?”
230230 </Step>
231231
232232 <Step title="Claude uses the tool to examine files or directories">
from line 235
235235 </Step>
236236
237237 <Step title="Run the view command and return results">
238 * Extract the file or directory path from Claude's tool use request.
239 * Read the file's contents or list the directory contents.
238 * Extract the file or directory path from Claude’s tool use request.
239 * Read the file’s contents or list the directory contents.
240240 * If you specified a `max_characters` parameter in the tool configuration, truncate the file contents to that length.
241241 * Return the results to Claude by continuing the conversation with a new `user` message containing a `tool_result` content block.
242242 </Step>
from line 247
247247 </Step>
248248
249249 <Step title="Make the edit and return results">
250 * Extract the file path, old text, and new text from Claude's tool use request.
250 * Extract the file path, old text, and new text from Claude’s tool use request.
251251 * Perform the text replacement in the file.
252252 * Return the results to Claude.
253253 </Step>
from line 267
267267
268268Parameters:
269269
270* `command`: Must be "view"
270* `command`: Must be `view`
271271* `path`: The path to the file or directory to view
272272* `view_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.
273273
from line 307
307307
308308Parameters:
309309
310* `command`: Must be "str\_replace"
310* `command`: Must be `str_replace`
311311* `path`: The path to the file to modify
312312* `old_str`: The text to replace (must match exactly, including whitespace and indentation)
313313* `new_str`: The new text to insert in place of the old text
from line 334
334334
335335Parameters:
336336
337* `command`: Must be "create"
337* `command`: Must be `create`
338338* `path`: The path where the new file should be created
339339* `file_text`: The content to write to the new file
340340
from line 359
359359
360360Parameters:
361361
362* `command`: Must be "insert"
362* `command`: Must be `insert`
363363* `path`: The path to the file to modify
364364* `insert_line`: The line number after which to insert the text (0 for beginning of file)
365365* `insert_text`: The text to insert
from line 1016
10161016<Tip>
10171017 **Line numbers**
10181018
1019 In the preceding example, the `view` tool result includes file contents with line numbers prepended to each line (for example, "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.
1019 In the preceding example, the `view` tool result includes file contents with line numbers prepended to each line (for example, “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.
10201020</Tip>
10211021
10221022Claude identifies the syntax error and uses the `str_replace` command to fix it:
from line 1478
14781478
14791479## Implement the text editor tool
14801480
1481The text editor tool is implemented as a schema-less tool. When using this tool, you don't need to provide an input schema as with other tools; the schema is built into Claude's model and can't be modified.
1481The text editor tool is implemented as a schema-less tool. When using this tool, you don’t need to provide an input schema as with other tools; the schema is built into Claude’s model and can’t be modified.
14821482
14831483The tool type is `type: "text_editor_20250728"` for Claude 4 and later models.
14841484
from line 1648
16481648 * Implement permissions checks
16491649 </Step>
16501650
1651 <Step title="Process Claude's responses">
1652 Extract and handle tool calls from Claude's responses:
1651 <Step title="Process Claude’s responses">
1652 Extract and handle tool calls from Claude’s responses:
16531653
16541654 <CodeGroup exclude="shell">
16551655 ```python Python
from line 1777
17771777
17781778<AccordionGroup>
17791779 <Accordion title="File not found">
1780 If Claude attempts to view or modify a file that doesn't exist, return an appropriate error message in the `tool_result`:
1780 If Claude attempts to view or modify a file that doesn’t exist, return an appropriate error message in the `tool_result`:
17811781
17821782 ```json
17831783 {
from line 1795
17951795 </Accordion>
17961796
17971797 <Accordion title="Multiple matches for replacement">
1798 If Claude's `str_replace` command matches multiple locations in the file, return an appropriate error message:
1798 If Claude’s `str_replace` command matches multiple locations in the file, return an appropriate error message:
17991799
18001800 ```json
18011801 {
from line 1813
18131813 </Accordion>
18141814
18151815 <Accordion title="No matches for replacement">
1816 If Claude's `str_replace` command doesn't match any text in the file, return an appropriate error message:
1816 If Claude’s `str_replace` command doesn’t match any text in the file, return an appropriate error message:
18171817
18181818 ```json
18191819 {
from line 1855
18551855 <Accordion title="Provide clear context">
18561856 When asking Claude to fix or modify code, be specific about what files to examine or what issues to address. Clear context helps Claude identify the right files and make appropriate changes.
18571857
1858 **Less helpful prompt:** "Can you fix my code?"
1858 **Less helpful prompt:** “Can you fix my code?”
18591859
1860 **Better prompt:** "There's a syntax error in my primes.py file that prevents it from running. Can you fix it?"
1860 **Better prompt:** “There’s a syntax error in my primes.py file that prevents it from running. Can you fix it?”
18611861 </Accordion>
18621862
18631863 <Accordion title="Be explicit about file paths">
1864 Specify file paths clearly when needed, especially if you're working with multiple files or files in different directories.
1864 Specify file paths clearly when needed, especially if you’re working with multiple files or files in different directories.
18651865
1866 **Less helpful prompt:** "Review my helper file"
1866 **Less helpful prompt:** “Review my helper file”
18671867
1868 **Better prompt:** "Can you check my utils/helpers.py file for any performance issues?"
1868 **Better prompt:** “Can you check my utils/helpers.py file for any performance issues?”
18691869 </Accordion>
18701870
18711871 <Accordion title="Create backups before editing">
from line 2227
22272227
22282228## Pricing and token usage
22292229
2230The text editor tool uses the same pricing structure as other tools used with Claude. It follows the standard input and output token pricing based on the Claude model you're using.
2230The text editor tool uses the same pricing structure as other tools used with Claude. It follows the standard input and output token pricing based on the Claude model you’re using.
22312231
22322232In addition to the base tokens, the following additional input tokens are needed for the text editor tool:
22332233
from line 2242
22422242
22432243You can use the text editor tool alongside other Claude tools. When combining tools, ensure you:
22442244
2245* Match the tool version with the model you're using
2245* Match the tool version with the model you’re using
22462246* Account for the additional token usage for all tools included in your request
22472247
22482248## Change log
No line in this hunk matches that.