Custom agents in ~/.claude/agents/ not detected — multiple discovery and UI bugs (v2.1.89)
Summary
Custom agents placed in ~/.claude/agents/ are not discovered by Claude Code. Multiple related bugs make the agent creation/editing workflow unreliable.
Environment
- Claude Code v2.1.89
- macOS (Darwin), Apple Silicon
- Installed via npm global
Bug 1: Manually created agent files are not detected
Steps to reproduce:
- Create
~/.claude/agents/my-agent.mdwith valid frontmatter (name, description, model, etc.) - Start a new Claude Code session
- Run
claude agentsor check/agentsUI
Expected: Agent appears in the list
Actual: Agent is not found. Error when invoking: Agent type 'my-agent' not found
Workaround: Create the agent through the /agents → "Create new agent" → "Personal" UI flow. Only this path registers the agent correctly.
Bug 2: claude agents CLI never shows user agents
Steps to reproduce:
- Create an agent via the
/agentsUI (it appears in the interactive list as "User agents") - Run
claude agentsfrom a terminal
Expected: User agents appear alongside plugin and built-in agents
Actual: Only shows plugin and built-in agents (always shows N agents, never includes user agents). The agent still works inside sessions — this is a display-only bug.
Bug 3: Overwriting agent file with Write tool breaks detection
Steps to reproduce:
- Create agent via
/agentsUI (works correctly) - Use the
Writetool (full file rewrite) to replace the file contents - Agent disappears from
/agentslist and stops being invocable
Expected: Modified file is still detected
Actual: Agent silently disappears. Must delete and recreate via UI.
Workaround: Use the Edit tool (diff-based edits) instead of Write. Diff edits preserve detection; full rewrites break it. Likely related to inode or file metadata changes.
Bug 4: /agents UI terminal corruption when pasting multiline text
Steps to reproduce:
/agents→ Create new agent → Manual configuration- At the "System prompt" step, paste multiline text (Cmd+V) or return from the external editor (ctrl+g)
- Terminal becomes unresponsive — escape sequences are printed (
^[[O^[[I), arrow keys and Enter stop working
Expected: Text is accepted or editor content is loaded
Actual: Terminal is corrupted. Only Ctrl+C recovers. Happens consistently, both inside and outside wrapper scripts.
What I tried that didn't help
- Reinstalling Claude Code via npm
- Moving file from subdirectory (
agents/my-agent/AGENT.md) to flat (agents/my-agent.md) - Different YAML formatting (quoted vs unquoted values, with/without special characters)
- Creating file via Bash (cat heredoc) vs Write tool
- Running
claude agentsfrom different working directories
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗