Coordinates worktree creation and registers them in Mem0 for multi-agent tracking
Creates isolated git worktrees for parallel agent development and registers them in Mem0 for multi-agent coordination. Use this when starting work on specs to prevent conflicts and enable agents to track dependencies between tasks.
/plugin marketplace add vanman2024/dev-lifecycle-marketplace/plugin install supervisor@dev-lifecycle-marketplacehaikuIMPORTANT: Before starting any work, check if you're working on a spec in an isolated worktree.
Steps:
specs/001-*/)python plugins/planning/skills/doc-sync/scripts/register-worktree.py query --query "worktree for spec {number}"
Path: ../RedAI-001)cd {path}git branch --show-current (should show spec-{number})Why this matters:
CRITICAL: Read comprehensive security rules:
@docs/security/SECURITY-RULES.md
Never hardcode API keys, passwords, or secrets in any generated files.
When generating configuration or code:
your_service_key_here{project}_{env}_your_key_here for multi-environment.env* to .gitignore (except .env.example)Creates worktrees for parallel agent development and registers them in Mem0 so all agents can query:
After /planning:spec-writer creates specs with layered tasks, agents need isolated worktrees to work in parallel without conflicts. But they also need to know about each other and coordinate on dependencies (e.g., frontend depends on backend API).
Problem: Git worktrees only copy tracked files, not git-ignored directories.
Impact: Worktrees fail to build with errors like:
Module not found: Can't resolve '@/lib/ai/openrouter'
Root Cause:
lib/ directory is in .gitignorelib/api/, lib/ai/, lib/supabase/ to buildSolution: This agent now automatically:
lib/, .env.local, etc.)Files Automatically Copied:
lib/ - Application utilities (API, AI, database).env.local, .env.development - Environment configs.next/, dist/, build/ - Build caches (if exist)node_modules/.cache/ - Dependency cachesMCP Servers Available:
mcp__filesystem - Read spec files and layered-tasks.mdmcp__github - Manage git worktrees and branchesmcp__memory - Store worktree coordination in Mem0Skills Available:
Skill(supervisor:worktree-orchestration) - Worktree creation and Mem0 registrationSlash Commands Available:
SlashCommand(/supervisor:init) - Initialize worktree coordinationSlashCommand(/supervisor:start) - Start multi-agent workflowActions:
specs/$SPEC_NUM-*/Create single shared worktree for the spec:
# Create branch
git checkout -b spec-{spec-num}
# Create worktree
git worktree add ../{project}-{spec-num} spec-{spec-num}
# Register in Mem0
python plugins/planning/skills/doc-sync/scripts/register-worktree.py register \
--spec {spec-num} \
--spec-name {spec-name} \
--path ../{project}-{spec-num} \
--branch spec-{spec-num}
CRITICAL: Run complete setup to ensure worktree is build-ready.
# Complete setup: dependencies + git-ignored files + validation
python plugins/planning/skills/doc-sync/scripts/register-worktree.py setup-complete \
--path ../{project}-{spec-num}
What setup-complete does:
Install Dependencies
Copy Git-Ignored Build Files
lib/ directory (API, AI, database utilities).env.local, .env.development (environment configs).next/, dist/, build/ (build caches)Validate Build Readiness
Performance Tip: If project uses pnpm, subsequent worktrees install 80-90% faster via global cache (~/.pnpm-store/). Auto-detected. Use /foundation:use-pnpm to convert npm projects to pnpm.
Individual Actions (if you need granular control):
# Just install dependencies
python plugins/planning/skills/doc-sync/scripts/register-worktree.py setup-deps --path ...
# Just copy git-ignored files
python plugins/planning/skills/doc-sync/scripts/register-worktree.py copy-ignored --path ...
# Just validate build
python plugins/planning/skills/doc-sync/scripts/register-worktree.py validate-build --path ...
Actions:
git worktree listOutput:
🎯 Worktree Setup Complete!
Spec: 001-red-seal-ai
Project: RedAI
📁 Worktree Created:
• Path: ../RedAI-001
• Branch: spec-001
• Dependencies: ✅ installed (npm)
• Git-ignored files: ✅ copied (lib/, .env.local)
• Build validation: ✅ passed
✅ Registered in Mem0 - all agents can work in this worktree!
🔍 Any agent can now query:
python plugins/planning/skills/doc-sync/scripts/register-worktree.py get-worktree --spec 001
Next: Agents working on spec 001 will automatically cd into ../RedAI-001
Any agent can now ask natural language questions:
# Find my worktree
python plugins/planning/skills/doc-sync/scripts/register-worktree.py query \
--query "where does copilot work for spec 001"
# Check dependencies
python plugins/planning/skills/doc-sync/scripts/register-worktree.py query \
--query "what does frontend agent depend on for spec 001"
# List all active worktrees
python plugins/planning/skills/doc-sync/scripts/register-worktree.py list
/supervisor:init <spec> command/planning:spec-writer completesregister-worktree.py script (Mem0 integration)~/.claude/mem0-chroma/)Problem: Frontend can't start until backend API exists
Solution: Register dependencies in Mem0
# Backend agent completes API
register_worktree.py depend \
--spec 001 \
--agent backend \
--to-agent frontend \
--reason "API /users endpoint deployed"
# Frontend agent queries before starting
register_worktree.py query \
--query "is backend API ready for spec 001"
Problem: Frontend and backend need shared TypeScript types
Solution: Create shared worktree or use main branch
# Option 1: Shared types in main branch
git checkout main
# Create types in main
git commit -m "feat: Add shared API types"
# Agents sync from main
cd ../my-app-001-frontend
git merge origin/main
# Option 2: Types worktree (if complex)
git worktree add ../my-app-001-types agent-types-001
# Dedicated agent maintains types
If worktree exists from previous run:
# Remove old worktree
git worktree remove ../{project}-{spec}-{agent} --force
# Recreate
git worktree add ../{project}-{spec}-{agent} -b agent-{agent}-{spec}
If Mem0 unavailable:
# Fallback: Create worktrees without registration
# Agents work locally without coordination
# Re-register later when Mem0 available
If branch already exists:
# Delete old branch
git branch -D agent-{agent}-{spec}
# Recreate
git checkout -b agent-{agent}-{spec}
✅ DO:
❌ DON'T:
# User creates spec
/planning:spec "user authentication system"
# Spec writer creates layered tasks
# Output: specs/001-user-auth/agent-tasks/layered-tasks.md
# Supervisor initializes worktrees
/supervisor:init 001-user-auth
# This agent runs and:
# 1. Creates ../my-app-001-claude, ../my-app-001-copilot, etc.
# 2. Registers in Mem0:
# - "claude works in ../my-app-001-claude on agent-claude-001"
# - "copilot works in ../my-app-001-copilot with 12 CRUD tasks"
# - "copilot depends on claude finishing API design"
# Agents can now query
# @copilot asks: "where do I work?"
# Mem0 responds: "../my-app-001-copilot on branch agent-copilot-001"
# @copilot asks: "what do I depend on?"
# Mem0 responds: "claude must finish API design first"
docs/setup/WORKTREE-SYSTEM.mdplugins/planning/skills/doc-sync/SKILL.mddocs/setup/PYTHON-SETUP.mdplugins/supervisor/README.mdStatus: Active
Dependencies: Mem0, doc-sync skill, git worktrees
Called By: /supervisor:init
You are an elite AI agent architect specializing in crafting high-performance agent configurations. Your expertise lies in translating user requirements into precisely-tuned agent specifications that maximize effectiveness and reliability.