[BUG] Write/Edit tools silently accept relative paths despite spec requiring absolute — confused Claude can trample files
Resolved 💬 5 comments Opened Mar 24, 2026 by Kenoubi Closed May 23, 2026
Bug description
The Write and Edit tool descriptions state file_path must be absolute:
The file_path parameter must be an absolute path, not a relative path
However, both tools silently accept and resolve relative paths. This is a safety issue, not just a UX bug:
- If Claude passes a relative path, it is not following the tool spec, which usually means Claude is confused about which file it is targeting
- Silently resolving the path masks the confusion — Claude thinks it succeeded at writing what it intended
- A confused Claude writing to an unexpected resolved path can trample files
Steps to reproduce
- Have Claude use
Writewithfile_path="scratch/test.txt"(relative) - File is created successfully — no error, no warning
- Claude does not realize it violated the tool spec
Expected behavior
The tool should reject relative paths with a clear error: "file_path must be absolute (got relative path: scratch/test.txt)". This forces Claude to clarify which file it actually means, catching confusion early.
Security impact
Relative path acceptance means Claude can write files based on whatever cwd happens to be, which varies by context (worktrees, subagents, plan-mode transitions). An absolute path requirement ensures Claude is explicit about where it is writing, making writes auditable and predictable.
Related
- #29841 — Write tool shows error but still writes with relative paths (same root cause, different symptom)
Environment
- Claude Code v2.1.x on Linux (WSL2)
- Discovered via PreToolUse hook that inspects file_path for permission decisions
This issue has 5 comments on GitHub. Read the full discussion on GitHub ↗