Cc skill continuous learning

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

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

How to use this skill

Skill file

Cc Skill Continuous Learning

Orchestrates intelligent skill selection and execution for cc skill continuous learning 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 update_skill_learning_metrics(
    skill_id: str,
    execution_outcome: Dict,
    learning_buffer: List[Dict],
    decay_factor: float = 0.95
) -> Dict:
    """Track execution outcomes and update continuous learning state.
    
    Implements Law 3 (Atomic Predictability) by returning new state dicts.
    Implements Law 4 (Fail Fast) by validating outcome structure immediately.
    """
    # Guard clause - validate outcome structure (Law 4)
    required_keys = {"success", "latency_ms", "confidence", "error_type"}
    if not required_keys.issubset(execution_outcome.keys()):
        raise ValueError(f"Invalid execution outcome: missing {required_keys - set(execution_outcome.keys())}")
    
    # Parse input at boundary (Law 2)
    new_record = {
        "skill_id": skill_id,
        "timestamp": time.time(),
        "success": execution_outcome["success"],
        "latency_ms": execution_outcome["latency_ms"],
        "confidence": execution_outcome["confidence"],
        "error_type": execution_outcome.get("error_type", "none")
    }
    
    # Append to learning buffer immutably
    updated_buffer = learning_buffer + [new_record]
    
    # Calculate rolling confidence using exponential decay
    recent_records = [r for r in updated_buffer if time.time() - r["timestamp"] < 3600]
    if not recent_records:
        return {"buffer": updated_buffer, "rolling_confidence": 0.0, "trigger_retrain": False}
        
    success_rate = sum(1 for r in recent_records if r["success"]) / len(recent_records)
    avg_latency = sum(r["latency_ms"] for r in recent_records) / len(recent_records)
    rolling_confidence = success_rate * (1.0 - min(avg_latency / 5000.0, 0.5))
    
    # Determine if continuous learning trigger is met
    trigger_retrain = rolling_confidence < 0.6 or len(recent_records) >= 50
    
    return {
        "buffer": updated_buffer,
        "rolling_confidence": round(rolling_confidence, 3),
        "trigger_retrain": trigger_retrain,
        "recent_sample_size": len(recent_records)
    }

Pattern 2: Execution with Fallback

def orchestrate_learning_fallback(
    skill_state: Dict,
    learning_buffer: List[Dict],
    fallback_skills: List[str],
    human_review_threshold: float = 0.4
) -> Dict:
    """Orchestrate fallback chain based on continuous learning metrics.
    
    Applies Law 1 (Early Exit) and Law 4 (Fail Loud) for degraded skills.
    """
    # Early exit if skill is already in stable state
    if skill_state.get("status") == "stable" and skill_state.get("rolling_confidence", 1.0) > 0.85:
        return {"action": "continue", "next_skill": skill_state["id"], "reason": "stable_performance"}
        
    # Parse buffer immutably (Law 2)
    recent_failures = [r for r in learning_buffer if not r["success"] and time.time() - r["timestamp"] < 1800]
    
    # Fail fast if critical degradation detected
    if len(recent_failures) >= 3:
        return {
            "action": "escalate_to_human",
            "reason": "critical_degradation",
            "failure_count": len(recent_failures),
            "fallback_chain": fallback_skills
        }
        
    # Apply adaptive fallback chain
    if fallback_skills:
        next_candidate = fallback_skills[0]
        return {
            "action": "switch_fallback",
            "target_skill": next_candidate,
            "reason": "confidence_drop",
            "current_confidence": skill_state.get("rolling_confidence", 0.0)
        }
        
    # Default: log and defer with adjusted parameters
    return {
        "action": "retry_with_adjusted_params",
        "reason": "transient_error",
        "adjustments": {"timeout_multiplier": 1.5, "retry_backoff": "exponential"}
    }

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


Constraints

MUST DO

MUST NOT DO

Live References

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

Related Skills

| Skill | Purpose |

|

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.