AgentSkillsCN

subagent-creator

创建新的 Claude Code 自定义代理(子代理)。当用户:(1) 希望创建新的自定义代理;(2) 提出“创建代理”、“新代理”、“制作子代理”;(3) 希望打造专门用于委派任务的代理时,可使用此技能。内容涵盖:代理文件格式、YAML frontmatter 字段、工具限制、模型选择、权限模式、持久化内存以及部署位置。

SKILL.md
--- frontmatter
name: subagent-creator
description: >
  Create new Claude Code custom agents (subagents). Use when: (1) User wants to create a new custom
  agent, (2) User says 'create agent', 'new agent', 'make subagent', (3) User wants a specialized
  agent for delegation. Covers: agent file format, YAML frontmatter fields, tool restrictions, model
  selection, permission modes, persistent memory, and placement.

Create Custom Agent

Agent File Format

Custom agents are Markdown files with YAML frontmatter stored in:

LocationScope
~/.claude/agents/All projects (personal)
.claude/agents/Current project only

Frontmatter Fields

FieldRequiredDescription
nameYesLowercase letters and hyphens identifier
descriptionYesWhat the agent does. Claude uses this to decide when to delegate
modelNosonnet, opus, haiku, or inherit (default)
toolsNoAllowlist of tools. Inherits all if omitted. Use Task(agent-name) to restrict subagent spawning
disallowedToolsNoDenylist of tools
permissionModeNodefault, acceptEdits, delegate, dontAsk, bypassPermissions, plan
maxTurnsNoMax agentic turns before stopping
skillsNoSkills to preload at startup
mcpServersNoMCP servers available to agent
hooksNoLifecycle hooks scoped to agent
memoryNouser, project, or local - persistent memory across sessions
colorNoColor for UI display

Workflow

Step 1: Understand the agent's purpose

Ask user:

  • What tasks should this agent handle?
  • Should it be personal (~/.claude/agents/) or project-scoped (.claude/agents/)?
  • Does it need write access or is it read-only?

Step 2: Choose appropriate settings

Model selection:

  • opus - Complex reasoning, code review, architecture decisions
  • sonnet - General development, balanced speed/quality
  • haiku - Fast simple tasks, formatting, quick lookups

Tool restrictions:

  • Read-only agent: tools: Read, Grep, Glob
  • Developer agent: omit tools (inherits all)
  • No web access: disallowedTools: WebFetch, WebSearch

Key constraints:

  • Subagents CANNOT spawn other subagents (no nesting)
  • Keep the body focused - it becomes the agent's system prompt

Step 3: Create the agent file

Template:

markdown
---
name: agent-name
description: One sentence describing when Claude should delegate to this agent
model: sonnet
tools: Read, Grep, Glob, Bash
---

You are a specialized [role]. [Core instruction in 1-2 sentences.]

## Responsibilities

[What this agent does - keep concise]

## Workflow

[Step-by-step procedure if applicable]

Step 4: Verify

After creating the file, verify:

  1. File is at the correct location
  2. YAML frontmatter parses correctly (no syntax errors)
  3. Description clearly indicates when to use the agent

Examples

Read-only code explorer

yaml
---
name: code-explorer
description: Explore and explain codebase architecture and patterns
tools: Read, Grep, Glob
model: sonnet
---

You are a codebase explorer. Analyze code structure,
explain architecture, and find patterns.

Developer with memory

yaml
---
name: project-dev
description: Project-aware developer that learns conventions over time
model: opus
memory: project
---

You are a developer for this project. Maintain memory of
conventions, patterns, and architectural decisions.

Reference

  • Agents are used via Task tool's subagent_type parameter
  • Skills can use agents via context: fork + agent: agent-name
  • Run directly: claude --agent agent-name