Feature Request: Support custom agents from .claude/agents/ in Task tool
Feature Request
Summary
Allow the Task tool to use custom agent definitions from directory as options.
Current Behavior
The Task tool only supports three built-in agent types:
general-purposestatusline-setupoutput-style-setup
Custom agent definitions can be created in .claude/agents/*.md (e.g., plan-architect.md, research-specialist.md), but cannot be invoked via the Task tool because they're not recognized as valid subagent_type values.
Desired Behavior
The Task tool should automatically discover and register custom agents from .claude/agents/:
# Example: .claude/agents/plan-architect.md
---
allowed-tools: Read, Write, Grep, Glob, WebSearch
description: Specialized in creating detailed, phased implementation plans
---
# Plan Architect Agent
[Agent instructions and behavioral guidelines...]
Then allow invocation:
Task {
subagent_type: "plan-architect",
description: "Create implementation plan",
prompt: "[Task details]"
}
Use Case
Custom slash commands (e.g., /plan, /orchestrate) can reference specialized agents for workflow phases:
plan-architect- Generates structured implementation plansresearch-specialist- Analyzes codebase and researches best practicescode-writer- Executes implementation plans phase-by-phasedebug-specialist- Root cause analysis and diagnostic reportingdoc-writer- Updates documentation and generates summaries
This would enable better workflow orchestration with tool-restricted, purpose-specific agents while maintaining the existing agent definition format.
Current Workaround
Use subagent_type: "general-purpose" and include custom agent instructions in the prompt, but this loses the benefits of:
- Tool access restrictions per agent type
- Clear agent type discovery/documentation
- Separation of concerns between agent definitions and command logic
Proposed Implementation
- Scan
.claude/agents/*.mdon startup - Parse frontmatter for
allowed-toolsanddescription - Register as valid
subagent_typeoptions for Task tool - Pass agent definition content as system instructions when invoked
- Enforce
allowed-toolsrestrictions from frontmatter
Additional Context
- Agent definitions already support frontmatter with
allowed-toolsanddescription - Slash commands in
.claude/commands/already reference these agents - This would align with the existing pattern of user-defined commands and hooks
This issue has 7 comments on GitHub. Read the full discussion on GitHub ↗