Brand Logo
Back to guides

How to create Claude Code subagents for your projects

The Rundown: Claude Code's sub-agents feature lets you create custom AI assistants with specific roles and instructions, each with their own context window and expertise.

🧰 Who is this useful for:

  • Developers managing complex codebases with multiple responsibilities
  • Team leads wanting specialized code review and testing workflows
  • Software engineers looking to automate repetitive development tasks
  • Project managers needing consistent quality control across different code areas


STEP 1: Install and Access Claude Code

First, make sure you have Node.js installed by running node -v in your terminal. Next, install Claude Code globally using:

npm install -g @anthropic-ai/claude-code

Navigate to your project directory and run the claude command. When prompted, allow Claude Code to access your folder. This gives the main agent permission to modify files, create new files, and fix bugs across your entire project.

image-1994.png


STEP 2: Create Your First Sub-Agent

Instead of manually writing configuration files, use Claude Code's built-in generation feature. Type /agents in the Claude Code interface to see your current agents and select "Create a new agent."

Choose whether to create the agent for this specific project or globally. For project-specific workflows, select the local option. When prompted, select "Generate with Claude" rather than manual configuration for the best results.

image-1995.png


STEP 3: Define and Configure Your Agent

Describe what your sub-agent should do in plain English. Be specific about the role and constraints. For example:

  • "Expert code review specialist that proactively reviews code for quality, security, and maintainability"
  • "Unit test generator that creates comprehensive tests for new code changes"
  • "Bug fix specialist focused on identifying and resolving performance issues"

Next, select which tools your sub-agent should have access to, choose the appropriate Claude model (Opus for complex tasks, Sonnet for balanced performance, Haiku for speed), and pick a background color for easy identification.

image-1996.png


STEP 4: Deploy Your Sub-Agent

Once you're satisfied with the configuration, save your sub-agent. It will automatically activate when Claude Code encounters tasks matching its expertise.

For example, when you ask to "create unit tests to make sure everything works properly," Claude Code will automatically switch to your Unit Test Generator sub-agent, which has specialized instructions and context for testing workflows.

image-1997.png

Pro tip: Create multiple specialized sub-agents for different aspects of your development workflow. Each agent maintains its own context window, preventing information overload and ensuring focused, expert-level assistance for specific tasks.