Skip to content

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.

  • 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

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

“Create a Makefile in the project root with targets for build, test, and clean.”

The AI will Write the full Makefile content to ./Makefile.

“Generate a docker-compose.yml for a PostgreSQL + Redis + Node.js app and save it.”

The AI will Write the complete YAML to ./docker-compose.yml.

ToolUse case
WriteCreate a new file or completely overwrite an existing one
EditTargeted 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