# write

Canonical URL: https://developers.iagenify.com/sdk/agent/tools/write/
Language: en

`write({ path, content })`

Create a file, or replace one whole. The previous version is kept automatically.

Status: category: write · keeps the old version · free in auto

| Name | Type | Requirement | Description |
| --- | --- | --- | --- |
| `path` | string | required | Relative to the workspace. Parent folders are created. |
| `content` | string | required | The whole file. |

## For an existing file, prefer edit {#prefer-edit}

> **Rewriting a file whole costs its whole length in output tokens**
>
> The agent is instructed to use edit or multi_edit on a file that exists, and write only for new ones. A 600-line file rewritten to change one line is 600 lines of output, paid for and slow.

## Nothing is lost {#versions}

Replacing a file writes the previous content under `.versions/` first. That is what lets [auto](/sdk/agent/modes/auto) mode let writes through without asking.

## Text only {#binary}

Content is a string. Generated media is written by its own tool, and a converted file by [convert](/sdk/agent/tools/convert).

- [edit](/sdk/agent/tools/edit): Changing part of a file.
- [delete](/sdk/agent/tools/delete): Removing one, recoverably.
- [Agent tools](/sdk/agent/tools): The 35, by family.
