Write
The Write tool creates a new file or completely overwrites an existing file with provided content. Use it when you need to generate a file from scratch or replace a file’s entire contents.
What It Does
Section titled “What It Does”- Creates a new file at the specified path (including any missing parent directories)
- Or completely overwrites an existing file with new content
- Returns confirmation once the file is written
When It’s Used
Section titled “When It’s Used”The AI uses Write when:
- You ask it to create a new file (script, config, document, etc.)
- You want to replace an entire file’s content
- It’s generating output that should be saved to disk
Example
Section titled “Example”“Create a
Makefilein the project root with targets for build, test, and clean.”
The AI will Write the full Makefile content to ./Makefile.
“Generate a
docker-compose.ymlfor a PostgreSQL + Redis + Node.js app and save it.”
The AI will Write the complete YAML to ./docker-compose.yml.
How It Differs from Edit
Section titled “How It Differs from Edit”| Tool | Use case |
|---|---|
| Write | Create a new file or completely overwrite an existing one |
| Edit | Targeted replacement of a specific piece of text in an existing file |
Write replaces the entire file. When modifying an existing file where only part of it needs to change, Edit is safer.
- Write will create intermediate directories if they don’t exist
- Always confirm you want a full overwrite before the AI uses Write on an existing file that has important content
- For large files, the AI may use a combination of Read + Edit instead of Write to avoid unintentional data loss