compound-engineering-pi 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +124 -0
- package/bin/compound-engineering-pi +12 -0
- package/bin/compound-plugin +12 -0
- package/compound-engineering-pi +12 -0
- package/compound-plugin +5 -0
- package/docs/pi.md +152 -0
- package/extensions/compound-engineering-compat.ts +452 -0
- package/package.json +84 -0
- package/pi-resources/compound-engineering/mcporter.json +7 -0
- package/plugins/coding-tutor/.claude-plugin/plugin.json +9 -0
- package/plugins/coding-tutor/README.md +37 -0
- package/plugins/coding-tutor/commands/quiz-me.md +1 -0
- package/plugins/coding-tutor/commands/sync-tutorials.md +25 -0
- package/plugins/coding-tutor/commands/teach-me.md +1 -0
- package/plugins/coding-tutor/skills/coding-tutor/SKILL.md +214 -0
- package/plugins/coding-tutor/skills/coding-tutor/scripts/create_tutorial.py +207 -0
- package/plugins/coding-tutor/skills/coding-tutor/scripts/index_tutorials.py +193 -0
- package/plugins/coding-tutor/skills/coding-tutor/scripts/quiz_priority.py +190 -0
- package/plugins/coding-tutor/skills/coding-tutor/scripts/setup_tutorials.py +118 -0
- package/plugins/compound-engineering/.claude-plugin/plugin.json +33 -0
- package/plugins/compound-engineering/CHANGELOG.md +457 -0
- package/plugins/compound-engineering/CLAUDE.md +89 -0
- package/plugins/compound-engineering/LICENSE +21 -0
- package/plugins/compound-engineering/README.md +232 -0
- package/plugins/compound-engineering/agents/design/design-implementation-reviewer.md +109 -0
- package/plugins/compound-engineering/agents/design/design-iterator.md +224 -0
- package/plugins/compound-engineering/agents/design/figma-design-sync.md +190 -0
- package/plugins/compound-engineering/agents/docs/ankane-readme-writer.md +65 -0
- package/plugins/compound-engineering/agents/research/best-practices-researcher.md +126 -0
- package/plugins/compound-engineering/agents/research/framework-docs-researcher.md +106 -0
- package/plugins/compound-engineering/agents/research/git-history-analyzer.md +59 -0
- package/plugins/compound-engineering/agents/research/learnings-researcher.md +264 -0
- package/plugins/compound-engineering/agents/research/repo-research-analyst.md +135 -0
- package/plugins/compound-engineering/agents/review/agent-native-reviewer.md +261 -0
- package/plugins/compound-engineering/agents/review/architecture-strategist.md +67 -0
- package/plugins/compound-engineering/agents/review/code-simplicity-reviewer.md +101 -0
- package/plugins/compound-engineering/agents/review/data-integrity-guardian.md +85 -0
- package/plugins/compound-engineering/agents/review/data-migration-expert.md +112 -0
- package/plugins/compound-engineering/agents/review/deployment-verification-agent.md +174 -0
- package/plugins/compound-engineering/agents/review/dhh-rails-reviewer.md +66 -0
- package/plugins/compound-engineering/agents/review/julik-frontend-races-reviewer.md +221 -0
- package/plugins/compound-engineering/agents/review/kieran-python-reviewer.md +133 -0
- package/plugins/compound-engineering/agents/review/kieran-rails-reviewer.md +115 -0
- package/plugins/compound-engineering/agents/review/kieran-typescript-reviewer.md +124 -0
- package/plugins/compound-engineering/agents/review/pattern-recognition-specialist.md +72 -0
- package/plugins/compound-engineering/agents/review/performance-oracle.md +137 -0
- package/plugins/compound-engineering/agents/review/schema-drift-detector.md +154 -0
- package/plugins/compound-engineering/agents/review/security-sentinel.md +114 -0
- package/plugins/compound-engineering/agents/workflow/bug-reproduction-validator.md +82 -0
- package/plugins/compound-engineering/agents/workflow/every-style-editor.md +64 -0
- package/plugins/compound-engineering/agents/workflow/lint.md +16 -0
- package/plugins/compound-engineering/agents/workflow/pr-comment-resolver.md +84 -0
- package/plugins/compound-engineering/agents/workflow/spec-flow-analyzer.md +134 -0
- package/plugins/compound-engineering/commands/agent-native-audit.md +278 -0
- package/plugins/compound-engineering/commands/changelog.md +138 -0
- package/plugins/compound-engineering/commands/create-agent-skill.md +9 -0
- package/plugins/compound-engineering/commands/deepen-plan.md +546 -0
- package/plugins/compound-engineering/commands/deploy-docs.md +113 -0
- package/plugins/compound-engineering/commands/feature-video.md +342 -0
- package/plugins/compound-engineering/commands/generate_command.md +163 -0
- package/plugins/compound-engineering/commands/heal-skill.md +143 -0
- package/plugins/compound-engineering/commands/lfg.md +20 -0
- package/plugins/compound-engineering/commands/release-docs.md +212 -0
- package/plugins/compound-engineering/commands/report-bug.md +151 -0
- package/plugins/compound-engineering/commands/reproduce-bug.md +100 -0
- package/plugins/compound-engineering/commands/resolve_parallel.md +35 -0
- package/plugins/compound-engineering/commands/resolve_todo_parallel.md +37 -0
- package/plugins/compound-engineering/commands/slfg.md +32 -0
- package/plugins/compound-engineering/commands/technical_review.md +8 -0
- package/plugins/compound-engineering/commands/test-browser.md +339 -0
- package/plugins/compound-engineering/commands/test-xcode.md +332 -0
- package/plugins/compound-engineering/commands/triage.md +311 -0
- package/plugins/compound-engineering/commands/workflows/brainstorm.md +124 -0
- package/plugins/compound-engineering/commands/workflows/compound.md +239 -0
- package/plugins/compound-engineering/commands/workflows/plan.md +551 -0
- package/plugins/compound-engineering/commands/workflows/review.md +526 -0
- package/plugins/compound-engineering/commands/workflows/work.md +433 -0
- package/plugins/compound-engineering/skills/agent-browser/SKILL.md +223 -0
- package/plugins/compound-engineering/skills/agent-native-architecture/SKILL.md +435 -0
- package/plugins/compound-engineering/skills/agent-native-architecture/references/action-parity-discipline.md +409 -0
- package/plugins/compound-engineering/skills/agent-native-architecture/references/agent-execution-patterns.md +467 -0
- package/plugins/compound-engineering/skills/agent-native-architecture/references/agent-native-testing.md +582 -0
- package/plugins/compound-engineering/skills/agent-native-architecture/references/architecture-patterns.md +478 -0
- package/plugins/compound-engineering/skills/agent-native-architecture/references/dynamic-context-injection.md +338 -0
- package/plugins/compound-engineering/skills/agent-native-architecture/references/files-universal-interface.md +301 -0
- package/plugins/compound-engineering/skills/agent-native-architecture/references/from-primitives-to-domain-tools.md +359 -0
- package/plugins/compound-engineering/skills/agent-native-architecture/references/mcp-tool-design.md +506 -0
- package/plugins/compound-engineering/skills/agent-native-architecture/references/mobile-patterns.md +871 -0
- package/plugins/compound-engineering/skills/agent-native-architecture/references/product-implications.md +443 -0
- package/plugins/compound-engineering/skills/agent-native-architecture/references/refactoring-to-prompt-native.md +317 -0
- package/plugins/compound-engineering/skills/agent-native-architecture/references/self-modification.md +269 -0
- package/plugins/compound-engineering/skills/agent-native-architecture/references/shared-workspace-architecture.md +680 -0
- package/plugins/compound-engineering/skills/agent-native-architecture/references/system-prompt-design.md +250 -0
- package/plugins/compound-engineering/skills/andrew-kane-gem-writer/SKILL.md +184 -0
- package/plugins/compound-engineering/skills/andrew-kane-gem-writer/references/database-adapters.md +231 -0
- package/plugins/compound-engineering/skills/andrew-kane-gem-writer/references/module-organization.md +121 -0
- package/plugins/compound-engineering/skills/andrew-kane-gem-writer/references/rails-integration.md +183 -0
- package/plugins/compound-engineering/skills/andrew-kane-gem-writer/references/resources.md +119 -0
- package/plugins/compound-engineering/skills/andrew-kane-gem-writer/references/testing-patterns.md +261 -0
- package/plugins/compound-engineering/skills/brainstorming/SKILL.md +190 -0
- package/plugins/compound-engineering/skills/compound-docs/SKILL.md +511 -0
- package/plugins/compound-engineering/skills/compound-docs/assets/critical-pattern-template.md +34 -0
- package/plugins/compound-engineering/skills/compound-docs/assets/resolution-template.md +93 -0
- package/plugins/compound-engineering/skills/compound-docs/references/yaml-schema.md +65 -0
- package/plugins/compound-engineering/skills/compound-docs/schema.yaml +176 -0
- package/plugins/compound-engineering/skills/create-agent-skills/SKILL.md +275 -0
- package/plugins/compound-engineering/skills/create-agent-skills/references/api-security.md +226 -0
- package/plugins/compound-engineering/skills/create-agent-skills/references/be-clear-and-direct.md +531 -0
- package/plugins/compound-engineering/skills/create-agent-skills/references/best-practices.md +404 -0
- package/plugins/compound-engineering/skills/create-agent-skills/references/common-patterns.md +595 -0
- package/plugins/compound-engineering/skills/create-agent-skills/references/core-principles.md +437 -0
- package/plugins/compound-engineering/skills/create-agent-skills/references/executable-code.md +175 -0
- package/plugins/compound-engineering/skills/create-agent-skills/references/iteration-and-testing.md +474 -0
- package/plugins/compound-engineering/skills/create-agent-skills/references/official-spec.md +134 -0
- package/plugins/compound-engineering/skills/create-agent-skills/references/recommended-structure.md +168 -0
- package/plugins/compound-engineering/skills/create-agent-skills/references/skill-structure.md +152 -0
- package/plugins/compound-engineering/skills/create-agent-skills/references/using-scripts.md +113 -0
- package/plugins/compound-engineering/skills/create-agent-skills/references/using-templates.md +112 -0
- package/plugins/compound-engineering/skills/create-agent-skills/references/workflows-and-validation.md +510 -0
- package/plugins/compound-engineering/skills/create-agent-skills/templates/router-skill.md +73 -0
- package/plugins/compound-engineering/skills/create-agent-skills/templates/simple-skill.md +33 -0
- package/plugins/compound-engineering/skills/create-agent-skills/workflows/add-reference.md +96 -0
- package/plugins/compound-engineering/skills/create-agent-skills/workflows/add-script.md +93 -0
- package/plugins/compound-engineering/skills/create-agent-skills/workflows/add-template.md +74 -0
- package/plugins/compound-engineering/skills/create-agent-skills/workflows/add-workflow.md +120 -0
- package/plugins/compound-engineering/skills/create-agent-skills/workflows/audit-skill.md +138 -0
- package/plugins/compound-engineering/skills/create-agent-skills/workflows/create-domain-expertise-skill.md +605 -0
- package/plugins/compound-engineering/skills/create-agent-skills/workflows/create-new-skill.md +191 -0
- package/plugins/compound-engineering/skills/create-agent-skills/workflows/get-guidance.md +121 -0
- package/plugins/compound-engineering/skills/create-agent-skills/workflows/upgrade-to-router.md +161 -0
- package/plugins/compound-engineering/skills/create-agent-skills/workflows/verify-skill.md +204 -0
- package/plugins/compound-engineering/skills/dhh-rails-style/SKILL.md +185 -0
- package/plugins/compound-engineering/skills/dhh-rails-style/references/architecture.md +653 -0
- package/plugins/compound-engineering/skills/dhh-rails-style/references/controllers.md +303 -0
- package/plugins/compound-engineering/skills/dhh-rails-style/references/frontend.md +510 -0
- package/plugins/compound-engineering/skills/dhh-rails-style/references/gems.md +266 -0
- package/plugins/compound-engineering/skills/dhh-rails-style/references/models.md +359 -0
- package/plugins/compound-engineering/skills/dhh-rails-style/references/testing.md +338 -0
- package/plugins/compound-engineering/skills/document-review/SKILL.md +87 -0
- package/plugins/compound-engineering/skills/dspy-ruby/SKILL.md +737 -0
- package/plugins/compound-engineering/skills/dspy-ruby/assets/config-template.rb +187 -0
- package/plugins/compound-engineering/skills/dspy-ruby/assets/module-template.rb +300 -0
- package/plugins/compound-engineering/skills/dspy-ruby/assets/signature-template.rb +221 -0
- package/plugins/compound-engineering/skills/dspy-ruby/references/core-concepts.md +674 -0
- package/plugins/compound-engineering/skills/dspy-ruby/references/observability.md +366 -0
- package/plugins/compound-engineering/skills/dspy-ruby/references/optimization.md +603 -0
- package/plugins/compound-engineering/skills/dspy-ruby/references/providers.md +418 -0
- package/plugins/compound-engineering/skills/dspy-ruby/references/toolsets.md +502 -0
- package/plugins/compound-engineering/skills/every-style-editor/SKILL.md +134 -0
- package/plugins/compound-engineering/skills/every-style-editor/references/EVERY_WRITE_STYLE.md +529 -0
- package/plugins/compound-engineering/skills/file-todos/SKILL.md +252 -0
- package/plugins/compound-engineering/skills/file-todos/assets/todo-template.md +155 -0
- package/plugins/compound-engineering/skills/frontend-design/SKILL.md +42 -0
- package/plugins/compound-engineering/skills/gemini-imagegen/SKILL.md +237 -0
- package/plugins/compound-engineering/skills/gemini-imagegen/requirements.txt +2 -0
- package/plugins/compound-engineering/skills/gemini-imagegen/scripts/compose_images.py +157 -0
- package/plugins/compound-engineering/skills/gemini-imagegen/scripts/edit_image.py +144 -0
- package/plugins/compound-engineering/skills/gemini-imagegen/scripts/gemini_images.py +263 -0
- package/plugins/compound-engineering/skills/gemini-imagegen/scripts/generate_image.py +133 -0
- package/plugins/compound-engineering/skills/gemini-imagegen/scripts/multi_turn_chat.py +216 -0
- package/plugins/compound-engineering/skills/git-worktree/SKILL.md +302 -0
- package/plugins/compound-engineering/skills/git-worktree/scripts/worktree-manager.sh +337 -0
- package/plugins/compound-engineering/skills/orchestrating-swarms/SKILL.md +1718 -0
- package/plugins/compound-engineering/skills/rclone/SKILL.md +150 -0
- package/plugins/compound-engineering/skills/rclone/scripts/check_setup.sh +60 -0
- package/plugins/compound-engineering/skills/resolve-pr-parallel/SKILL.md +89 -0
- package/plugins/compound-engineering/skills/resolve-pr-parallel/scripts/get-pr-comments +68 -0
- package/plugins/compound-engineering/skills/resolve-pr-parallel/scripts/resolve-pr-thread +23 -0
- package/plugins/compound-engineering/skills/skill-creator/SKILL.md +210 -0
- package/plugins/compound-engineering/skills/skill-creator/scripts/init_skill.py +303 -0
- package/plugins/compound-engineering/skills/skill-creator/scripts/package_skill.py +110 -0
- package/plugins/compound-engineering/skills/skill-creator/scripts/quick_validate.py +65 -0
- package/prompts/deepen-plan.md +549 -0
- package/prompts/feature-video.md +341 -0
- package/prompts/resolve_todo_parallel.md +36 -0
- package/prompts/test-browser.md +342 -0
- package/prompts/workflows-brainstorm.md +123 -0
- package/prompts/workflows-compound.md +238 -0
- package/prompts/workflows-plan.md +550 -0
- package/prompts/workflows-review.md +529 -0
- package/prompts/workflows-work.md +432 -0
- package/skills/agent-browser/SKILL.md +223 -0
- package/skills/agent-native-architecture/SKILL.md +435 -0
- package/skills/agent-native-architecture/references/action-parity-discipline.md +409 -0
- package/skills/agent-native-architecture/references/agent-execution-patterns.md +467 -0
- package/skills/agent-native-architecture/references/agent-native-testing.md +582 -0
- package/skills/agent-native-architecture/references/architecture-patterns.md +478 -0
- package/skills/agent-native-architecture/references/dynamic-context-injection.md +338 -0
- package/skills/agent-native-architecture/references/files-universal-interface.md +301 -0
- package/skills/agent-native-architecture/references/from-primitives-to-domain-tools.md +359 -0
- package/skills/agent-native-architecture/references/mcp-tool-design.md +506 -0
- package/skills/agent-native-architecture/references/mobile-patterns.md +871 -0
- package/skills/agent-native-architecture/references/product-implications.md +443 -0
- package/skills/agent-native-architecture/references/refactoring-to-prompt-native.md +317 -0
- package/skills/agent-native-architecture/references/self-modification.md +269 -0
- package/skills/agent-native-architecture/references/shared-workspace-architecture.md +680 -0
- package/skills/agent-native-architecture/references/system-prompt-design.md +250 -0
- package/skills/agent-native-reviewer/SKILL.md +260 -0
- package/skills/andrew-kane-gem-writer/SKILL.md +184 -0
- package/skills/andrew-kane-gem-writer/references/database-adapters.md +231 -0
- package/skills/andrew-kane-gem-writer/references/module-organization.md +121 -0
- package/skills/andrew-kane-gem-writer/references/rails-integration.md +183 -0
- package/skills/andrew-kane-gem-writer/references/resources.md +119 -0
- package/skills/andrew-kane-gem-writer/references/testing-patterns.md +261 -0
- package/skills/ankane-readme-writer/SKILL.md +63 -0
- package/skills/architecture-strategist/SKILL.md +66 -0
- package/skills/best-practices-researcher/SKILL.md +125 -0
- package/skills/brainstorming/SKILL.md +190 -0
- package/skills/bug-reproduction-validator/SKILL.md +81 -0
- package/skills/code-simplicity-reviewer/SKILL.md +100 -0
- package/skills/compound-docs/SKILL.md +511 -0
- package/skills/compound-docs/assets/critical-pattern-template.md +34 -0
- package/skills/compound-docs/assets/resolution-template.md +93 -0
- package/skills/compound-docs/references/yaml-schema.md +65 -0
- package/skills/compound-docs/schema.yaml +176 -0
- package/skills/create-agent-skills/SKILL.md +275 -0
- package/skills/create-agent-skills/references/api-security.md +226 -0
- package/skills/create-agent-skills/references/be-clear-and-direct.md +531 -0
- package/skills/create-agent-skills/references/best-practices.md +404 -0
- package/skills/create-agent-skills/references/common-patterns.md +595 -0
- package/skills/create-agent-skills/references/core-principles.md +437 -0
- package/skills/create-agent-skills/references/executable-code.md +175 -0
- package/skills/create-agent-skills/references/iteration-and-testing.md +474 -0
- package/skills/create-agent-skills/references/official-spec.md +134 -0
- package/skills/create-agent-skills/references/recommended-structure.md +168 -0
- package/skills/create-agent-skills/references/skill-structure.md +152 -0
- package/skills/create-agent-skills/references/using-scripts.md +113 -0
- package/skills/create-agent-skills/references/using-templates.md +112 -0
- package/skills/create-agent-skills/references/workflows-and-validation.md +510 -0
- package/skills/create-agent-skills/templates/router-skill.md +73 -0
- package/skills/create-agent-skills/templates/simple-skill.md +33 -0
- package/skills/create-agent-skills/workflows/add-reference.md +96 -0
- package/skills/create-agent-skills/workflows/add-script.md +93 -0
- package/skills/create-agent-skills/workflows/add-template.md +74 -0
- package/skills/create-agent-skills/workflows/add-workflow.md +120 -0
- package/skills/create-agent-skills/workflows/audit-skill.md +138 -0
- package/skills/create-agent-skills/workflows/create-domain-expertise-skill.md +605 -0
- package/skills/create-agent-skills/workflows/create-new-skill.md +191 -0
- package/skills/create-agent-skills/workflows/get-guidance.md +121 -0
- package/skills/create-agent-skills/workflows/upgrade-to-router.md +161 -0
- package/skills/create-agent-skills/workflows/verify-skill.md +204 -0
- package/skills/data-integrity-guardian/SKILL.md +84 -0
- package/skills/data-migration-expert/SKILL.md +111 -0
- package/skills/deployment-verification-agent/SKILL.md +173 -0
- package/skills/design-implementation-reviewer/SKILL.md +107 -0
- package/skills/design-iterator/SKILL.md +222 -0
- package/skills/dhh-rails-reviewer/SKILL.md +65 -0
- package/skills/dhh-rails-style/SKILL.md +185 -0
- package/skills/dhh-rails-style/references/architecture.md +653 -0
- package/skills/dhh-rails-style/references/controllers.md +303 -0
- package/skills/dhh-rails-style/references/frontend.md +510 -0
- package/skills/dhh-rails-style/references/gems.md +266 -0
- package/skills/dhh-rails-style/references/models.md +359 -0
- package/skills/dhh-rails-style/references/testing.md +338 -0
- package/skills/document-review/SKILL.md +87 -0
- package/skills/dspy-ruby/SKILL.md +737 -0
- package/skills/dspy-ruby/assets/config-template.rb +187 -0
- package/skills/dspy-ruby/assets/module-template.rb +300 -0
- package/skills/dspy-ruby/assets/signature-template.rb +221 -0
- package/skills/dspy-ruby/references/core-concepts.md +674 -0
- package/skills/dspy-ruby/references/observability.md +366 -0
- package/skills/dspy-ruby/references/optimization.md +603 -0
- package/skills/dspy-ruby/references/providers.md +418 -0
- package/skills/dspy-ruby/references/toolsets.md +502 -0
- package/skills/every-style-editor/SKILL.md +134 -0
- package/skills/every-style-editor/references/EVERY_WRITE_STYLE.md +529 -0
- package/skills/every-style-editor-2/SKILL.md +62 -0
- package/skills/figma-design-sync/SKILL.md +188 -0
- package/skills/file-todos/SKILL.md +252 -0
- package/skills/file-todos/assets/todo-template.md +155 -0
- package/skills/framework-docs-researcher/SKILL.md +105 -0
- package/skills/frontend-design/SKILL.md +42 -0
- package/skills/gemini-imagegen/SKILL.md +237 -0
- package/skills/gemini-imagegen/requirements.txt +2 -0
- package/skills/gemini-imagegen/scripts/compose_images.py +157 -0
- package/skills/gemini-imagegen/scripts/edit_image.py +144 -0
- package/skills/gemini-imagegen/scripts/gemini_images.py +263 -0
- package/skills/gemini-imagegen/scripts/generate_image.py +133 -0
- package/skills/gemini-imagegen/scripts/multi_turn_chat.py +216 -0
- package/skills/git-history-analyzer/SKILL.md +58 -0
- package/skills/git-worktree/SKILL.md +302 -0
- package/skills/git-worktree/scripts/worktree-manager.sh +337 -0
- package/skills/julik-frontend-races-reviewer/SKILL.md +220 -0
- package/skills/kieran-python-reviewer/SKILL.md +132 -0
- package/skills/kieran-rails-reviewer/SKILL.md +114 -0
- package/skills/kieran-typescript-reviewer/SKILL.md +123 -0
- package/skills/learnings-researcher/SKILL.md +263 -0
- package/skills/lint/SKILL.md +14 -0
- package/skills/orchestrating-swarms/SKILL.md +1718 -0
- package/skills/pattern-recognition-specialist/SKILL.md +71 -0
- package/skills/performance-oracle/SKILL.md +136 -0
- package/skills/pr-comment-resolver/SKILL.md +82 -0
- package/skills/rclone/SKILL.md +150 -0
- package/skills/rclone/scripts/check_setup.sh +60 -0
- package/skills/repo-research-analyst/SKILL.md +134 -0
- package/skills/resolve_pr_parallel/SKILL.md +89 -0
- package/skills/resolve_pr_parallel/scripts/get-pr-comments +68 -0
- package/skills/resolve_pr_parallel/scripts/resolve-pr-thread +23 -0
- package/skills/schema-drift-detector/SKILL.md +153 -0
- package/skills/security-sentinel/SKILL.md +113 -0
- package/skills/skill-creator/SKILL.md +210 -0
- package/skills/skill-creator/scripts/init_skill.py +303 -0
- package/skills/skill-creator/scripts/package_skill.py +110 -0
- package/skills/skill-creator/scripts/quick_validate.py +65 -0
- package/skills/spec-flow-analyzer/SKILL.md +133 -0
- package/src/commands/convert.ts +183 -0
- package/src/commands/install.ts +273 -0
- package/src/commands/list.ts +37 -0
- package/src/commands/sync.ts +89 -0
- package/src/converters/claude-to-codex.ts +182 -0
- package/src/converters/claude-to-opencode.ts +395 -0
- package/src/converters/claude-to-pi.ts +205 -0
- package/src/index.ts +22 -0
- package/src/parsers/claude-home.ts +65 -0
- package/src/parsers/claude.ts +252 -0
- package/src/sync/codex.ts +92 -0
- package/src/sync/opencode.ts +75 -0
- package/src/sync/pi.ts +88 -0
- package/src/targets/codex.ts +96 -0
- package/src/targets/index.ts +38 -0
- package/src/targets/opencode.ts +57 -0
- package/src/targets/pi.ts +131 -0
- package/src/templates/pi/compat-extension.ts +452 -0
- package/src/types/claude.ts +90 -0
- package/src/types/codex.ts +23 -0
- package/src/types/opencode.ts +54 -0
- package/src/types/pi.ts +40 -0
- package/src/utils/codex-agents.ts +64 -0
- package/src/utils/files.ts +77 -0
- package/src/utils/frontmatter.ts +65 -0
- package/src/utils/symlink.ts +43 -0
|
@@ -0,0 +1,1718 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: orchestrating-swarms
|
|
3
|
+
description: This skill should be used when orchestrating multi-agent swarms using Claude Code's TeammateTool and Task system. It applies when coordinating multiple agents, running parallel code reviews, creating pipeline workflows with dependencies, building self-organizing task queues, or any task benefiting from divide-and-conquer patterns.
|
|
4
|
+
disable-model-invocation: true
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Claude Code Swarm Orchestration
|
|
8
|
+
|
|
9
|
+
Master multi-agent orchestration using Claude Code's TeammateTool and Task system.
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## Primitives
|
|
14
|
+
|
|
15
|
+
| Primitive | What It Is | File Location |
|
|
16
|
+
|-----------|-----------|---------------|
|
|
17
|
+
| **Agent** | A Claude instance that can use tools. You are an agent. Subagents are agents you spawn. | N/A (process) |
|
|
18
|
+
| **Team** | A named group of agents working together. One leader, multiple teammates. | `~/.claude/teams/{name}/config.json` |
|
|
19
|
+
| **Teammate** | An agent that joined a team. Has a name, color, inbox. Spawned via Task with `team_name` + `name`. | Listed in team config |
|
|
20
|
+
| **Leader** | The agent that created the team. Receives teammate messages, approves plans/shutdowns. | First member in config |
|
|
21
|
+
| **Task** | A work item with subject, description, status, owner, and dependencies. | `~/.claude/tasks/{team}/N.json` |
|
|
22
|
+
| **Inbox** | JSON file where an agent receives messages from teammates. | `~/.claude/teams/{name}/inboxes/{agent}.json` |
|
|
23
|
+
| **Message** | A JSON object sent between agents. Can be text or structured (shutdown_request, idle_notification, etc). | Stored in inbox files |
|
|
24
|
+
| **Backend** | How teammates run. Auto-detected: `in-process` (same Node.js, invisible), `tmux` (separate panes, visible), `iterm2` (split panes in iTerm2). See [Spawn Backends](#spawn-backends). | Auto-detected based on environment |
|
|
25
|
+
|
|
26
|
+
### How They Connect
|
|
27
|
+
|
|
28
|
+
```mermaid
|
|
29
|
+
flowchart TB
|
|
30
|
+
subgraph TEAM[TEAM]
|
|
31
|
+
Leader[Leader - you]
|
|
32
|
+
T1[Teammate 1]
|
|
33
|
+
T2[Teammate 2]
|
|
34
|
+
|
|
35
|
+
Leader <-->|messages via inbox| T1
|
|
36
|
+
Leader <-->|messages via inbox| T2
|
|
37
|
+
T1 <-.->|can message| T2
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
subgraph TASKS[TASK LIST]
|
|
41
|
+
Task1["#1 completed: Research<br/>owner: teammate1"]
|
|
42
|
+
Task2["#2 in_progress: Implement<br/>owner: teammate2"]
|
|
43
|
+
Task3["#3 pending: Test<br/>blocked by #2"]
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
T1 --> Task1
|
|
47
|
+
T2 --> Task2
|
|
48
|
+
Task2 -.->|unblocks| Task3
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### Lifecycle
|
|
52
|
+
|
|
53
|
+
```mermaid
|
|
54
|
+
flowchart LR
|
|
55
|
+
A[1. Create Team] --> B[2. Create Tasks]
|
|
56
|
+
B --> C[3. Spawn Teammates]
|
|
57
|
+
C --> D[4. Work]
|
|
58
|
+
D --> E[5. Coordinate]
|
|
59
|
+
E --> F[6. Shutdown]
|
|
60
|
+
F --> G[7. Cleanup]
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Message Flow
|
|
64
|
+
|
|
65
|
+
```mermaid
|
|
66
|
+
sequenceDiagram
|
|
67
|
+
participant L as Leader
|
|
68
|
+
participant T1 as Teammate 1
|
|
69
|
+
participant T2 as Teammate 2
|
|
70
|
+
participant Tasks as Task List
|
|
71
|
+
|
|
72
|
+
L->>Tasks: TaskCreate (3 tasks)
|
|
73
|
+
L->>T1: spawn with prompt
|
|
74
|
+
L->>T2: spawn with prompt
|
|
75
|
+
|
|
76
|
+
T1->>Tasks: claim task #1
|
|
77
|
+
T2->>Tasks: claim task #2
|
|
78
|
+
|
|
79
|
+
T1->>Tasks: complete #1
|
|
80
|
+
T1->>L: send findings (inbox)
|
|
81
|
+
|
|
82
|
+
Note over Tasks: #3 auto-unblocks
|
|
83
|
+
|
|
84
|
+
T2->>Tasks: complete #2
|
|
85
|
+
T2->>L: send findings (inbox)
|
|
86
|
+
|
|
87
|
+
L->>T1: requestShutdown
|
|
88
|
+
T1->>L: approveShutdown
|
|
89
|
+
L->>T2: requestShutdown
|
|
90
|
+
T2->>L: approveShutdown
|
|
91
|
+
|
|
92
|
+
L->>L: cleanup
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
---
|
|
96
|
+
|
|
97
|
+
## Table of Contents
|
|
98
|
+
|
|
99
|
+
1. [Core Architecture](#core-architecture)
|
|
100
|
+
2. [Two Ways to Spawn Agents](#two-ways-to-spawn-agents)
|
|
101
|
+
3. [Built-in Agent Types](#built-in-agent-types)
|
|
102
|
+
4. [Plugin Agent Types](#plugin-agent-types)
|
|
103
|
+
5. [TeammateTool Operations](#teammatetool-operations)
|
|
104
|
+
6. [Task System Integration](#task-system-integration)
|
|
105
|
+
7. [Message Formats](#message-formats)
|
|
106
|
+
8. [Orchestration Patterns](#orchestration-patterns)
|
|
107
|
+
9. [Environment Variables](#environment-variables)
|
|
108
|
+
10. [Spawn Backends](#spawn-backends)
|
|
109
|
+
11. [Error Handling](#error-handling)
|
|
110
|
+
12. [Complete Workflows](#complete-workflows)
|
|
111
|
+
|
|
112
|
+
---
|
|
113
|
+
|
|
114
|
+
## Core Architecture
|
|
115
|
+
|
|
116
|
+
### How Swarms Work
|
|
117
|
+
|
|
118
|
+
A swarm consists of:
|
|
119
|
+
- **Leader** (you) - Creates team, spawns workers, coordinates work
|
|
120
|
+
- **Teammates** (spawned agents) - Execute tasks, report back
|
|
121
|
+
- **Task List** - Shared work queue with dependencies
|
|
122
|
+
- **Inboxes** - JSON files for inter-agent messaging
|
|
123
|
+
|
|
124
|
+
### File Structure
|
|
125
|
+
|
|
126
|
+
```
|
|
127
|
+
~/.claude/teams/{team-name}/
|
|
128
|
+
├── config.json # Team metadata and member list
|
|
129
|
+
└── inboxes/
|
|
130
|
+
├── team-lead.json # Leader's inbox
|
|
131
|
+
├── worker-1.json # Worker 1's inbox
|
|
132
|
+
└── worker-2.json # Worker 2's inbox
|
|
133
|
+
|
|
134
|
+
~/.claude/tasks/{team-name}/
|
|
135
|
+
├── 1.json # Task #1
|
|
136
|
+
├── 2.json # Task #2
|
|
137
|
+
└── 3.json # Task #3
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### Team Config Structure
|
|
141
|
+
|
|
142
|
+
```json
|
|
143
|
+
{
|
|
144
|
+
"name": "my-project",
|
|
145
|
+
"description": "Working on feature X",
|
|
146
|
+
"leadAgentId": "team-lead@my-project",
|
|
147
|
+
"createdAt": 1706000000000,
|
|
148
|
+
"members": [
|
|
149
|
+
{
|
|
150
|
+
"agentId": "team-lead@my-project",
|
|
151
|
+
"name": "team-lead",
|
|
152
|
+
"agentType": "team-lead",
|
|
153
|
+
"color": "#4A90D9",
|
|
154
|
+
"joinedAt": 1706000000000,
|
|
155
|
+
"backendType": "in-process"
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
"agentId": "worker-1@my-project",
|
|
159
|
+
"name": "worker-1",
|
|
160
|
+
"agentType": "Explore",
|
|
161
|
+
"model": "haiku",
|
|
162
|
+
"prompt": "Analyze the codebase structure...",
|
|
163
|
+
"color": "#D94A4A",
|
|
164
|
+
"planModeRequired": false,
|
|
165
|
+
"joinedAt": 1706000001000,
|
|
166
|
+
"tmuxPaneId": "in-process",
|
|
167
|
+
"cwd": "/Users/me/project",
|
|
168
|
+
"backendType": "in-process"
|
|
169
|
+
}
|
|
170
|
+
]
|
|
171
|
+
}
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
---
|
|
175
|
+
|
|
176
|
+
## Two Ways to Spawn Agents
|
|
177
|
+
|
|
178
|
+
### Method 1: Task Tool (Subagents)
|
|
179
|
+
|
|
180
|
+
Use Task for **short-lived, focused work** that returns a result:
|
|
181
|
+
|
|
182
|
+
```javascript
|
|
183
|
+
Task({
|
|
184
|
+
subagent_type: "Explore",
|
|
185
|
+
description: "Find auth files",
|
|
186
|
+
prompt: "Find all authentication-related files in this codebase",
|
|
187
|
+
model: "haiku" // Optional: haiku, sonnet, opus
|
|
188
|
+
})
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
**Characteristics:**
|
|
192
|
+
- Runs synchronously (blocks until complete) or async with `run_in_background: true`
|
|
193
|
+
- Returns result directly to you
|
|
194
|
+
- No team membership required
|
|
195
|
+
- Best for: searches, analysis, focused research
|
|
196
|
+
|
|
197
|
+
### Method 2: Task Tool + team_name + name (Teammates)
|
|
198
|
+
|
|
199
|
+
Use Task with `team_name` and `name` to **spawn persistent teammates**:
|
|
200
|
+
|
|
201
|
+
```javascript
|
|
202
|
+
// First create a team
|
|
203
|
+
Teammate({ operation: "spawnTeam", team_name: "my-project" })
|
|
204
|
+
|
|
205
|
+
// Then spawn a teammate into that team
|
|
206
|
+
Task({
|
|
207
|
+
team_name: "my-project", // Required: which team to join
|
|
208
|
+
name: "security-reviewer", // Required: teammate's name
|
|
209
|
+
subagent_type: "security-sentinel",
|
|
210
|
+
prompt: "Review all authentication code for vulnerabilities. Send findings to team-lead via Teammate write.",
|
|
211
|
+
run_in_background: true // Teammates usually run in background
|
|
212
|
+
})
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
**Characteristics:**
|
|
216
|
+
- Joins team, appears in `config.json`
|
|
217
|
+
- Communicates via inbox messages
|
|
218
|
+
- Can claim tasks from shared task list
|
|
219
|
+
- Persists until shutdown
|
|
220
|
+
- Best for: parallel work, ongoing collaboration, pipeline stages
|
|
221
|
+
|
|
222
|
+
### Key Difference
|
|
223
|
+
|
|
224
|
+
| Aspect | Task (subagent) | Task + team_name + name (teammate) |
|
|
225
|
+
|--------|-----------------|-----------------------------------|
|
|
226
|
+
| Lifespan | Until task complete | Until shutdown requested |
|
|
227
|
+
| Communication | Return value | Inbox messages |
|
|
228
|
+
| Task access | None | Shared task list |
|
|
229
|
+
| Team membership | No | Yes |
|
|
230
|
+
| Coordination | One-off | Ongoing |
|
|
231
|
+
|
|
232
|
+
---
|
|
233
|
+
|
|
234
|
+
## Built-in Agent Types
|
|
235
|
+
|
|
236
|
+
These are always available without plugins:
|
|
237
|
+
|
|
238
|
+
### Bash
|
|
239
|
+
```javascript
|
|
240
|
+
Task({
|
|
241
|
+
subagent_type: "Bash",
|
|
242
|
+
description: "Run git commands",
|
|
243
|
+
prompt: "Check git status and show recent commits"
|
|
244
|
+
})
|
|
245
|
+
```
|
|
246
|
+
- **Tools:** Bash only
|
|
247
|
+
- **Model:** Inherits from parent
|
|
248
|
+
- **Best for:** Git operations, command execution, system tasks
|
|
249
|
+
|
|
250
|
+
### Explore
|
|
251
|
+
```javascript
|
|
252
|
+
Task({
|
|
253
|
+
subagent_type: "Explore",
|
|
254
|
+
description: "Find API endpoints",
|
|
255
|
+
prompt: "Find all API endpoints in this codebase. Be very thorough.",
|
|
256
|
+
model: "haiku" // Fast and cheap
|
|
257
|
+
})
|
|
258
|
+
```
|
|
259
|
+
- **Tools:** All read-only tools (no Edit, Write, NotebookEdit, Task)
|
|
260
|
+
- **Model:** Haiku (optimized for speed)
|
|
261
|
+
- **Best for:** Codebase exploration, file searches, code understanding
|
|
262
|
+
- **Thoroughness levels:** "quick", "medium", "very thorough"
|
|
263
|
+
|
|
264
|
+
### Plan
|
|
265
|
+
```javascript
|
|
266
|
+
Task({
|
|
267
|
+
subagent_type: "Plan",
|
|
268
|
+
description: "Design auth system",
|
|
269
|
+
prompt: "Create an implementation plan for adding OAuth2 authentication"
|
|
270
|
+
})
|
|
271
|
+
```
|
|
272
|
+
- **Tools:** All read-only tools
|
|
273
|
+
- **Model:** Inherits from parent
|
|
274
|
+
- **Best for:** Architecture planning, implementation strategies
|
|
275
|
+
|
|
276
|
+
### general-purpose
|
|
277
|
+
```javascript
|
|
278
|
+
Task({
|
|
279
|
+
subagent_type: "general-purpose",
|
|
280
|
+
description: "Research and implement",
|
|
281
|
+
prompt: "Research React Query best practices and implement caching for the user API"
|
|
282
|
+
})
|
|
283
|
+
```
|
|
284
|
+
- **Tools:** All tools (*)
|
|
285
|
+
- **Model:** Inherits from parent
|
|
286
|
+
- **Best for:** Multi-step tasks, research + action combinations
|
|
287
|
+
|
|
288
|
+
### claude-code-guide
|
|
289
|
+
```javascript
|
|
290
|
+
Task({
|
|
291
|
+
subagent_type: "claude-code-guide",
|
|
292
|
+
description: "Help with Claude Code",
|
|
293
|
+
prompt: "How do I configure MCP servers?"
|
|
294
|
+
})
|
|
295
|
+
```
|
|
296
|
+
- **Tools:** Read-only + WebFetch + WebSearch
|
|
297
|
+
- **Best for:** Questions about Claude Code, Agent SDK, Anthropic API
|
|
298
|
+
|
|
299
|
+
### statusline-setup
|
|
300
|
+
```javascript
|
|
301
|
+
Task({
|
|
302
|
+
subagent_type: "statusline-setup",
|
|
303
|
+
description: "Configure status line",
|
|
304
|
+
prompt: "Set up a status line showing git branch and node version"
|
|
305
|
+
})
|
|
306
|
+
```
|
|
307
|
+
- **Tools:** Read, Edit only
|
|
308
|
+
- **Model:** Sonnet
|
|
309
|
+
- **Best for:** Configuring Claude Code status line
|
|
310
|
+
|
|
311
|
+
---
|
|
312
|
+
|
|
313
|
+
## Plugin Agent Types
|
|
314
|
+
|
|
315
|
+
From the `compound-engineering` plugin (examples):
|
|
316
|
+
|
|
317
|
+
### Review Agents
|
|
318
|
+
```javascript
|
|
319
|
+
// Security review
|
|
320
|
+
Task({
|
|
321
|
+
subagent_type: "compound-engineering:review:security-sentinel",
|
|
322
|
+
description: "Security audit",
|
|
323
|
+
prompt: "Audit this PR for security vulnerabilities"
|
|
324
|
+
})
|
|
325
|
+
|
|
326
|
+
// Performance review
|
|
327
|
+
Task({
|
|
328
|
+
subagent_type: "compound-engineering:review:performance-oracle",
|
|
329
|
+
description: "Performance check",
|
|
330
|
+
prompt: "Analyze this code for performance bottlenecks"
|
|
331
|
+
})
|
|
332
|
+
|
|
333
|
+
// Rails code review
|
|
334
|
+
Task({
|
|
335
|
+
subagent_type: "compound-engineering:review:kieran-rails-reviewer",
|
|
336
|
+
description: "Rails review",
|
|
337
|
+
prompt: "Review this Rails code for best practices"
|
|
338
|
+
})
|
|
339
|
+
|
|
340
|
+
// Architecture review
|
|
341
|
+
Task({
|
|
342
|
+
subagent_type: "compound-engineering:review:architecture-strategist",
|
|
343
|
+
description: "Architecture review",
|
|
344
|
+
prompt: "Review the system architecture of the authentication module"
|
|
345
|
+
})
|
|
346
|
+
|
|
347
|
+
// Code simplicity
|
|
348
|
+
Task({
|
|
349
|
+
subagent_type: "compound-engineering:review:code-simplicity-reviewer",
|
|
350
|
+
description: "Simplicity check",
|
|
351
|
+
prompt: "Check if this implementation can be simplified"
|
|
352
|
+
})
|
|
353
|
+
```
|
|
354
|
+
|
|
355
|
+
**All review agents from compound-engineering:**
|
|
356
|
+
- `agent-native-reviewer` - Ensures features work for agents too
|
|
357
|
+
- `architecture-strategist` - Architectural compliance
|
|
358
|
+
- `code-simplicity-reviewer` - YAGNI and minimalism
|
|
359
|
+
- `data-integrity-guardian` - Database and data safety
|
|
360
|
+
- `data-migration-expert` - Migration validation
|
|
361
|
+
- `deployment-verification-agent` - Pre-deploy checklists
|
|
362
|
+
- `dhh-rails-reviewer` - DHH/37signals Rails style
|
|
363
|
+
- `julik-frontend-races-reviewer` - JavaScript race conditions
|
|
364
|
+
- `kieran-python-reviewer` - Python best practices
|
|
365
|
+
- `kieran-rails-reviewer` - Rails best practices
|
|
366
|
+
- `kieran-typescript-reviewer` - TypeScript best practices
|
|
367
|
+
- `pattern-recognition-specialist` - Design patterns and anti-patterns
|
|
368
|
+
- `performance-oracle` - Performance analysis
|
|
369
|
+
- `security-sentinel` - Security vulnerabilities
|
|
370
|
+
|
|
371
|
+
### Research Agents
|
|
372
|
+
```javascript
|
|
373
|
+
// Best practices research
|
|
374
|
+
Task({
|
|
375
|
+
subagent_type: "compound-engineering:research:best-practices-researcher",
|
|
376
|
+
description: "Research auth best practices",
|
|
377
|
+
prompt: "Research current best practices for JWT authentication in Rails 2024-2026"
|
|
378
|
+
})
|
|
379
|
+
|
|
380
|
+
// Framework documentation
|
|
381
|
+
Task({
|
|
382
|
+
subagent_type: "compound-engineering:research:framework-docs-researcher",
|
|
383
|
+
description: "Research Active Storage",
|
|
384
|
+
prompt: "Gather comprehensive documentation about Active Storage file uploads"
|
|
385
|
+
})
|
|
386
|
+
|
|
387
|
+
// Git history analysis
|
|
388
|
+
Task({
|
|
389
|
+
subagent_type: "compound-engineering:research:git-history-analyzer",
|
|
390
|
+
description: "Analyze auth history",
|
|
391
|
+
prompt: "Analyze the git history of the authentication module to understand its evolution"
|
|
392
|
+
})
|
|
393
|
+
```
|
|
394
|
+
|
|
395
|
+
**All research agents:**
|
|
396
|
+
- `best-practices-researcher` - External best practices
|
|
397
|
+
- `framework-docs-researcher` - Framework documentation
|
|
398
|
+
- `git-history-analyzer` - Code archaeology
|
|
399
|
+
- `learnings-researcher` - Search docs/solutions/
|
|
400
|
+
- `repo-research-analyst` - Repository patterns
|
|
401
|
+
|
|
402
|
+
### Design Agents
|
|
403
|
+
```javascript
|
|
404
|
+
Task({
|
|
405
|
+
subagent_type: "compound-engineering:design:figma-design-sync",
|
|
406
|
+
description: "Sync with Figma",
|
|
407
|
+
prompt: "Compare implementation with Figma design at [URL]"
|
|
408
|
+
})
|
|
409
|
+
```
|
|
410
|
+
|
|
411
|
+
### Workflow Agents
|
|
412
|
+
```javascript
|
|
413
|
+
Task({
|
|
414
|
+
subagent_type: "compound-engineering:workflow:bug-reproduction-validator",
|
|
415
|
+
description: "Validate bug",
|
|
416
|
+
prompt: "Reproduce and validate this reported bug: [description]"
|
|
417
|
+
})
|
|
418
|
+
```
|
|
419
|
+
|
|
420
|
+
---
|
|
421
|
+
|
|
422
|
+
## TeammateTool Operations
|
|
423
|
+
|
|
424
|
+
### 1. spawnTeam - Create a Team
|
|
425
|
+
|
|
426
|
+
```javascript
|
|
427
|
+
Teammate({
|
|
428
|
+
operation: "spawnTeam",
|
|
429
|
+
team_name: "feature-auth",
|
|
430
|
+
description: "Implementing OAuth2 authentication"
|
|
431
|
+
})
|
|
432
|
+
```
|
|
433
|
+
|
|
434
|
+
**Creates:**
|
|
435
|
+
- `~/.claude/teams/feature-auth/config.json`
|
|
436
|
+
- `~/.claude/tasks/feature-auth/` directory
|
|
437
|
+
- You become the team leader
|
|
438
|
+
|
|
439
|
+
### 2. discoverTeams - List Available Teams
|
|
440
|
+
|
|
441
|
+
```javascript
|
|
442
|
+
Teammate({ operation: "discoverTeams" })
|
|
443
|
+
```
|
|
444
|
+
|
|
445
|
+
**Returns:** List of teams you can join (not already a member of)
|
|
446
|
+
|
|
447
|
+
### 3. requestJoin - Request to Join Team
|
|
448
|
+
|
|
449
|
+
```javascript
|
|
450
|
+
Teammate({
|
|
451
|
+
operation: "requestJoin",
|
|
452
|
+
team_name: "feature-auth",
|
|
453
|
+
proposed_name: "helper",
|
|
454
|
+
capabilities: "I can help with code review and testing"
|
|
455
|
+
})
|
|
456
|
+
```
|
|
457
|
+
|
|
458
|
+
### 4. approveJoin - Accept Join Request (Leader Only)
|
|
459
|
+
|
|
460
|
+
When you receive a `join_request` message:
|
|
461
|
+
```json
|
|
462
|
+
{"type": "join_request", "proposedName": "helper", "requestId": "join-123", ...}
|
|
463
|
+
```
|
|
464
|
+
|
|
465
|
+
Approve it:
|
|
466
|
+
```javascript
|
|
467
|
+
Teammate({
|
|
468
|
+
operation: "approveJoin",
|
|
469
|
+
target_agent_id: "helper",
|
|
470
|
+
request_id: "join-123"
|
|
471
|
+
})
|
|
472
|
+
```
|
|
473
|
+
|
|
474
|
+
### 5. rejectJoin - Decline Join Request (Leader Only)
|
|
475
|
+
|
|
476
|
+
```javascript
|
|
477
|
+
Teammate({
|
|
478
|
+
operation: "rejectJoin",
|
|
479
|
+
target_agent_id: "helper",
|
|
480
|
+
request_id: "join-123",
|
|
481
|
+
reason: "Team is at capacity"
|
|
482
|
+
})
|
|
483
|
+
```
|
|
484
|
+
|
|
485
|
+
### 6. write - Message One Teammate
|
|
486
|
+
|
|
487
|
+
```javascript
|
|
488
|
+
Teammate({
|
|
489
|
+
operation: "write",
|
|
490
|
+
target_agent_id: "security-reviewer",
|
|
491
|
+
value: "Please prioritize the authentication module. The deadline is tomorrow."
|
|
492
|
+
})
|
|
493
|
+
```
|
|
494
|
+
|
|
495
|
+
**Important for teammates:** Your text output is NOT visible to the team. You MUST use `write` to communicate.
|
|
496
|
+
|
|
497
|
+
### 7. broadcast - Message ALL Teammates
|
|
498
|
+
|
|
499
|
+
```javascript
|
|
500
|
+
Teammate({
|
|
501
|
+
operation: "broadcast",
|
|
502
|
+
name: "team-lead", // Your name
|
|
503
|
+
value: "Status check: Please report your progress"
|
|
504
|
+
})
|
|
505
|
+
```
|
|
506
|
+
|
|
507
|
+
**WARNING:** Broadcasting is expensive - sends N separate messages for N teammates. Prefer `write` to specific teammates.
|
|
508
|
+
|
|
509
|
+
**When to broadcast:**
|
|
510
|
+
- Critical issues requiring immediate attention
|
|
511
|
+
- Major announcements affecting everyone
|
|
512
|
+
|
|
513
|
+
**When NOT to broadcast:**
|
|
514
|
+
- Responding to one teammate
|
|
515
|
+
- Normal back-and-forth
|
|
516
|
+
- Information relevant to only some teammates
|
|
517
|
+
|
|
518
|
+
### 8. requestShutdown - Ask Teammate to Exit (Leader Only)
|
|
519
|
+
|
|
520
|
+
```javascript
|
|
521
|
+
Teammate({
|
|
522
|
+
operation: "requestShutdown",
|
|
523
|
+
target_agent_id: "security-reviewer",
|
|
524
|
+
reason: "All tasks complete, wrapping up"
|
|
525
|
+
})
|
|
526
|
+
```
|
|
527
|
+
|
|
528
|
+
### 9. approveShutdown - Accept Shutdown (Teammate Only)
|
|
529
|
+
|
|
530
|
+
When you receive a `shutdown_request` message:
|
|
531
|
+
```json
|
|
532
|
+
{"type": "shutdown_request", "requestId": "shutdown-123", "from": "team-lead", "reason": "Done"}
|
|
533
|
+
```
|
|
534
|
+
|
|
535
|
+
**MUST** call:
|
|
536
|
+
```javascript
|
|
537
|
+
Teammate({
|
|
538
|
+
operation: "approveShutdown",
|
|
539
|
+
request_id: "shutdown-123"
|
|
540
|
+
})
|
|
541
|
+
```
|
|
542
|
+
|
|
543
|
+
This sends confirmation and terminates your process.
|
|
544
|
+
|
|
545
|
+
### 10. rejectShutdown - Decline Shutdown (Teammate Only)
|
|
546
|
+
|
|
547
|
+
```javascript
|
|
548
|
+
Teammate({
|
|
549
|
+
operation: "rejectShutdown",
|
|
550
|
+
request_id: "shutdown-123",
|
|
551
|
+
reason: "Still working on task #3, need 5 more minutes"
|
|
552
|
+
})
|
|
553
|
+
```
|
|
554
|
+
|
|
555
|
+
### 11. approvePlan - Approve Teammate's Plan (Leader Only)
|
|
556
|
+
|
|
557
|
+
When teammate with `plan_mode_required` sends a plan:
|
|
558
|
+
```json
|
|
559
|
+
{"type": "plan_approval_request", "from": "architect", "requestId": "plan-456", ...}
|
|
560
|
+
```
|
|
561
|
+
|
|
562
|
+
Approve:
|
|
563
|
+
```javascript
|
|
564
|
+
Teammate({
|
|
565
|
+
operation: "approvePlan",
|
|
566
|
+
target_agent_id: "architect",
|
|
567
|
+
request_id: "plan-456"
|
|
568
|
+
})
|
|
569
|
+
```
|
|
570
|
+
|
|
571
|
+
### 12. rejectPlan - Reject Plan with Feedback (Leader Only)
|
|
572
|
+
|
|
573
|
+
```javascript
|
|
574
|
+
Teammate({
|
|
575
|
+
operation: "rejectPlan",
|
|
576
|
+
target_agent_id: "architect",
|
|
577
|
+
request_id: "plan-456",
|
|
578
|
+
feedback: "Please add error handling for the API calls and consider rate limiting"
|
|
579
|
+
})
|
|
580
|
+
```
|
|
581
|
+
|
|
582
|
+
### 13. cleanup - Remove Team Resources
|
|
583
|
+
|
|
584
|
+
```javascript
|
|
585
|
+
Teammate({ operation: "cleanup" })
|
|
586
|
+
```
|
|
587
|
+
|
|
588
|
+
**Removes:**
|
|
589
|
+
- `~/.claude/teams/{team-name}/` directory
|
|
590
|
+
- `~/.claude/tasks/{team-name}/` directory
|
|
591
|
+
|
|
592
|
+
**IMPORTANT:** Will fail if teammates are still active. Use `requestShutdown` first.
|
|
593
|
+
|
|
594
|
+
---
|
|
595
|
+
|
|
596
|
+
## Task System Integration
|
|
597
|
+
|
|
598
|
+
### TaskCreate - Create Work Items
|
|
599
|
+
|
|
600
|
+
```javascript
|
|
601
|
+
TaskCreate({
|
|
602
|
+
subject: "Review authentication module",
|
|
603
|
+
description: "Review all files in app/services/auth/ for security vulnerabilities",
|
|
604
|
+
activeForm: "Reviewing auth module..." // Shown in spinner when in_progress
|
|
605
|
+
})
|
|
606
|
+
```
|
|
607
|
+
|
|
608
|
+
### TaskList - See All Tasks
|
|
609
|
+
|
|
610
|
+
```javascript
|
|
611
|
+
TaskList()
|
|
612
|
+
```
|
|
613
|
+
|
|
614
|
+
Returns:
|
|
615
|
+
```
|
|
616
|
+
#1 [completed] Analyze codebase structure
|
|
617
|
+
#2 [in_progress] Review authentication module (owner: security-reviewer)
|
|
618
|
+
#3 [pending] Generate summary report [blocked by #2]
|
|
619
|
+
```
|
|
620
|
+
|
|
621
|
+
### TaskGet - Get Task Details
|
|
622
|
+
|
|
623
|
+
```javascript
|
|
624
|
+
TaskGet({ taskId: "2" })
|
|
625
|
+
```
|
|
626
|
+
|
|
627
|
+
Returns full task with description, status, blockedBy, etc.
|
|
628
|
+
|
|
629
|
+
### TaskUpdate - Update Task Status
|
|
630
|
+
|
|
631
|
+
```javascript
|
|
632
|
+
// Claim a task
|
|
633
|
+
TaskUpdate({ taskId: "2", owner: "security-reviewer" })
|
|
634
|
+
|
|
635
|
+
// Start working
|
|
636
|
+
TaskUpdate({ taskId: "2", status: "in_progress" })
|
|
637
|
+
|
|
638
|
+
// Mark complete
|
|
639
|
+
TaskUpdate({ taskId: "2", status: "completed" })
|
|
640
|
+
|
|
641
|
+
// Set up dependencies
|
|
642
|
+
TaskUpdate({ taskId: "3", addBlockedBy: ["1", "2"] })
|
|
643
|
+
```
|
|
644
|
+
|
|
645
|
+
### Task Dependencies
|
|
646
|
+
|
|
647
|
+
When a blocking task is completed, blocked tasks are automatically unblocked:
|
|
648
|
+
|
|
649
|
+
```javascript
|
|
650
|
+
// Create pipeline
|
|
651
|
+
TaskCreate({ subject: "Step 1: Research" }) // #1
|
|
652
|
+
TaskCreate({ subject: "Step 2: Implement" }) // #2
|
|
653
|
+
TaskCreate({ subject: "Step 3: Test" }) // #3
|
|
654
|
+
TaskCreate({ subject: "Step 4: Deploy" }) // #4
|
|
655
|
+
|
|
656
|
+
// Set up dependencies
|
|
657
|
+
TaskUpdate({ taskId: "2", addBlockedBy: ["1"] }) // #2 waits for #1
|
|
658
|
+
TaskUpdate({ taskId: "3", addBlockedBy: ["2"] }) // #3 waits for #2
|
|
659
|
+
TaskUpdate({ taskId: "4", addBlockedBy: ["3"] }) // #4 waits for #3
|
|
660
|
+
|
|
661
|
+
// When #1 completes, #2 auto-unblocks
|
|
662
|
+
// When #2 completes, #3 auto-unblocks
|
|
663
|
+
// etc.
|
|
664
|
+
```
|
|
665
|
+
|
|
666
|
+
### Task File Structure
|
|
667
|
+
|
|
668
|
+
`~/.claude/tasks/{team-name}/1.json`:
|
|
669
|
+
```json
|
|
670
|
+
{
|
|
671
|
+
"id": "1",
|
|
672
|
+
"subject": "Review authentication module",
|
|
673
|
+
"description": "Review all files in app/services/auth/...",
|
|
674
|
+
"status": "in_progress",
|
|
675
|
+
"owner": "security-reviewer",
|
|
676
|
+
"activeForm": "Reviewing auth module...",
|
|
677
|
+
"blockedBy": [],
|
|
678
|
+
"blocks": ["3"],
|
|
679
|
+
"createdAt": 1706000000000,
|
|
680
|
+
"updatedAt": 1706000001000
|
|
681
|
+
}
|
|
682
|
+
```
|
|
683
|
+
|
|
684
|
+
---
|
|
685
|
+
|
|
686
|
+
## Message Formats
|
|
687
|
+
|
|
688
|
+
### Regular Message
|
|
689
|
+
|
|
690
|
+
```json
|
|
691
|
+
{
|
|
692
|
+
"from": "team-lead",
|
|
693
|
+
"text": "Please prioritize the auth module",
|
|
694
|
+
"timestamp": "2026-01-25T23:38:32.588Z",
|
|
695
|
+
"read": false
|
|
696
|
+
}
|
|
697
|
+
```
|
|
698
|
+
|
|
699
|
+
### Structured Messages (JSON in text field)
|
|
700
|
+
|
|
701
|
+
#### Shutdown Request
|
|
702
|
+
```json
|
|
703
|
+
{
|
|
704
|
+
"type": "shutdown_request",
|
|
705
|
+
"requestId": "shutdown-abc123@worker-1",
|
|
706
|
+
"from": "team-lead",
|
|
707
|
+
"reason": "All tasks complete",
|
|
708
|
+
"timestamp": "2026-01-25T23:38:32.588Z"
|
|
709
|
+
}
|
|
710
|
+
```
|
|
711
|
+
|
|
712
|
+
#### Shutdown Approved
|
|
713
|
+
```json
|
|
714
|
+
{
|
|
715
|
+
"type": "shutdown_approved",
|
|
716
|
+
"requestId": "shutdown-abc123@worker-1",
|
|
717
|
+
"from": "worker-1",
|
|
718
|
+
"paneId": "%5",
|
|
719
|
+
"backendType": "in-process",
|
|
720
|
+
"timestamp": "2026-01-25T23:39:00.000Z"
|
|
721
|
+
}
|
|
722
|
+
```
|
|
723
|
+
|
|
724
|
+
#### Idle Notification (auto-sent when teammate stops)
|
|
725
|
+
```json
|
|
726
|
+
{
|
|
727
|
+
"type": "idle_notification",
|
|
728
|
+
"from": "worker-1",
|
|
729
|
+
"timestamp": "2026-01-25T23:40:00.000Z",
|
|
730
|
+
"completedTaskId": "2",
|
|
731
|
+
"completedStatus": "completed"
|
|
732
|
+
}
|
|
733
|
+
```
|
|
734
|
+
|
|
735
|
+
#### Task Completed
|
|
736
|
+
```json
|
|
737
|
+
{
|
|
738
|
+
"type": "task_completed",
|
|
739
|
+
"from": "worker-1",
|
|
740
|
+
"taskId": "2",
|
|
741
|
+
"taskSubject": "Review authentication module",
|
|
742
|
+
"timestamp": "2026-01-25T23:40:00.000Z"
|
|
743
|
+
}
|
|
744
|
+
```
|
|
745
|
+
|
|
746
|
+
#### Plan Approval Request
|
|
747
|
+
```json
|
|
748
|
+
{
|
|
749
|
+
"type": "plan_approval_request",
|
|
750
|
+
"from": "architect",
|
|
751
|
+
"requestId": "plan-xyz789",
|
|
752
|
+
"planContent": "# Implementation Plan\n\n1. ...",
|
|
753
|
+
"timestamp": "2026-01-25T23:41:00.000Z"
|
|
754
|
+
}
|
|
755
|
+
```
|
|
756
|
+
|
|
757
|
+
#### Join Request
|
|
758
|
+
```json
|
|
759
|
+
{
|
|
760
|
+
"type": "join_request",
|
|
761
|
+
"proposedName": "helper",
|
|
762
|
+
"requestId": "join-abc123",
|
|
763
|
+
"capabilities": "Code review and testing",
|
|
764
|
+
"timestamp": "2026-01-25T23:42:00.000Z"
|
|
765
|
+
}
|
|
766
|
+
```
|
|
767
|
+
|
|
768
|
+
#### Permission Request (for sandbox/tool permissions)
|
|
769
|
+
```json
|
|
770
|
+
{
|
|
771
|
+
"type": "permission_request",
|
|
772
|
+
"requestId": "perm-123",
|
|
773
|
+
"workerId": "worker-1@my-project",
|
|
774
|
+
"workerName": "worker-1",
|
|
775
|
+
"workerColor": "#4A90D9",
|
|
776
|
+
"toolName": "Bash",
|
|
777
|
+
"toolUseId": "toolu_abc123",
|
|
778
|
+
"description": "Run npm install",
|
|
779
|
+
"input": {"command": "npm install"},
|
|
780
|
+
"permissionSuggestions": ["Bash(npm *)"],
|
|
781
|
+
"createdAt": 1706000000000
|
|
782
|
+
}
|
|
783
|
+
```
|
|
784
|
+
|
|
785
|
+
---
|
|
786
|
+
|
|
787
|
+
## Orchestration Patterns
|
|
788
|
+
|
|
789
|
+
### Pattern 1: Parallel Specialists (Leader Pattern)
|
|
790
|
+
|
|
791
|
+
Multiple specialists review code simultaneously:
|
|
792
|
+
|
|
793
|
+
```javascript
|
|
794
|
+
// 1. Create team
|
|
795
|
+
Teammate({ operation: "spawnTeam", team_name: "code-review" })
|
|
796
|
+
|
|
797
|
+
// 2. Spawn specialists in parallel (single message, multiple Task calls)
|
|
798
|
+
Task({
|
|
799
|
+
team_name: "code-review",
|
|
800
|
+
name: "security",
|
|
801
|
+
subagent_type: "compound-engineering:review:security-sentinel",
|
|
802
|
+
prompt: "Review the PR for security vulnerabilities. Focus on: SQL injection, XSS, auth bypass. Send findings to team-lead.",
|
|
803
|
+
run_in_background: true
|
|
804
|
+
})
|
|
805
|
+
|
|
806
|
+
Task({
|
|
807
|
+
team_name: "code-review",
|
|
808
|
+
name: "performance",
|
|
809
|
+
subagent_type: "compound-engineering:review:performance-oracle",
|
|
810
|
+
prompt: "Review the PR for performance issues. Focus on: N+1 queries, memory leaks, slow algorithms. Send findings to team-lead.",
|
|
811
|
+
run_in_background: true
|
|
812
|
+
})
|
|
813
|
+
|
|
814
|
+
Task({
|
|
815
|
+
team_name: "code-review",
|
|
816
|
+
name: "simplicity",
|
|
817
|
+
subagent_type: "compound-engineering:review:code-simplicity-reviewer",
|
|
818
|
+
prompt: "Review the PR for unnecessary complexity. Focus on: over-engineering, premature abstraction, YAGNI violations. Send findings to team-lead.",
|
|
819
|
+
run_in_background: true
|
|
820
|
+
})
|
|
821
|
+
|
|
822
|
+
// 3. Wait for results (check inbox)
|
|
823
|
+
// cat ~/.claude/teams/code-review/inboxes/team-lead.json
|
|
824
|
+
|
|
825
|
+
// 4. Synthesize findings and cleanup
|
|
826
|
+
Teammate({ operation: "requestShutdown", target_agent_id: "security" })
|
|
827
|
+
Teammate({ operation: "requestShutdown", target_agent_id: "performance" })
|
|
828
|
+
Teammate({ operation: "requestShutdown", target_agent_id: "simplicity" })
|
|
829
|
+
// Wait for approvals...
|
|
830
|
+
Teammate({ operation: "cleanup" })
|
|
831
|
+
```
|
|
832
|
+
|
|
833
|
+
### Pattern 2: Pipeline (Sequential Dependencies)
|
|
834
|
+
|
|
835
|
+
Each stage depends on the previous:
|
|
836
|
+
|
|
837
|
+
```javascript
|
|
838
|
+
// 1. Create team and task pipeline
|
|
839
|
+
Teammate({ operation: "spawnTeam", team_name: "feature-pipeline" })
|
|
840
|
+
|
|
841
|
+
TaskCreate({ subject: "Research", description: "Research best practices for the feature", activeForm: "Researching..." })
|
|
842
|
+
TaskCreate({ subject: "Plan", description: "Create implementation plan based on research", activeForm: "Planning..." })
|
|
843
|
+
TaskCreate({ subject: "Implement", description: "Implement the feature according to plan", activeForm: "Implementing..." })
|
|
844
|
+
TaskCreate({ subject: "Test", description: "Write and run tests for the implementation", activeForm: "Testing..." })
|
|
845
|
+
TaskCreate({ subject: "Review", description: "Final code review before merge", activeForm: "Reviewing..." })
|
|
846
|
+
|
|
847
|
+
// Set up sequential dependencies
|
|
848
|
+
TaskUpdate({ taskId: "2", addBlockedBy: ["1"] })
|
|
849
|
+
TaskUpdate({ taskId: "3", addBlockedBy: ["2"] })
|
|
850
|
+
TaskUpdate({ taskId: "4", addBlockedBy: ["3"] })
|
|
851
|
+
TaskUpdate({ taskId: "5", addBlockedBy: ["4"] })
|
|
852
|
+
|
|
853
|
+
// 2. Spawn workers that claim and complete tasks
|
|
854
|
+
Task({
|
|
855
|
+
team_name: "feature-pipeline",
|
|
856
|
+
name: "researcher",
|
|
857
|
+
subagent_type: "compound-engineering:research:best-practices-researcher",
|
|
858
|
+
prompt: "Claim task #1, research best practices, complete it, send findings to team-lead. Then check for more work.",
|
|
859
|
+
run_in_background: true
|
|
860
|
+
})
|
|
861
|
+
|
|
862
|
+
Task({
|
|
863
|
+
team_name: "feature-pipeline",
|
|
864
|
+
name: "implementer",
|
|
865
|
+
subagent_type: "general-purpose",
|
|
866
|
+
prompt: "Poll TaskList every 30 seconds. When task #3 unblocks, claim it and implement. Then complete and notify team-lead.",
|
|
867
|
+
run_in_background: true
|
|
868
|
+
})
|
|
869
|
+
|
|
870
|
+
// Tasks auto-unblock as dependencies complete
|
|
871
|
+
```
|
|
872
|
+
|
|
873
|
+
### Pattern 3: Swarm (Self-Organizing)
|
|
874
|
+
|
|
875
|
+
Workers grab available tasks from a pool:
|
|
876
|
+
|
|
877
|
+
```javascript
|
|
878
|
+
// 1. Create team and task pool
|
|
879
|
+
Teammate({ operation: "spawnTeam", team_name: "file-review-swarm" })
|
|
880
|
+
|
|
881
|
+
// Create many independent tasks (no dependencies)
|
|
882
|
+
for (const file of ["auth.rb", "user.rb", "api_controller.rb", "payment.rb"]) {
|
|
883
|
+
TaskCreate({
|
|
884
|
+
subject: `Review ${file}`,
|
|
885
|
+
description: `Review ${file} for security and code quality issues`,
|
|
886
|
+
activeForm: `Reviewing ${file}...`
|
|
887
|
+
})
|
|
888
|
+
}
|
|
889
|
+
|
|
890
|
+
// 2. Spawn worker swarm
|
|
891
|
+
Task({
|
|
892
|
+
team_name: "file-review-swarm",
|
|
893
|
+
name: "worker-1",
|
|
894
|
+
subagent_type: "general-purpose",
|
|
895
|
+
prompt: `
|
|
896
|
+
You are a swarm worker. Your job:
|
|
897
|
+
1. Call TaskList to see available tasks
|
|
898
|
+
2. Find a task with status 'pending' and no owner
|
|
899
|
+
3. Claim it with TaskUpdate (set owner to your name)
|
|
900
|
+
4. Do the work
|
|
901
|
+
5. Mark it completed with TaskUpdate
|
|
902
|
+
6. Send findings to team-lead via Teammate write
|
|
903
|
+
7. Repeat until no tasks remain
|
|
904
|
+
`,
|
|
905
|
+
run_in_background: true
|
|
906
|
+
})
|
|
907
|
+
|
|
908
|
+
Task({
|
|
909
|
+
team_name: "file-review-swarm",
|
|
910
|
+
name: "worker-2",
|
|
911
|
+
subagent_type: "general-purpose",
|
|
912
|
+
prompt: `[Same prompt as worker-1]`,
|
|
913
|
+
run_in_background: true
|
|
914
|
+
})
|
|
915
|
+
|
|
916
|
+
Task({
|
|
917
|
+
team_name: "file-review-swarm",
|
|
918
|
+
name: "worker-3",
|
|
919
|
+
subagent_type: "general-purpose",
|
|
920
|
+
prompt: `[Same prompt as worker-1]`,
|
|
921
|
+
run_in_background: true
|
|
922
|
+
})
|
|
923
|
+
|
|
924
|
+
// Workers race to claim tasks, naturally load-balance
|
|
925
|
+
```
|
|
926
|
+
|
|
927
|
+
### Pattern 4: Research + Implementation
|
|
928
|
+
|
|
929
|
+
Research first, then implement:
|
|
930
|
+
|
|
931
|
+
```javascript
|
|
932
|
+
// 1. Research phase (synchronous, returns results)
|
|
933
|
+
const research = await Task({
|
|
934
|
+
subagent_type: "compound-engineering:research:best-practices-researcher",
|
|
935
|
+
description: "Research caching patterns",
|
|
936
|
+
prompt: "Research best practices for implementing caching in Rails APIs. Include: cache invalidation strategies, Redis vs Memcached, cache key design."
|
|
937
|
+
})
|
|
938
|
+
|
|
939
|
+
// 2. Use research to guide implementation
|
|
940
|
+
Task({
|
|
941
|
+
subagent_type: "general-purpose",
|
|
942
|
+
description: "Implement caching",
|
|
943
|
+
prompt: `
|
|
944
|
+
Implement API caching based on this research:
|
|
945
|
+
|
|
946
|
+
${research.content}
|
|
947
|
+
|
|
948
|
+
Focus on the user_controller.rb endpoints.
|
|
949
|
+
`
|
|
950
|
+
})
|
|
951
|
+
```
|
|
952
|
+
|
|
953
|
+
### Pattern 5: Plan Approval Workflow
|
|
954
|
+
|
|
955
|
+
Require plan approval before implementation:
|
|
956
|
+
|
|
957
|
+
```javascript
|
|
958
|
+
// 1. Create team
|
|
959
|
+
Teammate({ operation: "spawnTeam", team_name: "careful-work" })
|
|
960
|
+
|
|
961
|
+
// 2. Spawn architect with plan_mode_required
|
|
962
|
+
Task({
|
|
963
|
+
team_name: "careful-work",
|
|
964
|
+
name: "architect",
|
|
965
|
+
subagent_type: "Plan",
|
|
966
|
+
prompt: "Design an implementation plan for adding OAuth2 authentication",
|
|
967
|
+
mode: "plan", // Requires plan approval
|
|
968
|
+
run_in_background: true
|
|
969
|
+
})
|
|
970
|
+
|
|
971
|
+
// 3. Wait for plan approval request
|
|
972
|
+
// You'll receive: {"type": "plan_approval_request", "from": "architect", "requestId": "plan-xxx", ...}
|
|
973
|
+
|
|
974
|
+
// 4. Review and approve/reject
|
|
975
|
+
Teammate({
|
|
976
|
+
operation: "approvePlan",
|
|
977
|
+
target_agent_id: "architect",
|
|
978
|
+
request_id: "plan-xxx"
|
|
979
|
+
})
|
|
980
|
+
// OR
|
|
981
|
+
Teammate({
|
|
982
|
+
operation: "rejectPlan",
|
|
983
|
+
target_agent_id: "architect",
|
|
984
|
+
request_id: "plan-xxx",
|
|
985
|
+
feedback: "Please add rate limiting considerations"
|
|
986
|
+
})
|
|
987
|
+
```
|
|
988
|
+
|
|
989
|
+
### Pattern 6: Coordinated Multi-File Refactoring
|
|
990
|
+
|
|
991
|
+
```javascript
|
|
992
|
+
// 1. Create team for coordinated refactoring
|
|
993
|
+
Teammate({ operation: "spawnTeam", team_name: "refactor-auth" })
|
|
994
|
+
|
|
995
|
+
// 2. Create tasks with clear file boundaries
|
|
996
|
+
TaskCreate({
|
|
997
|
+
subject: "Refactor User model",
|
|
998
|
+
description: "Extract authentication methods to AuthenticatableUser concern",
|
|
999
|
+
activeForm: "Refactoring User model..."
|
|
1000
|
+
})
|
|
1001
|
+
|
|
1002
|
+
TaskCreate({
|
|
1003
|
+
subject: "Refactor Session controller",
|
|
1004
|
+
description: "Update to use new AuthenticatableUser concern",
|
|
1005
|
+
activeForm: "Refactoring Sessions..."
|
|
1006
|
+
})
|
|
1007
|
+
|
|
1008
|
+
TaskCreate({
|
|
1009
|
+
subject: "Update specs",
|
|
1010
|
+
description: "Update all authentication specs for new structure",
|
|
1011
|
+
activeForm: "Updating specs..."
|
|
1012
|
+
})
|
|
1013
|
+
|
|
1014
|
+
// Dependencies: specs depend on both refactors completing
|
|
1015
|
+
TaskUpdate({ taskId: "3", addBlockedBy: ["1", "2"] })
|
|
1016
|
+
|
|
1017
|
+
// 3. Spawn workers for each task
|
|
1018
|
+
Task({
|
|
1019
|
+
team_name: "refactor-auth",
|
|
1020
|
+
name: "model-worker",
|
|
1021
|
+
subagent_type: "general-purpose",
|
|
1022
|
+
prompt: "Claim task #1, refactor the User model, complete when done",
|
|
1023
|
+
run_in_background: true
|
|
1024
|
+
})
|
|
1025
|
+
|
|
1026
|
+
Task({
|
|
1027
|
+
team_name: "refactor-auth",
|
|
1028
|
+
name: "controller-worker",
|
|
1029
|
+
subagent_type: "general-purpose",
|
|
1030
|
+
prompt: "Claim task #2, refactor the Session controller, complete when done",
|
|
1031
|
+
run_in_background: true
|
|
1032
|
+
})
|
|
1033
|
+
|
|
1034
|
+
Task({
|
|
1035
|
+
team_name: "refactor-auth",
|
|
1036
|
+
name: "spec-worker",
|
|
1037
|
+
subagent_type: "general-purpose",
|
|
1038
|
+
prompt: "Wait for task #3 to unblock (when #1 and #2 complete), then update specs",
|
|
1039
|
+
run_in_background: true
|
|
1040
|
+
})
|
|
1041
|
+
```
|
|
1042
|
+
|
|
1043
|
+
---
|
|
1044
|
+
|
|
1045
|
+
## Environment Variables
|
|
1046
|
+
|
|
1047
|
+
Spawned teammates automatically receive these:
|
|
1048
|
+
|
|
1049
|
+
```bash
|
|
1050
|
+
CLAUDE_CODE_TEAM_NAME="my-project"
|
|
1051
|
+
CLAUDE_CODE_AGENT_ID="worker-1@my-project"
|
|
1052
|
+
CLAUDE_CODE_AGENT_NAME="worker-1"
|
|
1053
|
+
CLAUDE_CODE_AGENT_TYPE="Explore"
|
|
1054
|
+
CLAUDE_CODE_AGENT_COLOR="#4A90D9"
|
|
1055
|
+
CLAUDE_CODE_PLAN_MODE_REQUIRED="false"
|
|
1056
|
+
CLAUDE_CODE_PARENT_SESSION_ID="session-xyz"
|
|
1057
|
+
```
|
|
1058
|
+
|
|
1059
|
+
**Using in prompts:**
|
|
1060
|
+
```javascript
|
|
1061
|
+
Task({
|
|
1062
|
+
team_name: "my-project",
|
|
1063
|
+
name: "worker",
|
|
1064
|
+
subagent_type: "general-purpose",
|
|
1065
|
+
prompt: "Your name is $CLAUDE_CODE_AGENT_NAME. Use it when sending messages to team-lead."
|
|
1066
|
+
})
|
|
1067
|
+
```
|
|
1068
|
+
|
|
1069
|
+
---
|
|
1070
|
+
|
|
1071
|
+
## Spawn Backends
|
|
1072
|
+
|
|
1073
|
+
A **backend** determines how teammate Claude instances actually run. Claude Code supports three backends, and **auto-detects** the best one based on your environment.
|
|
1074
|
+
|
|
1075
|
+
### Backend Comparison
|
|
1076
|
+
|
|
1077
|
+
| Backend | How It Works | Visibility | Persistence | Speed |
|
|
1078
|
+
|---------|-------------|------------|-------------|-------|
|
|
1079
|
+
| **in-process** | Same Node.js process as leader | Hidden (background) | Dies with leader | Fastest |
|
|
1080
|
+
| **tmux** | Separate terminal in tmux session | Visible in tmux | Survives leader exit | Medium |
|
|
1081
|
+
| **iterm2** | Split panes in iTerm2 window | Visible side-by-side | Dies with window | Medium |
|
|
1082
|
+
|
|
1083
|
+
### Auto-Detection Logic
|
|
1084
|
+
|
|
1085
|
+
Claude Code automatically selects a backend using this decision tree:
|
|
1086
|
+
|
|
1087
|
+
```mermaid
|
|
1088
|
+
flowchart TD
|
|
1089
|
+
A[Start] --> B{Running inside tmux?}
|
|
1090
|
+
B -->|Yes| C[Use tmux backend]
|
|
1091
|
+
B -->|No| D{Running in iTerm2?}
|
|
1092
|
+
D -->|No| E{tmux available?}
|
|
1093
|
+
E -->|Yes| F[Use tmux - external session]
|
|
1094
|
+
E -->|No| G[Use in-process]
|
|
1095
|
+
D -->|Yes| H{it2 CLI installed?}
|
|
1096
|
+
H -->|Yes| I[Use iterm2 backend]
|
|
1097
|
+
H -->|No| J{tmux available?}
|
|
1098
|
+
J -->|Yes| K[Use tmux - prompt to install it2]
|
|
1099
|
+
J -->|No| L[Error: Install tmux or it2]
|
|
1100
|
+
```
|
|
1101
|
+
|
|
1102
|
+
**Detection checks:**
|
|
1103
|
+
1. `$TMUX` environment variable → inside tmux
|
|
1104
|
+
2. `$TERM_PROGRAM === "iTerm.app"` or `$ITERM_SESSION_ID` → in iTerm2
|
|
1105
|
+
3. `which tmux` → tmux available
|
|
1106
|
+
4. `which it2` → it2 CLI installed
|
|
1107
|
+
|
|
1108
|
+
### in-process (Default for non-tmux)
|
|
1109
|
+
|
|
1110
|
+
Teammates run as async tasks within the same Node.js process.
|
|
1111
|
+
|
|
1112
|
+
**How it works:**
|
|
1113
|
+
- No new process spawned
|
|
1114
|
+
- Teammates share the same Node.js event loop
|
|
1115
|
+
- Communication via in-memory queues (fast)
|
|
1116
|
+
- You don't see teammate output directly
|
|
1117
|
+
|
|
1118
|
+
**When it's used:**
|
|
1119
|
+
- Not running inside tmux session
|
|
1120
|
+
- Non-interactive mode (CI, scripts)
|
|
1121
|
+
- Explicitly set via `CLAUDE_CODE_SPAWN_BACKEND=in-process`
|
|
1122
|
+
|
|
1123
|
+
**Characteristics:**
|
|
1124
|
+
```
|
|
1125
|
+
┌─────────────────────────────────────────┐
|
|
1126
|
+
│ Node.js Process │
|
|
1127
|
+
│ ┌─────────┐ ┌─────────┐ ┌─────────┐ │
|
|
1128
|
+
│ │ Leader │ │Worker 1 │ │Worker 2 │ │
|
|
1129
|
+
│ │ (main) │ │ (async) │ │ (async) │ │
|
|
1130
|
+
│ └─────────┘ └─────────┘ └─────────┘ │
|
|
1131
|
+
└─────────────────────────────────────────┘
|
|
1132
|
+
```
|
|
1133
|
+
|
|
1134
|
+
**Pros:**
|
|
1135
|
+
- Fastest startup (no process spawn)
|
|
1136
|
+
- Lowest overhead
|
|
1137
|
+
- Works everywhere
|
|
1138
|
+
|
|
1139
|
+
**Cons:**
|
|
1140
|
+
- Can't see teammate output in real-time
|
|
1141
|
+
- All die if leader dies
|
|
1142
|
+
- Harder to debug
|
|
1143
|
+
|
|
1144
|
+
```javascript
|
|
1145
|
+
// in-process is automatic when not in tmux
|
|
1146
|
+
Task({
|
|
1147
|
+
team_name: "my-project",
|
|
1148
|
+
name: "worker",
|
|
1149
|
+
subagent_type: "general-purpose",
|
|
1150
|
+
prompt: "...",
|
|
1151
|
+
run_in_background: true
|
|
1152
|
+
})
|
|
1153
|
+
|
|
1154
|
+
// Force in-process explicitly
|
|
1155
|
+
// export CLAUDE_CODE_SPAWN_BACKEND=in-process
|
|
1156
|
+
```
|
|
1157
|
+
|
|
1158
|
+
### tmux
|
|
1159
|
+
|
|
1160
|
+
Teammates run as separate Claude instances in tmux panes/windows.
|
|
1161
|
+
|
|
1162
|
+
**How it works:**
|
|
1163
|
+
- Each teammate gets its own tmux pane
|
|
1164
|
+
- Separate process per teammate
|
|
1165
|
+
- You can switch panes to see teammate output
|
|
1166
|
+
- Communication via inbox files
|
|
1167
|
+
|
|
1168
|
+
**When it's used:**
|
|
1169
|
+
- Running inside a tmux session (`$TMUX` is set)
|
|
1170
|
+
- tmux available and not in iTerm2
|
|
1171
|
+
- Explicitly set via `CLAUDE_CODE_SPAWN_BACKEND=tmux`
|
|
1172
|
+
|
|
1173
|
+
**Layout modes:**
|
|
1174
|
+
|
|
1175
|
+
1. **Inside tmux (native):** Splits your current window
|
|
1176
|
+
```
|
|
1177
|
+
┌─────────────────┬─────────────────┐
|
|
1178
|
+
│ │ Worker 1 │
|
|
1179
|
+
│ Leader ├─────────────────┤
|
|
1180
|
+
│ (your pane) │ Worker 2 │
|
|
1181
|
+
│ ├─────────────────┤
|
|
1182
|
+
│ │ Worker 3 │
|
|
1183
|
+
└─────────────────┴─────────────────┘
|
|
1184
|
+
```
|
|
1185
|
+
|
|
1186
|
+
2. **Outside tmux (external session):** Creates a new tmux session called `claude-swarm`
|
|
1187
|
+
```bash
|
|
1188
|
+
# Your terminal stays as-is
|
|
1189
|
+
# Workers run in separate tmux session
|
|
1190
|
+
|
|
1191
|
+
# View workers:
|
|
1192
|
+
tmux attach -t claude-swarm
|
|
1193
|
+
```
|
|
1194
|
+
|
|
1195
|
+
**Pros:**
|
|
1196
|
+
- See teammate output in real-time
|
|
1197
|
+
- Teammates survive leader exit
|
|
1198
|
+
- Can attach/detach sessions
|
|
1199
|
+
- Works in CI/headless environments
|
|
1200
|
+
|
|
1201
|
+
**Cons:**
|
|
1202
|
+
- Slower startup (process spawn)
|
|
1203
|
+
- Requires tmux installed
|
|
1204
|
+
- More resource usage
|
|
1205
|
+
|
|
1206
|
+
```bash
|
|
1207
|
+
# Start tmux session first
|
|
1208
|
+
tmux new-session -s claude
|
|
1209
|
+
|
|
1210
|
+
# Or force tmux backend
|
|
1211
|
+
export CLAUDE_CODE_SPAWN_BACKEND=tmux
|
|
1212
|
+
```
|
|
1213
|
+
|
|
1214
|
+
**Useful tmux commands:**
|
|
1215
|
+
```bash
|
|
1216
|
+
# List all panes in current window
|
|
1217
|
+
tmux list-panes
|
|
1218
|
+
|
|
1219
|
+
# Switch to pane by number
|
|
1220
|
+
tmux select-pane -t 1
|
|
1221
|
+
|
|
1222
|
+
# Kill a specific pane
|
|
1223
|
+
tmux kill-pane -t %5
|
|
1224
|
+
|
|
1225
|
+
# View swarm session (if external)
|
|
1226
|
+
tmux attach -t claude-swarm
|
|
1227
|
+
|
|
1228
|
+
# Rebalance pane layout
|
|
1229
|
+
tmux select-layout tiled
|
|
1230
|
+
```
|
|
1231
|
+
|
|
1232
|
+
### iterm2 (macOS only)
|
|
1233
|
+
|
|
1234
|
+
Teammates run as split panes within your iTerm2 window.
|
|
1235
|
+
|
|
1236
|
+
**How it works:**
|
|
1237
|
+
- Uses iTerm2's Python API via `it2` CLI
|
|
1238
|
+
- Splits your current window into panes
|
|
1239
|
+
- Each teammate visible side-by-side
|
|
1240
|
+
- Communication via inbox files
|
|
1241
|
+
|
|
1242
|
+
**When it's used:**
|
|
1243
|
+
- Running in iTerm2 (`$TERM_PROGRAM === "iTerm.app"`)
|
|
1244
|
+
- `it2` CLI is installed and working
|
|
1245
|
+
- Python API enabled in iTerm2 preferences
|
|
1246
|
+
|
|
1247
|
+
**Layout:**
|
|
1248
|
+
```
|
|
1249
|
+
┌─────────────────┬─────────────────┐
|
|
1250
|
+
│ │ Worker 1 │
|
|
1251
|
+
│ Leader ├─────────────────┤
|
|
1252
|
+
│ (your pane) │ Worker 2 │
|
|
1253
|
+
│ ├─────────────────┤
|
|
1254
|
+
│ │ Worker 3 │
|
|
1255
|
+
└─────────────────┴─────────────────┘
|
|
1256
|
+
```
|
|
1257
|
+
|
|
1258
|
+
**Pros:**
|
|
1259
|
+
- Visual debugging - see all teammates
|
|
1260
|
+
- Native macOS experience
|
|
1261
|
+
- No tmux needed
|
|
1262
|
+
- Automatic pane management
|
|
1263
|
+
|
|
1264
|
+
**Cons:**
|
|
1265
|
+
- macOS + iTerm2 only
|
|
1266
|
+
- Requires setup (it2 CLI + Python API)
|
|
1267
|
+
- Panes die with window
|
|
1268
|
+
|
|
1269
|
+
**Setup:**
|
|
1270
|
+
```bash
|
|
1271
|
+
# 1. Install it2 CLI
|
|
1272
|
+
uv tool install it2
|
|
1273
|
+
# OR
|
|
1274
|
+
pipx install it2
|
|
1275
|
+
# OR
|
|
1276
|
+
pip install --user it2
|
|
1277
|
+
|
|
1278
|
+
# 2. Enable Python API in iTerm2
|
|
1279
|
+
# iTerm2 → Settings → General → Magic → Enable Python API
|
|
1280
|
+
|
|
1281
|
+
# 3. Restart iTerm2
|
|
1282
|
+
|
|
1283
|
+
# 4. Verify
|
|
1284
|
+
it2 --version
|
|
1285
|
+
it2 session list
|
|
1286
|
+
```
|
|
1287
|
+
|
|
1288
|
+
**If setup fails:**
|
|
1289
|
+
Claude Code will prompt you to set up it2 when you first spawn a teammate. You can choose to:
|
|
1290
|
+
1. Install it2 now (guided setup)
|
|
1291
|
+
2. Use tmux instead
|
|
1292
|
+
3. Cancel
|
|
1293
|
+
|
|
1294
|
+
### Forcing a Backend
|
|
1295
|
+
|
|
1296
|
+
```bash
|
|
1297
|
+
# Force in-process (fastest, no visibility)
|
|
1298
|
+
export CLAUDE_CODE_SPAWN_BACKEND=in-process
|
|
1299
|
+
|
|
1300
|
+
# Force tmux (visible panes, persistent)
|
|
1301
|
+
export CLAUDE_CODE_SPAWN_BACKEND=tmux
|
|
1302
|
+
|
|
1303
|
+
# Auto-detect (default)
|
|
1304
|
+
unset CLAUDE_CODE_SPAWN_BACKEND
|
|
1305
|
+
```
|
|
1306
|
+
|
|
1307
|
+
### Backend in Team Config
|
|
1308
|
+
|
|
1309
|
+
The backend type is recorded per-teammate in `config.json`:
|
|
1310
|
+
|
|
1311
|
+
```json
|
|
1312
|
+
{
|
|
1313
|
+
"members": [
|
|
1314
|
+
{
|
|
1315
|
+
"name": "worker-1",
|
|
1316
|
+
"backendType": "in-process",
|
|
1317
|
+
"tmuxPaneId": "in-process"
|
|
1318
|
+
},
|
|
1319
|
+
{
|
|
1320
|
+
"name": "worker-2",
|
|
1321
|
+
"backendType": "tmux",
|
|
1322
|
+
"tmuxPaneId": "%5"
|
|
1323
|
+
}
|
|
1324
|
+
]
|
|
1325
|
+
}
|
|
1326
|
+
```
|
|
1327
|
+
|
|
1328
|
+
### Troubleshooting Backends
|
|
1329
|
+
|
|
1330
|
+
| Issue | Cause | Solution |
|
|
1331
|
+
|-------|-------|----------|
|
|
1332
|
+
| "No pane backend available" | Neither tmux nor iTerm2 available | Install tmux: `brew install tmux` |
|
|
1333
|
+
| "it2 CLI not installed" | In iTerm2 but missing it2 | Run `uv tool install it2` |
|
|
1334
|
+
| "Python API not enabled" | it2 can't communicate with iTerm2 | Enable in iTerm2 Settings → General → Magic |
|
|
1335
|
+
| Workers not visible | Using in-process backend | Start inside tmux or iTerm2 |
|
|
1336
|
+
| Workers dying unexpectedly | Outside tmux, leader exited | Use tmux for persistence |
|
|
1337
|
+
|
|
1338
|
+
### Checking Current Backend
|
|
1339
|
+
|
|
1340
|
+
```bash
|
|
1341
|
+
# See what backend was detected
|
|
1342
|
+
cat ~/.claude/teams/{team}/config.json | jq '.members[].backendType'
|
|
1343
|
+
|
|
1344
|
+
# Check if inside tmux
|
|
1345
|
+
echo $TMUX
|
|
1346
|
+
|
|
1347
|
+
# Check if in iTerm2
|
|
1348
|
+
echo $TERM_PROGRAM
|
|
1349
|
+
|
|
1350
|
+
# Check tmux availability
|
|
1351
|
+
which tmux
|
|
1352
|
+
|
|
1353
|
+
# Check it2 availability
|
|
1354
|
+
which it2
|
|
1355
|
+
```
|
|
1356
|
+
|
|
1357
|
+
---
|
|
1358
|
+
|
|
1359
|
+
## Error Handling
|
|
1360
|
+
|
|
1361
|
+
### Common Errors
|
|
1362
|
+
|
|
1363
|
+
| Error | Cause | Solution |
|
|
1364
|
+
|-------|-------|----------|
|
|
1365
|
+
| "Cannot cleanup with active members" | Teammates still running | `requestShutdown` all teammates first, wait for approval |
|
|
1366
|
+
| "Already leading a team" | Team already exists | `cleanup` first, or use different team name |
|
|
1367
|
+
| "Agent not found" | Wrong teammate name | Check `config.json` for actual names |
|
|
1368
|
+
| "Team does not exist" | No team created | Call `spawnTeam` first |
|
|
1369
|
+
| "team_name is required" | Missing team context | Provide `team_name` parameter |
|
|
1370
|
+
| "Agent type not found" | Invalid subagent_type | Check available agents with proper prefix |
|
|
1371
|
+
|
|
1372
|
+
### Graceful Shutdown Sequence
|
|
1373
|
+
|
|
1374
|
+
**Always follow this sequence:**
|
|
1375
|
+
|
|
1376
|
+
```javascript
|
|
1377
|
+
// 1. Request shutdown for all teammates
|
|
1378
|
+
Teammate({ operation: "requestShutdown", target_agent_id: "worker-1" })
|
|
1379
|
+
Teammate({ operation: "requestShutdown", target_agent_id: "worker-2" })
|
|
1380
|
+
|
|
1381
|
+
// 2. Wait for shutdown approvals
|
|
1382
|
+
// Check for {"type": "shutdown_approved", ...} messages
|
|
1383
|
+
|
|
1384
|
+
// 3. Verify no active members
|
|
1385
|
+
// Read ~/.claude/teams/{team}/config.json
|
|
1386
|
+
|
|
1387
|
+
// 4. Only then cleanup
|
|
1388
|
+
Teammate({ operation: "cleanup" })
|
|
1389
|
+
```
|
|
1390
|
+
|
|
1391
|
+
### Handling Crashed Teammates
|
|
1392
|
+
|
|
1393
|
+
Teammates have a 5-minute heartbeat timeout. If a teammate crashes:
|
|
1394
|
+
|
|
1395
|
+
1. They'll be automatically marked as inactive after timeout
|
|
1396
|
+
2. Their tasks remain in the task list
|
|
1397
|
+
3. Another teammate can claim their tasks
|
|
1398
|
+
4. Cleanup will work after timeout expires
|
|
1399
|
+
|
|
1400
|
+
### Debugging
|
|
1401
|
+
|
|
1402
|
+
```bash
|
|
1403
|
+
# Check team config
|
|
1404
|
+
cat ~/.claude/teams/{team}/config.json | jq '.members[] | {name, agentType, backendType}'
|
|
1405
|
+
|
|
1406
|
+
# Check teammate inboxes
|
|
1407
|
+
cat ~/.claude/teams/{team}/inboxes/{agent}.json | jq '.'
|
|
1408
|
+
|
|
1409
|
+
# List all teams
|
|
1410
|
+
ls ~/.claude/teams/
|
|
1411
|
+
|
|
1412
|
+
# Check task states
|
|
1413
|
+
cat ~/.claude/tasks/{team}/*.json | jq '{id, subject, status, owner, blockedBy}'
|
|
1414
|
+
|
|
1415
|
+
# Watch for new messages
|
|
1416
|
+
tail -f ~/.claude/teams/{team}/inboxes/team-lead.json
|
|
1417
|
+
```
|
|
1418
|
+
|
|
1419
|
+
---
|
|
1420
|
+
|
|
1421
|
+
## Complete Workflows
|
|
1422
|
+
|
|
1423
|
+
### Workflow 1: Full Code Review with Parallel Specialists
|
|
1424
|
+
|
|
1425
|
+
```javascript
|
|
1426
|
+
// === STEP 1: Setup ===
|
|
1427
|
+
Teammate({ operation: "spawnTeam", team_name: "pr-review-123", description: "Reviewing PR #123" })
|
|
1428
|
+
|
|
1429
|
+
// === STEP 2: Spawn reviewers in parallel ===
|
|
1430
|
+
// (Send all these in a single message for parallel execution)
|
|
1431
|
+
Task({
|
|
1432
|
+
team_name: "pr-review-123",
|
|
1433
|
+
name: "security",
|
|
1434
|
+
subagent_type: "compound-engineering:review:security-sentinel",
|
|
1435
|
+
prompt: `Review PR #123 for security vulnerabilities.
|
|
1436
|
+
|
|
1437
|
+
Focus on:
|
|
1438
|
+
- SQL injection
|
|
1439
|
+
- XSS vulnerabilities
|
|
1440
|
+
- Authentication/authorization bypass
|
|
1441
|
+
- Sensitive data exposure
|
|
1442
|
+
|
|
1443
|
+
When done, send your findings to team-lead using:
|
|
1444
|
+
Teammate({ operation: "write", target_agent_id: "team-lead", value: "Your findings here" })`,
|
|
1445
|
+
run_in_background: true
|
|
1446
|
+
})
|
|
1447
|
+
|
|
1448
|
+
Task({
|
|
1449
|
+
team_name: "pr-review-123",
|
|
1450
|
+
name: "perf",
|
|
1451
|
+
subagent_type: "compound-engineering:review:performance-oracle",
|
|
1452
|
+
prompt: `Review PR #123 for performance issues.
|
|
1453
|
+
|
|
1454
|
+
Focus on:
|
|
1455
|
+
- N+1 queries
|
|
1456
|
+
- Missing indexes
|
|
1457
|
+
- Memory leaks
|
|
1458
|
+
- Inefficient algorithms
|
|
1459
|
+
|
|
1460
|
+
Send findings to team-lead when done.`,
|
|
1461
|
+
run_in_background: true
|
|
1462
|
+
})
|
|
1463
|
+
|
|
1464
|
+
Task({
|
|
1465
|
+
team_name: "pr-review-123",
|
|
1466
|
+
name: "arch",
|
|
1467
|
+
subagent_type: "compound-engineering:review:architecture-strategist",
|
|
1468
|
+
prompt: `Review PR #123 for architectural concerns.
|
|
1469
|
+
|
|
1470
|
+
Focus on:
|
|
1471
|
+
- Design pattern adherence
|
|
1472
|
+
- SOLID principles
|
|
1473
|
+
- Separation of concerns
|
|
1474
|
+
- Testability
|
|
1475
|
+
|
|
1476
|
+
Send findings to team-lead when done.`,
|
|
1477
|
+
run_in_background: true
|
|
1478
|
+
})
|
|
1479
|
+
|
|
1480
|
+
// === STEP 3: Monitor and collect results ===
|
|
1481
|
+
// Poll inbox or wait for idle notifications
|
|
1482
|
+
// cat ~/.claude/teams/pr-review-123/inboxes/team-lead.json
|
|
1483
|
+
|
|
1484
|
+
// === STEP 4: Synthesize findings ===
|
|
1485
|
+
// Combine all reviewer findings into a cohesive report
|
|
1486
|
+
|
|
1487
|
+
// === STEP 5: Cleanup ===
|
|
1488
|
+
Teammate({ operation: "requestShutdown", target_agent_id: "security" })
|
|
1489
|
+
Teammate({ operation: "requestShutdown", target_agent_id: "perf" })
|
|
1490
|
+
Teammate({ operation: "requestShutdown", target_agent_id: "arch" })
|
|
1491
|
+
// Wait for approvals...
|
|
1492
|
+
Teammate({ operation: "cleanup" })
|
|
1493
|
+
```
|
|
1494
|
+
|
|
1495
|
+
### Workflow 2: Research → Plan → Implement → Test Pipeline
|
|
1496
|
+
|
|
1497
|
+
```javascript
|
|
1498
|
+
// === SETUP ===
|
|
1499
|
+
Teammate({ operation: "spawnTeam", team_name: "feature-oauth" })
|
|
1500
|
+
|
|
1501
|
+
// === CREATE PIPELINE ===
|
|
1502
|
+
TaskCreate({ subject: "Research OAuth providers", description: "Research OAuth2 best practices and compare providers (Google, GitHub, Auth0)", activeForm: "Researching OAuth..." })
|
|
1503
|
+
TaskCreate({ subject: "Create implementation plan", description: "Design OAuth implementation based on research findings", activeForm: "Planning..." })
|
|
1504
|
+
TaskCreate({ subject: "Implement OAuth", description: "Implement OAuth2 authentication according to plan", activeForm: "Implementing OAuth..." })
|
|
1505
|
+
TaskCreate({ subject: "Write tests", description: "Write comprehensive tests for OAuth implementation", activeForm: "Writing tests..." })
|
|
1506
|
+
TaskCreate({ subject: "Final review", description: "Review complete implementation for security and quality", activeForm: "Final review..." })
|
|
1507
|
+
|
|
1508
|
+
// Set dependencies
|
|
1509
|
+
TaskUpdate({ taskId: "2", addBlockedBy: ["1"] })
|
|
1510
|
+
TaskUpdate({ taskId: "3", addBlockedBy: ["2"] })
|
|
1511
|
+
TaskUpdate({ taskId: "4", addBlockedBy: ["3"] })
|
|
1512
|
+
TaskUpdate({ taskId: "5", addBlockedBy: ["4"] })
|
|
1513
|
+
|
|
1514
|
+
// === SPAWN SPECIALIZED WORKERS ===
|
|
1515
|
+
Task({
|
|
1516
|
+
team_name: "feature-oauth",
|
|
1517
|
+
name: "researcher",
|
|
1518
|
+
subagent_type: "compound-engineering:research:best-practices-researcher",
|
|
1519
|
+
prompt: "Claim task #1. Research OAuth2 best practices, compare providers, document findings. Mark task complete and send summary to team-lead.",
|
|
1520
|
+
run_in_background: true
|
|
1521
|
+
})
|
|
1522
|
+
|
|
1523
|
+
Task({
|
|
1524
|
+
team_name: "feature-oauth",
|
|
1525
|
+
name: "planner",
|
|
1526
|
+
subagent_type: "Plan",
|
|
1527
|
+
prompt: "Wait for task #2 to unblock. Read research from task #1. Create detailed implementation plan. Mark complete and send plan to team-lead.",
|
|
1528
|
+
run_in_background: true
|
|
1529
|
+
})
|
|
1530
|
+
|
|
1531
|
+
Task({
|
|
1532
|
+
team_name: "feature-oauth",
|
|
1533
|
+
name: "implementer",
|
|
1534
|
+
subagent_type: "general-purpose",
|
|
1535
|
+
prompt: "Wait for task #3 to unblock. Read plan from task #2. Implement OAuth2 authentication. Mark complete when done.",
|
|
1536
|
+
run_in_background: true
|
|
1537
|
+
})
|
|
1538
|
+
|
|
1539
|
+
Task({
|
|
1540
|
+
team_name: "feature-oauth",
|
|
1541
|
+
name: "tester",
|
|
1542
|
+
subagent_type: "general-purpose",
|
|
1543
|
+
prompt: "Wait for task #4 to unblock. Write comprehensive tests for the OAuth implementation. Run tests. Mark complete with results.",
|
|
1544
|
+
run_in_background: true
|
|
1545
|
+
})
|
|
1546
|
+
|
|
1547
|
+
Task({
|
|
1548
|
+
team_name: "feature-oauth",
|
|
1549
|
+
name: "reviewer",
|
|
1550
|
+
subagent_type: "compound-engineering:review:security-sentinel",
|
|
1551
|
+
prompt: "Wait for task #5 to unblock. Review the complete OAuth implementation for security. Send final assessment to team-lead.",
|
|
1552
|
+
run_in_background: true
|
|
1553
|
+
})
|
|
1554
|
+
|
|
1555
|
+
// Pipeline auto-progresses as each stage completes
|
|
1556
|
+
```
|
|
1557
|
+
|
|
1558
|
+
### Workflow 3: Self-Organizing Code Review Swarm
|
|
1559
|
+
|
|
1560
|
+
```javascript
|
|
1561
|
+
// === SETUP ===
|
|
1562
|
+
Teammate({ operation: "spawnTeam", team_name: "codebase-review" })
|
|
1563
|
+
|
|
1564
|
+
// === CREATE TASK POOL (all independent, no dependencies) ===
|
|
1565
|
+
const filesToReview = [
|
|
1566
|
+
"app/models/user.rb",
|
|
1567
|
+
"app/models/payment.rb",
|
|
1568
|
+
"app/controllers/api/v1/users_controller.rb",
|
|
1569
|
+
"app/controllers/api/v1/payments_controller.rb",
|
|
1570
|
+
"app/services/payment_processor.rb",
|
|
1571
|
+
"app/services/notification_service.rb",
|
|
1572
|
+
"lib/encryption_helper.rb"
|
|
1573
|
+
]
|
|
1574
|
+
|
|
1575
|
+
for (const file of filesToReview) {
|
|
1576
|
+
TaskCreate({
|
|
1577
|
+
subject: `Review ${file}`,
|
|
1578
|
+
description: `Review ${file} for security vulnerabilities, code quality, and performance issues`,
|
|
1579
|
+
activeForm: `Reviewing ${file}...`
|
|
1580
|
+
})
|
|
1581
|
+
}
|
|
1582
|
+
|
|
1583
|
+
// === SPAWN WORKER SWARM ===
|
|
1584
|
+
const swarmPrompt = `
|
|
1585
|
+
You are a swarm worker. Your job is to continuously process available tasks.
|
|
1586
|
+
|
|
1587
|
+
LOOP:
|
|
1588
|
+
1. Call TaskList() to see available tasks
|
|
1589
|
+
2. Find a task that is:
|
|
1590
|
+
- status: 'pending'
|
|
1591
|
+
- no owner
|
|
1592
|
+
- not blocked
|
|
1593
|
+
3. If found:
|
|
1594
|
+
- Claim it: TaskUpdate({ taskId: "X", owner: "YOUR_NAME" })
|
|
1595
|
+
- Start it: TaskUpdate({ taskId: "X", status: "in_progress" })
|
|
1596
|
+
- Do the review work
|
|
1597
|
+
- Complete it: TaskUpdate({ taskId: "X", status: "completed" })
|
|
1598
|
+
- Send findings to team-lead via Teammate write
|
|
1599
|
+
- Go back to step 1
|
|
1600
|
+
4. If no tasks available:
|
|
1601
|
+
- Send idle notification to team-lead
|
|
1602
|
+
- Wait 30 seconds
|
|
1603
|
+
- Try again (up to 3 times)
|
|
1604
|
+
- If still no tasks, exit
|
|
1605
|
+
|
|
1606
|
+
Replace YOUR_NAME with your actual agent name from $CLAUDE_CODE_AGENT_NAME.
|
|
1607
|
+
`
|
|
1608
|
+
|
|
1609
|
+
// Spawn 3 workers
|
|
1610
|
+
Task({ team_name: "codebase-review", name: "worker-1", subagent_type: "general-purpose", prompt: swarmPrompt, run_in_background: true })
|
|
1611
|
+
Task({ team_name: "codebase-review", name: "worker-2", subagent_type: "general-purpose", prompt: swarmPrompt, run_in_background: true })
|
|
1612
|
+
Task({ team_name: "codebase-review", name: "worker-3", subagent_type: "general-purpose", prompt: swarmPrompt, run_in_background: true })
|
|
1613
|
+
|
|
1614
|
+
// Workers self-organize: race to claim tasks, naturally load-balance
|
|
1615
|
+
// Monitor progress with TaskList() or by reading inbox
|
|
1616
|
+
```
|
|
1617
|
+
|
|
1618
|
+
---
|
|
1619
|
+
|
|
1620
|
+
## Best Practices
|
|
1621
|
+
|
|
1622
|
+
### 1. Always Cleanup
|
|
1623
|
+
Don't leave orphaned teams. Always call `cleanup` when done.
|
|
1624
|
+
|
|
1625
|
+
### 2. Use Meaningful Names
|
|
1626
|
+
```javascript
|
|
1627
|
+
// Good
|
|
1628
|
+
name: "security-reviewer"
|
|
1629
|
+
name: "oauth-implementer"
|
|
1630
|
+
name: "test-writer"
|
|
1631
|
+
|
|
1632
|
+
// Bad
|
|
1633
|
+
name: "worker-1"
|
|
1634
|
+
name: "agent-2"
|
|
1635
|
+
```
|
|
1636
|
+
|
|
1637
|
+
### 3. Write Clear Prompts
|
|
1638
|
+
Tell workers exactly what to do:
|
|
1639
|
+
```javascript
|
|
1640
|
+
// Good
|
|
1641
|
+
prompt: `
|
|
1642
|
+
1. Review app/models/user.rb for N+1 queries
|
|
1643
|
+
2. Check all ActiveRecord associations have proper includes
|
|
1644
|
+
3. Document any issues found
|
|
1645
|
+
4. Send findings to team-lead via Teammate write
|
|
1646
|
+
`
|
|
1647
|
+
|
|
1648
|
+
// Bad
|
|
1649
|
+
prompt: "Review the code"
|
|
1650
|
+
```
|
|
1651
|
+
|
|
1652
|
+
### 4. Use Task Dependencies
|
|
1653
|
+
Let the system manage unblocking:
|
|
1654
|
+
```javascript
|
|
1655
|
+
// Good: Auto-unblocking
|
|
1656
|
+
TaskUpdate({ taskId: "2", addBlockedBy: ["1"] })
|
|
1657
|
+
|
|
1658
|
+
// Bad: Manual polling
|
|
1659
|
+
"Wait until task #1 is done, check every 30 seconds..."
|
|
1660
|
+
```
|
|
1661
|
+
|
|
1662
|
+
### 5. Check Inboxes for Results
|
|
1663
|
+
Workers send results to your inbox. Check it:
|
|
1664
|
+
```bash
|
|
1665
|
+
cat ~/.claude/teams/{team}/inboxes/team-lead.json | jq '.'
|
|
1666
|
+
```
|
|
1667
|
+
|
|
1668
|
+
### 6. Handle Worker Failures
|
|
1669
|
+
- Workers have 5-minute heartbeat timeout
|
|
1670
|
+
- Tasks of crashed workers can be reclaimed
|
|
1671
|
+
- Build retry logic into worker prompts
|
|
1672
|
+
|
|
1673
|
+
### 7. Prefer write Over broadcast
|
|
1674
|
+
`broadcast` sends N messages for N teammates. Use `write` for targeted communication.
|
|
1675
|
+
|
|
1676
|
+
### 8. Match Agent Type to Task
|
|
1677
|
+
- **Explore** for searching/reading
|
|
1678
|
+
- **Plan** for architecture design
|
|
1679
|
+
- **general-purpose** for implementation
|
|
1680
|
+
- **Specialized reviewers** for specific review types
|
|
1681
|
+
|
|
1682
|
+
---
|
|
1683
|
+
|
|
1684
|
+
## Quick Reference
|
|
1685
|
+
|
|
1686
|
+
### Spawn Subagent (No Team)
|
|
1687
|
+
```javascript
|
|
1688
|
+
Task({ subagent_type: "Explore", description: "Find files", prompt: "..." })
|
|
1689
|
+
```
|
|
1690
|
+
|
|
1691
|
+
### Spawn Teammate (With Team)
|
|
1692
|
+
```javascript
|
|
1693
|
+
Teammate({ operation: "spawnTeam", team_name: "my-team" })
|
|
1694
|
+
Task({ team_name: "my-team", name: "worker", subagent_type: "general-purpose", prompt: "...", run_in_background: true })
|
|
1695
|
+
```
|
|
1696
|
+
|
|
1697
|
+
### Message Teammate
|
|
1698
|
+
```javascript
|
|
1699
|
+
Teammate({ operation: "write", target_agent_id: "worker-1", value: "..." })
|
|
1700
|
+
```
|
|
1701
|
+
|
|
1702
|
+
### Create Task Pipeline
|
|
1703
|
+
```javascript
|
|
1704
|
+
TaskCreate({ subject: "Step 1", description: "..." })
|
|
1705
|
+
TaskCreate({ subject: "Step 2", description: "..." })
|
|
1706
|
+
TaskUpdate({ taskId: "2", addBlockedBy: ["1"] })
|
|
1707
|
+
```
|
|
1708
|
+
|
|
1709
|
+
### Shutdown Team
|
|
1710
|
+
```javascript
|
|
1711
|
+
Teammate({ operation: "requestShutdown", target_agent_id: "worker-1" })
|
|
1712
|
+
// Wait for approval...
|
|
1713
|
+
Teammate({ operation: "cleanup" })
|
|
1714
|
+
```
|
|
1715
|
+
|
|
1716
|
+
---
|
|
1717
|
+
|
|
1718
|
+
*Based on Claude Code v2.1.19 - Tested and verified 2026-01-25*
|