Git pr workflows onboard

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

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

How to use this skill

Skill file

Git Pr Workflows Onboard

Orchestrates intelligent skill selection and execution for git pr workflows onboard 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 analyze_pr_context_and_route(
    pr_metadata: Dict[str, Any],
    repo_config: Dict[str, Any],
    available_onboarding_skills: List[Dict],
    min_confidence: float = 0.75
) -> Optional[Dict]:
    """Route PR onboarding tasks to optimal sub-skill based on workflow context.
    
    Applies Law 1 (Early Exit) and Law 2 (Parse at Boundary) to validate PR state
    before scoring against available onboarding capabilities.
    """
    if not pr_metadata.get("branch_name") or not pr_metadata.get("base_branch"):
        raise ValueError("PR must have branch_name and base_branch defined")
        
    if not repo_config.get("branch_protection_rules"):
        raise ValueError("Repository must have branch protection rules configured")
        
    # Parse PR type and extract workflow features at boundary
    title_lower = pr_metadata.get("title", "").lower()
    labels = pr_metadata.get("labels", [])
    is_hotfix = any("hotfix" in lbl for lbl in labels) or "hotfix" in title_lower
    requires_review = repo_config.get("required_reviewers", 0) > 0
    ci_required = repo_config.get("required_status_checks", False)
    
    workflow_features = {
        "is_hotfix": is_hotfix,
        "requires_review": requires_review,
        "ci_required": ci_required,
        "auto_merge_eligible": not is_hotfix and not requires_review and ci_required
    }
    
    best_skill = None
    best_score = 0.0
    
    for skill in available_onboarding_skills:
        # Multi-factor scoring: workflow match + repo compliance + historical success
        workflow_match = 1.0 if skill["trigger_patterns"].get("pr_type") == (is_hotfix and "hotfix" or "standard") else 0.5
        compliance_score = 1.0 if all(skill["requirements"].get(k) <= v for k, v in workflow_features.items()) else 0.0
        historical_weight = skill.get("success_rate", 0.5)
        
        composite_score = (workflow_match * 0.4) + (compliance_score * 0.3) + (historical_weight * 0.3)
        
        if composite_score > best_score and composite_score >= min_confidence:
            best_score = composite_score
            best_skill = skill
            
    if best_skill is None:
        return None
        
    # Law 3: Return new structure, never mutate inputs
    return {
        "routed_skill": best_skill["name"],
        "confidence": best_score,
        "workflow_context": workflow_features,
        "timestamp": time.time()
    }

Pattern 2: Execution with Fallback

def execute_pr_onboarding_with_fallback(
    routed_skill: Dict,
    pr_context: Dict,
    repo_state: Dict,
    max_retries: int = 2
) -> Dict:
    """Execute PR onboarding workflow with domain-specific fallback chain.
    
    Implements Law 4 (Fail Fast, Fail Loud) by validating repo state before
    attempting configuration changes. Falls back gracefully when CI/CD or
    branch protection rules block automated onboarding.
    """
    required_perms = routed_skill.get("required_permissions", [])
    if not all(perm in repo_state.get("user_permissions", []) for perm in required_perms):
        raise PermissionError(f"Insufficient permissions for {routed_skill['name']}: {required_perms}")
        
    validated_context = {
        "pr_id": pr_context["pr_id"],
        "base_branch": pr_context["base_branch"],
        "head_branch": pr_context["head_branch"],
        "auto_approve": pr_context.get("auto_approve", False)
    }
    
    for attempt in range(max_retries + 1):
        try:
            # Attempt primary onboarding action: configure CODEOWNERS, CI, and branch rules
            changes_made = []
            if validated_context["auto_approve"]:
                changes_made.append("auto_approve_enabled")
            if repo_state.get("ci_configured") is False:
                changes_made.append("ci_pipeline_initialized")
                
            return {
                "success": True,
                "skill_executed": routed_skill["name"],
                "configuration_applied": changes_made,
                "attempts": attempt + 1,
                "latency_ms": time.time() * 1000
            }
            
        except BranchProtectionError as e:
            # Law 4: Fail immediately on immutable repo constraints
            raise OnboardingError(f"Branch protection blocks auto-onboarding: {e}") from e
            
        except CIConfigError as e:
            # Transient CI failure - apply fallback chain
            if attempt == max_retries:
                return {
                    "success": False,
                    "fallback_triggered": True,
                    "fallback_action": "manual_review_template_generated",
                    "reason": str(e),
                    "attempts": attempt + 1
                }
                
    raise OnboardingError(f"Failed to onboard PR after {max_retries + 1} 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

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.