Github actions templates

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

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

How to use this skill

Skill file

Github Actions Templates

Orchestrates intelligent skill selection and execution for github actions templates 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_github_action_template(
    task_description: str,
    available_templates: List[Dict],
    min_confidence: float = 0.7
) -> Optional[Dict]:
    """Generate a GitHub Actions workflow template based on task description.
    
    Selects the most appropriate base template (CI, CD, Lint, etc.) using
    multi-factor scoring: trigger type, language/framework, and historical usage.
    Applies Law 1 (Early Exit) and Law 2 (Immutable State).
    
    Args:
        task_description: Natural language description of the automation task
        available_templates: List of template metadata with triggers and languages
        min_confidence: Minimum match threshold for template selection
        
    Returns:
        Rendered workflow dict with metadata, or None if no suitable template
    """
    if not task_description or not task_description.strip():
        raise ValueError("Task description cannot be empty")
        
    if not available_templates:
        raise ValueError("No GitHub Actions templates available")
        
    # Extract intent features (Law 2: Parse at boundary)
    intent = _extract_workflow_intent(task_description)
    
    best_template = None
    best_score = 0.0
    
    for tmpl in available_templates:
        score = _calculate_template_match(intent, tmpl)
        if score > best_score and score >= min_confidence:
            best_score = score
            best_template = tmpl
            
    if best_template is None:
        return None
        
    # Law 3: Return new structure, never mutate input template
    workflow = {
        "name": best_template["name"],
        "on": best_template["triggers"],
        "jobs": {},
        "metadata": {
            "source_template": best_template["id"],
            "confidence": best_score,
            "generated_at": time.time()
        }
    }
    return workflow

Pattern 2: Execution with Fallback

def render_and_validate_template(
    workflow_template: Dict,
    context_vars: Dict,
    fallback_templates: List[Dict] = None
) -> Dict:
    """Render a GitHub Actions workflow with variable substitution and validation.
    
    Implements fallback chain (Law 4: Fail Fast, Fail Loud):
    1. Attempt full rendering with provided context
    2. Fallback to simplified template if complex variables fail
    3. Defer to manual review if YAML validation fails
    
    Args:
        workflow_template: Base workflow structure from Pattern 1
        context_vars: User-provided variables (e.g., python-version, os)
        fallback_templates: Alternative templates to try on failure
        
    Returns:
        Validated workflow YAML string with execution metadata
    """
    if not workflow_template or "jobs" not in workflow_template:
        raise ValueError("Invalid workflow template structure")
        
    # Law 2: Validate context before rendering
    validated_vars = _sanitize_context_vars(context_vars)
    
    try:
        # Attempt primary render
        rendered_yaml = _apply_jinja2_template(workflow_template, validated_vars)
        _validate_github_actions_schema(rendered_yaml)
        return {
            "success": True,
            "yaml": rendered_yaml,
            "strategy": "primary",
            "validation": "passed"
        }
    except SchemaValidationError as e:
        # Law 4: Fail fast on invalid state
        if fallback_templates:
            # Fallback 1: Try simplified template variant
            for alt in fallback_templates:
                try:
                    alt_yaml = _apply_jinja2_template(alt, validated_vars)
                    _validate_github_actions_schema(alt_yaml)
                    return {
                        "success": True,
                        "yaml": alt_yaml,
                        "strategy": "fallback_simplified",
                        "validation": "passed"
                    }
                except SchemaValidationError:
                    continue
                    
        # Fallback 2: Return structured error for human review
        return {
            "success": False,
            "error": f"Template validation failed: {str(e)}",
            "strategy": "defer_human",
            "raw_context": validated_vars
        }

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 |

|



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.

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.