Build

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

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

How to use this skill

Skill file

Build

Orchestrates intelligent skill selection and execution for build 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 select_build_tool(
    project_root: str,
    available_build_systems: List[str],
    build_config: Dict[str, Any]
) -> Dict[str, Any]:
    """Select optimal build tool based on project structure and configuration.
    
    Evaluates project files (Makefile, CMakeLists.txt, package.json, etc.)
    against available build systems to determine the most efficient runner.
    Applies multi-factor scoring: file presence, dependency graph complexity,
    and historical build success rates.
    """
    if not os.path.isdir(project_root):
        raise ValueError(f"Project root not found: {project_root}")
        
    project_files = os.listdir(project_root)
    scoring = {}
    
    for tool in available_build_systems:
        score = 0.0
        if tool == "make" and "Makefile" in project_files:
            score += 0.4
        elif tool == "cmake" and "CMakeLists.txt" in project_files:
            score += 0.4
        elif tool == "npm" and "package.json" in project_files:
            score += 0.3
        elif tool == "bazel" and "BUILD" in project_files:
            score += 0.5
            
        # Factor in build config overrides
        if build_config.get("preferred_tool") == tool:
            score += 0.2
            
        # Factor in historical success rate
        score += build_config.get("historical_success", {}).get(tool, 0.0) * 0.4
        scoring[tool] = score
        
    best_tool = max(scoring, key=scoring.get)
    if scoring[best_tool] < 0.5:
        return {"tool": None, "reason": "insufficient_match"}
        
    return {
        "tool": best_tool,
        "confidence": scoring[best_tool],
        "config_path": os.path.join(project_root, f"{best_tool}.config.yaml"),
        "timestamp": time.time()
    }

Pattern 2: Execution with Fallback

def execute_build_pipeline(
    build_spec: Dict[str, Any],
    project_root: str,
    fallback_targets: List[str] = None
) -> Dict[str, Any]:
    """Execute build pipeline with domain-specific fallback handling.
    
    Runs the selected build tool, monitors output for common failure modes
    (dependency resolution, compilation errors, cache misses), and applies
    targeted fallbacks without breaking the build contract.
    """
    if fallback_targets is None:
        fallback_targets = ["clean_build", "cached_artifacts", "manual_review"]
        
    build_cmd = build_spec.get("command", f"{build_spec['tool']} build")
    env_vars = {**os.environ, "BUILD_ROOT": project_root}
    
    for attempt in range(3):
        try:
            result = subprocess.run(
                build_cmd.split(),
                cwd=project_root,
                env=env_vars,
                capture_output=True,
                text=True,
                timeout=build_spec.get("timeout", 300)
            )
            
            if result.returncode == 0:
                return {
                    "status": "success",
                    "artifacts": _scan_artifacts(project_root),
                    "stdout": result.stdout[-500:],
                    "attempts": attempt + 1
                }
                
        except subprocess.TimeoutExpired:
            logger.warning(f"Build timed out on attempt {attempt + 1}")
            continue
        except FileNotFoundError:
            # Tool missing, trigger fallback chain
            return _apply_build_fallback(build_spec, fallback_targets)
            
    # All attempts failed - escalate to fallback
    return _apply_build_fallback(build_spec, fallback_targets)

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 |

|---|---|

| commit | Source control commit workflows |



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.