Skip to content

Custom Agents

Define persistent, specialized agents with custom tools, models, and system prompts — checked into your codebase and shared with your team.

Custom agents are persistent subagent definitions stored as Markdown files in .agent/agents/. We use “custom agents” here to distinguish file-based, reusable definitions from the temporary subagents the agent spawns dynamically for one-off tasks. Both are configured the same way; the difference is persistence and intent.

Each agent gets its own system prompt, tool set, model selection, and permission mode. When you or the agent invokes an agent, it runs in its own context with only the capabilities you’ve defined.

Creating an agent

Run /agents in your AI coding agent to create, edit, and manage agents interactively. Choose “Create new agent” → select scope (Personal or Project) → describe what the agent should do. The agent generates the configuration.

Manual file creation

Create a Markdown file in .agent/agents/ (project) or ~/.agent/agents/ (personal):

---
name: code-reviewer
description: Reviews code for quality and best practices. Use proactively after code changes.
tools: Read, Glob, Grep
model: standard
---

You are a senior code reviewer. Analyze code for:
- Security vulnerabilities
- Performance issues  
- Readability and maintainability
- Test coverage gaps

Provide specific, actionable feedback with code examples.

Supported frontmatter fields

FieldRequiredDescription
nameYesUnique identifier (lowercase, hyphens)
descriptionYesWhen the agent should delegate to this agent
toolsNoTools the agent can use (inherits all if omitted)
disallowedToolsNoTools to deny
modelNostandard, capable, fast, or inherit
permissionModeNodefault, acceptEdits, plan, auto, dontAsk, bypassPermissions
maxTurnsNoMaximum agentic turns before stopping
isolationNoSet to worktree for isolated file system
colorNoBackground color in the UI
memoryNouser, project, or local for persistent memory
skillsNoSkills loaded into the agent’s context
mcpServersNoMCP servers available to this agent
hooksNoLifecycle hooks scoped to this agent
effortNoThinking effort level: low, medium, high, max
backgroundNoRun the agent in the background
initialPromptNoFirst prompt sent automatically when the agent starts

Agent scope and priority

LocationScopePriority
Managed settingsOrganization-wideHighest
--agents CLI flagCurrent session onlyHigh
.agent/agents/Current projectMedium
~/.agent/agents/All your projectsLower
Plugin agents/Where plugin is enabledLowest

When multiple agents share the same name, the higher-priority location wins.

Launching agents

From the CLI:

agent --agent code-reviewer

During a session, run /agents to see available agents or ask the agent directly — it delegates based on the agent’s description.

For one-off agent definitions without saving files:

agent --agents '{"reviewer": {"description": "Code reviewer", "prompt": "You review code.", "tools": ["Read", "Grep"], "model": "standard"}}'

Custom agents vs subagents

Custom AgentsSubagents
Defined in.agent/agents/*.md filesSpawned dynamically by the agent
PersistencePermanent, version-controlledTemporary, single-task
ConfigurationFull frontmatter (tools, model, hooks, MCP)Inherited from parent with optional overrides
Use caseRecurring roles (reviewer, debugger, architect)One-off parallel investigations

Example agents

Read-only analyst

---
name: analyst
description: Analyzes code patterns and architecture without making changes
tools: Read, Glob, Grep, Bash
model: fast
---

You are a read-only code analyst. Never suggest edits directly.
Analyze patterns, dependencies, and architecture. Report findings clearly.

Build validator

---
name: build-validator
description: Validates that the project builds and tests pass
tools: Bash, Read
model: standard
---

Run the build and test suite. Report any failures with file paths and line numbers.
Do not fix issues — only report them.
Commands to run:
1. npm run build
2. npm test

Security auditor

---
name: security-auditor
description: Scans code for security vulnerabilities
tools: Read, Glob, Grep
model: capable
permissionMode: plan
---

You are a security auditor. Scan for OWASP Top 10 vulnerabilities:
- SQL injection, XSS, CSRF
- Hardcoded secrets and credentials
- Insecure dependencies
- Missing input validation

Report severity (Critical/High/Medium/Low) with specific file locations.

Tips

  • Start with read-only agents (restrict tools to Read, Glob, Grep) for safety.
  • Use model: fast for quick agents that don’t need deep reasoning.
  • Set isolation: worktree when agents need to make experimental changes.
  • Check project agents into version control so the whole team benefits.
  • Write clear descriptions — the agent uses them to decide when to delegate.