Legal noticePrivacy
Gaëtan Wittebolle.
UmamiContactFR
FR
← Guides
Claude Code, the guide
Chapter 7 / 22
  • 07Specialized agents
  • 08Slash commands and keyboard shortcuts
  • 09Permissions

Part 3 · Advanced tools

Specialized agents

Chapter 7 · 10 min reading

Goal: a /front and a /back that know their rules, subagents that work in parallel without cluttering your conversation, and the right reflex for choosing between a command, a subagent, a workflow and an agent team.

Four tools everyone calls "agents"

In Claude Code, the word "agent" covers four different mechanisms. Mixing them up wastes time and tokens (a token is the unit of text the model reads and writes, and what you're billed on).

MechanismWhat it isWho triggers itWhere it lives
Command / skill (/front)A prompt stored in a file. It runs in your conversation, with your contextYou, by typing /front.claude/commands/ or .claude/skills/
SubagentAnother Claude instance, with its own context. It does the work and only sends you back a summaryClaude, or you when you ask for it.claude/agents/ (project) or ~/.claude/agents/
Workflow (ultracode keyword)Claude writes a script that orchestrates dozens to hundreds of subagents in the backgroundYou, with the ultracode keyword or /effort ultracode.claude/workflows/ if you save it
Agent team (experimental)Several Claude sessions working together like a teamYou, through an environment variableEnabled by CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1

This chapter covers the first two in detail, the ones you'll use every day. Workflows and agent teams get a quick intro at the end of the chapter, with the details in chapter 18.

Specialized commands

Out of the box, Claude Code is a generalist. It can do everything, but without guidelines it makes inconsistent choices: the wrong color palette, a file put in the wrong place, a forgotten business rule.

A specialized command fixes that. It's briefed on its domain: which files it touches, which rules it follows, how it checks its work.

Same logic as in a restaurant: the chef knows the kitchen rules, and nobody asks them to do the bookkeeping.

What tutorials call /front or /back "agents" are actually commands. They run in your main conversation, share your context and don't run in parallel. For real parallelism, you need subagents (below).

1. Create the folder

Create a .claude/commands/ folder at the root of your project. Every .md file in it becomes a slash command. Since January 2026, commands and skills have been merged: .claude/commands/front.md and .claude/skills/front/SKILL.md both create /front. The skill format (a folder) is for when you want to ship extra files alongside the prompt.

your-project/
  .claude/
    commands/
      front.md       → /front (interface)
      back.md        → /back (business logic)
      database.md    → /database (database)
      qa.md          → /qa (quality)
      orchestrate.md → /orchestrate (project lead)

2. Structure of a command file

Each file answers 4 questions:

  1. Who are you? The role and specialty
  2. What do you work on? The files and folders involved
  3. What rules do you follow? The domain's conventions
  4. How do you check your work? The validation commands

Add a description in the frontmatter (the block between --- at the top of the file). That's what Claude reads to know when to suggest the command. Without it, it takes the first line of the file, which is rarely written for that. Chapter 8 shows the exact format.

The 6 typical commands for a SaaS

Frontend, /front

Handles everything visible: pages, components, layouts, design.

# /front - Frontend

You handle UI components, pages, layouts and the design system.

## Scope
- src/app/ (all pages and layouts)
- src/components/ (reusable components)
- src/app/globals.css (global styles)

## Palette
- Primary: #E8634A - buttons, active links
- Background: #FFFBF7 - page background
- Never use a color outside the palette

## Rules
- Server Components by default
- shadcn/ui for all base components
- UI copy in the app's language, spelled correctly
- One component per file, kebab-case

## Verification
After each change: npm run typecheck && npm run lint

Why the palette lives in /front: only the command that builds the interface needs to know it. You avoid loading those rules when you're working on the database, and you keep your CLAUDE.md short.

Backend, /back

Handles business logic, APIs, authentication.

# /back - Backend

You handle Server Actions, business logic and integrations.

## Scope
- src/lib/actions/ (Server Actions)
- src/lib/validators/ (Zod schemas)
- src/app/api/ (API routes)
- src/middleware.ts

## Rules
- Every mutation goes through a Server Action, not an API route
- Zod validation required on every input
- Check authentication in every action
- Never expose an API key on the client side

## Verification
After each change: npm run typecheck && npm run lint

Database, /database

Handles the SQL schema, migrations, security (RLS, Postgres's row-by-row access rules).

# /database - Database

You handle the PostgreSQL schema, migrations and RLS policies.

## Scope
- supabase/migrations/ (numbered SQL files)
- src/lib/types/database.types.ts (auto-generated types)

## Rules
- Any change → new numbered SQL migration
- RLS enabled on every table, filtered by organisation_id
- Never run supabase db reset

## Verification
npx supabase migration up --local
npx supabase gen types typescript --local > src/lib/types/database.types.ts
npm run typecheck

AI, /ia

Handles AI API integration, prompts, streaming.

# /ia - AI integration

You handle the Claude API integration, prompts and streaming.

## Scope
- src/lib/ai/ (client, prompts, rate-limit)
- src/app/api/ai/ (AI endpoints)

## Rules
- Always server-side, never an exposed API key
- Streaming via the Anthropic SDK
- Usage tracking in ai_usage after every call
- Rate limiting per user plan

QA, /qa

Handles tests, lint, typecheck.

# /qa - Quality

You handle tests and code quality.

## Quality Gates
| Gate | Command | When |
|------|---------|------|
| TypeScript | npm run typecheck | After each change |
| Lint | npm run lint | After each change |
| Unit Tests | npm run test | Before commit |
| Build | npm run build | Before deploy |

## Rules
- Unit tests for all business logic
- No tests for trivial boilerplate
- Minimum coverage: 80% on critical modules

Orchestrator, /orchestrate

Coordinates the rest. It's the project lead, and the only one on the list that has a reason to launch subagents.

# /orchestrate - Project lead

You supervise the execution of a plan.

## Workflow
1. Read the plan in docs/plans/
2. Independent tasks → one subagent per task, in parallel
3. Dependent tasks → sequential, in the main conversation
4. Check typecheck + lint after each group

## Quality Gates
- TypeScript: 0 errors
- Lint: 0 errors
- Build: success
- Tests: all pass

Using a command

You type the slash command, followed by your request:

/front Create a notification banner component that shows a temporary message at the top of the page, with a close button and a slide-in animation.

/front already knows it has to work in src/components/, stick to the palette, go through shadcn/ui and check with typecheck + lint. Without the command, you'd have had to write all that in your prompt.

You want to...CommandExample prompt
Create a page or component/front"Create a user profile page"
Add business logic/back"Create a Server Action to archive a piece of content"
Change the database/database"Add an 'archived_at' column to the contents table"
Add an AI endpoint/ia"Create a title generation endpoint"
Write tests/qa"Generate the tests for the archiving Server Action"
Implement a complete feature/orchestrate"Execute the plan in docs/plans/streak-plan.md"

You're not limited to these 6. An /email, a /deploy: create a command for any recurring need. The rule: if you repeat the same instructions more than 3 times, it deserves a file.

Subagents

A subagent works the opposite way from a command. You describe a goal, Claude delegates.

Subagentsub-agent, sous-agent

Another Claude instance launched by your session, with its own system prompt, its own tools and its own context window, which starts without your conversation. It can read 40 files, run tests or dig through logs, then only sends a summary back to your conversation. Your main context stays clean. It knows nothing about what you said before: everything goes through the brief.

Since Claude Code version 2.1.198 (July 1, 2026), subagents run in the background by default. You keep talking to Claude while they work, and they notify you when they're done. Claude can launch up to 20 in parallel.

CriterionCommandSubagent
TriggerYou type /frontClaude delegates, or you ask it to
Location.claude/commands/.claude/agents/ or ~/.claude/agents/
ContextShares the main contextIsolated context, only returns a summary
ParallelismOne at a timeUp to 20 in parallel, in the background
ModelYour session's modelConfigurable per subagent (model:)

Creating a subagent

The interactive /agents wizard was removed in v2.1.198. There are two ways to do it today.

The simplest: ask Claude.

"Create an explorer subagent in .claude/agents/ that maps an area of the code and returns the list of key files with a one-line explanation each. Haiku model."

By hand: a markdown file in .claude/agents/ (for the project) or ~/.claude/agents/ (for all your projects).

---
name: explorer
description: Maps an area of the code and returns the key files. Use before changing a part of the project you don't know.
model: haiku
---

You explore the code in read-only mode.
Return the list of relevant files, one line per file,
then the 3 things to watch out for before changing this area.
Don't modify any file.

The description matters as much as the prompt: it's what Claude reads to decide when to delegate. The model: field picks the subagent's model. Haiku is enough to explore, read logs or find a file, and costs much less than Opus.

The Agent tool and worktree isolation

To launch a subagent, Claude uses the Agent tool (it was called Task in older versions and old tutorials). The option to know is isolation: "worktree": the subagent gets its own git worktree, a separate copy of the repo on a dedicated branch. Since v2.1.222 (early August 2026), that isolation also covers its edits and its Bash commands.

Without a worktree, two subagents writing to app/page.tsx at the same time step on each other. With one, each has its own sandbox and you merge at the end.

Example: translating 3 articles from FR to EN

Three MDX articles, independent of each other. Three subagents in parallel, each on its own worktree.

What Claude sends (pseudo-code):

Agent({
  description: "Translate article 1",
  prompt:
    "Translate content/fr/article-1.mdx to content/en/article-1.mdx. Keep the MDX structure and the frontmatter. Casual tone.",
  isolation: "worktree",
});

Agent({
  description: "Translate article 2",
  prompt:
    "Translate content/fr/article-2.mdx to content/en/article-2.mdx. Same rules: MDX structure, frontmatter, casual tone.",
  isolation: "worktree",
});

Agent({
  description: "Translate article 3",
  prompt:
    "Translate content/fr/article-3.mdx to content/en/article-3.mdx. Same rules: MDX structure, frontmatter, casual tone.",
  isolation: "worktree",
});

All 3 run in the background. Each writes its file in its own worktree, Claude collects the results and merges. You only typed one sentence: "Translate these 3 articles in parallel, one subagent per article."

A subagent doesn't know your conversation. If you just spent 20 minutes defining a translation style with Claude, the subagent knows nothing about it. The brief has to contain everything (rules, examples, conventions). The only exception: the fork, right below.

The fork: a subagent that inherits your conversation

Forkforked subagent

A subagent that leaves with your whole conversation: it keeps the same system prompt, tools, model and history. Its first message therefore reads your session's cache (the part already processed, read back for almost nothing). Its tool calls stay on its side, only its result comes back. Useful when the brief would take too long to rewrite.

  • Claude launches it with subagent_type: "fork" in the Agent tool.
  • /subtask <task>: you launch a forked subagent yourself on a specific task.
  • /fork [prompt]: copies your conversation into a background session, with its own worktree. You keep going here, the copy moves forward on its own.

Workflows and agent teams, briefly

Workflows (since late May 2026): you add the ultracode keyword to your request ("ultracode: audit every API endpoint"). Claude then writes a script that Claude Code runs in the background across dozens, sometimes hundreds of subagents. /workflows lists the ones running and lets you save them in .claude/workflows/ to run them again. On Pro, you turn it on in /config, at a reduced size by default.

Agent teams: several Claude sessions coordinating with each other. Still experimental (CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1), and Anthropic's docs mention roughly 7 times more tokens than a standard session when teammates run in plan mode. Keep them for big projects.

Both, along with /goal, /loop and routines, are covered in detail in chapter 18.

When to use what

NeedUse
A task where you want to stay in controlCommand
A refactor that touches the whole project, step by stepCommand
Exploring code or reading logs without pollutingSubagent (haiku)
3 independent features to build at the same timeSubagents + worktree
A side task that needs all your contextFork (/subtask)
The same processing on 200 filesWorkflow (ultracode)

The rule: subagents when tasks are independent. If they depend on each other, stay sequential in your conversation.

What it costs

A subagent doesn't read your conversation's cache. It starts from zero, and its cache only lasts 5 minutes, even on a subscription (your main conversation gets 1 hour). Only the fork reuses the parent's cache.

In plain words

A subagent is the intern you send to the archives with an instruction sheet. They weren't at the meeting, so all they know is what's written on the sheet. They come back with a three-line summary, and your desk stays clear. The fork is the colleague who was at the meeting: no sheet needed, they heard everything. Cheaper to brief, but they also carry around everything that was said, including what's useless for their task.

In practice:

  • To read 50 files or logs, a haiku subagent costs less than loading everything into your Opus session, and your main context stays light.
  • For a small task that needs all your context, a fork is cheaper than a subagent you'd have to re-explain everything to.
  • Launching 20 subagents means 20 contexts filling up. You save time, your consumption doesn't go down.

The details of caching and billing mechanics are in chapter 19.

Question

Your main session has been running for an hour, its cache is warm. Claude launches an explorer subagent on haiku. Does its first message read your conversation's cache?

Pick an answer to see the explanation.

Key takeaways

  • Your /front and /back are commands: they run in your conversation, with your context.
  • A subagent starts from zero with its own context and only sends you a summary. Write it a complete brief, and set model: haiku when it's only exploring.
  • Need all your context for a side task? A fork (/subtask).
  • ultracode and agent teams: for big volumes, with an eye on consumption.

Sources

  • Official Claude Code changelog
  • Workflows, Claude Code documentation
  • Manage costs, Claude Code documentation
  • Prompt caching in Claude Code
← Chapter 6

The daily work cycle

Chapter 8 →

Slash commands and keyboard shortcuts