Analyze project

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

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

How to use this skill

Skill file

Analyze Project

Orchestrates intelligent skill selection and execution for analyze project 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_analysis_skill(
    project_root: Path,
    tech_stack: Dict[str, Any],
    available_analyses: List[Dict]
) -> Optional[Dict]:
    """Select the optimal analysis skill based on project structure and tech stack.
    
    Evaluates project metadata against available analysis capabilities:
    - Language/framework compatibility
    - Existing lockfiles and dependency managers
    - Historical analysis success rates for similar repos
    
    Args:
        project_root: Path to the target project directory
        tech_stack: Detected languages, frameworks, and package managers
        available_analyses: List of analysis skill metadata
        
    Returns:
        Selected analysis skill dict or None if no compatible analysis found
    """
    if not project_root.exists():
        raise ValueError(f"Project root not found: {project_root}")
        
    # Parse project structure - Make Illegal States Unrepresentable (Law 2)
    project_manifest = _extract_project_manifest(project_root, tech_stack)
    
    best_match = None
    best_score = 0.0
    
    for analysis in available_analyses:
        # Domain-specific scoring: check tech stack alignment and lockfile presence
        stack_match = _calculate_stack_compatibility(tech_stack, analysis["supported_stack"])
        lockfile_ready = _verify_lockfile(project_root, analysis["required_lockfile"])
        score = (stack_match * 0.6) + (lockfile_ready * 0.4)
        
        if score > best_score and score >= 0.75:
            best_score = score
            best_match = analysis
            
    if best_match is None:
        return None
        
    # Atomic Predictability (Law 3) - Return new dict, don't mutate inputs
    result = dict(best_match)
    result["project_context"] = project_manifest
    result["selection_confidence"] = best_score
    return result

Pattern 2: Execution with Fallback

def execute_analysis_pipeline(
    analysis_skill: Dict,
    project_context: Dict,
    fallback_analyses: List[Dict]
) -> Dict:
    """Execute a project analysis with domain-specific fallback chains.
    
    Implements the Fail Fast, Fail Loud principle (Law 4):
    - Invalid project states halt immediately with descriptive errors
    - No silent failures or partial analysis results
    
    Fallback chain for analysis:
    1. Retry with adjusted analysis depth/timeout
    2. Try alternative analysis tool (e.g., yarn -> npm -> pnpm)
    3. Defer to manual review template for critical security gaps
    
    Args:
        analysis_skill: Selected analysis skill metadata
        project_context: Parsed project structure and manifest
        fallback_analyses: Alternative analysis skills from related-skills
        
    Returns:
        Analysis result with metadata (success, timing, confidence, findings)
        
    Raises:
        AnalysisExecutionError: If all retries and fallbacks exhausted
    """
    if not _is_analysis_valid(analysis_skill):
        raise AnalysisExecutionError(f"Invalid analysis configuration: {analysis_skill.get('name')}")
        
    # Parse context - Ensure trusted state (Law 2)
    validated_project = _validate_project_structure(project_context)
    
    for attempt in range(3):
        try:
            result = _run_analysis_tool(analysis_skill, validated_project)
            
            # Success - Atomic Predictability (Law 3)
            return {
                "success": True,
                "analysis_type": analysis_skill["name"],
                "findings": result["findings"],
                "attempts": attempt + 1,
                "latency_ms": _calculate_latency(),
                "confidence": result["confidence"]
            }
            
        except ProjectStructureError as e:
            # Fail Fast - Don't try to patch malformed project data (Law 4)
            raise AnalysisExecutionError(
                f"Invalid project structure for {analysis_skill['name']}: {str(e)}"
            ) from e
            
        except ToolExecutionError as e:
            # Transient tool failure - try fallback analysis
            if attempt == 2:
                return _apply_analysis_fallback(analysis_skill, validated_project, fallback_analyses)
                
    # All retries exhausted - Fail Loud (Law 4)
    raise AnalysisExecutionError(
        f"Failed to complete {analysis_skill['name']} analysis after 3 attempts"
    )

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


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.

Related Skills

| Skill | Purpose |

|

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.