Skip to content
BENIBIX Learn

Write Tool

AI⌨️ Claude CodeBuilt-in Tools

Also known as Write, Claude Code Write tool

The tool that makes a new file or replaces a whole one.

Think of it like

It is like a clean new page. You write it all from the top.

Example

Lucy asks for a new test file. Claude uses Write to make it from scratch, then runs the tests to check it.

Why it matters

It is how brand new files appear, so it is one of the actions worth watching.

Definition

The Write tool makes a new file, or replaces a whole file with new text. It does not add to the end or mix old and new. For a small change to a file that already exists, Claude uses Edit instead. Before Claude replaces a file that exists, it usually has to have read it in the same session. Write asks for permission before it runs, unless your mode or rules allow it.

Example code

json
{"permissions": {"allow": ["Edit(./docs/**)"]}}
A rule for Edit on a folder works for Write too.
Write replaces a whole file. Edit changes one part.

Common mistake

Expecting Write to keep the old text. It replaces the whole file, so a change to one part is a job for Edit.

Key takeaways

  1. 1
    Whole file. New or replaced.
  2. 2
    Not a patch. Edit does small changes.
  3. 3
    Asks first. Unless allowed.

Compare

Learn it properly