# Write Tool

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

**Field:** Artificial Intelligence  
**Category:** Claude Code  
**Also known as:** Write, Claude Code Write tool

## Think of it like

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

## 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

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

## Example code

```json
{"permissions": {"allow": ["Edit(./docs/**)"]}}
```

A rule for Edit on a folder works for Write too.

## Why it matters

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

## 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.

## Three principles

- **Whole file.** New or replaced.
- **Not a patch.** Edit does small changes.
- **Asks first.** Unless allowed.

## Related terms

- [Edit Tool](https://learn.benibix.com/term/ai/edit-tool)
- [Read Tool](https://learn.benibix.com/term/ai/read-tool)
- [Claude Code Built-in Tool](https://learn.benibix.com/term/ai/claude-code-built-in-tool)

## Told apart from

- [Edit vs Write](https://learn.benibix.com/compare/edit-tool-vs-write-tool): People often think Write can change part of a file. It cannot. Write puts in a whole new file and throws the old text away. Edit swaps one exact piece of text and leaves the rest alone. So Claude uses Write for a new file and Edit for a small fix. A rule for Edit on a folder covers Write there too.

## Taught in

- [Claude Code File Tools](https://learn.benibix.com/learn/ai-claude-code/claude-code-file-tools): Claude Code, 9/16

![Glob finds files by name, Grep finds lines inside them, Read opens one, then Edit changes a part or Write replaces it all.](https://learn.benibix.com/diagrams/ct-file-tools.svg)

---

Source: https://learn.benibix.com/term/ai/write-tool
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-17
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
