Generalist vs Specialist
A generalist agent tries to do everything — code, review, test, document — and does all of it at a B-minus level. A specialist agent does one thing at an A-plus level. The difference is not capability but context. When Claude operates as a "Senior Security Reviewer," it catches vulnerabilities that a generalist misses entirely because its attention is focused on a single domain.
The principle is simple: constrain the role to sharpen the output. A code reviewer that only reviews code will outperform an agent that also writes code, plans architecture, and drafts documentation in the same session.
Configuring Agent Identity
Agent identity starts with a dedicated instruction file. Create an agents/ directory and give each agent its own markdown file with three sections:
- Identity block: "You are a Senior Test Engineer specializing in integration testing for Next.js applications"
- Scope constraints: What the agent should and should not do — a test agent should never refactor production code
- Quality criteria: Specific standards the agent must meet before considering work complete
When you load these instructions at session start, Claude adopts the persona and filters every decision through it. This is dramatically more effective than asking a generalist to "also think about testing."
Persistent Agent Memory
Specialist agents become powerful when they remember across sessions. Create an agent-memory/ directory with one file per agent. After each session, the agent writes what it learned: patterns that worked, mistakes to avoid, codebase-specific knowledge.
A code reviewer that remembers "this team always forgets null checks on API responses" catches the same bug faster next time. Memory turns a stateless tool into a teammate that learns.
Domain Expertise Injection
Beyond identity and memory, you can inject domain expertise by including reference material in the agent's context: API documentation, style guides, security checklists, or architecture decision records. The agent does not need to memorize these — it just needs them available when making decisions.
Keep injected context focused. A 500-line security checklist is more useful than a 5,000-line general reference. Relevance beats volume every time.
Spawning Specialist Subagents
The most powerful pattern is an orchestrator agent that spawns specialists on demand. When the orchestrator encounters a security question, it hands it to the security agent. When it needs tests, it delegates to the test agent. Each specialist operates with its own identity, memory, and expertise.
This mirrors how real engineering teams work: a tech lead coordinates, but the security audit goes to the security engineer and the performance review goes to the SRE. No single person does everything.
Practical Exercise
Create Your First Specialist Agent
Build a specialist code reviewer agent for your project:
- Create identity file: Write
agents/code-reviewer.mdwith a clear identity, scope constraints, and quality criteria - Add memory file: Create
agent-memory/code-reviewer.mdwith an initial "Known Patterns" section - Inject expertise: Include your team's coding standards and common bug patterns in the agent's context
- Test it: Run the agent against a recent pull request and compare its output to a generalist review
Want pre-built specialist agents? The AI Brain Pro package includes 11 production-tested agents covering code review, testing, security auditing, documentation, and more. View pricing →