write_file
Create or overwrite a file with specified text content, automatically creating parent directories. Supports custom encoding and optional confirmation for secure environments.
Instructions
Create or overwrite a file with the given content.
Creates parent directories automatically. Overwrites existing files
without warning — use file_exists() first if unsure.
Requires explicit confirmation when ``security.require_confirmation``
is enabled in config.
Args:
path: Path to write (absolute or relative to cwd).
content: The text content to write.
encoding: File encoding. Default: "utf-8".
confirm: Set to True to confirm when required by config.
Returns:
A dict with keys: status, data (path, size_bytes, lines).
Examples:
write_file("notes.txt", "Hello, World!")
write_file("src/config.py", "DEBUG = True
", confirm=True)
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | ||
| confirm | No | ||
| content | Yes | ||
| encoding | No | utf-8 |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||