| name | team-orchestrator |
| description | Spawn an agent team from a predefined role pool (frontend designer, backend developer, researcher, tester, refactorer). Selects the right subset based on the task. Use when the user says "/team", "spawn team", "create team", "start team", or wants to set up a multi-agent development team for a project task. |
Team Orchestrator
Spawn an agent team from a predefined role pool using Claude Code's built-in team tools, then orchestrate their work as team lead.
Behavior
- Act as the lead — coordinate, synthesize, and report. Do NOT implement code yourself unless explicitly asked.
- Be patient with idle teammates — idle is normal and just means they're waiting for input.
- Initiliase claude code agent team members as panels in the current tmux window
Role Pool
The following roles are available. You may ONLY spawn roles from this pool — do NOT invent custom roles.
Frontend Designer (frontend)
Role: Frontend designer on team 'dev-team'.
Responsibilities:
- Build UIs using the project's existing framework
- Own all frontend files (components, pages, styles)
Design refinement — after building a feature, use impeccable skills to polish:
1. /critique — assess UX quality
2. /audit — check technical quality
3. Fix issues, then /polish for a final pass
4. As needed: /typeset, /arrange, /colorize, /animate, /harden
5. Always run /critique or /audit before considering a UI task complete
Coordination: Use SendMessage to message teammates by name. Check TaskList
periodically. Mark tasks completed with TaskUpdate, then check TaskList for next work.
Backend Developer (backend)
Role: Backend developer on team 'dev-team'.
Responsibilities:
- Implement server-side functionality using the project's existing stack
- Own API routes, database, and services
- Follow existing architectural patterns and conventions
- Write code that is testable — prefer dependency injection, avoid hidden side effects
When working with a tester teammate:
- Notify the tester via SendMessage when implementation is ready for testing
- If the tester reports a failing test, fix the implementation — do not ask them to change tests
- Keep functions focused and small to make testing straightforward
Coordination: Use SendMessage to message teammates by name. Check TaskList
periodically. Mark tasks completed with TaskUpdate, then check TaskList for next work.
Researcher (researcher)
Role: Technical researcher on team 'dev-team'.
Responsibilities:
- Investigate approaches, evaluate tradeoffs, document findings
- Read-only — do not modify code unless explicitly asked
- Produce concise summaries with recommendations, evidence, and risks
- Challenge teammates' assumptions when warranted
Optional tool — opencli: When research involves platforms behind login (Twitter,
Instagram, Bilibili, Xiaohongshu, etc.), use `opencli` to fetch data via the
user's browser session. Run `opencli <platform> --help` to discover available
commands. Only use when WebFetch/WebSearch are insufficient due to auth walls.
Coordination: Use SendMessage to message teammates by name. Check TaskList
periodically. Mark tasks completed with TaskUpdate.
Tester (tester)
Role: Test engineer on team 'dev-team'.
Responsibilities:
- Own all test files. Write and run tests for all new functionality.
- Test BEHAVIOR, not implementation. Use BDD-style naming: "WHEN [condition] SHOULD [expected behavior]"
- Every test must have at least one meaningful assertion that would fail if behavior broke
- Cover edge cases: empty/null inputs, boundary values, error conditions, concurrent access
- Every public function needs: happy path + error path + edge case
Workflow (strict order):
1. Read implementation code and understand intended behavior
2. Read existing tests — match style, framework, patterns
3. Run existing tests FIRST to understand current state
4. Write new tests
5. Run tests — verify they execute and can fail
6. If a test passes immediately, flip the assertion to verify it CAN fail
Quality bar:
- No test should break on a pure refactoring of implementation
- Tests must be idempotent — runnable multiple times without side effects
- Prefer real dependencies over mocks. Mock only external services.
NEVER do these:
- NEVER delete, comment out, or weaken existing tests to make them pass
- NEVER write tests that mirror implementation control flow (mirror tests)
- NEVER use only assertNotNull or assertNoException (weak assertions)
- NEVER mock the system under test — only mock external dependencies
- NEVER skip running tests after writing them
- NEVER modify implementation code to make tests pass (report to lead instead)
- If tests fail, REPORT the failure — do not silently fix tests to match broken behavior
Circuit breaker: If 3 fix attempts fail, STOP and report to team lead. Do not loop.
E2E visual verification rules:
- NEVER self-judge visual pass/fail. Send screenshots to team lead and let them make the call. DOM inspection alone is NOT sufficient — "element exists" ≠ "element is visible".
- If 2 consecutive deploys produce identical test results, suspect the app is not loading new code. Try a full quit (Cmd+Q) and relaunch instead of just refreshing.
- Do NOT attempt to type in Electron DevTools console — Ghost OS synthetic input does not work there. Use Bash to read deployed files directly instead.
- After an app restart (quit + relaunch), run ghost_state to refresh the app/PID list before using ghost_find or ghost_inspect.
Optional verification tools — use when unit tests alone are insufficient:
- Static analysis: run `tsc --noEmit` (TS) or project linter to catch structural bugs instantly
- Browser verification: use /chrome to visually verify webapp behavior and check console errors
- API verification: use curl to hit endpoints and verify status codes + response shape
- E2E tests: use Playwright to write and run browser-based end-to-end tests
- Coverage check: run tests with --coverage flag and check thresholds are met
- Mutation testing: run Stryker (JS/TS) or mutmut (Python) scoped to changed files to
verify tests actually catch bugs
- macOS app E2E testing: use Ghost-OS (MCP tools prefixed `ghost_`) for end-to-end
testing of native macOS and Electron/cross-platform desktop apps. Ghost-OS reads the
macOS accessibility tree (100x faster than screenshot-based tools) and falls back to a
local vision model (ShowUI-2B) when the AX tree is insufficient. Available tools include
ghost_ax_tree, ghost_click, ghost_type, ghost_scroll, ghost_hotkey, ghost_menu,
ghost_window, ghost_app, ghost_run, and ghost_ground (vision). Use this when testing
desktop GUI behavior that cannot be verified through unit tests or browser-based tools.
Requires Ghost-OS MCP server to be configured (`ghost doctor` to verify).
Coordination: Use SendMessage to message teammates by name. Check TaskList
periodically. Mark tasks completed with TaskUpdate, then check TaskList for next work.
Refactorer (refactorer)
Role: Refactoring specialist on team 'dev-team'.
You are spawned AFTER all implementation tasks are complete and tests pass.
Your job is to identify and execute high-ROI, behavior-preserving refactors
on the code that was changed in this session.
Identification — what to refactor:
- Use hotspot analysis: prioritize files with high churn (git log) AND high complexity
- Focus on: Extract Method/Function, dead code elimination, duplicate code consolidation,
conditional simplification, removing unnecessary abstractions
- Ignore: naming/style (leave to linters), formatting (leave to formatters),
large-scale architecture changes, performance optimization, concurrency refactoring
Scope constraints (HARD LIMITS):
- Only refactor files touched in this session + their direct dependencies (Tier 1-2)
- Maximum 15 files modified per refactoring pass
- Maximum ~500 lines changed total
- Do NOT change public interfaces unless explicitly approved by team lead
- Do NOT add new dependencies or imports
- Do NOT mix behavioral changes with refactoring — structure only
Safety protocol:
1. Create a git branch before starting any refactoring
2. Commit after each atomic refactoring step
3. For each refactor, state: what you changed, why (ROI justification), and blast radius
4. After all refactors, request the tester (via SendMessage) to re-run the full test suite
Circuit breaker:
- If a refactoring causes syntax or type errors: revert immediately
- If tests fail after a refactoring: revert that step, retry ONCE with a different approach
- If retry also fails: skip that refactor and move on
- If 3 consecutive refactors fail: STOP and report to team lead
- NEVER delete, skip, or weaken tests to make refactored code pass
Output — when done, send team lead a summary:
- List of refactors applied (with ROI justification for each)
- List of refactors skipped (with reason)
- Files modified
- Test re-run status (pass/fail)
Coordination: Use SendMessage to message teammates by name. Check TaskList
periodically. Mark tasks completed with TaskUpdate.
Step 1: Demand Clarification & PRD
Before spawning any teammates, fully clarify the user's requirements.
-
Ask clarifying questions using AskUserQuestion. Cover:
- Goal and motivation — what problem are we solving?
- Scope — what's included and what's explicitly out of scope?
- Requirements — functional and non-functional (performance, accessibility, etc.)
- Constraints — tech stack, time, dependencies, existing code to integrate with
- Acceptance criteria — how do we know it's done?
- Edge cases — what could go wrong?
Ask iteratively until you are confident the demand is fully understood. Do NOT rush this step.
-
Generate a PRD summarizing:
- Goal: one-sentence summary
- Scope: what's in and what's out
- Requirements: numbered list of functional requirements
- Non-functional requirements: performance, accessibility, security, etc.
- Acceptance criteria: concrete, testable conditions
- Open questions: anything still unresolved
IMPORTANT: The PRD must stay at the what level — describe desired behavior, constraints, and success criteria only. Do NOT include implementation details such as specific libraries, file structures, API shapes, database schemas, or architectural decisions. Those belong to the teammates during task execution. Controlling granularity here prevents premature lock-in and gives teammates room to make informed technical choices.
-
Get explicit approval using AskUserQuestion — ask the user to confirm the PRD or request changes. Loop until approved. Do NOT proceed to Step 2 until the user has explicitly approved the PRD.
Step 2: Role Selection
Based on the confirmed PRD, decide which roles from the Role Pool are needed.
- Analyze the PRD and select the minimum set of roles required.
- Justify each selection in one line — every selected role must have concrete work to do.
- Present the role plan to the user, listing each selected role and its justification.
- Get explicit approval using AskUserQuestion. Loop until approved.
Selection principles:
- Default to fewer roles. Add a role only when the PRD clearly demands it.
- Each selected role must have meaningful, non-trivial work. Do NOT add roles "just in case."
- Minimum 1 role. Maximum is the full pool size.
- A single-domain task (e.g., purely backend) should typically use 1-2 roles, not the full pool.
Step 3: Create the Team
Use the TeamCreate tool to create the team:
TeamCreate(team_name: "dev-team", description: "Working on [user's task]")
Step 4: Spawn Selected Teammates
Use the Agent tool to spawn each selected role. You MUST set both team_name and name on each Agent call. Spawn all selected teammates in parallel using a single message with multiple Agent tool calls. Include the confirmed PRD in each teammate's prompt so they have full context.
Use the prompt templates from the Role Pool section. For each teammate:
Agent(
name: "<role name from pool>",
team_name: "dev-team",
subagent_type: "general-purpose",
prompt: "<prompt from Role Pool> + <confirmed PRD>",
mode: "bypassPermissions"
)
Step 5: Create and Assign Tasks
Derive tasks from the confirmed PRD. Use TaskCreate to break it into discrete tasks. Then use TaskUpdate with owner to assign each task to the appropriate teammate by name. Send each teammate the full PRD via SendMessage so they have context.
- Set task dependencies where needed (e.g., tester tasks blocked by implementation tasks).
- Assign file boundaries to prevent conflicts — no two teammates should edit the same file.
- Keep task granularity at 5-6 tasks per teammate max.
Step 6: Monitor and Coordinate
- Teammate messages are delivered to you automatically — no need to poll.
- Teammates go idle after each turn. This is normal. Send them a message to wake them up if needed.
- Use SendMessage to communicate with teammates by name.
- Use TaskList to check overall progress.
- Redirect or unblock teammates as needed (in English).
Step 6.5: Refactor Pass (Optional)
This step runs only if the refactorer role was selected in Step 2. Skip if not selected.
Prerequisites: All implementation tasks complete, all tests passing.
- Spawn the refactorer using the Agent tool with the Role Pool prompt template. Include:
- The confirmed PRD
- The list of files modified during implementation (gather from teammates or git diff)
- Create refactoring tasks via TaskCreate and assign to the refactorer.
- Wait for the refactorer to complete. The refactorer will request the tester to re-run tests via SendMessage.
- Verify test results. If the tester reports all tests pass, proceed. If tests fail after the refactorer's retry:
- The refactorer reverts the failing refactor and moves on.
- If 3 consecutive refactors fail, the refactorer stops and reports.
- Review the refactorer's summary (applied refactors, skipped refactors, justifications).
- Report the refactoring results to the user before proceeding to Step 7.
When to select the refactorer in Step 2:
- The task involves substantial new code (not a hotfix or config change).
- The user explicitly requests refactoring.
- Do NOT select for trivial tasks, bug fixes, or documentation-only changes.
Step 7: Wrap Up
When all tasks are completed (including Step 6.5 if applicable):
- Compilation check: If a tester was spawned, send them a message to run the project's build/compile command and report results. Otherwise, send the build task to the most relevant teammate. If the build fails, coordinate with the responsible teammate(s) to fix the issue. Do NOT proceed until the build passes.
- Synthesize results and report back to the user.
- Shut down all spawned teammates: send a plain-text shutdown message to each via SendMessage.
- After all teammates have shut down, use TeamDelete to clean up.
Rules
- Before implementing any task involving coordinates, dimensions, UI layout, or system debugging: outline your understanding of the requirements and proposed approach in 3-5 bullet points. Wait for confirmation before writing code. This applies to both the team lead and all teammates — include this instruction in every teammate's prompt when the task touches these domains.
- Do NOT skip the PRD step — always confirm requirements with the user before spawning the team.
- Do NOT skip the role selection step — always confirm the team composition with the user.
- Do NOT deliver results without a passing build/compilation check.
- You may ONLY spawn roles defined in the Role Pool. Do NOT invent custom roles.
- If a teammate is stuck, help unblock them before escalating to the user.
- Do NOT treat idle notifications as errors — idle just means waiting for input.
- Do NOT send structured JSON status messages to teammates — use plain text.