[BUG] Claude Code creates literal ~/ directory in working directory instead of expanding to home path
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
Claude Code's internal file operations create a literal ~/ directory in the current working directory instead of properly expanding ~ to the user's home directory.
It should not write "~/.claude" to the directory claude is operating out of. but expand the ~ to the home directory
Claude Code creates a literal directory named ~ in the working directory:
my-project/
├── ~/ # Should NOT exist
│ └── .claude-hs/
│ └── projects/
│ └── ...
├── src/
└── ...
The correct location should be:
/Users/username/.claude-hs/projects/...
Path expansion is not happening in Claude Code's internal file operations. When code attempts to write to ~/.claude-hs/..., it's being interpreted literally as ./~/.claude-hs/... relative to the current working directory.
What Should Happen?
Claude Code should expand ~ to the user's home directory (e.g., /Users/username/) when writing internal files.
Error Messages/Logs
Steps to Reproduce
I have not been able to reproduce this consistently, and figure out what command actually makes the write. But it happens fairly frequently.
Open Claude Code in any project directory
Let Claude Code run normally (no specific commands needed)
Check the working directory for a ~/ folder
Claude Model
None
Is this a regression?
Yes, this worked in a previous version
Last Working Version
_No response_
Claude Code Version
2.1.3 (Claude Code)
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
Terminal.app (macOS)
Additional Information
_No response_
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗