write_file — create a new file
write_file creates a new file at path and writes content to it. Parent directories are created automatically. When write_guard is enforced, the call is refused if path already exists — the agent should use edit_file or apply_patch instead.
Schema
Section titled “Schema”| Arg | Type | Required | Description |
|---|---|---|---|
path | string | yes | Relative or absolute path to the new file. |
content | string | yes | File body. May be empty. |
Example invocation
Section titled “Example invocation”{"path": "src/new_module.py", "content": "def hello():\n return 'hi'\n"}from chimera.tools.write import WriteFileTool
tool = WriteFileTool()result = tool.execute( {"path": "examples/note.txt", "content": "first line\n"}, env=local_env,)Output sample
Section titled “Output sample”Wrote 11 bytes to examples/note.txtOn a guarded clobber attempt:
write_file invariant violated for 'examples/note.txt': file already exists; use 'edit_file' or 'apply_patch' ...See also
Section titled “See also”edit_file— patch an existing file.apply_patch— atomic multi-file edits.write_guard— the invariant.