Preflight Checklist
What's Wrong?
When placing multiple agent .md files in ~/.claude/agents/ (user-level agents), only the last file alphabetically is loaded. All other agent files are silently ignored.
Workaround: Use project-level agents (.claude/agents/ in the repo root). Project-level agent loading does not have this bug.
What Should Happen?
All agents should have loaded from ~/.claude/agents, not just the last agent alphabetically.
Error Messages/Logs
Steps to Reproduce
- Create multiple valid agent .md files in ~/.claude/agents/ (aaa-agent, bbb-agent, ccc-agent)
- Restart Claude Code
- Check /agents dialog
- of user agents, only ccc-agent will be visible in /agents list, along with built-in and project level agents
Claude Model
Opus
Is this a regression?
Yes, this worked in a previous version
Last Working Version
2.1.41
Claude Code Version
2.1.42
Platform
Anthropic API
Operating System
Ubuntu/Debian Linux
Terminal/Shell
Terminal.app (macOS)
Additional Information
Claude itself diagnosed this issue. I created a Claude expert subagent and kept pushing it to run tests and eventually it stumbled upon the issue. Here is it's diagnostic info:
` Diagnostic Evidence
┌──────────────────────────────────────┬──────────────────────────────────────────┐
│ Files in ~/.claude/agents/ │ Agent that loads │
├──────────────────────────────────────┼──────────────────────────────────────────┤
│ 10 agents (a-w) │ weekly-dev-summary (last alphabetically) │
├──────────────────────────────────────┼──────────────────────────────────────────┤
│ claude-config-architect + test-agent │ test-agent (last alphabetically) │
├──────────────────────────────────────┼──────────────────────────────────────────┤
│ All above + zzz-test-agent │ zzz-test-agent (last alphabetically) │
└──────────────────────────────────────┴──────────────────────────────────────────┘
Each test involved a full restart of Claude Code.
Root Cause Hypothesis
The agent loader for user-level agents appears to overwrite a variable instead of appending to a collection when iterating over files. Since iteration
is alphabetical, only the last file survives.`
Preflight Checklist
What's Wrong?
When placing multiple agent .md files in ~/.claude/agents/ (user-level agents), only the last file alphabetically is loaded. All other agent files are silently ignored.
Workaround: Use project-level agents (.claude/agents/ in the repo root). Project-level agent loading does not have this bug.
What Should Happen?
All agents should have loaded from ~/.claude/agents, not just the last agent alphabetically.
Error Messages/Logs
Steps to Reproduce
Claude Model
Opus
Is this a regression?
Yes, this worked in a previous version
Last Working Version
2.1.41
Claude Code Version
2.1.42
Platform
Anthropic API
Operating System
Ubuntu/Debian Linux
Terminal/Shell
Terminal.app (macOS)
Additional Information
Claude itself diagnosed this issue. I created a Claude expert subagent and kept pushing it to run tests and eventually it stumbled upon the issue. Here is it's diagnostic info:
` Diagnostic Evidence
┌──────────────────────────────────────┬──────────────────────────────────────────┐
│ Files in ~/.claude/agents/ │ Agent that loads │
├──────────────────────────────────────┼──────────────────────────────────────────┤
│ 10 agents (a-w) │ weekly-dev-summary (last alphabetically) │
├──────────────────────────────────────┼──────────────────────────────────────────┤
│ claude-config-architect + test-agent │ test-agent (last alphabetically) │
├──────────────────────────────────────┼──────────────────────────────────────────┤
│ All above + zzz-test-agent │ zzz-test-agent (last alphabetically) │
└──────────────────────────────────────┴──────────────────────────────────────────┘
Each test involved a full restart of Claude Code.
Root Cause Hypothesis
The agent loader for user-level agents appears to overwrite a variable instead of appending to a collection when iterating over files. Since iteration
is alphabetical, only the last file survives.`