[BUG] /memory command fails when project path contains spaces
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?
When using the /memory command in a project whose path contains spaces, Claude Code incorrectly opens two files named after path segments instead of the memory file.
Likely Cause:
The project path is not being properly quoted when passed to the file open command, causing shell word splitting on spaces.
What Should Happen?
The /memory command should open the Claude memory file (.claude/CLAUDE.md or project-specific memory file) regardless of spaces in the project path.
Error Messages/Logs
Steps to Reproduce
- Navigate to or open a project at a path containing spaces (e.g.,
/Users/username/Documents/Dev/1. Main Projects/MyProject) - Start Claude Code in that directory
- Run the
/memorycommand - Observe that instead of opening the memory file, two files are created/opened: one named
1and another namedMain(these come from the path segment1. Main Projects)
Claude Model
None
Is this a regression?
Yes, this worked in a previous version
Last Working Version
_No response_
Claude Code Version
2.0.76 (Claude Code)
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
Terminal.app (macOS)
Additional Information
When Claude Code runs something like:
open /Users/username/Documents/Dev/1. Main Projects/MyProject/.claude/CLAUDE.md
The shell splits on spaces and interprets it as:
open /Users/username/Documents/Dev/1.
open Main
open Projects/MyProject/.claude/CLAUDE.md
The Fix
Wrap the path in quotes:
open "/Users/username/Documents/Dev/1. Main Projects/MyProject/.claude/CLAUDE.md"
In the Claude Code source, this would look something like:
// Before (broken)
exec(open ${memoryFilePath})
// After (fixed)
exec(open "${memoryFilePath}")
// Or better - use spawn with array args (no shell interpolation)
spawn('open', [memoryFilePath])
Best Practice
Using spawn with an array of arguments is the safest approach because it bypasses shell parsing entirely - each array element is passed as a literal argument.
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗