From agent-flow
Agent team best practices — philosophy, routing, execution model, adversarial loop, cost management, failure modes, and brief writing.
npx claudepluginhub timgranlundmarsden/claude-agent-flowThis skill uses the workspace's default tool permissions.
1. **Focused context beats broad context.** Narrow agent scope = better reasoning.
Guides composing agent teams for complex tasks with predefined roles: Orchestrator, Explorer, Frontend (React), Backend (Rails), iOS/Swift, Android/Kotlin, Database.
Orchestrates subagents by delegating tasks to role-matched specialists like engineer, reviewer, analyst for multi-agent coding workflows.
Guides subagent coordination through implementation workflows. Use when orchestrating multiple agents, managing workflow phases, or determining autonomous execution mode.
Share bugs, ideas, or general feedback.
AskUserQuestion tool for discrete options (multiple choice, yes/no, A/B/C) — never plain text. This includes design approvals, skill confirmations, and any question where the answer set is bounded.All agents run sequentially — one at a time, dependency order. Standard full sequence:
explorer → architect → storage (if schema) → backend → frontend → tester → critic loop (if /build) → reviewer → author
Adjust order by dependencies. Architect dispatches researcher internally if needed.
Never use run_in_background: true in a sequential pipeline. Foreground catches stalls immediately.
Stall detection: Builder agents (frontend, backend, storage) stalling 5+ minutes with no file writes
or [MILESTONE] markers → cancel and retry with incremental writing pattern. Non-builder agents: any
tool call or text output counts as activity.
/build)Use when correctness matters more than speed: security-critical paths, public APIs, data migrations, anything hard to roll back. Runs the complete sequence with adversarial critic loop.
Use for everyday work: bug fixes, small features, single-file changes, prototypes, docs. Runs: explorer → builder → reviewer. Builder covers basic tests and docs inline. Ask: "Could one agent handle this cleanly?" If yes, lite mode.
Key sequencing constraints (see agent files for full domain details):
/build. Canonical BATS command: .claude-agent-flow/tests/lib/bats-core/bin/bats --jobs 8 .claude-agent-flow/tests/*.bats/build or /review. Reviews diff only, not full codebase.builder → critic (FAIL) → builder fixes diff only → critic (FAIL) → ... → critic (PASS) → tester → reviewer → author
Key rules:
--loops N to override. Persistent failure = design problem, not code.Include: what it must do, what it must NOT do, known edge cases, acceptance criteria.
Bad: "build the login endpoint" Good: "build the login endpoint — email + password, returns JWT, rate-limit 5/min/IP, must not expose whether email exists, log failed attempts to audit table"
The model: field in agent frontmatter is not yet respected at runtime. All subagents
inherit the parent model. Values document intended tiers for when per-agent routing ships.
Subagents multiply tokens 4-7x. Justified when focused context beats one bloated session. NOT justified for single-file tasks or simple bug fixes. Default to lite mode; escalate when needed.
| Agent | Model | Role |
|---|---|---|
| orchestrator | opus | Routes and sequences — never writes code |
| architect | opus | Design decisions — may dispatch researcher |
| ideator | opus | Lateral thinking — output to human only |
| critic | opus | Adversarial review — tries to break code |
| frontend | sonnet | UI components, styling, client-side state |
| backend | sonnet | API routes, business logic, data persistence, auth |
| storage | sonnet | All persistence — sole RLS owner |
| researcher | sonnet | Web research, docs, library investigation |
| tester | sonnet | Tests — write, verify, visual checks |
| reviewer | sonnet | Code review — read only |
| explorer | haiku | Codebase navigation — read only, cheap |
| author | haiku | Docs and changelog — last step only |
| Failure | Symptom | Fix |
|---|---|---|
| Orchestrator implements | Editing files directly | Remind: "delegate only — never edit files" |
| Orchestrator applies fixes | Fixing critic/reviewer issues directly instead of routing to builder | Always pass issue list to the relevant builder agent — even for "trivial" fixes |
| Critic loop won't converge | New issues each iteration | Stop loop → architect with FAIL report → redesign |
| Builder off-pattern | Inconsistent files/patterns | Always run explorer before builders on multi-file tasks |
| Researcher mid-build | Build pauses for research | Invoke researcher before build, not during |
| Storage/backend out of sync | Backend queries missing columns | Storage must complete before backend starts |
| Agent stalls on large output | No writes/milestones for 5+ min | Use incremental writing pattern (skeleton + Edit calls) |
For files >200 lines, builders MUST use skeleton-first:
TODO placeholders per sectionPlaceholder styles: HTML <!-- TODO -->, JS/TS // TODO, JSX {/* TODO */},
Python # TODO, SQL -- TODO, CSS /* TODO */
Output [MILESTONE] markers after each section. Mandatory for all builder agents.
Orchestrator MUST inline reference material (CSS tokens, patterns, contracts, schemas) in builder briefs. Include directive: "Do NOT read additional files for context. All reference material is provided below." Target: 0-2 file reads by builder (CLAUDE.md and agent file don't count).
Builders MUST output [MILESTONE] markers: skeleton written, section N/M complete, file complete.
Orchestrator checks every 3 min. Builder stall (5 min, no writes/markers) → cancel and retry with skeleton+edit.
Non-builder agents: any tool call or text output = activity.
After any CSS or layout fix, agents MUST run visual-check.sh before marking done.
See playwright-cli-helpers skill for full usage, evidence capture, and troubleshooting.
Agents with visual responsibility: frontend, tester, critic, reviewer (flags missing checks).
UI skills required in agent frontmatter: playwright-cli, playwright-cli-helpers.
Every brief must answer four questions:
Task type → Route
─────────────────────────────────────────────────────
Single-file / small fix → lite (just ask naturally)
Multi-file feature, hard to undo → /build <brief>
Feature planning → /plan <idea>
Harden existing code → /review <files>
Codebase question → explorer
Design decision → architect
Stuck on approach → ideator
Library/API research → researcher
Schema/storage only → storage
API/server only → backend
UI/component only → frontend
Full feature (schema+API+UI) → orchestrator
Decision rule: "Could this break something across multiple systems?" Yes → /build. Otherwise → lite.