Lazy loaded image
Creating Custom Subagents in Claude Code
Words 415Read Time 2 min
2025-12-17
Column 1
Column 2
Subagents are specialized AI agents configured in your project's .claude/ directory. Here's how to create them:
Basic Configuration
Create or edit .claude/subagents.json:
Key Configuration Fields
  • name: Unique identifier for the subagent
  • description: What the subagent does
  • model: Claude model to use (e.g., claude-opus-4-5-20251101 for advanced tasks)
  • instructions: System prompt defining the subagent's behavior and expertise
  • tools: Array of tools the subagent can access (bash, file_editor, web_search, etc.)
  • permissions: Control what the subagent can access
Common Subagent Patterns for Software Development
  1. Code Reviewer Subagent
    1. Documentation Generator Subagent
      1. Test Writer Subagent
        1. Security Auditor Subagent
          1. Performance Optimizer Subagent
            Best Practices for Defining Subagents
            1. Narrow Focus: Each subagent should have a specific, well-defined purpose
            1. Clear Instructions: Write detailed system prompts that define expertise and behavior
            1. Minimal Permissions: Grant only the tools and permissions each subagent needs
            1. Model Selection: Use appropriate models (Opus for complex analysis, Haiku for simple tasks)
            1. Tool Selection: Only include tools the subagent actually needs
            1. Naming Convention: Use descriptive, kebab-case names (e.g., code-reviewer, test-writer)
            Invoking Subagents
            You can invoke subagents through:
            • Custom slash commands (like your /review and /security-review commands)
            • Direct CLI calls: kiro-cli subagent <name> <task>
            • Within agent workflows
            Your Current Setup
            I notice you already have custom slash commands configured:
            • /review: Likely uses a code review subagent
            • /security-review: Uses a security audit subagent
            • /pr-comments: Integrates with GitHub
            上一篇
            RTU异步事件框架技术文档
            下一篇
            Guide to Linux System

            Comments
            Loading...