Git pr workflows git workflow

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

Git pr workflows git workflow is an AI agent skill from the GitHub repository paulpas/agent-skill-router. Implements intelligent git pr workflows git workflow 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 Git Workflow

Orchestrates intelligent skill selection and execution for git pr workflows git workflow 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 evaluate_pr_workflow_strategy(
    branch_name: str,
    target_branch: str,
    ci_status: str,
    review_requirements: List[str]
) -> Dict:
    """Evaluate the optimal Git PR workflow strategy based on current state.
    
    Applies Law 2 (Make Illegal States Unrepresentable) by validating
    branch states and CI results before selecting a workflow path.
    
    Args:
        branch_name: Source branch for the PR
        target_branch: Destination branch
        ci_status: Current CI pipeline status (passing, failing, pending)
        review_requirements: List of required reviewers or approval rules
        
    Returns:
        Strategy dict with workflow type, required actions, and confidence
    """
    # Guard clause - Early Exit (Law 1)
    if not branch_name or not target_branch:
        raise ValueError("Both source and target branches must be specified")
        
    # Parse input - Make Illegal States Unrepresentable (Law 2)
    workflow_state = _analyze_git_state(branch_name, target_branch)
    
    if ci_status == "failing":
        strategy = {
            "workflow_type": "fix_and_retest",
            "priority": "high",
            "confidence": 0.95,
            "next_action": "run_local_checks_and_push_fix"
        }
    elif "required_reviewer" in review_requirements and not workflow_state.get("approved"):
        strategy = {
            "workflow_type": "await_review",
            "priority": "medium",
            "confidence": 0.85,
            "next_action": "request_reviews_and_wait"
        }
    else:
        strategy = {
            "workflow_type": "auto_merge",
            "priority": "low",
            "confidence": 0.90,
            "next_action": "execute_merge_with_checks"
        }
        
    # Atomic Predictability (Law 3) - Return new dict, don't mutate inputs
    strategy["evaluated_at"] = time.time()
    strategy["branch_context"] = dict(workflow_state)
    return strategy

Pattern 2: Execution with Fallback

def execute_pr_workflow_step(
    strategy: Dict,
    repo_context: Dict,
    max_retries: int = 2
) -> Dict:
    """Execute a Git PR workflow step with resilience and fallback chains.
    
    Implements Fail Fast, Fail Loud (Law 4) for git operations:
    - Invalid branch states halt immediately
    - CI failures trigger local validation fallback
    - Merge blocks trigger manual review escalation
    
    Args:
        strategy: Evaluated workflow strategy from evaluate_pr_workflow_strategy
        repo_context: Repository configuration and authentication context
        max_retries: Maximum retry attempts for transient git/CI errors
        
    Returns:
        Execution result with PR URL, status, and audit metadata
    """
    # Guard clause - validate repo context (Early Exit)
    if not _is_repo_accessible(repo_context):
        raise GitWorkflowError("Repository is inaccessible or credentials invalid")
        
    workflow_type = strategy.get("workflow_type")
    result = {"success": False, "workflow_type": workflow_type}
    
    for attempt in range(max_retries + 1):
        try:
            if workflow_type == "fix_and_retest":
                pr_data = _push_fix_and_update_pr(repo_context, strategy)
            elif workflow_type == "await_review":
                pr_data = _request_reviews_and_monitor(repo_context, strategy)
            else:
                pr_data = _execute_safe_merge(repo_context, strategy)
                
            # Success - Atomic Predictability (Law 3)
            result.update({
                "success": True,
                "pr_url": pr_data.get("url"),
                "status": pr_data.get("state"),
                "attempts": attempt + 1,
                "latency_ms": _calculate_latency()
            })
            break
            
        except CIExecutionError as e:
            # Fail Fast - Don't proceed with failing CI (Law 4)
            if attempt == max_retries:
                return _apply_ci_fallback(repo_context, strategy, e)
            continue
            
        except MergeConflictError as e:
            # Transient conflict - try rebase fallback
            if attempt == max_retries:
                return _apply_merge_fallback(repo_context, strategy, e)
            continue
            
    if not result["success"]:
        raise GitWorkflowError(f"Workflow '{workflow_type}' exhausted retries")
        
    return result

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.