Skip to main content

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

  • name: Agent identifier used in Task(subagent_type="weather-agent")
  • description: Includes “PROACTIVELY” to enable auto-invocation when Claude detects weather-related requests
  • tools: Explicit allowlist (agent can only use these tools)
  • model: sonnet for better reasoning with API responses
  • color: Terminal output color for visual distinction
  • 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
The 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.
Agent-scoped hooks run before/after tool use. This example plays sound notifications via a Python script.
The agent body references the preloaded skill and defines the expected workflow. Clear, numbered steps help Claude follow the process.

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.
This prevents knowledge drift — the agent’s skills always match the actual presentation state.

Agent Invocation

Agents can be invoked in three ways:
When the description includes “PROACTIVELY”, Claude automatically invokes the agent when it detects matching requests.

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 inherit
string
Terminal output color for visual distinction
number
Maximum agentic turns before stopping
string
Permission mode: acceptEdits, plan, bypassPermissions
string
Persistent memory scope: user, project, or local
array
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:
Or ask Claude to create one:
Claude will generate .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.

Commands Implementation

Learn how commands orchestrate agents

Skills Implementation

Understand agent skills vs standalone skills

Agent Memory

Deep dive into persistent memory scopes