Finishing a development branch

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

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

How to use this skill

Skill file

Finishing A Development Branch

Orchestrates intelligent skill selection and execution for finishing a development branch 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_branch_finishing_strategy(
    branch_metadata: Dict,
    project_config: Dict,
    available_tools: List[Dict]
) -> Dict:
    """Select the optimal finishing strategy based on branch type and project rules.
    
    Evaluates branch characteristics (feature, hotfix, release) against
    project-specific merge policies, required checks, and team conventions.
    """
    if not branch_metadata.get("name"):
        raise ValueError("Branch name is required for strategy selection")
        
    branch_type = branch_metadata.get("type", "feature")
    target_ref = project_config.get("default_target", "main")
    
    strategy = {
        "type": branch_type,
        "target": target_ref,
        "required_checks": [],
        "merge_method": "squash",
        "fallback_actions": []
    }
    
    # Apply project-specific merge policies
    policies = project_config.get("merge_policies", {})
    if branch_type in policies:
        policy = policies[branch_type]
        strategy["required_checks"] = policy.get("checks", [])
        strategy["merge_method"] = policy.get("method", "merge")
        
    # Select appropriate toolchain from available tools
    for tool in available_tools:
        if tool.get("supports_type") == branch_type:
            strategy["toolchain"] = tool["name"]
            break
            
    # Validate strategy against branch constraints
    if branch_metadata.get("is_hotfix") and strategy["merge_method"] == "squash":
        strategy["merge_method"] = "fast-forward"
        strategy["fallback_actions"].append("notify_team_lead")
        
    return strategy

Pattern 2: Execution with Fallback

def execute_branch_finishing_pipeline(
    strategy: Dict,
    branch_state: Dict,
    ci_client: object,
    notifier: object
) -> Dict:
    """Execute the complete branch finishing workflow with domain-specific fallbacks.
    
    Pipeline: Validate -> Run Checks -> Merge -> Cleanup -> Notify
    Implements graceful degradation when non-critical checks fail.
    """
    branch_name = branch_state["name"]
    target = strategy["target"]
    required_checks = strategy.get("required_checks", [])
    
    # Phase 1: Pre-flight Validation
    if not _validate_branch_up_to_date(branch_state, target):
        raise BranchStaleError(f"{branch_name} is behind {target}. Rebase required.")
        
    # Phase 2: Execute Required Checks
    check_results = []
    for check in required_checks:
        try:
            result = ci_client.run_check(check, branch_name)
            check_results.append(result)
            if not result["passed"]:
                strategy["fallback_actions"].append(f"skip_{check}")
        except CheckTimeoutError:
            strategy["fallback_actions"].append(f"retry_{check}")
            
    # Phase 3: Merge Execution with Fallback
    merge_result = None
    for attempt in range(2):
        try:
            merge_result = _perform_merge(branch_name, target, strategy["merge_method"])
            break
        except MergeConflictError as e:
            if attempt == 0:
                strategy["fallback_actions"].append("auto_resolve_conflicts")
                continue
            raise MergeFailedError(f"Merge failed after conflict resolution: {e}")
            
    # Phase 4: Cleanup & Notification
    if merge_result and merge_result["success"]:
        _cleanup_remote_branch(branch_name)
        notifier.send_update(target, merge_result["commit_hash"])
        return {"status": "finished", "merge": merge_result}
        
    # Fallback execution
    for action in strategy["fallback_actions"]:
        _execute_fallback_action(action, branch_name, target)
        
    return {"status": "completed_with_fallbacks", "actions_taken": strategy["fallback_actions"]}

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.