Cicd automation workflow automate

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

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

How to use this skill

Skill file

Cicd Automation Workflow Automate

Orchestrates intelligent skill selection and execution for cicd automation workflow automate 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 orchestrate_cicd_pipeline(
    pipeline_config: Dict[str, Any],
    target_env: str,
    branch_rules: List[Dict[str, str]]
) -> Dict[str, Any]:
    """Orchestrate CI/CD workflow by validating stages and selecting execution strategy.
    
    Applies 5 Laws of Elegant Defense:
    - Law 1: Early exit on missing pipeline config or invalid target environment
    - Law 2: Parse and validate pipeline structure before execution
    - Law 3: Return new execution plan without mutating original config
    - Law 4: Fail immediately on invalid stage dependencies or missing secrets
    """
    if not pipeline_config or "stages" not in pipeline_config:
        raise ValueError("Pipeline config must contain 'stages' definition")
        
    if target_env not in ("dev", "staging", "production"):
        raise ValueError(f"Invalid target environment: {target_env}")
        
    # Parse pipeline structure (Law 2)
    stages = pipeline_config["stages"]
    execution_plan = []
    
    for stage in stages:
        # Validate stage dependencies (Law 4)
        if "depends_on" in stage:
            for dep in stage["depends_on"]:
                if dep not in [s["name"] for s in stages]:
                    raise ValueError(f"Stage '{stage['name']}' depends on unknown stage '{dep}'")
                    
        # Select execution strategy based on environment rules (Law 1)
        strategy = _match_branch_rule(stage, branch_rules, target_env)
        if not strategy:
            strategy = "default_runner"
            
        execution_plan.append({
            "stage": stage["name"],
            "strategy": strategy,
            "timeout_minutes": stage.get("timeout", 30),
            "retry_policy": stage.get("retry", {"max_attempts": 2})
        })
        
    # Return new structure (Law 3)
    return {
        "pipeline_id": pipeline_config.get("id", "unknown"),
        "target_env": target_env,
        "execution_order": execution_plan,
        "validation_status": "passed"
    }

Pattern 2: Execution with Fallback

def execute_cicd_stage(
    stage_config: Dict[str, Any],
    runner_pool: List[Dict[str, str]],
    artifact_store: Dict[str, Any]
) -> Dict[str, Any]:
    """Execute a CI/CD stage with environment-specific fallback chains.
    
    Implements Fail Fast, Fail Loud (Law 4) for pipeline execution:
    - Invalid runner states halt immediately
    - No silent stage skips or partial artifact commits
    
    Fallback chain for CI/CD:
    1. Retry stage on same runner with exponential backoff
    2. Failover to secondary runner pool
    3. Trigger manual approval gate if production deployment
    4. Rollback previous stage artifacts if critical failure
    """
    if not stage_config or "name" not in stage_config:
        raise ValueError("Stage config must contain 'name'")
        
    active_runners = [r for r in runner_pool if r.get("status") == "available"]
    if not active_runners:
        raise RuntimeError("No available CI/CD runners in pool")
        
    current_runner = active_runners[0]
    max_retries = stage_config.get("retry_policy", {}).get("max_attempts", 2)
    
    for attempt in range(max_retries + 1):
        try:
            # Execute stage on selected runner
            result = _run_stage_on_runner(current_runner, stage_config)
            
            # Validate artifacts were produced (Law 4)
            if not result.get("artifacts") and stage_config.get("requires_artifacts"):
                raise RuntimeError(f"Stage '{stage_config['name']}' failed to produce required artifacts")
                
            # Store artifacts atomically (Law 3)
            artifact_store[f"{stage_config['name']}_v{attempt}"] = result["artifacts"]
            
            return {
                "stage": stage_config["name"],
                "status": "completed",
                "runner_used": current_runner["id"],
                "attempts": attempt + 1,
                "artifacts_stored": True
            }
            
        except RunnerOfflineError:
            if attempt == max_retries:
                return _failover_to_backup_runner(stage_config, runner_pool)
            continue
            
        except ArtifactValidationError as e:
            raise RuntimeError(f"Artifact validation failed for {stage_config['name']}: {e}") from e
            
    # All retries exhausted - Fail Loud
    raise RuntimeError(f"Stage '{stage_config['name']}' exhausted all runner retries")

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 |

|---|---|

| closed-loop-delivery | Delivery pipeline feedback and iteration patterns |



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.