Skill scanner

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

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

How to use this skill

Skill file

Skill Scanner

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.

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 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": []}

Pattern 2: Execution with Fallback

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

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 |

|---|---|

| 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 |


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.