[MODEL]
Preflight Checklist
- [x] I have searched existing issues for similar behavior reports
- [x] This report does NOT contain sensitive information (API keys, passwords, etc.)
Type of Behavior Issue
Claude modified files I didn't ask it to modify
What You Asked Claude to Do
I asked Claude "make code changes needed to fix the bug we've identified, run the tests locally, and then commit and push the branch"
What Claude Actually Did
Claude Code ran ln -sf ~/{project workspace director}/.env .env without verifying the working directory first. The CWD was already the target directory, so the command created a self-referential symlink that replaced the existing .env file. Claude Code then deleted that symlink to resolve a different error, permanently destroying the file.
The root cause was running a destructive command (ln -sf, which silently overwrites) without checking pwd first, and not recognizing that ln -sf <path> <path> pointed at itself.
Expected Behavior
Claude should not have touched the .env at all. There are no scenarios where that file needed to be symlinked, edited, removed, or otherwise touched.
Files Affected
~/{workspace_dir}/.env
Permission Mode
Accept Edits was ON (auto-accepting changes)
Can You Reproduce This?
No, only happened once
Steps to Reproduce
_No response_
Claude Model
Sonnet
Relevant Conversation
Impact
High - Significant unwanted changes
Claude Code Version
2.1.123
Platform
Anthropic API
Additional Context
_No response_
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗