Feature Request: Support custom agents from .claude/agents/ in Task tool

Resolved 💬 7 comments Opened Oct 1, 2025 by benbrastmckie Closed Feb 28, 2026

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-purpose
  • statusline-setup
  • output-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 plans
  • research-specialist - Analyzes codebase and researches best practices
  • code-writer - Executes implementation plans phase-by-phase
  • debug-specialist - Root cause analysis and diagnostic reporting
  • doc-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

  1. Scan .claude/agents/*.md on startup
  2. Parse frontmatter for allowed-tools and description
  3. Register as valid subagent_type options for Task tool
  4. Pass agent definition content as system instructions when invoked
  5. Enforce allowed-tools restrictions from frontmatter

Additional Context

  • Agent definitions already support frontmatter with allowed-tools and description
  • Slash commands in .claude/commands/ already reference these agents
  • This would align with the existing pattern of user-defined commands and hooks

View original on GitHub ↗

This issue has 7 comments on GitHub. Read the full discussion on GitHub ↗