mix claude.gen.subagent (claude v0.4.0)
View SourceGenerate a new Claude subagent for specialized AI assistance.
This task helps you create a new subagent that can be delegated to by Claude Code for specific tasks. Subagents are specialized AI assistants with their own system prompts and tool permissions.
Usage
Interactive Mode
mix claude.gen.subagent
The task will interactively prompt you for:
Non-Interactive Mode (for AI agents)
mix claude.gen.subagent --name my-assistant --description "Database query helper" \
--tools "read,grep,bash" --prompt "You are a database expert."
Options
--name
- The subagent name (lowercase-hyphen-separated)--description
- When Claude should invoke this subagent--tools
- Comma-separated list of tools (optional, defaults to read,grep,glob)--prompt
- The system prompt defining behavior
When all required flags are provided (name, description, prompt), the task runs in non-interactive mode, making it suitable for automation and AI agent invocation.
In interactive mode, the task prompts for:
- Name - A descriptive name for your subagent (e.g., "database-migration-agent")
- Description - When this subagent should be invoked (critical for delegation)
- Tools - Which tools the subagent needs (optional, defaults to minimal set)
- Prompt - The system prompt that defines the subagent's behavior
Delegation Descriptions
The description is critical for automatic delegation. Use clear, action-oriented language:
Good examples:
- "MUST BE USED for all database migration tasks"
- "Use PROACTIVELY when user asks about API documentation"
- "Expert in refactoring Elixir code to follow best practices"
Poor examples:
- "Database helper" (too vague)
- "Helps with migrations" (not directive enough)
Tool Selection
Choose minimal tools for better performance:
- Code analysis:
read, grep, glob
- Code modification:
read, edit, multi_edit
- Test execution:
read, edit, bash
- Documentation:
read, write, web_search
Never include task
(prevents delegation loops).
Example
$ mix claude.gen.subagent
Enter subagent name: Test Runner Agent
Enter description (when to invoke): MUST BE USED for running and analyzing test results
Enter tools (comma-separated, optional): read, grep, bash
Enter system prompt (multi-line, end with empty line):
# Purpose
You are an expert test runner and analyzer for Elixir projects.
## Instructions
When invoked:
1. First check for test files using grep
2. Run tests with appropriate mix commands
3. Analyze failures and suggest fixes
(empty line to finish)
The generated subagent will be:
- Added to your
.claude.exs
configuration - Written to
.claude/agents/test-runner-agent.md
- Available immediately after running
mix claude.install