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).
skill-scannerImplements intelligent skill scanner 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: skill-scanner compatibility: opencode completeness: 95 content-types:
Orchestrates intelligent skill selection and execution for skill scanner 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 scan_and_route_task(task_input: str, skill_registry: dict) -> dict:
"""Scan available skills and route task to the best matching handler.
Implements multi-factor scoring: trigger overlap, historical success, and dependency health.
"""
# Parse and normalize input
normalized_task = task_input.strip().lower()
if not normalized_task:
raise ValueError("Empty task input provided to scanner")
# Extract semantic features for matching
task_tokens = set(normalized_task.split())
candidates = []
for skill_name, metadata in skill_registry.items():
# Calculate trigger overlap score
skill_triggers = set(t.lower() for t in metadata.get("triggers", []))
overlap = len(task_tokens & skill_triggers) / max(len(task_tokens), len(skill_triggers))
# Factor in historical success rate
history_score = metadata.get("success_rate", 0.0) * 0.4
# Factor in dependency health
deps_healthy = all(
skill_registry.get(dep, {}).get("status") == "active"
for dep in metadata.get("dependencies", [])
)
dep_score = 0.3 if deps_healthy else 0.0
total_score = (overlap * 0.5) + history_score + dep_score
candidates.append({
"name": skill_name,
"score": round(total_score, 3),
"metadata": metadata
})
# Sort by score descending
candidates.sort(key=lambda x: x["score"], reverse=True)
# Apply minimum confidence threshold
best_match = candidates[0] if candidates else None
if best_match and best_match["score"] >= 0.65:
return {
"selected_skill": best_match["name"],
"confidence": best_match["score"],
"fallback_candidates": [c["name"] for c in candidates[1:3] if c["score"] > 0.4]
}
return {"selected_skill": None, "confidence": 0.0, "fallback_candidates": []}
def execute_with_skill_fallback(task: str, initial_skill: dict, fallback_chain: list) -> dict:
"""Execute the selected skill with a domain-specific fallback chain.
Implements the 5 Laws of Elegant Defense:
- Fail fast on invalid skill state
- Retry with parameter adjustments before switching skills
- Escalate to human if confidence drops below threshold
"""
execution_state = {
"task": task,
"current_skill": initial_skill["name"],
"attempts": 0,
"confidence_history": []
}
# Validate skill state before execution
if initial_skill.get("status") != "active":
raise RuntimeError(f"Skill {initial_skill['name']} is not active")
try:
# Attempt execution with current skill
result = _invoke_skill_handler(initial_skill, task)
execution_state["success"] = True
execution_state["result"] = result
return execution_state
except TransientDependencyError as e:
# Fallback Level 1: Retry with adjusted parameters/timeouts
execution_state["attempts"] += 1
adjusted_skill = {**initial_skill, "timeout": initial_skill.get("timeout", 30) * 2}
return execute_with_skill_fallback(task, adjusted_skill, fallback_chain)
except SkillMismatchError as e:
# Fallback Level 2: Switch to next candidate in fallback chain
if fallback_chain:
next_skill = fallback_chain.pop(0)
execution_state["fallback_triggered"] = True
return execute_with_skill_fallback(task, next_skill, fallback_chain)
# Fallback Level 3: Escalate if chain exhausted
execution_state["success"] = False
execution_state["escalation_required"] = True
execution_state["reason"] = "All fallback skills exhausted"
return execution_state
code-philosophy (5 Laws of Elegant Defense) in all logicWhen applying this skill, produce:
| Skill | Purpose |
|---|---|
skill-audit | Performs detailed quality audits after the scanner identifies skills that need attention |
skill-observability | Uses observability data to guide scanner focus on high-impact skill areas |
Authoritative documentation links for this domain. The model follows markdown links at load time to resolve external references and inline content.