协作头脑风暴
brainstorming
在实现前澄清需求、探索设计选择,并形成清晰的开发方向。
cc-skill-continuous-learning【开发与工程】Implements intelligent cc skill continuous learning with multi-factor skill selection, fallback chains, and adherence to the 5 Laws of Elegant Defense
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
name: cc-skill-continuous-learning compatibility: opencode completeness: 95 content-types:
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.
┌───────────────────────────────────────────────────────────────────────────────┐ │ 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 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)
}
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"}
}
code-philosophy (5 Laws of Elegant Defense) in all logicWhen applying this skill, produce:
Authoritative documentation links for this skill's domain. The model follows markdown links at load time to resolve external references and inline content.
| Skill | Purpose | |