--- name: loops description: Top-level workflow loops that chain multiple personas autonomously. Use *fix, *review, *impl, *qa, or *plan sprint instead of manually invoking each persona in sequence. triggers: ["*fix", "*review", "*impl", "*qa", "*plan sprint"] requires: ["bob-protocol", "chat", "make"] --- Top-level loop commands that run multi-persona chains autonomously without the user needing to invoke each step. TLDR: Use loop commands when you want a full workflow, not a single-persona response. Each loop runs its persona chain to completion — saving state and posting handoffs at every step. For direct single-persona control, use `*chat @persona *command` instead. # Loops — Multi-Persona Workflow Commands ## Overview Loop commands trigger an **autonomous chain** of personas. Each persona completes its role, saves state, hands off to the next, and the chain continues until the loop is done or a gate requires input. **Rule:** Every persona in a loop MUST save state and post a handoff message before switching — see bob-protocol State Management. --- ## Loop Commands ### `*fix ` **Fix loop** — investigate, fix, test, and review a bug or broken behavior. ``` Chain: Neo → Trin → Morpheus ``` | Step | Persona | Action | |------|---------|--------| | 1 | Neo | Investigate and fix: `*swe fix ` | | 2 | Trin | Verify fix, run tests: `*qa uat ` | | 3 | Morpheus | Code review: `*lead review ` | - If Trin's tests fail → back to Neo (`*swe fix`) - If Morpheus review fails → back to Neo (`*swe fix`) - Anti-loop: if Neo fails twice → Oracle consult required before retry **Example:** `*fix auth token expiry bug` --- ### `*impl ` **Implementation loop** — implement, test, and review a feature or sprint phase. ``` Chain: Neo → Trin → Morpheus ``` | Step | Persona | Action | |------|---------|--------| | 1 | Neo | TDD implementation: `*swe impl ` | | 2 | Trin | UAT — run tests, verify acceptance criteria: `*qa uat ` | | 3 | Morpheus | Code review — quality and architecture: `*lead review ` | - If Trin UAT fails → back to Neo for that phase only - If Morpheus review fails → back to Neo for that phase only - Do NOT restart the full sprint; fix the failing phase only **Example:** `*impl phase-2` --- ### `*qa ` **QA loop** — test and review without reimplementation. ``` Chain: Trin → Morpheus ``` | Step | Persona | Action | |------|---------|--------| | 1 | Trin | Test and verify: `*qa test ` | | 2 | Morpheus | Review results: `*lead review ` | **Example:** `*qa the new export command` --- ### `*review ` **Review loop** — architecture and quality review of existing code or a deliverable. ``` Chain: Morpheus → Trin (optional) ``` | Step | Persona | Action | |------|---------|--------| | 1 | Morpheus | Architecture review: `*lead review ` | | 2 | Trin | Quality review (if Morpheus flags issues): `*qa review ` | **Example:** `*review the new API design` --- ### `*plan sprint` **Sprint planning loop** — full planning sequence from stories through phase breakdown. ``` Chain: Cypher → [Smith gate] → Morpheus → [Smith gate] → Mouse → Morpheus review ``` | Step | Persona | Action | Gate | |------|---------|--------|------| | 1 | Cypher | Write stories + acceptance criteria: `*pm plan sprint` | Smith review | | 1a | Smith | `*user review ` → `*user approve` or `*user reject` | Must approve | | 2 | Morpheus | Architecture decisions: `*lead arch sprint` | Smith review | | 2a | Smith | `*user feedback ` → `*user approve` or `*user reject` | Must approve | | 3 | Mouse | Break into short phases (1-3 tasks each): `*sm plan sprint` | Morpheus review | | 3a | Morpheus | Review sprint plan vs. architecture: `*lead review sprint plan` | | **Gates are hard stops** — Smith must explicitly `*user approve` before the chain continues. **Example:** `*plan sprint` --- ## When to Use Loops vs. Direct Invocation | Situation | Use | |-----------|-----| | Fix a bug end-to-end | `*fix ` | | Implement a feature with tests and review | `*impl ` | | Just run tests and review | `*qa ` | | Architect review only | `*review ` | | Full sprint planning | `*plan sprint` | | Talk directly to one persona | `*chat @neo *swe fix X` | | Single-step with full control | `*chat @trin *qa test all` | --- ## Loop Handoff Format Every persona in a loop posts a handoff before switching: ```bash make chat MSG=" @NextPersona *command" PERSONA="" CMD=" handoff" TO="" ``` The next persona reads CHAT.md on entry — if the handoff isn't there, they start blind.