plugins/agent-architect/skills/patterns/agent-supervisor-pattern/SKILL.md
Use this skill when designing supervisor-based multi-agent systems. Activate when the user needs to orchestrate multiple AI agents, coordinate agent workflows, implement a central controller for agents, design hub-and-spoke agent architecture, or build hierarchical agent systems.
npx skillsauth add latestaiagents/agent-skills agent-supervisor-patternInstall 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.
Design centralized orchestration systems where a supervisor agent coordinates specialized worker agents.
┌─────────────┐
│ SUPERVISOR │
│ AGENT │
└──────┬──────┘
│
┌───────────────┼───────────────┐
│ │ │
▼ ▼ ▼
┌──────────┐ ┌──────────┐ ┌──────────┐
│ Research │ │ Writer │ │ Reviewer │
│ Agent │ │ Agent │ │ Agent │
└──────────┘ └──────────┘ └──────────┘
The brain that orchestrates the workflow.
interface SupervisorConfig {
name: string;
description: string;
workers: WorkerAgent[];
maxIterations: number;
routingStrategy: 'sequential' | 'parallel' | 'conditional';
}
const supervisorPrompt = `
You are a supervisor agent coordinating specialized workers.
Available Workers:
{{#each workers}}
- {{name}}: {{description}}
{{/each}}
Your responsibilities:
1. Analyze the incoming task
2. Decompose into subtasks for appropriate workers
3. Route subtasks to the right worker
4. Synthesize results into final output
5. Handle errors and retry if needed
For each step, output:
{
"reasoning": "Why this worker for this subtask",
"worker": "worker_name",
"task": "Specific instructions for the worker",
"expectedOutput": "What you expect back"
}
When complete, output:
{
"status": "complete",
"result": "Final synthesized result"
}
`;
Specialized agents for specific tasks.
interface WorkerAgent {
name: string;
description: string;
systemPrompt: string;
tools: Tool[];
outputSchema?: JSONSchema;
}
const researchWorker: WorkerAgent = {
name: 'researcher',
description: 'Searches and analyzes information from various sources',
systemPrompt: `You are a research specialist.
Search for accurate, up-to-date information.
Always cite sources.
Return structured findings.`,
tools: [webSearch, documentReader],
outputSchema: {
type: 'object',
properties: {
findings: { type: 'array' },
sources: { type: 'array' },
confidence: { type: 'number' }
}
}
};
Routes tasks to appropriate workers.
interface RouterDecision {
worker: string;
task: string;
priority: number;
dependencies: string[];
}
async function routeTask(
task: string,
context: WorkflowContext
): Promise<RouterDecision[]> {
// Supervisor decides routing
const decision = await supervisor.decide({
task,
availableWorkers: workers.map(w => ({
name: w.name,
description: w.description,
currentLoad: w.pendingTasks
})),
completedSteps: context.history
});
return decision.subtasks;
}
Task → Worker A → Worker B → Worker C → Result
async function sequentialPipeline(task: string) {
const supervisor = createSupervisor({
routingStrategy: 'sequential',
workers: [researcher, writer, reviewer]
});
let context = { task, results: {} };
// Supervisor determines order
const plan = await supervisor.plan(task);
for (const step of plan.steps) {
const worker = workers.find(w => w.name === step.worker);
const result = await worker.execute(step.task, context);
context.results[step.worker] = result;
// Supervisor validates and decides next step
const validation = await supervisor.validate(result, step);
if (!validation.proceed) {
return supervisor.handleFailure(validation.reason, context);
}
}
return supervisor.synthesize(context.results);
}
┌─→ Path A Workers ─┐
Task → Classifier ─┤ ├→ Result
└─→ Path B Workers ─┘
async function conditionalWorkflow(task: string) {
// Supervisor classifies the task
const classification = await supervisor.classify(task);
const workflow = workflowMap[classification.type];
return executeWorkflow(workflow, task);
}
const workflowMap = {
'code_review': [securityReviewer, performanceReviewer, styleReviewer],
'content_creation': [researcher, writer, editor],
'data_analysis': [dataFetcher, analyzer, visualizer]
};
┌─→ Worker A ─┐
Task → ────┼─→ Worker B ─┼─→ Aggregator → Result
└─→ Worker C ─┘
async function parallelExecution(task: string) {
// Supervisor splits task
const subtasks = await supervisor.decompose(task);
// Execute in parallel
const results = await Promise.all(
subtasks.map(async (subtask) => {
const worker = selectWorker(subtask);
return {
worker: worker.name,
result: await worker.execute(subtask)
};
})
);
// Supervisor synthesizes
return supervisor.aggregate(results);
}
## Your Role
You are the Supervisor Agent for a content creation system.
## Your Capabilities
- Decompose complex writing tasks into subtasks
- Assign subtasks to specialized worker agents
- Validate worker outputs meet quality standards
- Synthesize multiple outputs into coherent final product
## Your Constraints
- Never attempt tasks yourself - always delegate to workers
- Maximum 5 worker invocations per task
- Must validate each output before proceeding
## Output Format
For every decision, provide:
```json
{
"thought": "Your reasoning process",
"decision": "What you decided",
"rationale": "Why this is the right choice",
"nextAction": {
"type": "delegate|validate|synthesize|complete|error",
"details": {...}
}
}
### Error Handling Instructions
```markdown
## When Workers Fail
1. First retry: Same worker, rephrased instructions
2. Second retry: Same worker, simpler subtask
3. Third failure: Try alternative worker if available
4. Final failure: Return partial results with explanation
Always log failures for human review.
interface WorkflowState {
taskId: string;
originalTask: string;
currentPhase: string;
completedSteps: Step[];
pendingSteps: Step[];
workerOutputs: Map<string, WorkerOutput>;
errors: Error[];
startTime: Date;
tokenUsage: TokenUsage;
}
class SupervisorStateManager {
async checkpoint(state: WorkflowState): Promise<void> {
// Persist state for recovery
await this.store.save(state.taskId, state);
}
async recover(taskId: string): Promise<WorkflowState | null> {
return this.store.load(taskId);
}
}
interface SupervisorMetrics {
taskId: string;
totalDuration: number;
workerInvocations: {
worker: string;
duration: number;
tokens: number;
success: boolean;
}[];
decisionPoints: {
timestamp: Date;
decision: string;
reasoning: string;
}[];
finalStatus: 'success' | 'partial' | 'failed';
}
// Log for analysis
function logSupervisorRun(metrics: SupervisorMetrics) {
console.log(JSON.stringify({
type: 'supervisor_run',
...metrics
}));
}
| Pattern | Best For | |---------|----------| | Supervisor | Complex orchestration, visibility needed | | Swarm/Mesh | Peer-to-peer collaboration, resilience | | Pipeline | Linear workflows, streaming | | Hierarchical | Large scale, nested supervision |
development
Test skills for correct activation, content quality, and regression — both automated checks (frontmatter validity, lint) and manual verification (query-suite activation testing). Covers CI integration and how to catch skill regressions before users do. Use this skill when adding skills to a repo, setting up CI for a skill library, or debugging "the skill exists but doesn't work". Activate when: test skills, validate skills, skill CI, skill linting, skill activation test, skill regression.
documentation
Write the YAML frontmatter for a SKILL.md file so it activates reliably — name, description, and activation keywords that the model matches against. Covers length, tone, and the most common frontmatter mistakes. Use this skill when authoring a new skill, fixing a skill that isn't auto-activating, or reviewing skills for publication. Activate when: SKILL.md frontmatter, skill description, skill activation, skill YAML, write a skill, author a skill.
development
Design skills that fire at the right moment — neither over-eager (noise) nor under-eager (silent). Covers activation specificity, trigger phrases, disambiguation between overlapping skills, and debugging activation. Use this skill when multiple skills could fire on the same query, a skill never fires, or a skill fires too often. Activate when: skill won't activate, skill over-activates, overlapping skills, skill triggers, skill selection, skill disambiguation.
development
Structure SKILL.md content so the model reads just enough — concise summary up front, progressively deeper detail, examples on demand. Covers section ordering, length budgets, when to split into multiple skills. Use this skill when writing or refactoring a skill body, one skill has grown too long, or a skill is wordy but not useful. Activate when: SKILL.md structure, skill content, skill too long, split skill, progressive disclosure, skill body.