协作头脑风暴
brainstorming
在实现前澄清需求、探索设计选择,并形成清晰的开发方向。
cc-skill-coding-standards【开发与工程】Implements intelligent cc skill coding standards with multi-factor skill selection, fallback chains, and adherence to the 5 Laws of Elegant Defense
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
name: cc-skill-coding-standards compatibility: opencode completeness: 95 content-types:
Orchestrates intelligent skill selection and execution for cc skill coding standards 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 validate_skill_standards(skill_path: str, standards_config: Dict) -> Dict:
"""Validate a skill file against CC coding standards.
Implements Law 2 (Parse at boundary) by strictly parsing YAML frontmatter
and required ## sections before any logic runs.
"""
# Law 1: Early exit on missing/invalid file
if not os.path.exists(skill_path):
raise FileNotFoundError(f"Skill file not found: {skill_path}")
raw_content = Path(skill_path).read_text()
frontmatter = _parse_frontmatter(raw_content)
# Law 2: Make illegal states unrepresentable
required_fields = standards_config.get("required_fields", ["name", "version", "description"])
missing = [f for f in required_fields if f not in frontmatter]
if missing:
raise ValueError(f"Missing required frontmatter fields: {missing}")
# Extract and validate ## sections
sections = _extract_headings(raw_content)
required_sections = standards_config.get("required_sections", ["TL;DR Checklist", "Core Workflow"])
missing_sections = [s for s in required_sections if s not in sections]
# Law 3: Return new structure, never mutate input
compliance_report = {
"path": skill_path,
"valid": len(missing_sections) == 0,
"missing_sections": missing_sections,
"frontmatter_fields": frontmatter,
"timestamp": time.time()
}
return compliance_report
def enforce_standards_with_fallback(
skill_path: str,
standards_config: Dict,
auto_fix: bool = True
) -> Dict:
"""Run standards enforcement pipeline with fallback chain.
Implements Law 4 (Fail Fast, Fail Loud) by halting on critical violations
and routing to appropriate fallbacks based on severity.
"""
# Law 1: Early exit on invalid config
if not standards_config.get("severity_threshold"):
raise ValueError("Severity threshold must be defined in standards_config")
report = validate_skill_standards(skill_path, standards_config)
if report["valid"]:
return {"status": "compliant", "report": report}
# Fallback chain based on violation severity
violations = report["missing_sections"]
if auto_fix and len(violations) <= 2:
# Fallback 1: Auto-generate missing sections
return _auto_generate_sections(skill_path, violations)
if len(violations) > 2:
# Fallback 2: Route to human review for critical gaps
return _route_to_human_review(skill_path, violations)
# Fallback 3: Log and return with warning (Law 4)
return {
"status": "non_compliant",
"report": report,
"action": "logged_for_review",
"warning": "Critical standards missing. Manual intervention required."
}
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 | |