Get startedGet started for free

Custom Agents

1. Custom Agents

The workflow is in place. Now it's time to extend it. You'll add custom features built for your team and your project. First up: agents.

2. What Are Agents?

Agents are specialized assistants inside Claude Code. Each one has a defined role and specific capabilities. Some come built-in, others you create yourself. Together, they let Claude tackle complex tasks by delegating work to the right expert.

3. Built-in Agents

The three built-in agents cover the most common needs. Explore reads code without modifying anything, safe for investigation. Plan thinks before acting. General is the default workhorse. Claude selects the right agent automatically, but you can trigger one directly too. You've already done this with slash plan. Run slash agents to see everything available.

4. Why Create Custom Agents?

Custom agents solve a specific problem: consistency. Instead of repeating the same instructions every session, you define them once. Code review standards, security checks, documentation rules: captured in a file, available every time, shareable with your team.

5. Creating an Agent File

So how do you build one? An agent is a markdown file in dot-claude slash agents directory. It needs three things: a name, a description that tells Claude when to use it, and a body with the actual instructions. In the next demo, Claude generates this file for you. But knowing the structure means you can review, edit, and refine it. That's where the real value is.

6. Creating a Code Reviewer Custom Agent

Run slash agents and select the option to create a new agent. Choose project-level so it's available to everyone on the team, then let Claude generate it. Describe what you want: a code reviewer that checks naming conventions, error handling, and performance. Claude will prompt you for a few configuration options along the way; we're keeping it brief here. Once done, review the generated file, approve it, and it's available across every session in this project.

7. The Project So Far

The project now has a code reviewer agent in the agents subfolder. Next, you'll point it at routes.py to see what it finds. But first, let's look at how Claude decides when to use agents.

8. When Agents Spawn

When you send a prompt, Claude acts as the orchestrator. For simple, specific tasks it handles the work directly. For broader tasks like investigation, planning, or anything requiring a custom agent, it spawns a sub-agent to handle it in isolation. The distinction matters because sub-agents run in separate context, keeping the main conversation clean. You don't manage this manually; Claude decides. But knowing the pattern helps you prompt more deliberately.

9. Using Our Custom Agent

To use the agent, prefix your prompt with @ code reviewer and describe the task. Claude routes the request to the agent, which applies the rules you defined: naming conventions, error handling, performance. The result is a structured review, shaped entirely by your instructions.

10. Agent Benefits

That review is useful, but agents offer two deeper advantages. First, they run in their own context window, separate from your main conversation. That means the agent can do its work without cluttering the primary session with intermediate steps and results. Second, the Explore agent is strictly read-only. No accidental changes while investigating unfamiliar code.

11. When to Use Agents

Use this as a mental model: specific questions go directly to Claude, broad investigative questions go to Explore, strategic questions go to Plan, and custom agents handle whatever you've defined. The more deliberately you prompt, the more predictable the behavior.

12. Let's Practice!

Built-in and custom agents are how you give Claude Code a consistent, specialized skillset. In the exercises, you'll use one yourself. Let's practice.

Create Your Free Account

or

By continuing, you accept our Terms of Use, our Privacy Policy and that your data is stored in the USA.