C.W.K.
Stream
Lesson 08 of 08 · published

Sub-Agents, Slash Commands, and Skills

~14 min · subagents, slash-commands, skills

Level 0Observer
0 XP0/64 lessons0/13 achievements
0/150 XP to next level150 XP to go0% complete

Sub-agents via Task

The Task tool spawns a sub-agent — a fresh subprocess with its own options, prompt, and tool set, isolated from the parent. Useful for delegating big tasks (run a 50-step workflow, return only the summary) without polluting the parent's context. Sub-agents bill separately; budget accordingly.

Slash commands as user shortcuts

The Agent SDK supports slash commands defined as Markdown files in ~/.claude/commands/ (CLI-shared) or in your project. A slash command is a parameterized prompt fragment — /review <file> expands to a structured review prompt. Same plumbing the Claude Code CLI uses; the SDK respects the same definitions.

Skills as packaged behaviors

Skills (Anthropic's term for portable agent behaviors) live in ~/.claude/skills/ as folders with metadata, instructions, and optional resources. The Agent SDK loads available skills and the model invokes them via the Skill tool. A skill is a way to bundle 'this is how to do X' so it can be reused across sessions and machines.

Principle: Sub-agents for delegation, slash commands for shortcuts, skills for portable behaviors. Different tools for different reuse patterns.

Code

Spawning a sub-agent with Task·python
options = ClaudeAgentOptions(
    cwd="/srv",
    allowed_tools=["Task", "Read"],  # parent only delegates and reads
    system_prompt="You are a coordinator. Delegate file analysis to a sub-agent.",
)

# In the agent's response, you might see a Task tool_use block like:
# {"name": "Task", "input": {
#   "description": "Analyze /srv/large_file.csv for outliers",
#   "prompt": "Read the CSV, list the top 10 outlier rows by z-score.",
#   "subagent_type": "general-purpose",
# }}
A slash command as a Markdown file·markdown
<!-- ~/.claude/commands/review.md -->
---
description: Review a file for quality and risks
argument-hint: <file path>
---

Read {{ARGS}} and produce a code review with three sections:
1. Quality concerns
2. Security concerns
3. Suggested improvements

Cite file:line for every finding.

External links

Exercise

Pick one repeating workflow you run via prompt today. Convert it into either a slash command or a skill. Use it three times this week and note any rough edges.
Hint
If the workflow has hard-coded paths or arguments, slash command. If it has reusable steps and metadata, skill.

Progress

Progress is local-only — sign in to sync across devices.
Spotted a bug or have feedback on this page?Report an Issue

Comments 0

🔔 Reply notifications (sign in)
Sign inPlease sign in to comment.

No comments yet — be the first.