Write Tool - Claude Code
Create or overwrite files; requires permission for existing paths.
The Write tool creates new files or replaces existing ones entirely. It's the simplest way to put content on disk.
What it does
Write takes an absolute path and a body of content and writes it atomically. Overwriting an existing file requires that Claude has Read it in the current session, which prevents accidental clobbering. For partial edits, the Edit tool is almost always the right choice instead.
When to use it
- Creating a brand-new file from scratch.
- Complete rewrites where an Edit would be longer than the new content.
- Generating boilerplate like config files, templates, or scaffolds.
- Writing binary content through base64 round-trips is not supported - use Bash for that.
Gotchas
- Write overwrites without merging. A typo in the path can destroy a file.
- You cannot Write to a path you haven't Read unless it's new. This is a safety feature.
- Prefer Edit over Write for existing files - diffs are cheaper to review.
Official docs: https://code.claude.com/docs/en/tools-reference.md
Technical content at the intersection of AI and development. Building with AI agents, Claude Code, and modern dev tools - then showing you exactly how it works.
Get the weekly deep dive
Tutorials on Claude Code, AI agents, and dev tools - delivered free every week.
Was this helpful?




