[BUG] EEXIST: file already exists, mkdir '~/.claude/agents' when trying to create an agent
Resolved 💬 1 comment Opened Jun 8, 2026 by alvaromartmart Closed Jun 16, 2026
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?
I prompted Claude Code v2.1.168 to create a custom subagent and it failed to create it with
EEXIST: file already exists, mkdir '~/.claude/agents'
My assumption is that it's trying to mkdir agents without checking if the folder exists first and gets stuck at that point.
I couldn't find a workaround and had to re-create the agent in a different scope and move it back to the user context.
What Should Happen?
The agent should have been created by Claude Code correctly
Error Messages/Logs
Steps to Reproduce
/agents- Select "create with Claude in user context"
- Provide the agent description
- Submit
- Gets stuck when trying to create the files (I assume)
Claude Model
None
Is this a regression?
Yes, this worked in a previous version
Last Working Version
_No response_
Claude Code Version
2.1.168 (Claude Code)
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
Other
Additional Information
_No response_
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗