Skip to content

Write

write_file creates or overwrites a host file. To change part of an existing file, use edit_file or multi_edit.

NeedParameters
Textpath, content
Appendmode:"append". Does not trigger the rewrite guard.
Binarycontent_base64, or content with encoding:"base64"

mode is overwrite (default) or append.

The write is temp file plus rename. See Atomic writes. Structured output includes path, bytes_written, content_hash, verified, and message. backup_id is present when a safety backup was created.

verified is true only when the final host file was reopened and measured. Confirm with get_file_info or read_file when the content matters. A successful tool response is not the only check.

write_file has no dry_run. Status is applied.

Secret paths are denied unless --allow-secrets. A file security policy can still block the write.

--readonly rejects this tool. --mutation-budget counts an applied write. Over the limit the code is BUDGET_EXCEEDED (retryable false). Dry-run does not count. write_file has no dry-run, so a real write counts.