Write File Skill
Write content to a file, creating it if it doesn't exist.
When to Use
Use the write_file skill for:
- Creating new files: New source files, configs, documentation
- Overwriting files: Replace entire file contents
- Appending to files: Add content to end of existing file
- Creating with directories: Auto-create parent directories
Input Format
{
"path": "src/new-file.ts",
"content": "export const hello = 'world';",
"createDirs": true
}
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
path |
string | Yes | - | Path to file (relative to workspace) |
content |
string | Yes | - | Content to write |
append |
boolean | No | false | Append instead of overwrite |
createDirs |
boolean | No | true | Create parent directories |
Output Format
{
"success": true,
"output": "File written: src/new-file.ts (42 bytes)",
"exitCode": 0
}
Examples
Create a new file
{
"path": "src/utils/helper.ts",
"content": "export function helper() {\n return 'help';\n}\n"
}
Append to a file
{
"path": "log.txt",
"content": "New log entry\n",
"append": true
}
Limitations
- Text only — this tool writes UTF-8 text. It cannot produce binary files (PDF, images, DOCX, ZIP, etc.). Writing text to a
.pdfor other binary extension will create a corrupt, unreadable file. - To generate PDFs, use the pdf skill (write a .typ file, compile with typst).
- To generate images, use bash with an appropriate library.
Security
- Paths are validated to stay within workspace
- Cannot write to system directories
- Symlinks escaping workspace are blocked