brainstorming
brainstorming
You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation).
git-pr-workflows-onboardImplements intelligent git pr workflows onboard with multi-factor skill selection, fallback chains, and adherence to the 5 Laws of Elegant Defense
Independent GitHub snapshot · Automated classification · Original documentation governs
name: git-pr-workflows-onboard compatibility: opencode completeness: 95 content-types:
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.
┌───────────────────────────────────────────────────────────────────────────────┐ │ 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 │ │ │ └──────────────────────────────────────────────────────────┘ │ └─────────────────────────────────────────────────────────────────────┘
Use this skill when:
Avoid this skill for:
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.
Score Available Skills - Calculate match scores using multi-factor algorithm:
Checkpoint: Skip to fallback if no skill scores above threshold.
Select Optimal Skill - Choose skill with highest score that meets minimum confidence. Checkpoint: Verify skill has not been disabled or deprecated.
Execute with Fallback - Run skill execution wrapped in retry and fallback logic. Checkpoint: Log all execution attempts for audit trail.
Return or Fallback - Either return successful result or apply fallback chain:
related-skillsCheckpoint: Record outcome with timing and confidence metadata.
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()
}
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")
code-philosophy (5 Laws of Elegant Defense) in all logicWhen applying this skill, produce:
| Skill | Purpose | |
Authoritative documentation links for this skill's domain. The model follows markdown links at load time to resolve external references and inline content.