# Write File

> Write or create a file in the workspace

- Skill: `tashfeenahmed/write-file` (Agent Skill, multi-file: 2 files)
- Install (CLI): `npx skillmds@latest add tashfeenahmed/write-file`
- Raw SKILL.md: https://api.skillmd.com/api/skills/tashfeenahmed/write-file/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: tashfeenahmed (https://skillmd.com/u/tashfeenahmed)
- Updated: 2026-09-21
- Page: https://skillmd.com/skills/tashfeenahmed/write-file

---


# 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

```json
{
  "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

```json
{
  "success": true,
  "output": "File written: src/new-file.ts (42 bytes)",
  "exitCode": 0
}
```

## Examples

### Create a new file

```json
{
  "path": "src/utils/helper.ts",
  "content": "export function helper() {\n  return 'help';\n}\n"
}
```

### Append to a file

```json
{
  "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 `.pdf` or 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

