MANDATORY — Context Gathering Protocol
Before applying any workflow guidance, gather context:
Check for Maestro context in the project root
- First check
.maestro/context.md (v2 layout)
- Then check
.maestro.md (v1 layout — backward compatible)
- If it exists → read it and use the workflow context within
- If it doesn't exist → tell the user: "No workflow context found. Run /teach-maestro to set up project-specific context for better results."
Check for decision history (optional)
- If
.maestro/decisions.jsonl exists → read the last 5 decisions for session continuity
- If it doesn't exist → proceed without it (no error)
Minimum viable context (if no .maestro.md):
- What AI model(s) are being used?
- What is the workflow's primary task?
- Are there existing prompts, tools, or agents to work with?
- What are the quality/speed/cost priorities?
DO NOT proceed without at least understanding the model, task, and priorities.
Maestro — AI Agent Workflow Mastery
This skill provides the foundational knowledge for designing, building, and maintaining
production-grade AI agent workflows. All Maestro commands build on these principles.
Core Principles
- Structure over improvisation — Workflows should be deliberate, not emergent
- Constraints are features — Explicit boundaries prevent failure modes
- Measure, don't assume — Every workflow needs evaluation, not just testing
- Appropriate complexity — Match the solution to the problem, not the ambition
- Graceful degradation — Every component should fail safely
1. Prompt Engineering
DO:
- Use structured prompts with clear sections (role, context, instructions, output format)
- Define output schemas explicitly (JSON schema, markdown template, typed response)
- Use few-shot examples for ambiguous tasks
- Chain-of-thought for multi-step reasoning
- Keep system prompts focused — one clear role per prompt
DON'T:
- Write wall-of-text prompts with no structure
- Assume the model understands implicit output format
- Use the same prompt for fundamentally different tasks
- Put conflicting instructions in the same prompt
- Rely on the model to "figure it out"
→ Consult prompt engineering reference for structure, patterns, and output schemas.
2. Context Management
DO:
- Budget context window usage (system prompt, examples, user input, tool results, output)
- Place critical information at the start AND end of context (attention gradient)
- Use retrieval (RAG) instead of stuffing full documents
- Maintain conversation state explicitly
- Summarize long histories instead of passing raw transcripts
DON'T:
- Dump entire codebases, databases, or documents into context
- Ignore context window limits until you hit them
- Assume the model pays equal attention to all context
- Pass irrelevant information "just in case"
- Rely on implicit memory across turns
→ Consult context management reference for window optimization and memory patterns.
3. Tool Orchestration
DO:
- Give tools clear, specific names and descriptions
- Define input/output schemas for every tool
- Handle tool errors gracefully (the tool WILL fail eventually)
- Keep tool sets focused — 3-7 tools per agent is ideal
- Make tools idempotent where possible
DON'T:
- Expose 30+ tools and hope the model picks the right one
- Use vague tool descriptions ("does stuff with data")
- Skip error handling in tool implementations
- Let tools have side effects without confirmation for destructive operations
- Create tools that overlap in functionality
→ Consult tool orchestration reference for selection heuristics and composition patterns.
4. Agent Architecture
DO:
- Start with a single agent — add agents only when a single agent demonstrably fails
- Define clear boundaries and responsibilities for each agent
- Use structured handoff protocols between agents
- Implement supervisor patterns for multi-agent systems
- Design for observability — log agent decisions, not just outputs
DON'T:
- Build multi-agent systems for problems a single agent handles
- Create agents without clear boundaries (overlapping responsibilities = conflicts)
- Use unstructured communication between agents
- Skip the supervisor — autonomous agent swarms are unpredictable
- Assume agents will coordinate without explicit protocols
→ Consult agent architecture reference for topology patterns and delegation.
5. Feedback Loops
DO:
- Build evaluation into the workflow from day one
- Create golden test sets with known-good inputs and outputs
- Use automated evaluators for consistent quality scoring
- Track regression — compare new outputs against baselines
- Implement self-correction loops for critical outputs
DON'T:
- Ship without evaluation ("it seems to work" is not evaluation)
- Rely solely on human review at scale
- Use the same model to evaluate its own output without structure
- Skip regression testing when changing prompts or models
- Conflate "the model ran without errors" with "the output is correct"
→ Consult feedback loops reference for evaluation patterns and self-correction.
6. Knowledge Systems
DO:
- Choose retrieval strategy based on query type (semantic, keyword, hybrid)
- Chunk documents thoughtfully (semantic boundaries, not arbitrary token counts)
- Include source attribution in every retrieved result
- Test retrieval quality independently of generation quality
- Version your knowledge base — know what the model has access to
DON'T:
- Build RAG without testing retrieval quality first
- Use fixed chunk sizes for all document types
- Skip source attribution (hallucination without attribution is undetectable)
- Index everything without curation (garbage in = garbage out)
- Assume embedding similarity equals relevance
→ Consult knowledge systems reference for RAG, embeddings, and grounding.
7. Guardrails & Safety
DO:
- Validate inputs before processing (schema validation, size limits)
- Filter outputs for sensitive content, PII, and policy violations
- Set hard cost ceilings (max tokens, max API calls, max spend per run)
- Implement circuit breakers for cascading failures
- Log everything for audit trails
DON'T:
- Deploy without input validation (prompt injection is real)
- Trust model output without verification for high-stakes decisions
- Run without cost controls (one runaway loop can cost thousands)
- Skip rate limiting on external API calls
- Assume the model will follow safety instructions 100% of the time
→ Consult guardrails reference for validation, sandboxing, and constraints.
The Workflow Slop Test
If any of these are true, the workflow needs work:
Zero checked = production-ready. 3+ checked = workflow slop.
Available Commands
Use these commands to apply specific aspects of workflow mastery:
{{available_commands}}
1---2name: agent-workflow3description: Use when any Maestro command is invoked — provides foundational workflow design principles across prompt engineering, context management, tool orchestration, agent architecture, feedback loops, knowledge systems, and guardrails.4---56## MANDATORY — Context Gathering Protocol78Before applying any workflow guidance, gather context:9101. **Check for Maestro context** in the project root11 - First check `.maestro/context.md` (v2 layout)12 - Then check `.maestro.md` (v1 layout — backward compatible)13 - If it exists → read it and use the workflow context within14 - If it doesn't exist → tell the user: *"No workflow context found. Run /teach-maestro to set up project-specific context for better results."*15162. **Check for decision history** (optional)17 - If `.maestro/decisions.jsonl` exists → read the last 5 decisions for session continuity18 - If it doesn't exist → proceed without it (no error)19202. **Minimum viable context** (if no `.maestro.md`):21 - What AI model(s) are being used?22 - What is the workflow's primary task?23 - Are there existing prompts, tools, or agents to work with?24 - What are the quality/speed/cost priorities?25263. **DO NOT** proceed without at least understanding the model, task, and priorities.2728---2930# Maestro — AI Agent Workflow Mastery3132This skill provides the foundational knowledge for designing, building, and maintaining33production-grade AI agent workflows. All Maestro commands build on these principles.3435## Core Principles36371. **Structure over improvisation** — Workflows should be deliberate, not emergent382. **Constraints are features** — Explicit boundaries prevent failure modes393. **Measure, don't assume** — Every workflow needs evaluation, not just testing404. **Appropriate complexity** — Match the solution to the problem, not the ambition415. **Graceful degradation** — Every component should fail safely4243---4445## 1. Prompt Engineering4647**DO**:4849- Use structured prompts with clear sections (role, context, instructions, output format)50- Define output schemas explicitly (JSON schema, markdown template, typed response)51- Use few-shot examples for ambiguous tasks52- Chain-of-thought for multi-step reasoning53- Keep system prompts focused — one clear role per prompt5455**DON'T**:5657- Write wall-of-text prompts with no structure58- Assume the model understands implicit output format59- Use the same prompt for fundamentally different tasks60- Put conflicting instructions in the same prompt61- Rely on the model to "figure it out"6263→ *Consult [prompt engineering reference](reference/prompt-engineering.md) for structure, patterns, and output schemas.*6465---6667## 2. Context Management6869**DO**:7071- Budget context window usage (system prompt, examples, user input, tool results, output)72- Place critical information at the start AND end of context (attention gradient)73- Use retrieval (RAG) instead of stuffing full documents74- Maintain conversation state explicitly75- Summarize long histories instead of passing raw transcripts7677**DON'T**:7879- Dump entire codebases, databases, or documents into context80- Ignore context window limits until you hit them81- Assume the model pays equal attention to all context82- Pass irrelevant information "just in case"83- Rely on implicit memory across turns8485→ *Consult [context management reference](reference/context-management.md) for window optimization and memory patterns.*8687---8889## 3. Tool Orchestration9091**DO**:9293- Give tools clear, specific names and descriptions94- Define input/output schemas for every tool95- Handle tool errors gracefully (the tool WILL fail eventually)96- Keep tool sets focused — 3-7 tools per agent is ideal97- Make tools idempotent where possible9899**DON'T**:100101- Expose 30+ tools and hope the model picks the right one102- Use vague tool descriptions ("does stuff with data")103- Skip error handling in tool implementations104- Let tools have side effects without confirmation for destructive operations105- Create tools that overlap in functionality106107→ *Consult [tool orchestration reference](reference/tool-orchestration.md) for selection heuristics and composition patterns.*108109---110111## 4. Agent Architecture112113**DO**:114115- Start with a single agent — add agents only when a single agent demonstrably fails116- Define clear boundaries and responsibilities for each agent117- Use structured handoff protocols between agents118- Implement supervisor patterns for multi-agent systems119- Design for observability — log agent decisions, not just outputs120121**DON'T**:122123- Build multi-agent systems for problems a single agent handles124- Create agents without clear boundaries (overlapping responsibilities = conflicts)125- Use unstructured communication between agents126- Skip the supervisor — autonomous agent swarms are unpredictable127- Assume agents will coordinate without explicit protocols128129→ *Consult [agent architecture reference](reference/agent-architecture.md) for topology patterns and delegation.*130131---132133## 5. Feedback Loops134135**DO**:136137- Build evaluation into the workflow from day one138- Create golden test sets with known-good inputs and outputs139- Use automated evaluators for consistent quality scoring140- Track regression — compare new outputs against baselines141- Implement self-correction loops for critical outputs142143**DON'T**:144145- Ship without evaluation ("it seems to work" is not evaluation)146- Rely solely on human review at scale147- Use the same model to evaluate its own output without structure148- Skip regression testing when changing prompts or models149- Conflate "the model ran without errors" with "the output is correct"150151→ *Consult [feedback loops reference](reference/feedback-loops.md) for evaluation patterns and self-correction.*152153---154155## 6. Knowledge Systems156157**DO**:158159- Choose retrieval strategy based on query type (semantic, keyword, hybrid)160- Chunk documents thoughtfully (semantic boundaries, not arbitrary token counts)161- Include source attribution in every retrieved result162- Test retrieval quality independently of generation quality163- Version your knowledge base — know what the model has access to164165**DON'T**:166167- Build RAG without testing retrieval quality first168- Use fixed chunk sizes for all document types169- Skip source attribution (hallucination without attribution is undetectable)170- Index everything without curation (garbage in = garbage out)171- Assume embedding similarity equals relevance172173→ *Consult [knowledge systems reference](reference/knowledge-systems.md) for RAG, embeddings, and grounding.*174175---176177## 7. Guardrails & Safety178179**DO**:180181- Validate inputs before processing (schema validation, size limits)182- Filter outputs for sensitive content, PII, and policy violations183- Set hard cost ceilings (max tokens, max API calls, max spend per run)184- Implement circuit breakers for cascading failures185- Log everything for audit trails186187**DON'T**:188189- Deploy without input validation (prompt injection is real)190- Trust model output without verification for high-stakes decisions191- Run without cost controls (one runaway loop can cost thousands)192- Skip rate limiting on external API calls193- Assume the model will follow safety instructions 100% of the time194195→ *Consult [guardrails reference](reference/guardrails-safety.md) for validation, sandboxing, and constraints.*196197---198199## The Workflow Slop Test200201If any of these are true, the workflow needs work:202203- [ ] Prompts are unstructured walls of text → run `/refine`204- [ ] No output schema defined — model decides the format → run `/refine`205- [ ] Context window used without budget — everything stuffed in → run `/accelerate`206- [ ] More than 10 tools exposed to a single agent → run `/streamline`207- [ ] No error handling — happy path only → run `/fortify`208- [ ] No evaluation — "it seems to work" → run `/iterate`209- [ ] Multi-agent system for a single-agent problem → run `/temper`210- [ ] No cost controls — unbounded token usage → run `/guard`211- [ ] Tools have vague one-line descriptions → run `/calibrate`212- [ ] No logging — can't debug production issues → run `/fortify`213214**Zero checked = production-ready. 3+ checked = workflow slop.**215216---217218## Available Commands219220Use these commands to apply specific aspects of workflow mastery:221222{{available_commands}}