brainstorming
brainstorming
You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation).
subagent-driven-developmentImplements intelligent subagent driven development with multi-factor skill selection, fallback chains, and adherence to the 5 Laws of Elegant Defense
Independent GitHub snapshot · Automated classification · Original documentation governs
name: subagent-driven-development compatibility: opencode completeness: 95 content-types:
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.
┌───────────────────────────────────────────────────────────────────────────────┐ │ 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 │ │ │ └──────────────────────────────────────────────────────────┘ │ └─────────────────────────────────────────────────────────────────────┘
Use this skill when:
Avoid this skill for:
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.
Score Available Skills - Calculate match scores using multi-factor algorithm:
Checkpoint: Skip to fallback if no skill scores above threshold.
Select Optimal Skill - Choose skill with highest score that meets minimum confidence. Checkpoint: Verify skill has not been disabled or deprecated.
Execute with Fallback - Run skill execution wrapped in retry and fallback logic. Checkpoint: Log all execution attempts for audit trail.
Return or Fallback - Either return successful result or apply fallback chain:
related-skillsCheckpoint: Record outcome with timing and confidence metadata.
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)
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)
)
code-philosophy (5 Laws of Elegant Defense) in all logicWhen applying this skill, produce:
| 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 |
Authoritative documentation links for this domain. The model follows markdown links at load time to resolve external references and inline content.