Skip to main content
Esta página todavía está en inglés. La traducción al español está en progreso.

Creating a Custom Agent

This guide walks through creating a new agent from scratch.
Quick method: Use the create-agent skill — it guides you through the process interactively. Just say “create an agent” or “new agent” in Claude Code.

Core vs Custom Agents

Custom agents use the custom- prefix, which triggers gitignore rules so they stay personal to your workspace. The dashboard auto-discovers them and shows them alongside core agents.

File Structure

An agent requires two files:

Step 1: Agent File

Create .claude/agents/my-agent.md with YAML frontmatter followed by the system prompt.

Frontmatter Format

Description Field (Important)

The description field controls auto-routing. It should include concrete examples of user messages that should trigger this agent:

Step 2: System Prompt

Below the frontmatter, write the system prompt. This defines the agent’s identity and behavior.

Step 3: Command File

Create .claude/commands/my-agent.md:
The $ARGUMENTS placeholder passes whatever the user types after the slash command.

Step 4: Agent Memory Directory

The memory directory at .claude/agent-memory/<agent-name>/ is created automatically when the agent first saves a memory. No manual setup needed. If you want to pre-populate memory, create the directory and add a MEMORY.md index file:

Best Practices for System Prompts

Do

  • Define identity clearly in the first line: name, role, tone
  • List specific responsibilities so the agent knows its scope
  • Set anti-patterns — things the agent should never do
  • Point to context files the agent should read before starting
  • Specify output locations — which folder, what file prefix
  • Include memory instructions to build knowledge over time

Don’t

  • Write prompts longer than 300 lines (agent + memory boilerplate)
  • Overlap responsibilities with existing agents
  • Include API keys or secrets in the prompt
  • Make the agent too generic — specialization is the point

Full Example: Support Agent

.claude/agents/support-agent.md:
.claude/commands/support.md:
After creating both files, the agent is immediately available via /support in Claude Code.