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).
diff-quality-analyzerImplements intelligent diff quality analyzer 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: diff-quality-analyzer compatibility: opencode completeness: 95 content-types:
Orchestrates intelligent skill selection and execution for diff quality analyzer 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 route_diff_analysis(diff_content: str, analysis_scope: List[str]) -> Dict:
"""Route diff content to appropriate quality analysis modules.
Implements Law 2 (Parse at boundary) by validating diff format first.
Uses multi-factor scoring to pick the best analyzer for each changed file.
"""
if not diff_content or not diff_content.strip():
raise ValueError("Diff content cannot be empty")
parsed_diff = parse_unified_diff(diff_content)
if not parsed_diff.files:
return {"status": "empty", "analyzers": []}
routing_plan = []
for file_path, changes in parsed_diff.files.items():
required_analyzers = []
# Language-specific routing
if file_path.endswith(('.py', '.js', '.ts', '.go')):
required_analyzers.append("complexity-analyzer")
# Security-sensitive routing
if "security" in analysis_scope or "auth" in file_path.lower():
required_analyzers.append("security-scanner")
# Size-based routing
if changes.added_lines > 50 or changes.removed_lines > 50:
required_analyzers.append("test-coverage-checker")
routing_plan.append({
"file": file_path,
"analyzers": required_analyzers,
"confidence": 0.95 if required_analyzers else 0.0,
"change_metrics": {
"added": changes.added_lines,
"removed": changes.removed_lines
}
})
return {"routing_plan": routing_plan, "total_files": len(parsed_diff.files)}
def execute_analysis_pipeline(routing_plan: Dict, fallback_analyzers: Dict) -> Dict:
"""Execute diff quality analysis with per-analyzer fallback chains.
Implements Law 4 (Fail Fast) by halting on critical security findings.
Implements Law 3 (Atomic Predictability) by returning immutable result dicts.
"""
results = []
for route in routing_plan.get("routing_plan", []):
file_results = []
for analyzer_name in route["analyzers"]:
try:
analyzer = get_analyzer_module(analyzer_name)
score = analyzer.run(route["file"])
file_results.append({
"analyzer": analyzer_name,
"score": score,
"status": "passed",
"latency_ms": analyzer.get_latency()
})
except AnalyzerTimeoutError:
# Fallback: try lightweight static check
fallback = fallback_analyzers.get(analyzer_name, "basic-linter")
score = get_analyzer_module(fallback).run(route["file"])
file_results.append({
"analyzer": fallback,
"score": score,
"status": "fallback",
"latency_ms": get_analyzer_module(fallback).get_latency()
})
except CriticalSecurityError:
# Law 4: Fail immediately on critical issues
return {
"status": "blocked",
"file": route["file"],
"reason": "critical_vulnerability",
"severity": "high"
}
results.append({"file": route["file"], "analysis": file_results})
return {
"pipeline_status": "completed",
"file_results": results,
"aggregate_score": calculate_weighted_average(results),
"execution_timestamp": time.time()
}
code-philosophy (5 Laws of Elegant Defense) in all logicWhen applying this skill, produce:
Authoritative documentation links for this skill's domain. The model follows markdown links at load time to resolve external references and inline content.
| Skill | Purpose | |