Optimal multi-agent coordination strategies for the rails-architect
Optimizes multi-agent coordination for Rails workflows by deciding parallel vs sequential execution based on task dependencies. Auto-invokes only for rails-architect agent to maximize efficiency and prevent race conditions during complex feature implementation.
/plugin marketplace add nbarthel/claudy/plugin install rails-workflow@claudyThis skill inherits all available tools. When active, it can use any tool Claude has access to.
Provides optimal coordination strategies for multi-agent Rails workflows.
For Rails Architect:
Auto-invokes: Only for rails-architect agent Purpose: Optimize agent coordination for efficiency
When to use:
Example:
Feature: Blog with posts and comments
Parallel execution:
├── Agent 1: Create Post model
└── Agent 2: Create Comment model
Both can start immediately (independent models)
Pattern:
Task tool invocations:
1. Invoke rails-model-specialist (Post) - don't wait
2. Invoke rails-model-specialist (Comment) - don't wait
3. Wait for both completions
4. Proceed with next phase
Benefits:
When to use:
Example:
Feature: API endpoint for posts
Sequential execution:
1. Create Post model (needed by controller)
2. Wait for completion
3. Create PostsController (uses Post model)
4. Wait for completion
5. Create tests (test both model + controller)
Pattern:
Task tool invocations:
1. Invoke rails-model-specialist (Post)
2. Wait for completion
3. Invoke rails-controller-specialist (uses Post)
4. Wait for completion
5. Invoke rails-test-specialist
Benefits:
When to use:
Example:
Feature: Complete e-commerce order flow
Phase 1 (Parallel):
├── Create Order model
├── Create OrderItem model
└── Create Product model (if needed)
Phase 2 (Sequential after Phase 1):
├── Create OrderProcessingService (needs Order, OrderItem, Product)
Phase 3 (Parallel):
├── Create OrdersController
└── Create API serializers
Phase 4 (Sequential):
└── Create comprehensive tests
Pattern:
# Phase 1
parallel_invoke([
rails-model-specialist(Order),
rails-model-specialist(OrderItem),
rails-model-specialist(Product)
])
wait_all()
# Phase 2
invoke(rails-service-specialist(OrderProcessingService))
wait()
# Phase 3
parallel_invoke([
rails-controller-specialist(OrdersController),
rails-view-specialist(Serializers)
])
wait_all()
# Phase 4
invoke(rails-test-specialist(ComprehensiveTests))
Benefits:
1. Model Dependencies:
User model → Post model (belongs_to :user)
Post model → Comment model (has_many :comments)
Order: User → Post → Comment (sequential)
2. Controller Dependencies:
Model exists → Controller can be created
Routes defined → Controller actions valid
Order: Model → Controller (sequential)
3. View Dependencies:
Controller exists → Views can reference actions
Model exists → Views can access attributes
Order: Model + Controller → Views (sequential after both)
4. Test Dependencies:
Implementation exists → Tests can be written
Order: Feature implementation → Tests (sequential)
Exception: TDD approach inverts this (tests first)
Automatic detection:
# Code analysis
class Post < ApplicationRecord
belongs_to :user # Depends on User model
end
# Architect detects:
# - User model must exist before Post
# - Sequential: User → Post
Manual specification:
User specifies: "Create Order with OrderItems"
Architect infers:
- OrderItem references Order (foreign key)
- Order must be created first
- Sequential: Order → OrderItem
Scenario: Agent fails with correctable error
Strategy:
1. Agent fails (e.g., missing gem)
2. Analyze error message
3. Apply fix (add gem to Gemfile)
4. Retry same agent
5. Success
Max retries: 3 per agent
Scenario: Agent fails, different approach needed
Strategy:
1. Agent fails (e.g., complex service object too ambitious)
2. Analyze failure reason
3. Switch to simpler pattern (extract to concern instead)
4. Invoke different agent or modify parameters
5. Success
Scenario: Agent fails, feature can be partial
Strategy:
1. Core agent succeeds (Model created)
2. Enhancement agent fails (Serializer generation)
3. Decision: Ship core functionality
4. Log TODO for enhancement
5. Continue with partial implementation
Problem: Agent B needs info from Agent A
Solution 1: File system state
1. Agent A creates Model file
2. Agent B reads Model file
3. Agent B uses Model info (class name, associations)
Solution 2: Explicit parameter passing
1. Agent A returns: { model_name: "Post", attributes: [...] }
2. Architect stores in context
3. Agent B receives context: create_controller(context[:model_name])
Problem: Two agents modify same file
Solution: Sequential execution
Scenario: Two agents both need to modify routes.rb
Wrong (parallel):
├── Agent A: adds posts routes
└── Agent B: adds comments routes
Result: Race condition, lost changes
Correct (sequential):
1. Agent A: adds posts routes
2. Wait for completion
3. Agent B: adds comments routes (reads latest routes.rb)
Result: Both changes preserved
Don't over-parallelize:
Bad: Spawn 10 agents simultaneously
- Resource contention
- Harder to debug
- Diminishing returns
Good: Spawn 2-3 agents per phase
- Manageable
- Clear progress
- Easier error tracking
Sequential baseline:
7 agents × 5 min each = 35 min total
With optimal parallelism:
Phase 1: 2 agents parallel = 5 min
Phase 2: 3 agents parallel = 5 min
Phase 3: 2 agents parallel = 5 min
Total: 15 min (2.3x faster)
# .agent-coordination.yml
execution:
max_parallel_agents: 3
retry_limit: 3
timeout_per_agent: 300 # 5 min
dependencies:
auto_detect: true
strict_ordering: false
error_recovery:
retry_on_failure: true
alternative_approaches: true
graceful_degradation: true
This skill helps the architect coordinate agents efficiently for fast, reliable implementations.
This skill should be used when the user asks to "create a slash command", "add a command", "write a custom command", "define command arguments", "use command frontmatter", "organize commands", "create command with file references", "interactive command", "use AskUserQuestion in command", or needs guidance on slash command structure, YAML frontmatter fields, dynamic arguments, bash execution in commands, user interaction patterns, or command development best practices for Claude Code.
This skill should be used when the user asks to "create an agent", "add an agent", "write a subagent", "agent frontmatter", "when to use description", "agent examples", "agent tools", "agent colors", "autonomous agent", or needs guidance on agent structure, system prompts, triggering conditions, or agent development best practices for Claude Code plugins.
This skill should be used when the user asks to "create a hook", "add a PreToolUse/PostToolUse/Stop hook", "validate tool use", "implement prompt-based hooks", "use ${CLAUDE_PLUGIN_ROOT}", "set up event-driven automation", "block dangerous commands", or mentions hook events (PreToolUse, PostToolUse, Stop, SubagentStop, SessionStart, SessionEnd, UserPromptSubmit, PreCompact, Notification). Provides comprehensive guidance for creating and implementing Claude Code plugin hooks with focus on advanced prompt-based hooks API.