# Qcsd Cicd Swarm

> QCSD Verification phase swarm for CI/CD pipeline quality gates using regression analysis, flaky test detection, quality gate enforcement, and deployment readiness assessment. Consumes Development outputs (SHIP/CONDITIONAL/HOLD decisions, quality metrics) and produces signals for Production monitoring.

- Skill: `fndlalit/qcsd-cicd-swarm` (Agent Skill)
- Install (CLI): `npx skillmds@latest add fndlalit/qcsd-cicd-swarm`
- Raw SKILL.md: https://api.skillmd.com/api/skills/fndlalit/qcsd-cicd-swarm/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: DevOps & Infra
- Author: fndlalit (https://skillmd.com/u/fndlalit)
- Updated: 2026-09-10
- Page: https://skillmd.com/skills/fndlalit/qcsd-cicd-swarm

---


# QCSD CI/CD Swarm v1.0

Shift-left quality engineering swarm for CI/CD pipeline verification and release readiness.

---

## Overview

The CI/CD Swarm takes code that passed Development quality checks and validates it is
safe to release through the CI/CD pipeline. Where the Development Swarm asks "Is the
code quality sufficient to ship?", the CI/CD Swarm asks "Is this change safe to release?"

This swarm operates at the pipeline level, analyzing test results, regression risk,
flaky test impact, security pipeline status, and infrastructure changes to render
a RELEASE / REMEDIATE / BLOCK decision.

### QCSD Phase Positioning

| Phase | Swarm | Question | Decision | When |
|-------|-------|----------|----------|------|
| Ideation | qcsd-ideation-swarm | Should we build this? | GO / CONDITIONAL / NO-GO | PI/Sprint Planning |
| Refinement | qcsd-refinement-swarm | How should we test this? | READY / CONDITIONAL / NOT-READY | Sprint Refinement |
| Development | qcsd-development-swarm | Is the code quality sufficient? | SHIP / CONDITIONAL / HOLD | During Sprint |
| **Verification** | **qcsd-cicd-swarm** | **Is this change safe to release?** | **RELEASE / REMEDIATE / BLOCK** | **Pre-Release / CI-CD** |

### Key Differentiators from Development Swarm

| Dimension | Development Swarm | CI/CD Swarm |
|-----------|-------------------|-------------|
| Framework | TDD + Complexity + Coverage | Quality Gates + Regression + Stability |
| Agents | 7 (3 core + 3 conditional + 1 analysis) | 7 (3 core + 3 conditional + 1 analysis) |
| Core Output | Code quality assessment | Release readiness assessment |
| Decision | SHIP / CONDITIONAL / HOLD | RELEASE / REMEDIATE / BLOCK |
| Flags | HAS_SECURITY_CODE, HAS_PERFORMANCE_CODE, HAS_CRITICAL_CODE | HAS_SECURITY_PIPELINE, HAS_PERFORMANCE_PIPELINE, HAS_INFRA_CHANGE |
| Phase | During Sprint Development | Pre-Release / CI-CD Pipeline |
| Input | Source code + test files | Pipeline artifacts + test results + build output |
| Final Step | Defect prediction analysis | Deployment readiness advisory |

---

### Parameters

- `PIPELINE_ARTIFACTS`: Path to CI/CD artifacts, test results, and build output (required, e.g., `ci/artifacts/`)
- `BASELINE_REF`: Git ref for baseline comparison (optional, default: `main`)
- `OUTPUT_FOLDER`: Where to save reports (default: `${PROJECT_ROOT}/Agentic QCSD/cicd/`)
- `DEPLOY_TARGET`: Target deployment environment (optional, e.g., `staging`, `production`)

---

## ENFORCEMENT RULES - READ FIRST

**These rules are NON-NEGOTIABLE. Violation means skill execution failure.**

| Rule | Enforcement |
|------|-------------|
| **E1** | You MUST spawn ALL THREE core agents (qe-quality-gate, qe-regression-analyzer, qe-flaky-hunter) in Phase 2. No exceptions. |
| **E2** | You MUST put all parallel Task calls in a SINGLE message. |
| **E3** | You MUST STOP and WAIT after each batch. No proceeding early. |
| **E4** | You MUST spawn conditional agents if flags are TRUE. No skipping. |
| **E5** | You MUST apply RELEASE/REMEDIATE/BLOCK logic exactly as specified in Phase 5. |
| **E6** | You MUST generate the full report structure. No abbreviated versions. |
| **E7** | Each agent MUST read its reference files before analysis. |
| **E8** | You MUST apply qe-deployment-advisor analysis on ALL pipeline data in Phase 8. Always. |
| **E9** | You MUST execute Phase 7 learning persistence. Store verification findings to memory BEFORE Phase 8. No skipping. |

**PROHIBITED BEHAVIORS:**
- Summarizing instead of spawning agents
- Skipping agents "for brevity"
- Proceeding before background tasks complete
- Providing your own analysis instead of spawning specialists
- Omitting report sections
- Using placeholder text like "[details here]"
- Skipping the deployment readiness analysis
- Skipping learning persistence (Phase 7) or treating it as optional
- Generating pipeline analysis yourself instead of using specialist agents

---

## PHASE 1: Analyze Pipeline Context (Flag Detection)

**MANDATORY: You must complete this analysis before Phase 2.**

Scan the pipeline artifacts, CI/CD configuration, test results, and change diff to SET these flags. Do not skip any flag.

### Flag Detection (Check ALL THREE)

```
HAS_SECURITY_PIPELINE = FALSE
  Set TRUE if pipeline contains ANY of: security scan results, SAST output,
  DAST output, dependency audit results, CVE reports, container scan,
  secrets detection output, compliance check results, SBOM generation,
  penetration test results, security gate failures, auth-related changes,
  certificate changes, encryption changes, API key rotation

HAS_PERFORMANCE_PIPELINE = FALSE
  Set TRUE if pipeline contains ANY of: load test results, performance
  benchmark output, latency metrics, throughput data, stress test results,
  memory profiling output, CPU profiling data, response time baselines,
  scalability test results, database query performance, cache hit ratios,
  CDN performance data, API response times, SLA compliance metrics

HAS_INFRA_CHANGE = FALSE
  Set TRUE if changes include ANY of: Dockerfile, docker-compose,
  kubernetes manifests, terraform files, CloudFormation templates,
  CI/CD pipeline config (.github/workflows, .gitlab-ci, Jenkinsfile),
  infrastructure as code, helm charts, ansible playbooks,
  environment variables, nginx config, database migrations,
  service mesh config, load balancer config, DNS changes
```

### Validation Checkpoint

Before proceeding to Phase 2, confirm:

```
+-- I have read the pipeline artifacts and test results
+-- I have read the CI/CD configuration files
+-- I have reviewed the change diff against baseline
+-- I have evaluated ALL THREE flags
+-- I have recorded which flags are TRUE
+-- I understand which conditional agents will be needed
```

**DO NOT proceed to Phase 2 until all checkboxes are confirmed.**

### MANDATORY: Output Flag Detection Results

You MUST output flag detection results before proceeding:

```
+-------------------------------------------------------------+
|                    FLAG DETECTION RESULTS                    |
+-------------------------------------------------------------+
|                                                             |
|  HAS_SECURITY_PIPELINE:    [TRUE/FALSE]                     |
|  Evidence:                 [what triggered it - specific]   |
|                                                             |
|  HAS_PERFORMANCE_PIPELINE: [TRUE/FALSE]                     |
|  Evidence:                 [what triggered it - specific]   |
|                                                             |
|  HAS_INFRA_CHANGE:         [TRUE/FALSE]                     |
|  Evidence:                 [what triggered it - specific]   |
|                                                             |
|  EXPECTED AGENTS:                                           |
|  - Core: 3 (always)                                         |
|  - Conditional: [count based on TRUE flags]                 |
|  - Analysis: 1 (always)                                     |
|  - TOTAL: [3 + conditional count + 1]                       |
|                                                             |
+-------------------------------------------------------------+
```

**DO NOT proceed to Phase 2 without outputting flag detection results.**

---

## PHASE 2: Spawn Core Agents (PARALLEL BATCH 1)

### CRITICAL ENFORCEMENT

```
+-------------------------------------------------------------+
|  YOU MUST INCLUDE ALL THREE TASK CALLS IN YOUR NEXT MESSAGE  |
|                                                              |
|  - Task 1: qe-quality-gate                                  |
|  - Task 2: qe-regression-analyzer                           |
|  - Task 3: qe-flaky-hunter                                  |
|                                                              |
|  If your message contains fewer than 3 Task calls, you have |
|  FAILED this phase. Start over.                              |
+-------------------------------------------------------------+
```

### Domain Context

| Agent | Domain | MCP Tool Mapping |
|-------|--------|------------------|
| qe-quality-gate | quality-assessment | `quality_assess` |
| qe-regression-analyzer | test-execution | `test_execute_parallel` |
| qe-flaky-hunter | test-execution | `test_execute_parallel` |

### Agent 1: Quality Gate Evaluator

**This agent MUST evaluate quality gate thresholds and enforce pass/fail criteria.**

```
Task({
  description: "Quality gate threshold evaluation",
  prompt: `You are qe-quality-gate. Your output quality is being audited.

## MANDATORY FIRST STEPS (DO NOT SKIP)

1. READ the pipeline test results and build artifacts provided below IN FULL.
2. READ the quality gate configuration if available.
3. READ any previous QCSD Development phase signals if available.

## PIPELINE DATA TO ANALYZE

=== TEST RESULTS START ===
[PASTE THE COMPLETE TEST RESULTS HERE - DO NOT SUMMARIZE]
=== TEST RESULTS END ===

=== BUILD ARTIFACTS START ===
[PASTE BUILD OUTPUT / COVERAGE REPORTS HERE - DO NOT SUMMARIZE]
=== BUILD ARTIFACTS END ===

=== DEVELOPMENT PHASE SIGNALS (if available) START ===
[PASTE any Development phase SHIP/CONDITIONAL/HOLD signals]
=== DEVELOPMENT PHASE SIGNALS END ===

## REQUIRED OUTPUT (ALL SECTIONS MANDATORY)

### 1. Quality Gate Assessment

Evaluate each quality dimension against thresholds:

| Gate | Metric | Value | Threshold | Status |
|------|--------|-------|-----------|--------|
| Test Pass Rate | X/Y passed | X% | >= 100% | PASS/FAIL |
| Code Coverage | Line coverage | X% | >= 80% | PASS/WARN/FAIL |
| Branch Coverage | Branch coverage | X% | >= 70% | PASS/WARN/FAIL |
| Build Success | Build status | Pass/Fail | Pass | PASS/FAIL |
| Lint Errors | Error count | X | 0 | PASS/WARN/FAIL |
| Type Check | Type errors | X | 0 | PASS/FAIL |
| Bundle Size | Size delta | +X KB | <= +50 KB | PASS/WARN/FAIL |
| Test Duration | Total time | Xs | <= baseline + 10% | PASS/WARN/FAIL |

**QUALITY GATE STATUS: PASSED / FAILED (X/Y gates passed)**

### 2. Test Results Analysis

| Category | Total | Passed | Failed | Skipped | Pass Rate |
|----------|-------|--------|--------|---------|-----------|
| Unit Tests | X | X | X | X | X% |
| Integration Tests | X | X | X | X | X% |
| E2E Tests | X | X | X | X | X% |
| Contract Tests | X | X | X | X | X% |
| **Total** | **X** | **X** | **X** | **X** | **X%** |

### 3. Failed Test Analysis

For each failed test:

| Test Name | Suite | Failure Reason | Severity | Flaky? |
|-----------|-------|---------------|----------|--------|
| test_name | suite | [error message] | Critical/High/Medium | Yes/No |

### 4. Coverage Delta Analysis

| Module | Before | After | Delta | Status |
|--------|--------|-------|-------|--------|
| Module 1 | X% | X% | +/-X% | Improved/Declined/Stable |
| Module 2 | X% | X% | +/-X% | Improved/Declined/Stable |
| **Overall** | **X%** | **X%** | **+/-X%** | **Improved/Declined/Stable** |

### 5. Quality Gate Score

| Dimension | Score (0-10) | Notes |
|-----------|-------------|-------|
| Test completeness | X/10 | ... |
| Coverage adequacy | X/10 | ... |
| Build health | X/10 | ... |
| Pipeline stability | X/10 | ... |
| Threshold compliance | X/10 | ... |

**QUALITY GATE SCORE: X/50**

**MINIMUM: Evaluate all 8 quality gates and provide test results breakdown by category.**

## OUTPUT FORMAT

Save your complete analysis in Markdown to:
${OUTPUT_FOLDER}/02-quality-gate.md

Use the Write tool to save BEFORE completing.
Report MUST be complete - no placeholders.

## VALIDATION BEFORE SUBMITTING

+-- Did I read all test results and build artifacts?
+-- Did I evaluate all 8 quality gates?
+-- Did I analyze test results by category?
+-- Did I analyze coverage delta?
+-- Did I identify all failed tests?
+-- Did I save the report to the correct output path?`,
  subagent_type: "qe-quality-gate",
  run_in_background: true
})
```

### Agent 2: Regression Analyzer

**This agent MUST analyze regression risk and test selection effectiveness.**

```
Task({
  description: "Regression risk analysis and test selection",
  prompt: `You are qe-regression-analyzer. Your output quality is being audited.

## PIPELINE DATA TO ANALYZE

=== CHANGE DIFF START ===
[PASTE THE COMPLETE DIFF/CHANGESET HERE - DO NOT SUMMARIZE]
=== CHANGE DIFF END ===

=== TEST RESULTS START ===
[PASTE THE COMPLETE TEST RESULTS HERE - DO NOT SUMMARIZE]
=== TEST RESULTS END ===

=== HISTORICAL TEST DATA (if available) START ===
[PASTE any historical test run data]
=== HISTORICAL TEST DATA END ===

## REQUIRED OUTPUT (ALL SECTIONS MANDATORY)

### 1. Change Impact Analysis

| File Changed | Lines Changed | Modules Affected | Risk Score |
|-------------|---------------|-------------------|------------|
| file.ts | +X / -Y | [dependent modules] | High/Medium/Low |

**Impact Radius:**
- Direct changes: X files
- Directly affected modules: X
- Transitively affected modules: X
- Total blast radius: X files

### 2. Regression Risk Assessment

| Risk Factor | Score (0-10) | Evidence | Mitigation |
|-------------|-------------|----------|------------|
| Code churn | X/10 | [X files, Y lines changed] | [action] |
| Dependency depth | X/10 | [X transitive deps affected] | [action] |
| Historical failure rate | X/10 | [X% failure rate in affected area] | [action] |
| Test coverage of changes | X/10 | [X% of changed code tested] | [action] |
| Complexity of changes | X/10 | [cyclomatic complexity delta] | [action] |

**OVERALL REGRESSION RISK: X/50 (High/Medium/Low)**

### 3. Test Selection Effectiveness

| Selection Criteria | Tests Selected | Tests Relevant | Precision |
|-------------------|----------------|----------------|-----------|
| Changed file mapping | X | X | X% |
| Dependency analysis | X | X | X% |
| Historical correlation | X | X | X% |
| Risk-based selection | X | X | X% |

### 4. Missing Test Coverage for Changes

| Changed Code | Coverage Status | Risk | Suggested Test |
|-------------|----------------|------|----------------|
| file:line-range | Covered/Uncovered | High/Medium/Low | [specific test] |

### 5. Regression Prediction

| Module | Regression Probability | Confidence | Key Risk |
|--------|----------------------|------------|----------|
| Module 1 | X% | High/Medium/Low | [factor] |
| Module 2 | X% | High/Medium/Low | [factor] |

**REGRESSION RISK SCORE: X/100** (inverse: lower risk = higher score)

**MINIMUM: Analyze all changed files and identify at least 3 regression risk factors.**

## OUTPUT FORMAT

Save your complete analysis in Markdown to:
${OUTPUT_FOLDER}/03-regression-analysis.md

Use the Write tool to save BEFORE completing.
Report MUST be complete - no placeholders.

## VALIDATION BEFORE SUBMITTING

+-- Did I analyze all changed files?
+-- Did I calculate blast radius?
+-- Did I score all 5 regression risk factors?
+-- Did I evaluate test selection effectiveness?
+-- Did I identify missing test coverage?
+-- Did I save the report to the correct output path?`,
  subagent_type: "qe-regression-analyzer",
  run_in_background: true
})
```

### Agent 3: Flaky Test Hunter

**This agent MUST detect flaky tests and assess pipeline stability. Flaky count is mandatory.**

```
Task({
  description: "Flaky test detection and pipeline stability assessment",
  prompt: `You are qe-flaky-hunter. Your output quality is being audited.

## PIPELINE DATA TO ANALYZE

=== TEST RESULTS START ===
[PASTE THE COMPLETE TEST RESULTS HERE - DO NOT SUMMARIZE]
=== TEST RESULTS END ===

=== TEST HISTORY (if available) START ===
[PASTE historical test results from previous runs]
=== TEST HISTORY END ===

=== CI/CD LOGS START ===
[PASTE relevant CI/CD pipeline logs]
=== CI/CD LOGS END ===

## REQUIRED OUTPUT (ALL SECTIONS MANDATORY)

### 1. Flaky Test Detection

For EACH suspected flaky test:

| Test Name | Suite | Flakiness Score | Evidence | Root Cause |
|-----------|-------|----------------|----------|------------|
| test_name | suite | X/10 | [why suspected flaky] | [timing/ordering/state/env] |

**Flakiness Indicators:**
- Test passes on retry but fails initially
- Test fails inconsistently across runs
- Test depends on execution order
- Test has timing-sensitive assertions
- Test depends on external state
- Test uses non-deterministic data
- Test has race conditions

### 2. Pipeline Stability Assessment

| Metric | Value | Threshold | Status |
|--------|-------|-----------|--------|
| Overall pass rate (last 10 runs) | X% | >= 95% | PASS/WARN/FAIL |
| Flaky test rate | X% | <= 2% | PASS/WARN/FAIL |
| Average retry count | X | <= 0.5 | PASS/WARN/FAIL |
| Pipeline timeout rate | X% | <= 1% | PASS/WARN/FAIL |
| Deterministic pass rate | X% | >= 98% | PASS/WARN/FAIL |

### 3. Flaky Test Root Cause Analysis

| Root Cause Category | Count | Tests Affected | Remediation |
|--------------------|-------|----------------|-------------|
| Timing/Race Conditions | X | [test list] | [specific fix] |
| External Dependencies | X | [test list] | [mock/stub] |
| Shared State | X | [test list] | [isolation] |
| Environment Sensitivity | X | [test list] | [env fix] |
| Data Dependencies | X | [test list] | [data setup] |
| Ordering Dependencies | X | [test list] | [independence] |

### 4. Test Stability Trends

| Time Period | Pass Rate | Flaky Rate | Trend |
|-------------|-----------|------------|-------|
| Current run | X% | X% | - |
| Last 5 runs | X% | X% | Improving/Declining/Stable |
| Last 10 runs | X% | X% | Improving/Declining/Stable |
| Last 30 runs | X% | X% | Improving/Declining/Stable |

### 5. Flaky Test Impact Assessment

| Impact | Count | Description |
|--------|-------|-------------|
| False failures blocking releases | X | [which tests cause false blocks] |
| Developer confidence erosion | High/Medium/Low | [evidence] |
| CI/CD resource waste | X% extra runs | [retry cost] |
| Mean time to resolution | X hours | [average time to investigate] |

**FLAKY TESTS TOTAL: X**
**CRITICAL FLAKY (blocking releases): X**

**STABILITY SCORE: X/100** (higher = more stable)

**MINIMUM: Identify at least 3 flaky test indicators or explicitly state "No flaky tests detected after thorough analysis".**

## OUTPUT FORMAT

Save your complete analysis in Markdown to:
${OUTPUT_FOLDER}/04-flaky-test-analysis.md

Use the Write tool to save BEFORE completing.
Report MUST be complete - no placeholders.

## VALIDATION BEFORE SUBMITTING

+-- Did I analyze all test results for flakiness indicators?
+-- Did I check historical test data for patterns?
+-- Did I categorize root causes?
+-- Did I assess pipeline stability with all 5 metrics?
+-- Did I calculate stability trends?
+-- Did I save the report to the correct output path?`,
  subagent_type: "qe-flaky-hunter",
  run_in_background: true
})
```

### Post-Spawn Confirmation

After sending all three Task calls, you MUST tell the user:

```
I've launched 3 core agents in parallel:

  qe-quality-gate [Domain: quality-assessment]
   - Evaluating quality gate thresholds (8 dimensions)
   - Analyzing test results by category (unit, integration, e2e, contract)
   - Calculating coverage delta against baseline

  qe-regression-analyzer [Domain: test-execution]
   - Computing change impact blast radius
   - Scoring regression risk across 5 factors
   - Evaluating test selection effectiveness

  qe-flaky-hunter [Domain: test-execution]
   - Detecting flaky tests with root cause analysis
   - Assessing pipeline stability (5 metrics)
   - Calculating stability trends

  WAITING for all agents to complete before proceeding...
```

**DO NOT proceed to Phase 3 until you have sent this confirmation.**

---

## PHASE 3: Wait for Batch 1 Completion

### ENFORCEMENT: NO EARLY PROCEEDING

```
+-------------------------------------------------------------+
|  YOU MUST WAIT FOR ALL THREE BACKGROUND TASKS TO COMPLETE    |
|                                                              |
|  DO NOT summarize what agents "would" find                   |
|  DO NOT proceed to Phase 4 early                             |
|  DO NOT provide your own analysis as substitute              |
|                                                              |
|  WAIT for actual agent results                               |
|  ONLY proceed when all three have returned                   |
+-------------------------------------------------------------+
```

### Results Extraction Checklist

When results return, extract and record:

```
From qe-quality-gate:
[ ] qualityGateStatus = PASSED/FAILED (X/Y gates passed)
[ ] testPassRate = __% overall pass rate
[ ] coverageDelta = +/-__% coverage change
[ ] failedTests = __ count of failed tests
[ ] qualityGateScore = __/50

From qe-regression-analyzer:
[ ] regressionRisk = __/50 risk score
[ ] blastRadius = __ files in blast radius
[ ] changedFiles = __ files changed
[ ] missingCoverage = __ uncovered changes
[ ] regressionRiskLevel = High/Medium/Low

From qe-flaky-hunter:
[ ] flakyTests = __ total flaky tests detected
[ ] criticalFlaky = __ blocking releases
[ ] pipelineStability = __% pass rate
[ ] stabilityScore = __/100
[ ] flakyRate = __% flaky rate
```

### Metrics Summary Box

Output extracted metrics:

```
+-------------------------------------------------------------+
|                    BATCH 1 RESULTS SUMMARY                   |
+-------------------------------------------------------------+
|                                                              |
|  Quality Gate:             PASSED/FAILED (X/Y gates)         |
|  Test Pass Rate:           __%                               |
|  Coverage Delta:           +/-__%                            |
|  Failed Tests:             __                                |
|  Quality Gate Score:       __/50                              |
|                                                              |
|  Regression Risk:          __/50 (High/Med/Low)              |
|  Blast Radius:             __ files                          |
|  Changed Files:            __                                |
|  Missing Coverage:         __ uncovered changes              |
|                                                              |
|  Flaky Tests:              __                                |
|  Critical Flaky:           __                                |
|  Pipeline Stability:       __%                               |
|  Stability Score:          __/100                            |
|  Flaky Rate:               __%                               |
|                                                              |
+-------------------------------------------------------------+
```

**DO NOT proceed to Phase 4 until ALL fields are filled.**

---

## PHASE 4: Spawn Conditional Agents (PARALLEL BATCH 2)

### ENFORCEMENT: NO SKIPPING CONDITIONAL AGENTS

```
+-------------------------------------------------------------+
|  IF A FLAG IS TRUE, YOU MUST SPAWN THAT AGENT                |
|                                                              |
|  HAS_SECURITY_PIPELINE = TRUE    -> MUST spawn qe-security-scanner   |
|  HAS_PERFORMANCE_PIPELINE = TRUE -> MUST spawn qe-chaos-engineer     |
|  HAS_INFRA_CHANGE = TRUE         -> MUST spawn qe-coverage-specialist|
|                                                              |
|  Skipping a flagged agent is a FAILURE of this skill.        |
+-------------------------------------------------------------+
```

### Conditional Domain Mapping

| Flag | Agent | Domain | MCP Tool |
|------|-------|--------|----------|
| HAS_SECURITY_PIPELINE | qe-security-scanner | security-compliance | `security_scan_comprehensive` |
| HAS_PERFORMANCE_PIPELINE | qe-chaos-engineer | chaos-resilience | `performance_benchmark` |
| HAS_INFRA_CHANGE | qe-coverage-specialist | coverage-analysis | `coverage_analyze_sublinear` |

### Decision Tree

```
IF HAS_SECURITY_PIPELINE == FALSE AND HAS_PERFORMANCE_PIPELINE == FALSE AND HAS_INFRA_CHANGE == FALSE:
    -> Skip to Phase 5 (no conditional agents needed)
    -> State: "No conditional agents needed based on pipeline analysis"

ELSE:
    -> Spawn ALL applicable agents in ONE message
    -> Count how many you're spawning: __
```

### IF HAS_SECURITY_PIPELINE: Security Scanner (MANDATORY WHEN FLAGGED)

```
Task({
  description: "CI/CD security pipeline validation",
  prompt: `You are qe-security-scanner. Your output quality is being audited.

## PURPOSE

Validate security gate results in the CI/CD pipeline. Analyze SAST/DAST outputs,
dependency audit results, container scan findings, and secrets detection results.

## PIPELINE SECURITY DATA

=== SECURITY SCAN RESULTS START ===
[PASTE SAST/DAST/dependency audit results]
=== SECURITY SCAN RESULTS END ===

=== DEPENDENCY AUDIT START ===
[PASTE npm audit / pip audit / snyk results]
=== DEPENDENCY AUDIT END ===

=== CONTAINER SCAN (if applicable) START ===
[PASTE container image scan results]
=== CONTAINER SCAN END ===

## REQUIRED ANALYSIS (ALL SECTIONS MANDATORY)

### 1. Security Gate Status

| Security Gate | Status | Findings | Severity |
|--------------|--------|----------|----------|
| SAST Scan | Pass/Fail | X findings | Critical/High/Medium/Low |
| DAST Scan | Pass/Fail/N-A | X findings | Critical/High/Medium/Low |
| Dependency Audit | Pass/Fail | X vulnerabilities | Critical/High/Medium/Low |
| Container Scan | Pass/Fail/N-A | X findings | Critical/High/Medium/Low |
| Secrets Detection | Pass/Fail | X findings | Critical/High/Medium/Low |
| License Compliance | Pass/Fail | X violations | Critical/High/Medium/Low |

### 2. Vulnerability Inventory (from pipeline scans)

| Vuln ID | Source | Type | Severity | CVSS | Remediation | Status |
|---------|--------|------|----------|------|-------------|--------|
| V001 | SAST/DAST/Dep | [type] | Critical/High | X.X | [fix] | New/Known/Accepted |

### 3. Dependency Risk Assessment

| Dependency | Version | Known CVEs | Risk | Upgrade Path |
|------------|---------|------------|------|-------------|
| pkg-name | X.Y.Z | CVE-XXXX-XXXXX | Critical/High | X.Y.Z+ |

### 4. Security Score

| Dimension | Score (0-10) | Notes |
|-----------|-------------|-------|
| SAST compliance | X/10 | ... |
| Dependency health | X/10 | ... |
| Container security | X/10 | ... |
| Secrets hygiene | X/10 | ... |
| License compliance | X/10 | ... |

**SECURITY PIPELINE SCORE: X/50**

**MINIMUM: Evaluate all 6 security gates and inventory all vulnerabilities found.**

## OUTPUT FORMAT

Save to: ${OUTPUT_FOLDER}/05-security-pipeline.md
Use the Write tool to save BEFORE completing.`,
  subagent_type: "qe-security-scanner",
  run_in_background: true
})
```

### IF HAS_PERFORMANCE_PIPELINE: Chaos Engineer (MANDATORY WHEN FLAGGED)

```
Task({
  description: "Performance pipeline validation and resilience assessment",
  prompt: `You are qe-chaos-engineer. Your output quality is being audited.

## PURPOSE

Validate performance test results in the CI/CD pipeline. Analyze load test output,
latency baselines, throughput metrics, and resilience test results.

## PERFORMANCE PIPELINE DATA

=== PERFORMANCE TEST RESULTS START ===
[PASTE load test / benchmark results]
=== PERFORMANCE TEST RESULTS END ===

=== BASELINE METRICS (if available) START ===
[PASTE previous performance baselines]
=== BASELINE METRICS END ===

## REQUIRED ANALYSIS (ALL SECTIONS MANDATORY)

### 1. Performance Gate Assessment

| Gate | Metric | Value | Baseline | Delta | Status |
|------|--------|-------|----------|-------|--------|
| Response Time (p50) | Xs | Xs | +/-X% | PASS/WARN/FAIL |
| Response Time (p95) | Xs | Xs | +/-X% | PASS/WARN/FAIL |
| Response Time (p99) | Xs | Xs | +/-X% | PASS/WARN/FAIL |
| Throughput (RPS) | X | X | +/-X% | PASS/WARN/FAIL |
| Error Rate | X% | X% | +/-X% | PASS/WARN/FAIL |
| Memory Usage | X MB | X MB | +/-X% | PASS/WARN/FAIL |

### 2. Performance Regression Detection

| Endpoint/Feature | Before | After | Regression? | Severity |
|-----------------|--------|-------|-------------|----------|
| GET /api/... | Xms | Xms | Yes/No | Critical/High/Medium |

### 3. Resource Consumption Analysis

| Resource | Peak Usage | Limit | Utilization | Risk |
|----------|-----------|-------|-------------|------|
| CPU | X% | X% | X% | High/Medium/Low |
| Memory | X MB | X MB | X% | High/Medium/Low |
| Disk I/O | X MB/s | X MB/s | X% | High/Medium/Low |
| Network | X MB/s | X MB/s | X% | High/Medium/Low |

### 4. Resilience Assessment

| Scenario | Result | Recovery Time | Status |
|----------|--------|--------------|--------|
| High load (2x baseline) | Pass/Fail | Xs | PASS/FAIL |
| Dependency timeout | Pass/Fail | Xs | PASS/FAIL |
| Memory pressure | Pass/Fail | Xs | PASS/FAIL |
| Connection pool exhaustion | Pass/Fail/N-A | Xs | PASS/FAIL/N-A |

### 5. Performance Score

| Dimension | Score (0-10) | Notes |
|-----------|-------------|-------|
| Latency compliance | X/10 | ... |
| Throughput stability | X/10 | ... |
| Resource efficiency | X/10 | ... |
| Resilience | X/10 | ... |

**PERFORMANCE PIPELINE SCORE: X/40**

**MINIMUM: Evaluate all 6 performance gates and detect any regressions.**

## OUTPUT FORMAT

Save to: ${OUTPUT_FOLDER}/06-performance-pipeline.md
Use the Write tool to save BEFORE completing.`,
  subagent_type: "qe-chaos-engineer",
  run_in_background: true
})
```

### IF HAS_INFRA_CHANGE: Coverage Specialist (MANDATORY WHEN FLAGGED)

```
Task({
  description: "Infrastructure change coverage and impact analysis",
  prompt: `You are qe-coverage-specialist. Your output quality is being audited.

## PURPOSE

Analyze coverage impact of infrastructure changes. Validate that infrastructure
modifications are properly tested, configuration changes are covered, and
deployment artifacts are verified.

## INFRASTRUCTURE CHANGE DATA

=== INFRA CHANGES START ===
[PASTE infrastructure file diffs - Dockerfiles, CI configs, k8s manifests, etc.]
=== INFRA CHANGES END ===

=== TEST RESULTS FOR INFRA START ===
[PASTE any infrastructure test results - smoke tests, config validation, etc.]
=== TEST RESULTS END ===

## REQUIRED ANALYSIS (ALL SECTIONS MANDATORY)

### 1. Infrastructure Change Inventory

| File | Change Type | Risk | Test Coverage |
|------|-----------|------|---------------|
| Dockerfile | Modified/New | High/Medium/Low | Tested/Untested |
| .github/workflows/... | Modified/New | High/Medium/Low | Tested/Untested |
| k8s/deployment.yaml | Modified/New | High/Medium/Low | Tested/Untested |
| terraform/... | Modified/New | High/Medium/Low | Tested/Untested |

### 2. Configuration Drift Analysis

| Config Parameter | Previous | New | Impact | Verified |
|-----------------|----------|-----|--------|----------|
| env_var | old_value | new_value | High/Medium/Low | Yes/No |
| resource_limit | old | new | High/Medium/Low | Yes/No |

### 3. Deployment Artifact Verification

| Artifact | Status | Size Delta | Integrity Check |
|----------|--------|-----------|-----------------|
| Container image | Built/Failed | +/-X MB | Pass/Fail |
| Bundle | Built/Failed | +/-X KB | Pass/Fail |
| Migration script | Valid/Invalid | N/A | Pass/Fail |

### 4. Infrastructure Test Coverage

| Test Type | Count | Status | Coverage |
|-----------|-------|--------|----------|
| Smoke tests | X | Pass/Fail | X% of changes |
| Config validation | X | Pass/Fail | X% of changes |
| Integration tests | X | Pass/Fail | X% of changes |
| Deployment dry-run | X | Pass/Fail | X% of changes |

### 5. Infrastructure Risk Score

| Dimension | Score (0-10) | Notes |
|-----------|-------------|-------|
| Change scope | X/10 | ... |
| Test coverage | X/10 | ... |
| Rollback capability | X/10 | ... |
| Configuration safety | X/10 | ... |

**INFRASTRUCTURE COVERAGE SCORE: X/40**

**MINIMUM: Inventory all infrastructure changes and assess test coverage for each.**

## OUTPUT FORMAT

Save to: ${OUTPUT_FOLDER}/07-infrastructure-coverage.md
Use the Write tool to save BEFORE completing.`,
  subagent_type: "qe-coverage-specialist",
  run_in_background: true
})
```

### Agent Count Validation

**Before proceeding, verify agent count:**

```
+-------------------------------------------------------------+
|                   AGENT COUNT VALIDATION                     |
+-------------------------------------------------------------+
|                                                              |
|  CORE AGENTS (ALWAYS 3):                                     |
|    [ ] qe-quality-gate - SPAWNED? [Y/N]                     |
|    [ ] qe-regression-analyzer - SPAWNED? [Y/N]              |
|    [ ] qe-flaky-hunter - SPAWNED? [Y/N]                     |
|                                                              |
|  CONDITIONAL AGENTS (based on flags):                        |
|    [ ] qe-security-scanner - SPAWNED? [Y/N] (HAS_SEC_PIPE)  |
|    [ ] qe-chaos-engineer - SPAWNED? [Y/N] (HAS_PERF_PIPE)   |
|    [ ] qe-coverage-specialist - SPAWNED? [Y/N] (HAS_INFRA)  |
|                                                              |
|  VALIDATION:                                                 |
|    Expected agents: [3 + count of TRUE flags]                |
|    Actual spawned:  [count]                                  |
|    Status:          [PASS/FAIL]                              |
|                                                              |
|  If ACTUAL < EXPECTED, you have FAILED. Spawn missing        |
|  agents before proceeding.                                   |
|                                                              |
+-------------------------------------------------------------+
```

**DO NOT proceed if validation FAILS.**

### Post-Spawn Confirmation (If Applicable)

```
I've launched [N] conditional agent(s) in parallel:

[IF HAS_SECURITY_PIPELINE]    qe-security-scanner [Domain: security-compliance]
                              - SAST/DAST validation, dependency audit, container scan
[IF HAS_PERFORMANCE_PIPELINE] qe-chaos-engineer [Domain: chaos-resilience]
                              - Performance regression detection, resource analysis, resilience
[IF HAS_INFRA_CHANGE]         qe-coverage-specialist [Domain: coverage-analysis]
                              - Infrastructure change coverage, config drift, artifact verification

  WAITING for conditional agents to complete...
```

---

## PHASE 5: Synthesize Results & Determine Recommendation

### ENFORCEMENT: EXACT DECISION LOGIC

**You MUST apply this logic EXACTLY. No interpretation.**

```
STEP 1: Derive composite metrics
-----------------------------------------------------------
qualityGatesPassed = (qualityGateStatus == "PASSED")
testPassRate = testPassRate from qe-quality-gate
regressionRisk = regressionRisk from qe-regression-analyzer (0-50 scale)
flakyRate = flakyRate from qe-flaky-hunter
criticalFlaky = criticalFlaky from qe-flaky-hunter
failedTests = failedTests from qe-quality-gate
securityFindings = (critical + high severity findings from security, if ran)
performanceRegressions = (count of regressions from chaos engineer, if ran)

STEP 2: Check BLOCK conditions (ANY triggers BLOCK)
-----------------------------------------------------------
IF qualityGatesPassed == FALSE        -> BLOCK ("Quality gates failed")
IF testPassRate < 95                  -> BLOCK ("Test pass rate critically low")
IF failedTests > 0 AND critical       -> BLOCK ("Critical test failures")
IF regressionRisk > 40               -> BLOCK ("Regression risk too high")
IF securityFindings > 0 (critical)    -> BLOCK ("Critical security vulnerabilities")

STEP 3: Check RELEASE conditions (ALL required for RELEASE)
-----------------------------------------------------------
IF qualityGatesPassed == TRUE
   AND testPassRate >= 99
   AND regressionRisk <= 15
   AND flakyRate <= 2
   AND criticalFlaky == 0
   AND failedTests == 0
   AND securityFindings == 0          -> RELEASE

STEP 4: Default
-----------------------------------------------------------
ELSE                                  -> REMEDIATE
```

### Decision Recording

```
METRICS:
- qualityGatesPassed = TRUE/FALSE
- testPassRate = __%
- regressionRisk = __/50
- flakyRate = __%
- criticalFlaky = __
- failedTests = __
- securityFindings = __ (if applicable)
- performanceRegressions = __ (if applicable)

BLOCK CHECK:
- qualityGatesPassed == FALSE? __ (YES/NO)
- testPassRate < 95? __ (YES/NO)
- critical test failures? __ (YES/NO)
- regressionRisk > 40? __ (YES/NO)
- critical security findings? __ (YES/NO)

RELEASE CHECK (only if no BLOCK triggered):
- qualityGatesPassed == TRUE? __ (YES/NO)
- testPassRate >= 99? __ (YES/NO)
- regressionRisk <= 15? __ (YES/NO)
- flakyRate <= 2? __ (YES/NO)
- criticalFlaky == 0? __ (YES/NO)
- failedTests == 0? __ (YES/NO)
- securityFindings == 0? __ (YES/NO)

FINAL RECOMMENDATION: [RELEASE / REMEDIATE / BLOCK]
REASON: ___
```

### Remediate Recommendations

If recommendation is REMEDIATE, provide specific remediation steps:

| Issue | Current Value | Required Value | Owner | Action |
|-------|--------------|----------------|-------|--------|
| ... | ... | ... | [who] | [what to do] |

If recommendation is BLOCK, provide mandatory fixes:

| Fix | Priority | Effort | Must Complete Before |
|-----|----------|--------|---------------------|
| ... | P0 | [scope] | [release can proceed] |

---

## PHASE 6: Generate Verification Report

### ENFORCEMENT: COMPLETE REPORT STRUCTURE

**ALL sections below are MANDATORY. No abbreviations.**

```markdown
# QCSD CI/CD Verification Report: [Feature/Release Name]

**Generated**: [Date/Time]
**Recommendation**: [RELEASE / REMEDIATE / BLOCK]
**Agents Executed**: [List all agents that ran]
**Parallel Batches**: [2 or 3 depending on conditional agents]
**Baseline Ref**: [BASELINE_REF value]
**Deploy Target**: [DEPLOY_TARGET value or "Not specified"]

---

## Executive Summary

| Metric | Value | Threshold | Status |
|--------|-------|-----------|--------|
| Quality Gates | X/Y passed | All pass | PASS/FAIL |
| Test Pass Rate | X% | >= 99% | PASS/WARN/FAIL |
| Regression Risk | X/50 | <= 15 | PASS/WARN/FAIL |
| Flaky Rate | X% | <= 2% | PASS/WARN/FAIL |
| Pipeline Stability | X/100 | >= 90 | PASS/WARN/FAIL |

**Recommendation Rationale**: [1-2 sentences explaining why RELEASE/REMEDIATE/BLOCK]

---

## Quality Gate Analysis

[EMBED or LINK the full report from qe-quality-gate]

### Gate Summary

| Gate | Status |
|------|--------|
[All 8 quality gates from qe-quality-gate]

### Failed Test Details
[Key findings from agent output]

---

## Regression Analysis

[EMBED or LINK the full report from qe-regression-analyzer]

### Impact Summary

| Dimension | Value | Risk |
|-----------|-------|------|
[Key metrics from agent output]

### Missing Coverage
[Gaps identified in changed code]

---

## Flaky Test Analysis

[EMBED or LINK the full report from qe-flaky-hunter]

### Stability Summary

| Metric | Value | Status |
|--------|-------|--------|
[Key metrics from agent output]

### Flaky Tests Identified
[List from agent output]

---

## Conditional Analysis

[INCLUDE O

…(truncated)
