.claude/skills/orchestrator/SKILL.md
Full orchestration workflow with swarm mode: evaluate -> clarify -> classify -> persist -> plan mode -> spawn teammates -> execute -> validate -> retrospective. Use when: (1) implementing features, (2) complex refactoring, (3) multi-file changes, (4) tasks requiring coordination. Triggers: /orchestrator, /orch, 'orchestrate', 'full workflow', 'implement feature'.
npx skillsauth add alfredolopez80/multi-agent-ralph-loop orchestratorInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Smart Memory-Driven Orchestration with swarm mode, parallel memory search, RLM-inspired routing, and quality-first validation.
Based on @PerceptualPeak Smart Forking concept:
"Why not utilize the knowledge gained from your hundreds/thousands of other Claude code sessions? Don't let that valuable context go to waste!!"
# Via skill invocation
/orchestrator Implement OAuth2 authentication with Google
# Via CLI
ralph orch "Migrate database from MySQL to PostgreSQL"
# With specific teammates
/orchestrator "Refactor database layer" --teammates coder,reviewer
~/.claude/settings.json or CLI/env varsANTHROPIC_DEFAULT_*_MODEL env varsdocs/architecture/Swarm mode is now ENABLED by default using native Claude Code multi-agent features:
0. EVALUATE -> Quick complexity assessment (trivial vs non-trivial)
1. CLARIFY -> AskUserQuestion intensively (MUST_HAVE + NICE_TO_HAVE)
2. CLASSIFY -> Complexity 1-10, model routing
2b. WORKTREE -> Ask about worktree isolation
3. PLAN -> Design detailed plan (orchestrator analysis)
3b. PERSIST -> Write to .claude/orchestrator-analysis.md
4. PLAN MODE -> EnterPlanMode (reads analysis as foundation)
5. DELEGATE -> Route to appropriate model/agent
6. EXECUTE -> Parallel subagents
7. VALIDATE -> Quality gates + Adversarial
8. RETROSPECT -> Analyze and improve
Phase A: Aristotle First Principles (integrated, not pre-step):
For complexity 1-3 (quick mode):
For complexity 4+ (full mode):
Reference: docs/reference/aristotle-first-principles.md
Phase B: Classification (RLM-inspired): | Dimension | Values | Purpose | |-----------|--------|---------| | Complexity | 1-10 | Scope, risk, ambiguity | | Information Density | CONSTANT / LINEAR / QUADRATIC | How answer scales | | Context Requirement | FITS / CHUNKED / RECURSIVE | Decomposition needs |
Workflow Routing: | Density | Context | Complexity | Route | |---------|---------|------------|-------| | CONSTANT | FITS | 1-3 | FAST_PATH (3 steps) | | CONSTANT | FITS | 4-10 | STANDARD | | LINEAR | CHUNKED | ANY | PARALLEL_CHUNKS | | QUADRATIC | ANY | ANY | RECURSIVE_DECOMPOSE |
MUST_HAVE Questions (Blocking):
AskUserQuestion:
questions:
- question: "What is the primary goal?"
header: "Goal"
options:
- label: "New feature"
- label: "Bug fix"
- label: "Refactoring"
- label: "Performance"
| Score | Complexity | Model | Adversarial | |-------|------------|-------|-------------| | 1-2 | Trivial | GLM-4.7 / glm-5 | No | | 3-4 | Simple | GLM-4.7 / glm-5 | No | | 5-6 | Medium | Sonnet | Optional | | 7-8 | Complex | Opus | Yes | | 9-10 | Critical | Opus (thinking) | Yes |
Write plan to .claude/orchestrator-analysis.md with:
EnterPlanMode: {} # Claude Code reads orchestrator-analysis.md
Exit with ExitPlanMode when approved.
REQUIRED: Parallel execution for ALL independent tasks. Sequential only with documented dependency.
See rule: .claude/rules/parallel-first.md
# With swarm mode (v2.81+)
Task:
subagent_type: "orchestrator"
description: "Full orchestration with swarm"
prompt: "$ARGUMENTS"
model: "sonnet"
team_name: "orchestration-team"
name: "orchestrator-lead"
mode: "delegate"
# ExitPlanMode with swarm launch:
ExitPlanMode:
launchSwarm: true
teammateCount: 3
Nested loop with parallel substeps:
EXTERNAL RALPH LOOP (max 25)
└── For EACH step:
├── LSA-VERIFY (architecture check)
├── IMPLEMENT (parallel if independent)
├── PLAN-SYNC (drift detection)
└── MICRO-GATE (max 3 retries)
CRITICAL: model: "sonnet" for all subagents
Stage 1: CORRECTNESS (BLOCKING)
Stage 2: QUALITY (BLOCKING)
Stage 3: CONSISTENCY (ADVISORY - not blocking)
Stage 4: ADVERSARIAL (if complexity >= 7)
ralph adversarial "Design review"
ralph retrospective
Save learnings to memory:
ralph memvid save "Implemented OAuth2 successfully: [pattern details]"
ralph memvid save "AVOID: [error pattern] caused [issue]"
-> VERIFIED_DONE
| Route | Primary | Secondary | Max Iter | |-------|---------|-----------|----------| | FAST_PATH | sonnet | - | 3 | | STANDARD (1-4) | glm-5 | sonnet | 25 | | STANDARD (5-6) | sonnet | opus | 25 | | STANDARD (7-10) | opus | sonnet | 25 | | PARALLEL_CHUNKS | sonnet (chunks) | opus (aggregate) | 15/chunk | | RECURSIVE | opus (root) | sonnet (sub) | 15/sub |
When $ARGUMENTS contains --with-glm5:
Step 1: Parse Arguments
TASK=<everything before --with-glm5>
USE_GLM5=true
Step 2: Spawn GLM-5 Teammates
# GLM-5 Coder
.claude/scripts/glm5-teammate.sh "glm5-coder" "$CODER_TASK" "$TASK_ID-coder"
# GLM-5 Reviewer
.claude/scripts/glm5-teammate.sh "glm5-reviewer" "$REVIEW_TASK" "$TASK_ID-reviewer"
# GLM-5 Tester
.claude/scripts/glm5-teammate.sh "glm5-tester" "$TEST_TASK" "$TASK_ID-tester"
Step 3: Wait for Completion
cat .ralph/teammates/$TASK_ID-*/status.json
Step 4: Aggregate Results
.ralph/reasoning/| Teammate | Role | Best For |
|----------|------|----------|
| coder | Implementation | Writing code, fixing bugs |
| reviewer | Code Review | Quality checks, security |
| tester | Test Generation | Unit tests, coverage |
| orchestrator | Coordination | Complex multi-step tasks |
VERIFIED_DONE requires ALL:
# Standard orchestration
ralph orch "task description"
# With GLM-5 teammates
ralph orch "task description" --with-glm5
ralph orch "complex feature" --with-glm5 --teammates coder,reviewer,tester
# Quality gates
ralph gates
ralph adversarial "spec"
# Memory
ralph memory-search "query"
ralph fork-suggest "Add authentication"
/iterate - Iterative execution until VERIFIED_DONE/gates - Quality validation gates/adversarial - Spec refinement/parallel - Parallel subagent execution/retrospective - Post-task analysis/clarify - Requirement clarificationOptimal Scenario: Integrated (Agent Teams + Custom Subagents)
This skill uses the INTEGRATED approach combining Agent Teams coordination with Custom Subagent specialization.
TeamCreate(team_name, description)
→ TaskCreate(evaluate, clarify, classify, persist)
→ TaskCreate(plan-mode tasks)
→ Task(subagent_type="ralph-*", team_name) for execute phase
→ TaskUpdate(status="completed") as phases finish
→ Hooks validate quality at each stage
→ VERIFIED_DONE after retrospective
| Agent | Role | Tools | Model |
|-------|------|-------|-------|
| ralph-coder | Code implementation | Read, Edit, Write, Bash | Inherited from settings.json |
| ralph-reviewer | Code review (security, quality) | Read, Grep, Glob | Inherited from settings.json |
| ralph-tester | Testing & QA | Read, Edit, Write, Bash(test) | Inherited from settings.json |
| ralph-researcher | Research & exploration | Read, Grep, Glob, WebSearch | Inherited from settings.json |
Note: All agents inherit their model from ~/.claude/settings.json via ANTHROPIC_DEFAULT_*_MODEL environment variables (v2.88 model-agnostic architecture).
The orchestrator ensures VERIFIED_DONE through these critical hooks:
| Hook | Event | Purpose | Exit 2 Behavior |
|------|-------|---------|-----------------|
| teammate-idle-quality-gate.sh | TeammateIdle | Quality check before idle | Keep working + feedback |
| task-completed-quality-gate.sh | TaskCompleted | Quality before task completion | Prevent completion + feedback |
| ralph-subagent-stop.sh | SubagentStop | Quality gate for ralph-* agents | Block if incomplete |
Exit 2 Behavior: When hooks return exit code 2, the agent continues working instead of completing/idling, ensuring continuous execution until VERIFIED_DONE.
# 1. Create team (automatic on skill invocation)
TeamCreate:
team_name: "orchestration-team-20250214"
description: "Orchestrating feature implementation"
# 2. Create tasks for teammates
TaskCreate:
subject: "Implement OAuth2 flow"
description: "Add OAuth2 authentication with Google provider"
metadata:
assigned_to: "ralph-coder"
priority: "high"
TaskCreate:
subject: "Review OAuth2 implementation"
description: "Security and quality review of OAuth2 code"
metadata:
assigned_to: "ralph-reviewer"
depends_on: ["implement-oauth2-flow"]
TaskCreate:
subject: "Test OAuth2 authentication"
description: "Unit and integration tests for OAuth2"
metadata:
assigned_to: "ralph-tester"
depends_on: ["implement-oauth2-flow"]
# 3. Spawn teammates for parallel execution
Task:
subagent_type: "ralph-coder"
team_name: "orchestration-team-20250214"
Task:
subagent_type: "ralph-reviewer"
team_name: "orchestration-team-20250214"
Task:
subagent_type: "ralph-tester"
team_name: "orchestration-team-20250214"
# 4. Monitor progress and aggregate results
TaskList:
status: "in_progress"
# 5. Mark tasks complete
TaskUpdate:
taskId: "1"
status: "completed"
# 6. Delete team when VERIFIED_DONE
TeamDelete:
team_name: "orchestration-team-20250214"
Teammates communicate via the shared task list and SendMessage tool:
SendMessage:
type: "message"
recipient: "ralph-reviewer"
content: "OAuth2 implementation complete, ready for review"
summary: "Implementation ready for review"
El orchestrator genera reportes automáticos completos para garantiza trazabilidad:
Cuando /orchestrator completa, se genera automáticamente:
docs/actions/orchestrator/{timestamp}.md.claude/metadata/actions/orchestrator/{timestamp}.jsonCada reporte incluye:
Si necesitas control manual del reporte:
# Al inicio
source .claude/lib/action-report-lib.sh
start_action_report "orchestrator" "Implementing OAuth2 with Google"
# Durante ejecución
mark_iteration # Cada iteración del loop
mark_file_modified "src/auth/oauth.ts" # Cada archivo modificado
record_error "Type mismatch in config" # Si hay errores
# Al completar
complete_action_report \
"success" \
"OAuth2 implementation completed" \
"1. Run tests: npm test
2. Security audit: /security src/
3. Create PR: gh pr create"
# Listar todos los reportes del orchestrator
ls -lt docs/actions/orchestrator/
# Ver el reporte más reciente
cat $(ls -t docs/actions/orchestrator/*.md | head -1)
# Buscar reportes fallidos
grep -l "Status: FAILED" docs/actions/orchestrator/*.md
source .claude/lib/action-report-generator.sh
get_skill_stats "orchestrator"
# Output:
# Skill: orchestrator
# Total Reports: 45
# Completed: 42
# Failed: 3
# Success Rate: 93%
El sistema de reportes del orchestrator se integra con:
| Hook | Propósito | Ubicación |
|------|-----------|-----------|
| action-report-tracker.sh | Genera reportes automáticos | .claude/hooks/ |
| orchestrator-report.sh | Reportes de sesión | ~/.ralph/reports/ |
| progress-tracker.sh | Tracking en tiempo real | .claude/progress.md |
Nota: Los reportes de acción (docs/actions/) son COMPLEMENTARIOS a los reportes de sesión (~/.ralph/reports/).
See master table: docs/reference/anti-rationalization.md
| Excuse | Rebuttal | |---|---| | "Step 0 is just classification, I can skip it" | Step 0 includes Aristotle analysis. Never skip. | | "Memory search is slow, I'll skip it" | Memory prevents repeated mistakes. Worth the wait. | | "Complexity is 2, no need for full workflow" | FAST_PATH still has 3 steps. Follow them. | | "The plan is obvious, no need for EnterPlanMode" | Plans catch assumptions you didn't question. | | "I already know the answer" | Memory is unreliable across sessions. Verify. | | "I'll add documentation later" | Documentation is part of the deliverable. | | "The user seems to want a quick fix" | Quick != sloppy. FAST_PATH exists for speed with quality. |
development
Living knowledge base management. Actions: search (query vault), save (store learning), index (update indices), compile (raw->wiki->rules graduation), init (create vault structure). Follows Karpathy pipeline: ingest->compile->query. Use when: (1) searching accumulated knowledge, (2) saving learnings, (3) compiling raw notes into wiki, (4) initializing a new vault. Triggers: /vault, 'vault search', 'knowledge base', 'save learning'.
testing
Produce a verifiable technical specification before coding. 6 mandatory sections: Interfaces, Behaviors, Invariants (from Aristotle Phase 2), File Plan, Test Plan, Exit Criteria (executable bash commands + expected results). Use when: (1) before implementing features with complexity > 4, (2) as Step 1.5 in orchestrator workflow, (3) when requirements need formalization. Triggers: /spec, 'create spec', 'write specification', 'technical spec'.
testing
Pre-launch shipping checklist orchestrating /gates, /security, /browser-test, /perf. Ensures nothing ships without passing all quality checks. Use when: (1) before deploying, (2) before merging to main, (3) before release. Triggers: /ship, 'ship it', 'ready to deploy', 'pre-launch check'.
development
Performance optimization skill. Core Web Vitals via Lighthouse, bundle size analysis, metrics tracking over time. Use when: (1) optimizing frontend performance, (2) analyzing bundle size, (3) tracking metrics regression. Triggers: /perf, 'performance audit', 'core web vitals', 'bundle size'.