Writes a file to the local filesystem. Creates parent directories automatically.

Usage:
- This tool will overwrite the existing file if there is one at the provided path.
- If this is an existing file, you MUST use the `read` tool first to read the full file. Partial reads do not authorize whole-file writes.
- ALWAYS prefer editing existing files with `edit`. NEVER write new files unless explicitly required.
- NEVER proactively create documentation files (*.md) or README files. Only create documentation if explicitly requested by the user.
- Only use emojis if the user explicitly requests it. Avoid writing emojis to files unless asked.

IMPORTANT:
- Parent directories are created automatically — no need to `mkdir` first.
- For small files: include COMPLETE content in a single call.
- For large files (200+ lines): use mode="append" to build incrementally across multiple calls.
- For reading files, use the `read` tool — never use `bash` with cat/type/Get-Content.
- Do NOT use `write` when only a small part of an existing file needs to change — use `edit` or `patch` instead.
- Do NOT delegate file creation to `task` — just call `write` directly.

Parameters:
- path (required): file path (absolute or relative)
- content (required): file content to write
- mode (optional): "overwrite" (default), "append", or "insert"
  - overwrite: replaces entire file (default behavior)
  - append: adds content to end of existing file (creates file if new)
  - insert: inserts content at a specific line, shifting existing lines down
- insert_at_line (optional): 1-based line number for insert mode

Building large files incrementally (avoids output truncation):
1. First call: write(path, content, mode="overwrite") — create with initial section
2. Subsequent calls: write(path, content, mode="append") — add remaining sections
Each call should be ~100-150 lines to stay well within output limits.

When to use `write` vs `edit` vs `patch`:
- New file that doesn't exist yet → `write`
- Replacing entire file content → `write` (after reading it first)
- Adding content to end of file → `write` with mode="append"
- Changing a few lines in an existing file → `edit`
- Renaming a variable across a file → `edit` with replace_all
- Replacing a large section by line numbers → `patch`
