Skip to Content
AdvancedAgent Guide

Agent Guide

Detailed guide to MoAI-ADK’s agent system.

One-line summary: Agents are expert teams for each domain. MoAI acts as team leader, delegating tasks to appropriate experts.

What are Agents?

Agents are AI task executors specialized in specific domains.

Based on Claude Code’s Sub-agent system, each agent has an independent context window, custom system prompt, specific tool access, and independent permissions.

Using a company organization analogy: MoAI is the CEO, Manager agents are department heads, Expert agents are experts in each field, and Builder agents are HR teams recruiting new team members.

MoAI Orchestrator

MoAI is the top-level coordinator of MoAI-ADK. It analyzes user requests and delegates tasks to appropriate agents.

MoAI’s Core Rules

RuleDescription
Delegation OnlyComplex tasks are delegated to expert agents, not performed directly
User InterfaceOnly MoAI handles user interaction (subagents cannot)
Parallel ExecutionIndependent tasks are delegated to multiple agents simultaneously
Result IntegrationConsolidates agent execution results and reports to user

MoAI’s Request Processing Flow

Agent 3-Tier Structure

MoAI-ADK agents are organized into 3 tiers:

Manager Agent Details

Manager agents coordinate and manage workflows.

AgentRoleUsed SkillsMain Tools
manager-specSPEC document creation, EARS format requirementsmoai-workflow-specRead, Write, Grep
manager-dddANALYZE-PRESERVE-IMPROVE cycle executionmoai-workflow-ddd, moai-foundation-coreRead, Write, Edit, Bash
manager-docsDocument generation, Nextra integrationmoai-library-nextra, moai-docs-generationRead, Write, Edit
manager-qualityTRUST 5 verification, code reviewmoai-foundation-qualityRead, Grep, Bash
manager-strategySystem design, architecture decisionsmoai-foundation-core, moai-foundation-philosopherRead, Grep, Glob
manager-projectProject configuration, initializationmoai-workflow-projectRead, Write, Bash
manager-tddRED-GREEN-REFACTOR cycle executionmoai-workflow-tdd, moai-foundation-coreRead, Write, Edit, Bash
manager-gitGit branching, merge strategymoai-foundation-coreBash (git)

Manager Agents and Workflow Commands

Manager agents connect directly to major MoAI workflow commands:

# Plan phase: manager-spec creates SPEC document > /moai plan "Implement user authentication system" # Run phase: manager-ddd executes DDD cycle > /moai run SPEC-AUTH-001 # Sync phase: manager-docs synchronizes documentation > /moai sync SPEC-AUTH-001

Expert Agent Details

Expert agents perform actual implementation work in specific domains.

AgentRoleUsed SkillsMain Tools
expert-backendAPI development, server logic, DB integrationmoai-domain-backend, language-specific skillsRead, Write, Edit, Bash
expert-frontendReact components, UI implementationmoai-domain-frontend, moai-lang-typescriptRead, Write, Edit, Bash
expert-securitySecurity analysis, OWASP compliancemoai-foundation-core (TRUST 5)Read, Grep, Bash
expert-devopsCI/CD, infrastructure, deployment automationPlatform-specific skillsRead, Write, Bash
expert-performancePerformance optimization, profilingDomain-specific skillsRead, Grep, Bash
expert-debugDebugging, error analysis, problem resolutionLanguage-specific skillsRead, Grep, Bash
expert-testingTest creation, coverage improvementmoai-workflow-testingRead, Write, Bash
expert-refactoringCode refactoring, architecture improvementmoai-workflow-dddRead, Write, Edit

Expert Agent Usage Examples

# Backend API development request > Create a user CRUD API with FastAPI # → MoAI delegates to expert-backend # → Activates moai-lang-python + moai-domain-backend skills # Security analysis request > Analyze security vulnerabilities in this code # → MoAI delegates to expert-security # → Analyzes based on OWASP Top 10 criteria # Performance optimization request > This query is slow, optimize it # → MoAI delegates to expert-performance # → Profiling and optimization recommendations

Builder Agent Details

Builder agents create new components that extend MoAI-ADK.

AgentRoleOutput
builder-agentCreate new agent definitions.claude/agents/moai/*.md
builder-skillCreate new skills.claude/skills/my-skills/*/skill.md
builder-pluginCreate new plugins.claude-plugin/plugin.json

For details on builder agents, refer to Builder Agent Guide.

Agent Selection Decision Tree

The process by which MoAI analyzes user requests and selects appropriate agents:

Agent Selection Criteria

Task TypeAgent to SelectExample
Code reading/analysisExplore”Analyze this project’s structure”
API developmentexpert-backend”Create REST API endpoints”
UI implementationexpert-frontend”Create login page”
Bug fixingexpert-debug”Find cause of this error”
Test writingexpert-testing”Add tests for this function”
Security reviewexpert-security”Check for security vulnerabilities”
SPEC creationmanager-spec/moai plan "feature description"
DDD implementationmanager-ddd/moai run SPEC-XXX
Document generationmanager-docs/moai sync SPEC-XXX
Code reviewmanager-quality”Review this PR”
Extension creationbuilder-*“Create new skill”

Agent Definition Files

Agents are defined as markdown files in the .claude/agents/moai/ directory.

File Structure

.claude/agents/moai/ ├── expert-backend.md ├── expert-frontend.md ├── expert-security.md ├── expert-devops.md ├── expert-performance.md ├── expert-debug.md ├── expert-testing.md ├── expert-refactoring.md ├── manager-spec.md ├── manager-ddd.md ├── manager-docs.md ├── manager-quality.md ├── manager-strategy.md ├── manager-project.md ├── manager-git.md ├── builder-agent.md ├── builder-skill.md └── builder-plugin.md

Agent Definition Format

--- name: expert-backend description: > Backend API development expert. Handles API design, server logic, database integration. PROACTIVELY use for automatic delegation during backend implementation tasks. tools: Read, Write, Edit, Grep, Glob, Bash, TodoWrite model: sonnet --- You are a backend development expert. ## Role - REST/GraphQL API design and implementation - Database schema design - Authentication/authorization system implementation - Server-side business logic ## Used Skills - moai-domain-backend - moai-lang-python (for Python projects) - moai-lang-typescript (for TypeScript projects) ## Quality Standards - TRUST 5 framework compliance - 85%+ test coverage - OWASP Top 10 security standards

Caution: Subagents cannot directly ask users questions. All user interaction happens only through MoAI. Collect necessary information before delegating to agents.

Agent Collaboration Patterns

Sequential Execution (With Dependencies)

# 1. manager-spec creates SPEC # 2. manager-ddd implements based on SPEC # 3. manager-docs generates documentation > /moai plan "authentication system" > /moai run SPEC-AUTH-001 > /moai sync SPEC-AUTH-001

Parallel Execution (Independent Tasks)

# MoAI delegates independent tasks simultaneously # - expert-backend: API implementation # - expert-frontend: UI implementation # - expert-testing: Test writing > Create both backend API and frontend UI simultaneously

Agent Chain

For complex tasks, multiple agents work sequentially, handing off to each other.

Sub-agent System

Claude Code’s official Sub-agent system forms the foundation of MoAI-ADK’s agent architecture.

What are Sub-agents?

Sub-agents are AI assistants specialized for specific task types.

FeatureDescription
Independent ContextEach sub-agent runs in its own context window
Custom PromptsCustomized system prompts define behavior
Specific Tool AccessOnly necessary tools provided
Independent PermissionsIndividual permission settings

Sub-agent vs Agent Teams

Sub-agent ModeAgent Teams Mode
Single sub-agent works sequentiallyMultiple team members collaborate in parallel
Best for simple tasksBest for complex multi-phase tasks
Faster executionRequires careful coordination

Agent Teams

Agent Teams mode is an advanced workflow where multiple experts collaborate in parallel.

Experimental Feature: Agent Teams require Claude Code v2.1.32+ with CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1 environment variable and workflow.team.enabled: true setting.

Team Mode Settings

SettingDefaultDescription
workflow.team.enabledfalseEnable Agent Teams mode
workflow.team.max_teammates10Maximum number of teammates per team
workflow.team.auto_selectiontrueAuto-select mode based on complexity

Mode Selection

FlagBehavior
—teamForce team mode
—soloForce sub-agent mode
No flagAuto-select based on complexity thresholds

/moai —team Workflow

MoAI’s --team flag activates Agent Teams for SPEC workflow.

# Plan phase: Team mode for research and analysis > /moai plan --team "user authentication system" # researcher, analyst, architect work in parallel # Run phase: Team mode for implementation > /moai run --team SPEC-AUTH-001 # backend-dev, frontend-dev, tester work in parallel # Sync phase: Documentation (always sub-agent) > /moai sync SPEC-AUTH-001 # manager-docs generates documentation

Team Composition

RolePlan PhaseRun PhasePermissions
Team LeadMoAIMoAICoordinates all work
Researcherresearcher (haiku)-Read-only code analysis
Analystanalyst (inherit)-Requirements analysis
Architectarchitect (inherit)-Technical design
Backend Dev-backend-dev (acceptEdits)Server-side files
Frontend Dev-frontend-dev (acceptEdits)Client-side files
Tester-tester (acceptEdits)Test files
Designer-designer (acceptEdits)UI/UX design
Quality-quality (plan)TRUST 5 validation

Team File Ownership

Agent Teams clearly separate file ownership to prevent conflicts.

File TypeOwnership
.md docsAll team members
src/backend-dev
components/frontend-dev
tests/tester
*.design.pendesigner
Shared configAll team members

Tip: You don’t need to specify agents directly. Just make natural language requests to MoAI and it will automatically select the optimal agent. Say “Create API” and expert-backend is automatically called, “Review this code” and manager-quality is automatically called.

Last updated on