Lint and validate

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

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

How to use this skill

Skill file

Lint And Validate

Orchestrates intelligent skill selection and execution for lint and validate 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 extract_and_validate_targets(
    project_root: str,
    config: Dict[str, Any],
    allowed_linters: List[str]
) -> Dict[str, Any]:
    """Extract lint targets and validate environment readiness.
    
    Implements Law 2 (Parse at boundary) and Law 1 (Early exit).
    Returns a validated execution plan with targets and tool configurations.
    """
    # Law 1: Early exit on invalid paths
    if not os.path.isdir(project_root):
        raise ValueError(f"Project root not found: {project_root}")
        
    # Law 2: Parse and validate config at boundary
    if not config.get("linters"):
        raise ValueError("No linters specified in configuration")
        
    # Validate allowed tools against system availability
    available_tools = _check_system_linters(allowed_linters)
    if not available_tools:
        return {"status": "skipped", "reason": "No compatible linters found"}
        
    # Law 3: Return new structure, never mutate inputs
    execution_plan = {
        "targets": _discover_files(project_root, config.get("extensions", ["*.py", "*.js"])),
        "tools": available_tools,
        "rules": config.get("rules", {}),
        "max_issues": config.get("max_issues", 50)
    }
    
    return execution_plan

Pattern 2: Execution with Fallback

def run_lint_pipeline(
    plan: Dict[str, Any],
    strict_mode: bool = True
) -> Dict[str, Any]:
    """Execute linting pipeline with fallback chain for tool failures.
    
    Implements Law 4 (Fail fast/loud) and adaptive fallback.
    Fallback: strict_linter -> lenient_linter -> static_analysis_report
    """
    results = []
    fallback_chain = ["ruff", "flake8", "bandit"] if strict_mode else ["pylint", "mypy"]
    
    for tool in fallback_chain:
        if tool not in plan["tools"]:
            continue
            
        try:
            # Execute specific linter with timeout and strictness
            output = subprocess.run(
                [tool, "--output-format=json"] + plan["targets"],
                capture_output=True, text=True, timeout=120
            )
            
            if output.returncode != 0:
                issues = json.loads(output.stdout)
                results.append({"tool": tool, "issues": issues, "severity": "high"})
                
                # Law 4: Fail loud on critical security issues
                if _has_critical_security_issues(issues):
                    raise LintCriticalError("Critical security vulnerabilities detected")
                    
            else:
                results.append({"tool": tool, "issues": [], "severity": "pass"})
                
        except subprocess.TimeoutExpired:
            # Fallback: skip to next tool if timeout occurs
            continue
        except FileNotFoundError:
            # Tool not found, try next in chain
            continue
            
    # Aggregate and return new structure
    return {
        "status": "failed" if any(r["severity"] == "high" for r in results) else "passed",
        "total_issues": sum(len(r["issues"]) for r in results),
        "details": results,
        "fallback_used": len(results) > 1
    }

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.