Edit Tool - Claude Code
Targeted edits to specific sections without rewriting entire files.

Edit is the workhorse for modifying existing files. It performs exact string replacements so you review a diff, not a whole new file.
What it does
Edit takes a file path, an old string, and a new string. It replaces the first occurrence - or all occurrences with replace_all - and leaves everything else untouched. Because it's a diff-style edit, the change is easy to review and less likely to introduce regressions than a full-file Write.
When to use it
- Fixing bugs in specific lines or blocks.
- Renaming variables or functions across a file with
replace_all. - Tweaking config values without rewriting config.
- Any change where the rest of the file should stay byte-identical.
Gotchas
- The
old_stringmust be unique in the file unless you usereplace_all. Include surrounding context to make it unique. - Indentation must match exactly - tabs versus spaces will break a match.
- Edit requires a prior Read of the file. Claude won't edit sight unseen.
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.
Was this helpful?
Related Guides
Related Tools
Claude Code
Anthropic's agentic coding CLI. Runs in your terminal, edits files autonomously, spawns sub-agents, and maintains memory...
View ToolClaude Agent SDK
Anthropic's SDK for building agents on the same tools, agent loop, and context management that power Claude Code. Python...
View ToolAgentCanvas
A hosted infinite canvas your headless AI agents drive over MCP. Any MCP-speaking agent - Claude Code, Codex, Cursor, or...
View ToolZed
High-performance code editor built in Rust with native AI integration. Sub-millisecond input latency. Built-in assistant...
View ToolRelated Videos

Generate Videos in Codex + Claude Code with This...
Check out HeyGen! https://heygen.1stcollab.com/developersdigest The video introduces HeyGen, an AI video generation platform with a rich API and a CLI that lets developers create, fetch, and manipula...

10x Design in Claude Code and Codex
Try Higgsfield: https://higgsfield.ai/s/higgsfield-general-campaign-developersdigest-juDMTi AI coding agents can build entire websites in minutes, but the default results often still look generic and...

Self Improving Applications with Claude Code & Codex
Build a Self‑Improving Next.js App: Supabase + Vercel Eve + GitHub Issues + Agent Loops Check out Supabase: https://supabase.plug.dev/1wWOTGS The video demonstrates how to build and deploy a self-im...
Related Posts

Claude Fable 5.1 in Claude Code: How to Switch, Pin, and Pay Less
Claude Code v2.1.257 points /model fable at Fable 5.1: 1M context, $10/$50 per MTok, $0.25 cache reads. Setup, gotchas,...

Claude Design, Slides and Docs in Any Chat: How to Use Them
Claude Design, Slides and Docs now open in any Claude chat, Claude Code session or the Artifacts tab, on every plan. Exa...

Claude for Startups Offer Paused: What Founders Do Now
Claude for Startups paused its free Claude Team year and $1,000 API credit offer at capacity. What the program page says...

Claude Advisor Tool vs a Bigger Model: When the Pairing Pays
Anthropic's own runs: a Fable 5.1 advisor added 1.7 points to Opus 5.5 for 2.1x the cost. When the Claude advisor tool p...

Claude Code Retry Watchdog: Keep Unattended Runs Alive
CLAUDE_CODE_RETRY_WATCHDOG=1 makes Claude Code wait out 429 and 529 errors instead of failing after 10 retries. When to...

Claude Max API Credits: $100 a Month, What They Cover
Claude Max and Team plans now include a monthly Claude API credit, starting at $100 on Max 5x. What it covers, what it d...
