协作头脑风暴
brainstorming
在实现前澄清需求、探索设计选择,并形成清晰的开发方向。
skill-writer【开发与工程】Implements intelligent skill writer with multi-factor skill selection, fallback chains, and adherence to the 5 Laws of Elegant Defense
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
name: skill-writer compatibility: opencode completeness: 95 content-types:
Orchestrates intelligent skill selection and execution for skill writer 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 generate_skill_manifest(
intent_description: str,
existing_skills: List[Dict],
schema_version: str = "1.0.0"
) -> Dict:
"""Generate a structured skill manifest based on user intent.
Validates intent against available skill triggers, constructs
YAML frontmatter, and assembles the markdown skeleton.
Applies Law 2 (Parse at boundary) by strictly validating inputs.
"""
if not intent_description or not intent_description.strip():
raise ValueError("Intent description is required for skill generation")
# Parse intent features at boundary
intent_features = _parse_intent_features(intent_description)
# Match against existing skill patterns to avoid duplication
matches = _find_similar_skills(intent_features, existing_skills)
if matches:
return {
"status": "duplicate_detected",
"suggested_skill": matches[0]["name"],
"confidence": matches[0]["match_score"]
}
# Construct domain-specific manifest structure
manifest = {
"frontmatter": {
"name": _sanitize_skill_name(intent_features["core_action"]),
"version": schema_version,
"triggers": intent_features["trigger_keywords"],
"role": intent_features["agent_role"],
"scope": intent_features["execution_scope"]
},
"structure": {
"sections": ["TL;DR Checklist", "Core Workflow", "Implementation Patterns", "Constraints"],
"required_code_blocks": 2,
"min_domain_specific_lines": 15
}
}
# Atomic Predictability (Law 3) - return fresh structure
return manifest
def validate_and_refine_skill(
skill_content: str,
validation_rules: Dict,
max_refinement_cycles: int = 3
) -> Dict:
"""Validate generated skill content against domain rules and refine iteratively.
Implements Law 4 (Fail Fast) by halting on structural violations.
Uses a refinement fallback chain when initial generation misses compliance.
"""
if not skill_content or len(skill_content) < 100:
raise ValueError("Skill content too short to validate")
parsed = _parse_skill_markdown(skill_content)
if not parsed.get("frontmatter"):
raise ValueError("Missing YAML frontmatter - cannot proceed")
for cycle in range(max_refinement_cycles):
violations = _check_compliance(parsed, validation_rules)
if not violations:
return {
"status": "validated",
"skill_name": parsed["frontmatter"]["name"],
"compliance_score": 1.0,
"cycles_used": cycle + 1
}
# Fallback: Apply targeted refinement based on violation type
parsed = _apply_refinement(parsed, violations)
_log_refinement_cycle(cycle + 1, violations)
# All cycles exhausted - Fail Loud with actionable error
return {
"status": "refinement_exhausted",
"skill_name": parsed["frontmatter"]["name"],
"remaining_violations": violations,
"confidence": 0.0
}
code-philosophy (5 Laws of Elegant Defense) in all logicWhen applying this skill, produce:
| Skill | Purpose |
|---|---|
skill-creator | The creation workflow counterpart — writer focuses on documentation, creator covers the full lifecycle |
skill-documentation-best-practices | Provides documentation patterns that skill writers use to produce high-fidelity content |
Authoritative documentation links for this domain. The model follows markdown links at load time to resolve external references and inline content.