Write
writeCreate or replace entire file content, append text, or preview changes before committing. Refreshes the cache so later reads and searches see the new text.
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; an update reports diff_state, and includes the diff
against the previous content only when you ask with show_diff. A
dry_run writes nothing and says so: the status is
would_create/would_update and dry_run: true comes back with it.
Writing refreshes the cache so later reads, grep, and search see the
new text.
A full write supplies the whole file, so the content_hash it returns is
claimable. An append only adds a tail: pass known_hash to show you held
the rest, or you get file_hash instead. auto_format reports file_hash
too — the formatter's output is not what you sent.
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. | |
| known_hash | No | The `content_hash` you hold for this file. Only needed for `append`, to prove you hold the part you are not resending. | |
| auto_format | No | Run the formatter after writing. | |
| create_parents | No | Create any missing parent directories. |