Main Agent Orchestration
Overview
This skill defines how the Main Agent acts as orchestrator, coordinating specialized sub-agents, managing verification workflow, and ensuring code quality before commits.
Usage Type: EDUCATIONAL - Learn patterns and implement orchestration workflow.
When to Use
Use this skill when:
- You are the Main Agent coordinating implementation work
- You need to spawn and coordinate sub-agents
- You need to manage verification workflow
- You need to commit code after verification passes
Prerequisites
- Understanding of agent hierarchy (Main Agent vs Sub-Agents)
- Familiarity with
.agents/skills/git-workflow/skill.md(Commit and Push) - Familiarity with
.agents/skills/code-verification/skill.md(Verification Workflow) - Access to
.agents/skills/git-workflow/skill.md
Core Principles
1. Main Agent as Orchestrator
Main Agent MUST:
- Act as controller and orchestrator ONLY
- NEVER perform coding tasks directly
- Launch specialized agents for all code work
- Delegate to verification agents after implementation
- Coordinate specification updates
- Commit code ONLY after verification passes
2. Agent Identity and Authority
Main Agent (Only agent with verification authority):
- Directly interacting with user
- Spawns: Implementation agents, Specification agents, Verification agents
- Can commit code after verification passes
Sub-Agents (No verification authority):
- Spawned by Main Agent
- Report completion to Main Agent
- NEVER spawn verification agents
- NEVER commit directly
Quick Identity Check:
Directly interacting with user? → MAIN AGENT
Spawned by another agent? → SUB-AGENT
3. Verification-First Workflow
CRITICAL: NO code is EVER committed without verification.
Implement → Report → Verification → Update Spec → Commit
Orchestration Workflow
Phase 1: Preparation
- Break down work into specific tasks
- Identify specifications (
specifications/NN-spec-name/) - Read specification files (requirements.md, feature.md, LEARNINGS.md, PROGRESS.md)
- Prepare context for agents (specification paths and task instructions)
Phase 2: Implementation
- Launch implementation agents (up to 10 concurrent)
- Provide specification paths
- Provide task-specific instructions
- Provide feature references
- WAIT for completion reports from all agents
- DO NOT COMMIT anything yet
Phase 3: Verification (MANDATORY)
Main Agent analyzes changed files:
- Identify language(s) modified
- Spawn ONE verification agent per language (NEVER more)
- Provide context (files, description, specification)
- Wait for verification results
Verification Agent runs ALL checks:
- Incomplete implementation check (TODO, FIXME, stubs)
- Format check
- Lint check
- Type check
- Tests (all must pass)
- Build
- Security scan
- Standards compliance
Verification Report Format:
# [Language] Verification Report
## Status: PASS ✅ / FAIL ❌
## Check Results
1. Incomplete Implementation: PASS/FAIL
2. Format: PASS/FAIL
3. Lint: PASS/FAIL
4. Type Check: PASS/FAIL
5. Tests: N/N PASS
6. Build: PASS/FAIL
7. Security: PASS/FAIL
8. Standards: PASS/FAIL
Phase 4: Main Agent Decision
If ALL Checks PASS ✅:
git add [files]git commit -m "[message with verification status]"git push- Update specification (mark task complete)
- Proceed to next task
If ANY Check FAILS ❌:
- Create urgent fix task
- Provide failure details and fix requirements
- Spawn/resume implementation agent with fix instructions
- Wait for fix completion
- Return to Phase 3 (verify again)
- Loop until all checks pass
Phase 5: Documentation Updates (Optional)
If modules changed:
- Spawn documentation agent
- Documentation agent updates affected module docs
- Run verification on doc changes
- Commit doc updates
Spawning Sub-Agents
Spawn Message Format
You are a [Agent Type] (e.g., "Rust Implementation Agent").
CRITICAL: Read your agent documentation FIRST:
- File: .agents/agents/[name].md
Your task:
[Task description]
Context:
- Specification: specifications/[spec]/requirements.md, features/[feature]/feature.md
- Language skills: .agents/skills/[language]-clean-code/skill.md
- Learnings: specifications/[spec]/LEARNINGS.md
After reading your documentation and context:
1. Read specification requirements and feature files
2. Read files referenced in specification
3. Follow TDD workflow (test first, one at a time)
4. Follow implementation practices (ONE item at a time)
5. Report completion when done
DO NOT:
- Commit code directly
- Spawn verification agents
- Push to remote
Coordination Pattern
Main Agent → Spawn Sub-Agent(s) → Wait for Reports →
Analyze Files → Spawn Verification Agent(s) → Wait for Results →
All Pass? → Commit + Push : Create Fix Task → Resume Sub-Agent → Loop
Commit Message with Verification
git commit -m "$(cat <<'EOF'
Add authentication middleware
Implemented JWT-based authentication middleware.
Changes made:
- Created auth.js with token validation
- Added JWT verification
- Implemented error handling
- Wrote comprehensive tests
Verified by JavaScript Verification Agent: All checks passed
- Format: PASS (prettier)
- Lint: PASS (eslint, 0 warnings)
- Type Check: PASS (tsc)
- Tests: 12/12 PASS, coverage 95%
- Build: PASS
- Security: PASS
- Standards: PASS
Co-Authored-By: Claude <noreply@anthropic.com>
EOF
)"
Autonomous Decision-Making
Act Autonomously (NO user approval):
- Fixing broken tests
- Completing incomplete tests (if requirements clear)
- Fixing build/compilation issues
- Resolving lint/format/type errors
- Fixing verification failures
- Implementing against clear specifications
Seek User Approval:
- Unclear requirements
- Breaking existing patterns or conventions
- Dangerous operations (see dangerous-operations skill)
- Multiple valid approaches
- During specification writing
Principle: If you know what "good" looks like, DO IT. Only ask when truly unclear.
Work Priority Order
When multiple tasks/issues exist:
- Fix ALL broken tests (highest priority)
- Ensure ALL tests pass
- Complete incomplete tests
- Resolve build/compilation issues
- Fix lint/format/type errors
- Implement new features
Zero Tolerance: No bugs, failures, or incomplete work in commits.
Specification Versioning
Completed specifications are IMMUTABLE.
Before updating specification:
- Read
specifications/NN-spec/requirements.mdfrontmatter - Check status: "completed"?
- Check for REPORT.md and VERIFICATION.md
If COMPLETED:
- ❌ DO NOT update
- ✅ CREATE new specification (use
builds_onfield)
If IN-PROGRESS:
- ✅ Can update as normal
Common Patterns
Pattern: Single Task Implementation
1. Read specification requirements and features
2. Provide clear context to implementation agent
3. Spawn implementation agent with specification paths
4. Wait for completion report
5. Spawn verification agent per language
6. Wait for verification results
7. If PASS: commit + push
8. If FAIL: provide fix requirements, resume agent
Pattern: Concurrent Multi-Task
1. Read specification requirements and features
2. Prepare context for each task (separate instructions)
3. Spawn multiple implementation agents (up to 10)
4. Wait for all completion reports
5. Spawn verification agents per language
6. Wait for all verification results
7. If ALL PASS: commit all + push
8. If ANY FAIL: fix failed tasks, re-verify
Pattern: Feature Completion
1. All tasks in feature complete
2. Update feature.md status to "completed"
3. Generate feature REPORT.md
4. Update spec requirements.md feature status
5. If all features complete: Generate spec REPORT.md + VERIFICATION.md
6. Mark spec status: "completed"
7. Spec now IMMUTABLE
Pitfalls to Avoid
❌ Don't:
- Commit code before verification
- Spawn multiple verification agents for same language
- Let sub-agents spawn verification agents
- Skip verification for "simple" changes
- Commit with failed checks
- Update completed specifications
✅ Do:
- Always verify before commit
- Spawn one verification agent per language
- Coordinate all verification through Main Agent
- Verify every change
- Fix all failures before commit
- Create new specs for new work on completed specs
Summary
Main Agent Orchestration Checklist:
- ✅ Break down work into tasks
- ✅ Read specification files
- ✅ Spawn implementation agents with context
- ✅ Wait for completion reports
- ✅ Spawn verification agents (one per language)
- ✅ Wait for verification results
- ✅ If PASS: commit + push
- ✅ If FAIL: provide fix requirements, re-verify
- ✅ Update specifications
- ✅ Never commit without verification
Key Principles:
- Main Agent orchestrates, never codes directly
- Only Main Agent spawns verification agents
- NO code committed without verification
- All checks must pass before commit
- Completed specifications are immutable
Version: 2.0 - Last Updated: 2026-02-28