# `write_file` Create a file, or overwrite one in full. **Input** — `path` (required), `contents` (required) For changing part of an existing file, prefer [`edit_file`](edit_file.md): it replaces just the matched text, so the model doesn't have to reproduce the rest of the file and can't silently discard edits it never read. This tool is for a new file, or for when the file should become exactly these contents. Overwrites, or creates along with any missing directories. Returns the byte count and a unified diff against what was there before, so the model sees what it actually changed rather than assuming. The dock renders that diff in colour in the tool card. Diffing is skipped for files over 2000 lines — the LCS pass is O(n·m) and would stall the editor — and the result says so.