Custom Commands & Subagents Basics
7 examples to get you started with Custom Commands & Subagents - 5 basic and 2 intermediate.
Search across all documentation pages
7 examples to get you started with Custom Commands & Subagents - 5 basic and 2 intermediate.
.claude/commands/ (created on demand, no install step required).Agent tool, nothing to configure up front.Every custom command lives as a markdown file under .claude/commands/.
mkdir -p .claude/commandsThe simplest command is a frontmatter header plus a single prompt sentence.
---
description: Summarize the current git diff in plain language
---
Summarize the currently staged git changes in two or three sentences, written for a teammate who has not seen the diff yet..claude/commands/summarize-diff.md and the command becomes available as /summarize-diff.description frontmatter field is what shows up when a user tab-completes available commands.Once the file exists, the command is live immediately, no restart required.
# inside a Claude Code session
/summarize-diff/summarize-diff inserts the file's prompt body into the conversation and runs it right away.Related: Writing Your First Custom Slash Command with Markdown Frontmatter - the full frontmatter schema
Commands can reference the text typed after the command name.
---
description: Explain a specific file's purpose
---
Read $ARGUMENTS and explain what it does, who calls it, and any non-obvious side effects, in under 150 words.$ARGUMENTS is replaced with whatever the user typed after the command name, e.g. /explain-file lib/auth.ts.$ARGUMENTS is empty, so word the prompt to degrade gracefully or note that a target is required.A subagent is a separate Claude instance with its own context, launched to handle one bounded task.
# a plain-language request in the main session, not a shell command
# "Use a subagent to find every place notification emails are sent
# in this codebase and summarize the trigger conditions for each."Related: How Subagents Get Their Own Context and Tools - why the isolation exists
A command's prompt body can itself ask Claude to delegate to a subagent.
---
description: Audit a feature area and report findings, without derailing the main session
---
Use a subagent to research how $ARGUMENTS is implemented across this codebase:
entry points, data flow, and any tests that cover it. Have the subagent report
back a concise summary (file paths and a short description each), not full file contents..claude/commands/audit-feature.md, this makes /audit-feature payment retries a repeatable one-liner that always delegates the same way.For larger audits, a single command can ask for multiple subagents to run against independent parts of the codebase at once.
---
description: Research three subsystems in parallel and compare their patterns
---
Spawn three subagents in parallel, one each for: the authentication code,
the billing code, and the notifications code. Each subagent should report
back the error-handling pattern it finds in its area. Then compare the
three patterns and note any inconsistency worth fixing.Related: Spawning Parallel Subagents for Isolated Research Tasks - the fan-out pattern in depth
Stack versions: Written against the Claude model lineup current as of ~June 2026 - Claude Fable 5, Claude Opus 4.8, Claude Sonnet 5 (the default), and Claude Haiku 4.5. Model names, pricing, and product features move quickly - verify current specifics at platform.claude.com/docs before relying on them.
Reviewed by Chris St. John·Last updated Jul 18, 2026