claude-code - 💡(How to fix) Fix [BUG] Edit tool breaks hardlinks [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#48424Fetched 2026-04-16 07:00:32
View on GitHub
Comments
1
Participants
2
Timeline
5
Reactions
0
Author
Timeline (top)
labeled ×4commented ×1

Fix Action

Fix / Workaround

This is a serious bug. I can't let claude-code modify anything that is a hardlink. There is no workaround.

Code Example

echo "line 1" > /tmp/source.md
   echo "line 2" >> /tmp/source.md
   cp -l /tmp/source.md /tmp/deployed.md
   # Verify same inode:
   stat /tmp/source.md /tmp/deployed.md

---

stat /tmp/source.md /tmp/deployed.md
   # source.md has a NEW inode number
   # deployed.md has the OLD inode number
   # They are no longer linked

   cat /tmp/deployed.md
   # Still shows "line 1" — old content
RAW_BUFFERClick to expand / collapse

Preflight Checklist

  • I have searched existing issues and this hasn't been reported yet
  • This is a single bug report (please file separate reports for different bugs)
  • I am using the latest version of Claude Code

What's Wrong?

Already reported but closed due to inactivity https://github.com/anthropics/claude-code/issues/28376

This is a serious bug. I can't let claude-code modify anything that is a hardlink. There is no workaround.

What Should Happen?

Do not replace hardlinks, edit them in place.

Steps to Reproduce

  1. Create a test file and hard link:

    echo "line 1" > /tmp/source.md
    echo "line 2" >> /tmp/source.md
    cp -l /tmp/source.md /tmp/deployed.md
    # Verify same inode:
    stat /tmp/source.md /tmp/deployed.md
  2. Open Claude Code in the directory containing source.md

  3. Ask Claude: "Edit /tmp/source.md — replace 'line 1' with 'modified line 1'"

  4. Claude uses the Edit tool. The edit succeeds.

  5. Check the hard link:

    stat /tmp/source.md /tmp/deployed.md
    # source.md has a NEW inode number
    # deployed.md has the OLD inode number
    # They are no longer linked
    
    cat /tmp/deployed.md
    # Still shows "line 1" — old content

Claude Model

Opus

Is this a regression?

No, this never worked

Last Working Version

No response

Claude Code Version

2.1.92 (Claude Code)

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

iTerm2

Additional Information

No response

extent analysis

TL;DR

The issue can be mitigated by modifying Claude Code to edit files in place instead of replacing them, especially when dealing with hardlinks.

Guidance

  • Verify that the issue is indeed caused by Claude Code's file replacement behavior by checking the inode numbers of the files before and after editing.
  • Investigate the Edit tool used by Claude Code to see if it can be configured to edit files in place instead of replacing them.
  • Consider adding a check for hardlinks before editing a file, and if a hardlink is detected, edit the file in place instead of replacing it.
  • Check the Anthropic API documentation to see if there are any existing features or workarounds for handling hardlinks.

Example

No code snippet is provided as the issue does not imply a specific code solution, but rather a change in behavior or configuration.

Notes

The issue is specific to the Opus Claude Model and the Anthropic API, so any solution or workaround may need to be tailored to these specific technologies. Additionally, the issue has been reported before but was closed due to inactivity, so it's possible that the solution may involve revisiting previous discussions or code changes.

Recommendation

Apply workaround: Modify Claude Code to edit files in place instead of replacing them, especially when dealing with hardlinks, as this is the most likely solution to resolve the issue without waiting for a potential fix in a future version.

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