Skip to main content

GOAP Plan Execution Commands

Immediate Execution Steps (Copy-Paste Ready)

Step 1: Initialize Swarm (Mesh Topology for Coordination)

# Run this first to set up coordination topology
npx claude-flow@alpha hooks pre-task --description "Initialize mesh swarm for AI agent v2 development"

Step 2: Create Memory Namespaces

# Set up isolated memory spaces for each phase
npx claude-flow@alpha memory store swarm/ai-agent-v2/status "Phase 0: Planning Complete" --namespace "ai-agent-v2"
npx claude-flow@alpha memory store swarm/ai-agent-v2/phase "foundation" --namespace "ai-agent-v2"
npx claude-flow@alpha memory store swarm/ai-agent-v2/session-id "swarm_1764655531178_udtox74dx" --namespace "ai-agent-v2"

Step 3: Launch Phase 1 (Foundation) - 4 Parallel Agents

Use Claude Code’s Task tool to spawn these agents IN A SINGLE MESSAGE:

Task 1 - "Research Agent: Task Planner"
Description: "Create task-planner.js module following SPARC methodology.
SPECIFICATION (2h): Define intent taxonomy (ADD, UPDATE, DELETE, SEARCH, QUERY, ANALYZE), action generation pipeline, and dependency resolution.
PSEUDOCODE (1h): Write algorithms for intent classification, action sequencing, and dependency graph building.
ARCHITECTURE (1h): Design IntentClassifier, ActionGenerator, and DependencyResolver classes with memory system integration.
REFINEMENT (2h): Implement TDD with tests for intent classification (>85% accuracy), action sequence generation, and dependency resolution.
COMPLETION (1h): Integrate with existing agent, add error handling and logging.
Store all decisions in memory namespace 'ai-agent-v2/task-planner'.
Run hooks: pre-task, post-edit for each file, post-task when complete."

Task 2 - "Coder Agent: Change Preview"
Description: "Create change-preview.js module following SPARC methodology.
SPECIFICATION (1h): Define diff generation strategies, preview formatting, and approval mechanism.
PSEUDOCODE (1h): Write algorithms for file diffing, syntax-aware formatting, and preview rendering.
ARCHITECTURE (1h): Design DiffGenerator, PreviewFormatter, ApprovalHandler classes.
REFINEMENT (1h): TDD with tests for accurate diffs, readable formatting, and approval workflow.
COMPLETION (1h): CLI integration and user feedback mechanisms.
Store decisions in 'ai-agent-v2/change-preview'.
Run hooks throughout."

Task 3 - "Coder Agent: Ruvector Bridge"
Description: "Create ruvector-bridge.js module following SPARC methodology.
SPECIFICATION (1h): Define bridge API, semantic search integration, graph query patterns.
PSEUDOCODE (1h): Write bridge initialization, search adapter, graph adapter, recommendation engine.
ARCHITECTURE (1h): Design RuvectorBridge class with adapter pattern, result normalization.
REFINEMENT (1h): TDD with tests for semantic search, graph queries, contextual recommendations.
COMPLETION (1h): Performance optimization and caching layer.
Store decisions in 'ai-agent-v2/ruvector-bridge'.
Run hooks throughout."

Task 4 - "Code Analyzer Agent: Site Context"
Description: "Create site-context.js module following SPARC methodology.
SPECIFICATION (1h): Define site structure analysis, schema detection, context caching.
PSEUDOCODE (1h): Write site crawler, schema detector, context builder algorithms.
ARCHITECTURE (1h): Design SiteAnalyzer, SchemaDetector, ContextCache classes.
REFINEMENT (1h): TDD with tests for structure detection, schema identification, efficient caching.
COMPLETION (1h): Incremental updates and change detection.
Store decisions in 'ai-agent-v2/site-context'.
Run hooks throughout."

Step 4: Monitor Phase 1 Progress

# Check coordination status
npx claude-flow@alpha hooks session-restore --session-id "swarm_1764655531178_udtox74dx"

# Check memory for updates
npx claude-flow@alpha memory list --namespace "ai-agent-v2"

# View metrics
npx claude-flow@alpha metrics

Step 5: Phase 1 Checkpoint

Once all Phase 1 agents complete, verify:

# Check files exist
ls -la ai-agent-simple/task-planner.js
ls -la ai-agent-simple/change-preview.js
ls -la ai-agent-simple/ruvector-bridge.js
ls -la ai-agent-simple/site-context.js

# Run tests (if created)
npm test -- --grep "task-planner"
npm test -- --grep "change-preview"
npm test -- --grep "ruvector-bridge"
npm test -- --grep "site-context"

# Update phase in memory
npx claude-flow@alpha memory store swarm/ai-agent-v2/phase "specialization" --namespace "ai-agent-v2"

Phase 2: Specialization (5 Parallel Agents)

Launch after Phase 1 completes:

Task 5 - "Research Agent: Intent Classifier"
Description: "Implement intent classification in task-planner.js.
Build NLP intent detection for ADD, UPDATE, SEARCH, QUERY intents.
Target >85% classification accuracy.
Use pattern matching and entity extraction.
Test with 100+ example inputs.
Store patterns in 'ai-agent-v2/task-planner/intents'."

Task 6 - "Coder Agent: Diff Generator"
Description: "Implement diff generation in change-preview.js.
Create file content → visual diff algorithm.
Use unified diff format with syntax highlighting.
Support all file types (HTML, CSS, JS, JSON).
Store diff strategies in 'ai-agent-v2/change-preview/diffs'."

Task 7 - "Coder Agent: Search Integration"
Description: "Implement search adapter in ruvector-bridge.js.
Integrate semantic search with ruvector.
Vectorize queries and re-rank by context.
Test relevance score >0.7.
Store search configs in 'ai-agent-v2/ruvector-bridge/search'."

Task 8 - "Coder Agent: Graph Integration"
Description: "Implement graph adapter in ruvector-bridge.js.
Integrate graph queries for page relationships.
Support traversal and path finding.
Store graph patterns in 'ai-agent-v2/ruvector-bridge/graph'."

Task 9 - "Code Analyzer Agent: Site Structure Analysis"
Description: "Implement structure analyzer in site-context.js.
Crawl project to identify pages, components, assets.
Build dependency tree.
Cache structure with change detection.
Store analysis in 'ai-agent-v2/site-context/structure'."

Phase 3: Advanced Features (4 Parallel Agents)

Launch after Phase 2 completes:

Task 10 - "Coder Agent: Action Generator"
Description: "Implement action sequencing in task-planner.js.
Convert intents → ordered action sequences.
Resolve dependencies between actions.
Estimate costs for each action.
Store action templates in 'ai-agent-v2/task-planner/actions'."

Task 11 - "Coder Agent: Preview Formatter"
Description: "Implement preview formatting in change-preview.js.
Transform diffs → user-friendly output.
Add color coding and context lines.
Support side-by-side and unified views.
Store formatting configs in 'ai-agent-v2/change-preview/format'."

Task 12 - "Coder Agent: Recommendations"
Description: "Implement recommendation engine in ruvector-bridge.js.
Use semantic search + graph queries.
Provide contextual suggestions.
Boost by recency and working set.
Store recommendation logic in 'ai-agent-v2/ruvector-bridge/recommendations'."

Task 13 - "Code Analyzer Agent: Schema Detector"
Description: "Implement schema detection in site-context.js.
Identify content patterns (blog posts, products, etc.).
Extract schema from existing content.
Support schema-based generation.
Store schemas in 'ai-agent-v2/site-context/schemas'."

Phase 4: Workflow Integration (Sequential)

Launch after Phase 3 completes:

Task 14 - "System Architect Agent: Approval Workflow"
Description: "Create approval-workflow.js module following SPARC.
Implement workflow states: DRAFT, PREVIEW, APPROVED, REJECTED, EXECUTING, COMPLETE, FAILED, ROLLED_BACK.
Design state transition rules and validation.
Implement snapshot/rollback mechanism.
Create event emission system.
Run full SPARC cycle (5h).
Store workflow in 'ai-agent-v2/approval-workflow'."

Task 15 - "System Architect Agent: State Machine"
Description: "Implement WorkflowStateMachine class in approval-workflow.js.
Build state transition validator.
Implement snapshot taking and restoration.
Add pre/post transition hooks.
Create comprehensive state machine tests.
Store state configs in 'ai-agent-v2/approval-workflow/states'."

Phase 5: System Integration (Single Agent)

Launch after Phase 4 completes:

Task 16 - "System Architect Agent: Module Integration"
Description: "Integrate all modules in ai-agent-simple/index.js.
Wire up: task-planner → change-preview → approval-workflow.
Connect ruvector-bridge and site-context as dependencies.
Implement end-to-end user flows:
  1. User request → Intent classification → Action generation
  2. Actions → Preview generation → User approval
  3. Approval → Execution with rollback safety
Create integration tests for all flows.
Store integration patterns in 'ai-agent-v2/integration'."

Phase 6: Quality Assurance (5 Parallel Agents)

Launch after Phase 5 completes:

Task 17 - "Tester Agent: Test Task Planner"
Description: "Create comprehensive test suite for task-planner.js in tests/.
Test intent classification with 100+ examples.
Test action generation for all intent types.
Test dependency resolution.
Achieve >80% code coverage.
Store test cases in 'ai-agent-v2/tests/task-planner'."

Task 18 - "Tester Agent: Test Change Preview"
Description: "Create comprehensive test suite for change-preview.js.
Test diff generation for all file types.
Test preview formatting (unified, side-by-side).
Test approval mechanism.
Achieve >80% code coverage."

Task 19 - "Tester Agent: Test Ruvector Bridge"
Description: "Create comprehensive test suite for ruvector-bridge.js.
Test semantic search with mock vectors.
Test graph queries and traversal.
Test recommendation relevance.
Achieve >80% code coverage."

Task 20 - "Tester Agent: Test Site Context"
Description: "Create comprehensive test suite for site-context.js.
Test structure analysis with mock projects.
Test schema detection on various content types.
Test context caching and invalidation.
Achieve >80% code coverage."

Task 21 - "Tester Agent: Test Approval Workflow"
Description: "Create comprehensive test suite for approval-workflow.js.
Test all state transitions (valid and invalid).
Test snapshot and rollback mechanisms.
Test event emission.
Achieve >80% code coverage."

Phase 7: Documentation (Single Agent)

Launch after Phase 6 completes:

Task 22 - "API Docs Agent: Write Documentation"
Description: "Create comprehensive documentation in docs/.
Write API reference for all modules.
Create user guide with examples for each intent type.
Generate architecture diagrams (mermaid).
Write troubleshooting guide for common issues.
Create example gallery demonstrating all features.
Store docs in 'ai-agent-v2/documentation'."

Checkpoint Commands (Run after each phase)

After Phase 1

npx claude-flow@alpha memory store swarm/ai-agent-v2/milestone "Foundation Complete" --namespace "ai-agent-v2"
npx claude-flow@alpha hooks notify --message "Phase 1 Foundation complete: 4 core modules created"

After Phase 2

npx claude-flow@alpha memory store swarm/ai-agent-v2/milestone "Specialization Complete" --namespace "ai-agent-v2"
npx claude-flow@alpha hooks notify --message "Phase 2 Specialization complete: 5 sub-modules implemented"

After Phase 3

npx claude-flow@alpha memory store swarm/ai-agent-v2/milestone "Advanced Features Complete" --namespace "ai-agent-v2"
npx claude-flow@alpha hooks notify --message "Phase 3 Advanced complete: 4 enhancement modules added"

After Phase 4

npx claude-flow@alpha memory store swarm/ai-agent-v2/milestone "Workflow Integration Complete" --namespace "ai-agent-v2"
npx claude-flow@alpha hooks notify --message "Phase 4 Workflow complete: Approval system operational"

After Phase 5

npx claude-flow@alpha memory store swarm/ai-agent-v2/milestone "System Integration Complete" --namespace "ai-agent-v2"
npx claude-flow@alpha hooks notify --message "Phase 5 Integration complete: All modules connected"

After Phase 6

npx claude-flow@alpha memory store swarm/ai-agent-v2/milestone "Quality Assurance Complete" --namespace "ai-agent-v2"
npx claude-flow@alpha hooks notify --message "Phase 6 QA complete: All tests passing"

After Phase 7 (FINAL)

npx claude-flow@alpha memory store swarm/ai-agent-v2/milestone "Documentation Complete - GOAL ACHIEVED" --namespace "ai-agent-v2"
npx claude-flow@alpha hooks post-task --task-id "ai-agent-v2-goap-plan"
npx claude-flow@alpha hooks session-end --export-metrics true

Emergency Commands

If an agent gets stuck

# Check agent status
npx claude-flow@alpha agent list

# Check last memory update
npx claude-flow@alpha memory list --namespace "ai-agent-v2" | tail -20

# Respawn agent with same task
# (Use Task tool with updated instructions)

If coordination breaks

# Reset coordination
npx claude-flow@alpha hooks session-end --export-metrics false
npx claude-flow@alpha hooks pre-task --description "Resume AI agent v2 development"

# Restore from memory
npx claude-flow@alpha hooks session-restore --session-id "swarm_1764655531178_udtox74dx"

If tests fail

# Run individual module tests
npm test -- --grep "module-name"

# Check test coverage
npm run test:coverage

# View detailed errors
npm test -- --reporter spec

Success Validation

After all phases complete, verify:

# 1. All files exist
ls -la ai-agent-simple/*.js
ls -la tests/*.test.js
ls -la docs/

# 2. All tests pass
npm test

# 3. Test coverage >80%
npm run test:coverage

# 4. Try end-to-end flow
node ai-agent-simple/index.js --request "Add a new blog post about AI to the website"
# Should output: intent, actions, preview, prompt for approval

# 5. Check memory for completion
npx claude-flow@alpha memory get swarm/ai-agent-v2/milestone --namespace "ai-agent-v2"
# Should show: "Documentation Complete - GOAL ACHIEVED"

READY TO EXECUTE

The plan is complete and ready for execution. Start with Step 1 (Initialize Swarm) and proceed through each phase systematically.

Estimated completion: 7 days (36 hours wall clock time with parallelism)

Next command to run:

npx claude-flow@alpha hooks pre-task --description "Initialize mesh swarm for AI agent v2 development"