write
Write file content and instantly update the cache so reads and searches see the new text. Supports append, diff preview, and auto-formatting.
Instructions
Create a file or replace its entire contents.
Use this for new files or full rewrites; for localized changes prefer
edit or batch_edit. Status is created for a new path or updated
for an existing one, and an update returns a unified diff against the
previous content. Writing refreshes the cache so later reads, grep, and
search see the new text. The response carries the new content_hash;
pass it back as read's known_hash to get unchanged instead of
re-reading the file you just wrote. Missing parent directories are created
unless create_parents=false.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | File path to create or replace (absolute, or relative to root). | |
| append | No | Append `content` to the end of the file instead of overwriting. | |
| content | Yes | Full file content, or the text to append when `append=true`. | |
| dry_run | No | Preview the result without writing. | |
| show_diff | No | Return the unified diff even on a deterministic write. | |
| auto_format | No | Run the formatter after writing. | |
| create_parents | No | Create any missing parent directories. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| diff | No | ||
| path | No | ||
| status | No | ||
| created | No | ||
| dry_run | No | ||
| truncated | No | ||
| diff_state | No | ||
| diff_stats | No | ||
| from_cache | No | ||
| content_hash | No | ||
| diff_omitted | No | ||
| tokens_saved | No | ||
| bytes_written | No | ||
| tokens_written | No |