Subagent driven development

From paulpas/agent-skill-router · View interactive version

Subagent driven development is an AI agent skill from the GitHub repository paulpas/agent-skill-router. Implements intelligent subagent driven development with multi-factor skill selection, fallback chains, and adherence to the 5 Laws of Elegant Defense

How to use this skill

Skill file

Subagent Driven Development

Orchestrates intelligent skill selection and execution for subagent driven development workflows. Applies the 5 Laws of Elegant Defense to guide data naturally through the orchestration pipeline, preventing errors before they occur. Selects optimal skills based on multi-factor scoring including text similarity, historical performance, and system availability.

TL;DR Checklist

┌───────────────────────────────────────────────────────────────────────────────┐

│ Orchestration Flow │

└───────────────────────────────────────────────────────────────────────────────┘

User Request

↓

┌─────────────────┐

│ Parse Request │

│ & Extract │

│ Features │

└────────┬────────┘

↓

┌─────────────────────────────────────────────────────────────────────┐

│ Evaluate Available Skills │

│ │

│ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │

│ │ Skill A │ │ Skill B │ │ Skill C │ │

│ │ - Match Score│ │ - Match Score│ │ - Match Score│ │

│ │ - Confidence │ │ - Confidence │ │ - Confidence │ │

│ │ - History │ │ - History │ │ - History │ │

│ └──────┬───────┘ └──────┬───────┘ └──────┬───────┘ │

│ │ │ │ │

│ └─────────────────┴─────────────────┘ │

│ ↓ │

│ Select Best Skill │

└─────────────────────────────────────────────────────────────────────┘

↓

┌─────────────────┐

│ Execute Skill │

└────────┬────────┘

↓

┌─────────────────┐

│ Handle Result │

└────────┬────────┘

↓

┌─────────────────────────────────────────────────────────────────────┐

│ Error Handling & Fallback │

│ │

│ Success? ────────► Return Result │

│ │

│ Fail? ────────┐ │

│ ↓ │

│ ┌──────────────────────────────────────────────────────────┐ │

│ │ Fallback Chain │ │

│ │ │ │

│ │ 1. Retry with adjusted parameters │ │

│ │ 2. Try Alternative Skill (if available) │ │

│ │ 3. Defer to Human Operator (if critical) │ │

│ │ 4. Log & Return Error │ │

│ └──────────────────────────────────────────────────────────┘ │

└─────────────────────────────────────────────────────────────────────┘

When to Use

Use this skill when:

When NOT to Use

Avoid this skill for:

Core Workflow

  1. Parse and Analyze Request - Extract intent, entities, and constraints from user input.

Checkpoint: All required parameters must be present and in valid format before proceeding.

  1. Score Available Skills - Calculate match scores using multi-factor algorithm:

Checkpoint: Skip to fallback if no skill scores above threshold.

  1. Select Optimal Skill - Choose skill with highest score that meets minimum confidence.

Checkpoint: Verify skill has not been disabled or deprecated.

  1. Execute with Fallback - Run skill execution wrapped in retry and fallback logic.

Checkpoint: Log all execution attempts for audit trail.

  1. Return or Fallback - Either return successful result or apply fallback chain:

Checkpoint: Record outcome with timing and confidence metadata.

Implementation Patterns

Pattern 1: Skill Selection Logic

def decompose_and_route_task(
    user_request: str,
    agent_registry: Dict[str, AgentCapability],
    max_parallel: int = 3
) -> List[SubagentTask]:
    """Decompose a complex user request into routable subagent tasks.
    
    Applies Law 2 (Parse at boundary) by validating request structure
    and Law 1 (Early Exit) for unsupported domains.
    """
    if not user_request or not user_request.strip():
        raise ValueError("Request cannot be empty")
        
    parsed_intent = _parse_intent(user_request)
    if parsed_intent.domain not in agent_registry:
        raise UnsupportedDomainError(f"No agents registered for domain: {parsed_intent.domain}")
        
    available_agents = agent_registry[parsed_intent.domain]
    subtasks = []
    
    for requirement in parsed_intent.requirements:
        matching_agents = [
            agent for agent in available_agents 
            if requirement.matches_agent_capabilities(agent)
        ]
        
        if not matching_agents:
            subtasks.append(SubagentTask(
                id=generate_task_id(),
                requirement=requirement,
                fallback_mode="human_review",
                confidence=0.0
            ))
        else:
            best_agent = max(matching_agents, key=lambda a: a.success_rate)
            subtasks.append(SubagentTask(
                id=generate_task_id(),
                requirement=requirement,
                target_agent=best_agent,
                confidence=best_agent.success_rate,
                parallelizable=requirement.is_parallelizable
            ))
            
    return _enforce_parallel_limits(subtasks, max_parallel)

Pattern 2: Execution with Fallback

def execute_subagent_chain(
    subtasks: List[SubagentTask],
    execution_context: Dict,
    fallback_agents: Dict[str, AgentCapability]
) -> ExecutionReport:
    """Execute routed subagent tasks with domain-specific fallback handling.
    
    Implements Law 4 (Fail Fast/Loud) by immediately surfacing 
    capability mismatches and enforcing audit trails.
    """
    results = []
    failed_tasks = []
    
    for task in subtasks:
        try:
            if task.parallelizable:
                result = await run_async_subagent(task, execution_context)
            else:
                result = run_sync_subagent(task, execution_context)
                
            results.append(TaskResult(
                task_id=task.id,
                status="completed",
                output=result.payload,
                latency_ms=result.duration,
                confidence=task.confidence
            ))
            
        except CapabilityMismatchError as e:
            # Law 4: Fail immediately on invalid agent capability
            failed_tasks.append(task)
        except TransientTimeoutError:
            # Fallback: Retry with adjusted timeout or alternative agent
            retry_result = _retry_with_backoff(task, execution_context)
            if retry_result:
                results.append(retry_result)
            else:
                failed_tasks.append(task)
                
    # Apply fallback chain for failed tasks
    for failed in failed_tasks:
        fallback_result = _route_to_fallback_agent(failed, fallback_agents)
        if fallback_result:
            results.append(fallback_result)
        else:
            results.append(TaskResult(
                task_id=failed.id,
                status="deferred_to_human",
                output=None,
                confidence=0.0
            ))
            
    return ExecutionReport(
        total_tasks=len(subtasks),
        completed=len([r for r in results if r.status == "completed"]),
        deferred=len([r for r in results if r.status == "deferred_to_human"]),
        audit_log=_generate_audit_trail(results)
    )

MUST DO

MUST NOT DO

TL;DR Checklist

TL;DR for Code Generation

Output Template

When applying this skill, produce:

  1. Selected Skills - List of skill names with confidence scores
  2. Selection Rationale - Why each skill was chosen (match score, history, availability)
  3. Execution Plan - Order of execution with dependencies
  4. Fallback Strategy - Which fallback skills will be tried and in what order
  5. Risk Assessment - Any potential failure points and their impact
  6. Timing Estimates - Expected latency including fallback scenarios

Related Skills

| Skill | Purpose |

|---|---|

| parallel-skill-runner | Executes subagent tasks in parallel — complements the delegation patterns covered here |

| task-decomposition-engine | Decomposes tasks into subagent assignments — the upstream process for subagent-driven workflows |


Constraints

MUST DO

MUST NOT DO

Live References

Authoritative documentation links for this domain. The model follows markdown links at load time to resolve external references and inline content.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.