Skill writer

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

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

How to use this skill

Skill file

Skill Writer

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.

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

Pattern 2: Execution with Fallback

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
    }

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


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.