Overview
Subagents are specialized AI assistants that handle specific tasks with domain expertise. They can be preloaded with skills, use restricted tools, run in isolated contexts, and maintain persistent memory. This page shows real implementations demonstrating two key patterns:- Data-fetching agents with preloaded skills
- Self-evolving agents that update their own knowledge
Weather Agent
A specialized agent that fetches weather data using a preloaded skill for API instructions.Complete Implementation
Location:.claude/agents/weather-agent.md
Key Implementation Details
Frontmatter: Agent Identity
Frontmatter: Agent Identity
- name: Agent identifier used in
Task(subagent_type="weather-agent") - description: Includes “PROACTIVELY” to enable auto-invocation when Claude detects weather-related requests
Frontmatter: Tools and Model
Frontmatter: Tools and Model
- tools: Explicit allowlist (agent can only use these tools)
- model:
sonnetfor better reasoning with API responses - color: Terminal output color for visual distinction
Frontmatter: Execution Control
Frontmatter: Execution Control
- maxTurns: Prevents infinite loops (agent stops after 5 turns)
- permissionMode: Auto-accepts file edits without user confirmation
- memory: Persistent project-scoped memory for tracking historical readings
Frontmatter: Preloaded Skills
Frontmatter: Preloaded Skills
weather-fetcher skill is injected into the agent’s context at startup. This is the agent skill pattern — the skill provides domain knowledge without being invoked separately.Frontmatter: Lifecycle Hooks
Frontmatter: Lifecycle Hooks
Body: Task Definition
Body: Task Definition
Presentation Curator Agent
A self-evolving agent that updates presentation slides and then updates its own skills to stay in sync.Complete Implementation (Excerpt)
Location:.claude/agents/presentation-curator.md
Self-Evolution Pattern
1
Execute Primary Task
The agent modifies the presentation slides based on user request.
2
Read Current State
After making changes, the agent reads the updated
presentation/index.html.3
Update Own Skills
The agent edits its preloaded skills (
.claude/skills/presentation/*) to reflect the new state.4
Record Learnings
The agent appends findings to its own markdown body for future invocations.
Agent Invocation
Agents can be invoked in three ways:- Automatic (PROACTIVELY)
- From Commands (Task Tool)
- Manual (Direct Request)
Frontmatter Reference
string
required
Agent identifier used in
Task(subagent_type="name")string
required
When to invoke the agent. Include “PROACTIVELY” for auto-invocation.
string
Comma-separated allowlist of tools. Omit to inherit all tools.
string
default:"inherit"
Model alias:
haiku, sonnet, opus, or inheritstring
Terminal output color for visual distinction
number
Maximum agentic turns before stopping
string
Permission mode:
acceptEdits, plan, bypassPermissionsstring
Persistent memory scope:
user, project, or localarray
List of skill names to preload into agent context (agent skill pattern)
object
Lifecycle hooks scoped to this agent (
PreToolUse, PostToolUse, etc.)Creating Your Own Agents
Use the/agents command:
.claude/agents/api-tester.md with YAML frontmatter and body.
Best Practices
Single Responsibility
Each agent should handle one domain. Don’t create general-purpose agents.
Preload Skills
Use the
skills: field to inject domain knowledge at startup.Restrict Tools
Use the
tools: allowlist to prevent unintended tool usage.Use Memory
Enable
memory: project for agents that need historical context.Related Documentation
Commands Implementation
Learn how commands orchestrate agents
Skills Implementation
Understand agent skills vs standalone skills
Agent Memory
Deep dive into persistent memory scopes
