[BUG] Custom Subagents in ~/.claude/agents/ Not Discovered or Loaded (v2.0.35)
[BUG] Custom Subagents in ~/.claude/agents/ Not Discovered or Loaded (v2.0.35)
Summary
Custom subagents placed in ~/.claude/agents/ are completely ignored by Claude Code v2.0.35, despite following the official documentation exactly. This has been an ongoing issue since v1.0.60 when subagents were first introduced (75+ versions ago), making custom agents effectively unusable for users who manually create agent files.
Environment
- Claude Code Version: 2.0.35
- Platform: Android (Termux)
- OS: Linux 5.4.254-qgki-gd2808d43acca aarch64
- Shell: Bash
- Installation Method: npm (via Termux)
Expected Behavior
According to the official documentation (https://code.claude.com/docs/en/subagents):
File locations Subagents are stored as Markdown files with YAML frontmatter in two possible locations: | Type | Location | Scope | |------|----------|-------| | User subagents | ~/.claude/agents/ | Available across all projects |
Custom agents in ~/.claude/agents/ should be automatically discovered at session startup and available via the Task tool with subagent_type parameter.
Actual Behavior
Custom agents in ~/.claude/agents/ are completely ignored. Only built-in agents are available:
general-purposestatusline-setupExplorePlan
When attempting to invoke a custom agent:
Task({
subagent_type: "termux-platform-agent",
prompt: "Test agent"
})
Error: Agent type 'termux-platform-agent' not found.
Available agents: general-purpose, statusline-setup, Explore, Plan
Reproduction Steps
1. Create a Valid Custom Agent
mkdir -p ~/.claude/agents
cat > ~/.claude/agents/test-agent.md << 'EOF'
---
name: test-agent
description: Simple test agent to verify discovery mechanism
tools: Read, Bash
model: sonnet
---
You are a test agent. Confirm you're operational when invoked.
EOF
2. Verify File Exists and is Valid
$ ls -la ~/.claude/agents/test-agent.md
-rw-------. 1 user user 156 Nov 7 12:00 ~/.claude/agents/test-agent.md
$ head -10 ~/.claude/agents/test-agent.md
---
name: test-agent
description: Simple test agent to verify discovery mechanism
tools: Read, Bash
model: sonnet
---
You are a test agent. Confirm you're operational when invoked.
3. Start Fresh Claude Code Session
claude
# or restart existing session with /exit and relaunch
4. Attempt to Invoke Custom Agent
Within Claude Code:
> Use the Task tool to invoke test-agent
Result: Agent type 'test-agent' not found
5. Compare with UI-Created Agent
> /agents
[Select "Create New Agent"]
[Create any simple agent through UI]
Result: UI-created agent DOES work immediately, proving the Task tool itself functions correctly.
Evidence Collected
Agent Files Present (16 custom agents)
$ ls -1 ~/.claude/agents/*.md | grep -v README | grep -v SUMMARY
/home/user/.claude/agents/companion-platform-agent.md
/home/user/.claude/agents/config-validator.md
/home/user/.claude/agents/cross-platform-builder.md
/home/user/.claude/agents/cross-platform-validator.md
/home/user/.claude/agents/integrated-system-validator.md
/home/user/.claude/agents/integration-tester.md
/home/user/.claude/agents/mobile-platform-agent.md
/home/user/.claude/agents/quadra-lock-cssr.md
/home/user/.claude/agents/quadran-lock-gatekeeper.md
/home/user/.claude/agents/restraint-doctrine.md
/home/user/.claude/agents/security-audit-agent.md
/home/user/.claude/agents/termux-platform-agent.md
/home/user/.claude/agents/test-agent.md
/home/user/.claude/agents/test-discovery.md
/home/user/.claude/agents/test-suite-auditor.md
/home/user/.claude/agents/windows-platform-agent.md
Example Valid Agent File
---
name: termux-platform-agent
description: Termux Android CLI development and deployment specialist. Use when working with Termux-specific features, Android environment, or mobile CLI deployments.
tools: Read, Grep, Bash, Glob, Edit, Write
model: sonnet
color: green
---
You are a Termux platform specialist with expertise in Android CLI development, Termux environment configuration, and mobile deployment strategies.
[... system prompt continues ...]
Validation Results
All agent files pass validation:
- ✅ Valid YAML frontmatter
- ✅ Required fields present (
name,description) - ✅ Optional fields properly formatted (
tools,model,color) - ✅ System prompt content after frontmatter
- ✅ No syntax errors or hidden characters
Tested Scenarios
| Scenario | Result |
|----------|--------|
| Manually created agent before session start | ❌ Not discovered |
| Manually created agent during active session | ❌ Not discovered |
| Manually created agent, then restart | ❌ Not discovered |
| UI-created agent via /agents command | ✅ Works immediately |
| Adding color field to match UI format | ❌ Still not discovered |
| Built-in agents (Explore, Plan, etc.) | ✅ Work correctly |
Key Findings
1. Only UI-Created Agents Work
Agents created through the /agents interactive UI are immediately available and functional. The UI does something special (registration/indexing?) that manual file creation does not trigger.
2. No Reload/Refresh Mechanism
There's no command to reload agents from ~/.claude/agents/:
- No
/reload-agentscommand --agentsCLI flag only works for inline JSON definitions- Restarting Claude Code doesn't help
3. UI-Created Agents Also Disappear
Even UI-created agents (like config-validator) that worked in one session are gone after restart, suggesting the agent registry is session-scoped only and never persists from file discovery.
4. File Location is Correct
$ echo $HOME
/data/data/com.termux/files/home
$ ls -ld ~/.claude/agents
drwx------. 2 user user 8192 Nov 7 12:02 /data/data/com.termux/files/home/.claude/agents
The directory structure matches documentation exactly.
Impact
Severity: HIGH - Custom agents are a core feature introduced in v1.0.60 (75 versions ago) but remain completely broken for manual file creation.
User Impact:
- Custom agents are effectively unusable unless created via UI
- No way to version control or share agent files with teams
- Cannot automate agent deployment
- Cannot bulk-create or programmatically generate agents
- Forces tedious manual UI recreation for each agent
- Breaks expected workflow documented in official docs
Affected Users:
- Anyone following the official documentation to create custom agents manually
- Users wanting to version control their agent configurations
- Teams wanting to share agent definitions via git
- Power users creating multiple specialized agents
- Anyone who's been trying to use this feature since v1.0.60
Workarounds Attempted
❌ Failed Workarounds
- Adding
colorfield to match UI-created agents - Restarting Claude Code
- Creating agents during active session
- Different YAML formatting
- Checking file permissions (all files readable)
- Verifying no hidden characters in frontmatter
✅ Working Workaround (suboptimal)
Use /agents UI command to manually recreate each agent. This is:
- Tedious for multiple agents
- Not version controllable
- Not automatable
- Doesn't persist between major sessions
- Defeats the purpose of file-based agent definitions
Additional Context
Historical Context
This issue has persisted since v1.0.60 when custom subagents were first introduced. Users have been dealing with this broken behavior across:
- v1.0.60 → v1.0.x (initial buggy releases)
- v2.0.0 (major rewrite: "Claude Code SDK" → "Claude Agent SDK")
- v2.0.1 → v2.0.35 (current, 35 patch versions with issue still present)
Related Files Checked
# No agent registration/cache files found
$ find ~/.claude -name "*agent*" -type f | grep -v ".md" | grep -v "archive"
# Only session transcripts and todos, no registry/index
# Config files don't reference agent discovery
$ grep -r "agent" ~/.claude/*.json
# No relevant agent configuration found
Requested Fix
- Implement proper file discovery at session startup that scans
~/.claude/agents/recursively - Add reload command like
/reload-agentsto trigger discovery without restart - Make UI and manual creation equivalent - whatever the UI does should work for manual files
- Add debugging - show which agents were discovered during startup (e.g., in verbose mode)
- Document limitations if certain fields are required that aren't in docs
Additional Questions for Maintainers
- Is there an agent registry/index file we're supposed to create?
- Are there required fields beyond
nameanddescriptionthat aren't documented? - Is
~/.claude/agents/discovery actually implemented in v2.0.35? - Should we be using project-level
.claude/agents/instead? - Is the
--agentsCLI flag the intended way to use custom agents?
Files Available for Testing
I can provide:
- All 16 agent files for reproduction
- Test script that validates agent file formats
- Session transcripts showing the issue
- Comparison between working UI-created and non-working manual agents
---
This bug makes custom agents effectively unusable for the documented workflow. Please prioritize fixing agent file discovery in ~/.claude/agents/ to match the official documentation.
Filed by user experiencing this issue consistently since v1.0.60 (75+ versions).
12 Comments
Found 3 possible duplicate issues:
This issue will be automatically closed as a duplicate in 3 days.
🤖 Generated with Claude Code
This is a issue, seriously
This issue has been inactive for 30 days. If the issue is still occurring, please comment to let us know. Otherwise, this issue will be automatically closed in 30 days for housekeeping purposes.
i never had this problem until "upgrading" to 2.1.1 this week.
now 2 of my 5 custom agents are not showing up. they had previously worked well for several months.
after letting claude flail around trying to figure it out across several sessions, the best it could come up with
is that it may be related to the size of the agent definition file (the files defining the missing agents are 17548
and 29387 bytes; of the ones that show up, the largest size is 15541). however, it seems pretty unlikely that
size would be the issue. claude's own analysis showed no syntax or related issues with the definitions of the
missing agents, which have been stable for several weeks. the only change has been CC itself.
CC 2.1.1 on macos
notable output from
/doctor:however, both files do have properly defined
namefields.update 2 - a possible solution (for the issue as described in this comment anyway):
upon closer inspection of the failing-to-parse definition files, i became suspicious of the way the
descriptionfields were formatted, specifically with regard to quoting. all my agents have been developed via an iterative
process wherein i ask claude to create an agent definition based on my criteria, which are then refined over
the course of different sessions as issues are discovered or enhancements are required. this is done not by
using the
/agentsinterface, but rather by discussing the changes with CC and then having it edit the filesdirectly. across various refinement sessions, some of the descriptions became quite complex (spanning multiple
lines, containing both single and double-quotes, colons, XML-like markup, etc.). my issue turns out to have been
caused by these (formerly parse-able) descriptions. apparently 2.1.x is using stricter parsing for the YAML
frontmatter. when i updated the
descriptionfields to use literal block scalars, the issue no longer occurred.hopefully this may help others if they've been experiencing similar problems since 2.1 ...
properly quoted description block, e.g.:
Same issue here.
The problem in my case was the examples containing html blocks. Regardless, i used claude to fix claude :)
I just used the
/doctoroutput as input for this query:That fixed them all.
Claude probably needs to be a little less strict in it's parsing or use itself to parse those files and install those agents.
Confirmed Bug in Claude Code 2.1.7
Everything is set up correctly:
But /agents shows "No agents found" - this is a regression bug.
You should report this:
Issue: Custom agents in .claude/agents/ not loaded
Claude Code version: 2.1.7
OS: macOS Darwin 25.2.0
Steps to reproduce:
Expected: Agents from .claude/agents/*.md should appear in /agents list
Actual: "No agents found"
Agent file format (confirmed valid per docs):
---
name: code-reviewer
description: Use this agent to perform comprehensive code reviews...
model: opus
---
[agent body]
Samesies, running 2.1.31 on Windows and we have several agents defined in
.claude/agentswhich worked before but which no longer load. Very annoying. I tried using/feedbackto report the bug in Claude, but it kept cancelling out after typing a few characters in the bug description (which may itself be a bug...)Yet persists
Claude CLI created subagents loaded uncompletely. Only one out of several PERSONAL agents from
~/.claude/agentsand one out of several PROJECT agents from.claude/agents.verified on version: 2.1.80 and 2.1.62
This was plaguing me and seemed random.
Took a copy of the leaked source code and made a utility with better error reporting in between steps to look up agents by file.
For our use case, we were installing globally in a devcontainer via npm and the following resolved the issue for us.
Root cause:
npm install -g @anthropic-ai/claude-codestrips execute permissions from the vendorripgrepbinary (vendor/ripgrep/x64-linux/rg gets 644 instead of 755). CC'sloadMarkdownFiles()catches the resultingEACCESerror and silently returns[].fix:
The relevant caller from cc => loadMarkdownFiles() in claude-code/src/utils/markdownConfigLoader.ts, lines 546-600:
Reproducing on macOS Darwin 25.2.0 with Claude Code v2.1.143
Hit this today — confirming the bug is platform-agnostic and still present 75+ versions later.
Environment
Setup
~/.claude/agents/:fetch-vault.md(tools: Read, Glob, Grep)vault-curator.md(tools: Read, Edit, Glob, Grep, Bash)vault-scribe.md(tools: Read, Write, Edit, Glob, Grep)name,description,tools,model: inherit).claude/agents/involved~/.claude/settings.jsonand~/.claude/settings.local.jsoncontain no agent-related allow/deny rulesObserved
Agent(subagent_type="fetch-vault", ...)\returns:> \
Agent type 'fetch-vault' not found. Available agents: claude-code-guide, Explore, general-purpose, Plan, statusline-setup\Downstream effect
Any slash-command or skill that wraps a custom subagent fails mid-flow. In my case
/fetch_agent(a thin wrapper aroundAgent(subagent_type="fetch-vault", ...)) errors out at every invocation.Discovery vs runtime registry are out of sync. Discovery scans
~/.claude/agents/correctly; the registry that gates the Agent tool'ssubagent_typeenum doesn't see them.Likely same root cause as the open #59881 (project-scope) and the closed-as-dup #20931.
Still hitting this on Linux (x86_64, npm install, v2.0.35+) — not Termux-specific. Reproduces the same way: agents in
~/.claude/agents/are silently ignored, only the four builtin types (general-purpose,Plan,Explore,statusline-setup) resolve, andsubagent_type: "<custom>"returnsAgent type 'X' not found.A few diagnostic notes from chasing this down on my end — sharing in case they help narrow it:
<project>/.claude/agents/work fine. The discovery bug is specific to the user-scoped path. That tells me the file format, YAML frontmatter, and CLI-side parsing are all healthy — what's broken is whichever code path walks~/.claude/agents/at session init.claude --list-agents(when available in your build) confirms it. On affected builds, the user-scoped directory contents simply don't appear in the listing. That decouples the bug from "discovery happened but resolution failed" — it's a load-time miss, not a runtime mismatch.ln -s ~/.claude/agents/my-agent.md <project>/.claude/agents/my-agent.mdis ugly but it side-steps the missing user-scope walker entirely. Useful only if you've got a small number of projects.If a maintainer wants more debug surface, happy to share
strace/fs_usagetraces showing the session-init process never opens any path under~/.claude/agents/on affected builds — the absence of those file opens is the clearest fingerprint of the load-time miss.