claude-code - 💡(How to fix) Fix [BUG] Write tool resolves absolute paths through `~/.claude` symlink to a literal-backslash-escaped path stored under cwd [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#55139Fetched 2026-05-01 05:45:15
View on GitHub
Comments
1
Participants
2
Timeline
5
Reactions
0
Author
Timeline (top)
labeled ×4commented ×1

Error Message

Cross-class observation — silent-rot class member: this bug is a textbook silent-rot incident (per the umbrella addendum just shipped to Jane's lessons-learned tonight): tool returns success → file doesn't end up where expected → caller assumes operation worked → discovery requires explicit verification (find or ls). Same shape as Sheets API batch_update silently succeeding with wrong sheetId (Jane's lesson #13). The Write tool's failure mode would not surface through reactive error-handling — it requires the proactive read-back-after-mutation discipline. Worth Anthropic awareness: Write tool joins the Sheets API + iMessage MCP + jq schema-drift class as a silent-rot tool. 3. Fail-fast on backslash-escape detection. If the resolved path contains backslash-escaped path components (a strong sign of resolution failure), error rather than silently storing at the escaped-path location.

Root Cause

Severity: Medium (silent-rot class — write returns success, file lands at wrong path; recovery is straightforward via find + cp but discovery requires explicit verification because the success message itself doesn't reveal the bug).

Fix Action

Fix / Workaround

Workarounds in place (two paths):

RAW_BUFFERClick to expand / collapse

Severity: Medium (silent-rot class — write returns success, file lands at wrong path; recovery is straightforward via find + cp but discovery requires explicit verification because the success message itself doesn't reveal the bug).

Filing target: github.com/anthropics/claude-code — confirmed via package.json of the installed @anthropic-ai/[email protected] (homepage field: https://github.com/anthropics/claude-code). This is Claude Code core, distinct from #4's anthropics/claude-plugins-official (the plugin marketplace).

Title: Write tool resolves absolute paths through ~/.claude symlink to a literal-backslash-escaped path stored under cwd

Repro (deterministic, 6/6 confirmed independently tonight across 3 agents and both leaf + index file types):

  1. Agent has cwd at /Volumes/Jane-Data/claudeclaw/agents/<agent>/.
  2. Agent calls Write with file_path="/Users/jane/.claude/projects/-Volumes-Jane-Data-claudeclaw-agents-<agent>/memory/<filename>.md" (absolute path through ~/.claude, which on this system is a symlink to /Volumes/Jane-Data/claude-config).
  3. Write tool returns success with reported path: \/Volumes\/Jane-Data\/claude-config\/projects/-Volumes-Jane-Data-claudeclaw-agents-<agent>/memory/<filename>.md (forward slashes through the symlink target are backslash-escaped).
  4. The actual file lands at <cwd>/\/Volumes\/Jane-Data\/claude-config\/projects/-Volumes-Jane-Data-claudeclaw-agents-<agent>/memory/<filename>.md — a literal directory tree where the directory names contain backslash characters, prepended by cwd because the leading \/ is no longer recognized as an absolute-path-start.
  5. The intended absolute path (e.g. /Users/jane/.claude/projects/...) remains empty — read attempts via ls against the intended path show the file is not there.

Concrete incidents (independently observed, 6 of 6 hit the same pattern):

  • 2026-04-26 ~18:50 BST — Jane writing feedback_no_backticks_in_hcom_send.md to /Users/jane/.claude/projects/-Users-jane/memory/. Hit the escape-path bug.
  • 2026-04-26 18:51 BST — Bookworm writing feedback_push_peer_to_reclaim_canonical_name.md to /Users/jane/.claude/projects/-Volumes-Jane-Data-claudeclaw-agents-bookworm/memory/. Hit the escape-path bug.
  • 2026-04-26 18:51 BST — Bookworm's MEMORY.md (index file, not just leaf memory) write to the same directory. Hit the escape-path bug.
  • 2026-04-26 19:14 BST — Jane writing feedback_claim_proper_name_on_startup.md to her own memory dir. Hit the escape-path bug. Indexed in MEMORY.md as a phantom for ~25 min before audit.
  • 2026-04-26 ~19:50 BST — Guardian writing feedback_peer_restart_reclaim_nudge.md to /Users/jane/.claude/projects/-Volumes-Jane-Data-claudeclaw-agents-guardian/memory/. Hit the escape-path bug. Caught via post-write index-vs-files audit.
  • 2026-04-26 19:38 BST — Jane writing feedback_audit_after_memory_write.md (drafted via heredoc to bypass the bug). The heredoc path landed correctly; this is the negative-control confirming the bug is Write-tool-specific, not a filesystem issue.

All six writes succeeded as files on disk — the data isn't lost — but they landed at literal-backslash-escaped paths under their respective cwds rather than the intended ~/.claude/... absolute path. Six of six Write-tool calls through the symlink hit the same encoding pattern across 3 different agent cwds (Jane / Bookworm / Guardian) and across multiple file types (leaf memory *.md files + the MEMORY.md index file itself). Bash heredoc to the same path landed correctly (negative control). Appears deterministic for absolute paths whose first segment resolves through the /Users/jane/.claude → /Volumes/Jane-Data/claude-config symlink, specifically when invoked via the Write tool. Recovery is universal: find <cwd> -name <filename> + cp to intended path.

Workarounds in place (two paths):

  1. Heredoc bypass (preferred — ships clean on first attempt): use Bash heredoc directly instead of the Write tool: cat > /Users/jane/.claude/projects/.../foo.md << 'EOF' ... EOF. Bypasses the Write tool's path-resolution logic entirely; bash handles the symlinked path correctly. Bookworm shipped two memory writes via this path tonight, both landed at the intended absolute path on first attempt.

  2. Write-then-recover (fallback if heredoc not viable): after every Write to a ~/.claude/... path, verify the file landed at the intended absolute path via ls -la <intended-path>. If absent, run find <cwd> -name <filename> 2>/dev/null to locate the actual landing site, then cp to the intended path. Adds ~15 sec per write; not blocking but introduces silent-rot risk if the verification step is skipped (the Write tool's success message itself does NOT reveal the path-misdirection).

Expected: Write to /Users/jane/.claude/projects/.../foo.md lands at exactly that absolute path (or its symlink-resolved equivalent /Volumes/Jane-Data/claude-config/projects/.../foo.md); both ls /Users/jane/.claude/... and ls /Volumes/Jane-Data/claude-config/... should show the file.

Actual: file lands at <cwd>/\/Volumes\/Jane-Data\/claude-config\/projects/.../foo.md with backslash-escaped path components stored as literal directory names. Intended path remains empty.

Versions:

  • Claude Code core tool (Write). Version TBD — observed on the production version running on this system as of 2026-04-26 (Guardian to confirm exact version).
  • Bug observed on macOS Darwin 25.3.0 (M4 Mac Mini). Symlink topology: /Users/jane/.claude → /Volumes/Jane-Data/claude-config (via mklink-style link or ln -s).

Cross-class observation — silent-rot class member: this bug is a textbook silent-rot incident (per the umbrella addendum just shipped to Jane's lessons-learned tonight): tool returns success → file doesn't end up where expected → caller assumes operation worked → discovery requires explicit verification (find or ls). Same shape as Sheets API batch_update silently succeeding with wrong sheetId (Jane's lesson #13). The Write tool's failure mode would not surface through reactive error-handling — it requires the proactive read-back-after-mutation discipline. Worth Anthropic awareness: Write tool joins the Sheets API + iMessage MCP + jq schema-drift class as a silent-rot tool.

Likely sibling issues in the same path-resolution code (open as of filing):

  • #52463[BUG] Edit tool silently fails (reports success, no write) when target is a relative .. symlink inside a symlinked-directory chain. Same silent-failure family (tool reports success, write goes nowhere), different trigger (Edit + relative-..-leaf-symlink vs Write + absolute path through symlinked-directory). Fix probably touches the same symlink-resolution layer.
  • #45260[BUG] Standalone auto-updater writes to CWD instead of ~/.local/share/claude, creates relative symlink. Same wrong-path-CWD-fallback behavior we observe (intended absolute target → write actually lands under cwd). Different code path (updater vs Write tool) but identical failure shape.
  • #52772[BUG] Auto memory system prompt path uses CWD-based path but /memory creates directory at git-root-based path. Same area (auto-memory + path resolution + CWD divergence). Different symptom but adjacent code.

Triaging these together may surface a shared root cause in Claude Code's path-resolution / symlink-handling layer.

Asks (in preference order):

  1. Fix the path-resolution. Write should resolve ~/.claude symlinks normally (treating the resolved path as absolute), without backslash-escaping forward slashes in the resolved target. The fix likely sits at the symlink-handling layer of the path-resolution code.
  2. Surface the resolved path in the success message. Even after fix, returning the actual landing path (not the input path) on success would help callers verify correctly. Currently the success message echoes the input path, which masks the divergence.
  3. Fail-fast on backslash-escape detection. If the resolved path contains backslash-escaped path components (a strong sign of resolution failure), error rather than silently storing at the escaped-path location.

Logs/evidence pointers (local files, not for upload):

  • /Volumes/Jane-Data/claudeclaw/agents/bookworm/\/Volumes\/Jane-Data\/claude-config\/projects/-Volumes-Jane-Data-claudeclaw-agents-bookworm/memory/feedback_push_peer_to_reclaim_canonical_name.md — Bookworm's wrong-path file (kept temporarily as evidence; intended-path copy is canonical)
  • hcom thread: messages #34503 (watcher confirms allow-prompt resolved), #34528 (Bookworm flagging the bug post-recovery), #34535 (Jane confirming independent observation) — intra-team threading; not for upload

extent analysis

TL;DR

The Write tool's path-resolution logic should be fixed to correctly handle symlinks, specifically treating the resolved path as absolute and avoiding backslash-escaping of forward slashes.

Guidance

  • Verify the Write tool's version to ensure it's the latest, as the exact version is TBD.
  • Review the path-resolution code to identify the root cause of the backslash-escaping issue, potentially related to symlink handling.
  • Consider implementing a fail-fast mechanism to detect and error on backslash-escaped path components.
  • In the meantime, use the heredoc bypass workaround for writing to ~/.claude/... paths, as it bypasses the Write tool's path-resolution logic.

Example

No code snippet is provided, as the issue is related to the Write tool's internal logic.

Notes

The bug is a silent-rot incident, requiring explicit verification to discover, and is likely related to other issues in the same path-resolution code, such as #52463, #45260, and #52772.

Recommendation

Apply the heredoc bypass workaround until the path-resolution logic is fixed, as it provides a reliable way to write to ~/.claude/... paths without relying on the Write tool's flawed logic.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix [BUG] Write tool resolves absolute paths through `~/.claude` symlink to a literal-backslash-escaped path stored under cwd [1 comments, 2 participants]