---
stage: common_artifacts
requires: 04d-report-verification
outputs: common_artifacts_complete
version: 3.6.0
estimated_tokens: 2000

guardrails:
  enforcement: active
  allowed_tools:
    - civyk-repoix
    - Read
    - Grep
    - Glob
    - Bash
  forbidden_actions:
    - "Delete any files"
    - "Modify any source files"
  read_only: true
---
# Stage 5: Common Artifacts Generation

## Purpose

Generate artifacts common to both analysis scopes: EXECUTIVE-SUMMARY.md, dependency-audit.json, and metrics-summary.json.

---

{{include:strict-execution-mode.md}}

{{include:analyze-state-management.md}}

{{include:analyze-file-write-policy.md}}

{{include:ai-cache-enforcement.md}}

---

## Recall Module Understanding

```text
# Project understanding already recalled via cache enforcement above.
# Additionally recall module-level understanding (adjust paths to match project structure):
understand(action="recall", target="{project_path}/auth")
understand(action="recall", target="{project_path}/api")
understand(action="recall", target="{project_path}/data")
understand(action="recall", target="{project_path}/services")
# IF found AND fresh: Use cached analysis for executive summary
```

---

## Pre-Check

1. Verify `{reports_dir}/analysis-report.md` exists and is complete

---

## Artifact 1: EXECUTIVE-SUMMARY.md

---
**[STOP: GENERATE_EXECUTIVE_SUMMARY]**

Generate C-level summary using CLI: `civyk-hatch write-report EXECUTIVE-SUMMARY.md --stage=05a-executive-summary --content '<md>' --analysis-dir "{analysis_dir}"`

This saves to: `{reports_dir}/EXECUTIVE-SUMMARY.md`

```markdown
# Executive Summary: {Project Name}

## Overview

- **Project:** {name}
- **Analysis Date:** {date}
- **Analysis Scope:** {Full Application | Cross-Cutting Concern}
- **Chain ID:** {chain_id}

## Key Findings

### Current State

| Metric | Value | Rating |
|--------|-------|--------|
| Technology Stack | {stack} | {rating} |
| Project Size | {LOC} LOC, {files} files | - |
| Test Coverage | {coverage}% | {rating} |
| Technical Debt | {count} items | {HIGH/MEDIUM/LOW} |
| Security Issues | {count} ({critical} critical) | {rating} |

### Recommendations

| Aspect | Recommendation |
|--------|----------------|
| **Primary Approach** | {approach} |
| **Confidence** | {percentage}% |
| **Timeline** | {duration} |
| **Effort** | {person-weeks} |

### Business Impact

| Factor | Assessment |
|--------|------------|
| Risk Level | {LOW/MEDIUM/HIGH} |
| Downtime Required | {Yes/No} |
| Training Required | {Yes/No} |

### Immediate Actions

1. {action 1}
2. {action 2}
3. {action 3}

---
*Generated by Civyk Hatch Advanced v5.0.0*

```

**Verify:** Read file, confirm no placeholders
**Output:** `[ok] Generated: EXECUTIVE-SUMMARY.md`

---

## Artifact 2: dependency-audit.json

---
**[STOP: GENERATE_DEPENDENCY_AUDIT]**

Generate machine-readable dependency audit using CLI: `civyk-hatch write-data dependency-audit.json --stage=05a-executive-summary --content '<json>' --analysis-dir "{analysis_dir}"`

This saves to: `{data_dir}/dependency-audit.json`

```json
{
  "audit_date": "{ISO-8601}",
  "project": "{name}",
  "total_dependencies": {count},
  "direct_dependencies": {count},
  "transitive_dependencies": {count},
  "outdated": [
    {"name": "{pkg}", "current": "{ver}", "latest": "{ver}", "type": "major|minor|patch"}
  ],
  "vulnerable": [
    {"name": "{pkg}", "version": "{ver}", "severity": "CRITICAL|HIGH|MEDIUM|LOW", "cve": "{CVE}", "description": "{desc}", "remediation": "{fix}"}
  ],
  "deprecated": [
    {"name": "{pkg}", "replacement": "{alternative}"}
  ],
  "summary": {
    "outdated_count": {n},
    "vulnerable_count": {n},
    "deprecated_count": {n},
    "critical_vulns": {n},
    "high_vulns": {n}
  }
}

```

**Verify:** Validate JSON parseable
**Output:** `[ok] Generated: dependency-audit.json`

---

## Artifact 3: metrics-summary.json

---
**[STOP: GENERATE_METRICS_SUMMARY]**

Generate metrics for tracking using CLI: `civyk-hatch write-data metrics-summary.json --stage=05a-executive-summary --content '<json>' --analysis-dir "{analysis_dir}"`

This saves to: `{data_dir}/metrics-summary.json`

```json
{
  "project": "{name}",
  "analysis_date": "{ISO-8601}",
  "chain_id": "{chain_id}",
  "metrics": {
    "code": {
      "total_lines": {count},
      "total_files": {count},
      "languages": {"java": {lines}, "javascript": {lines}}
    },
    "quality": {
      "test_coverage_percent": {n},
      "tech_debt_score": {n},
      "security_score": {n},
      "maintainability_score": {n}
    },
    "dependencies": {
      "total": {n},
      "outdated": {n},
      "vulnerable": {n},
      "critical_vulns": {n}
    },
    "complexity": {
      "score": {0-100},
      "rating": "LOW|MEDIUM|HIGH|VERY HIGH"
    },
    "feasibility": {
      "inline_upgrade": {n},
      "greenfield_rewrite": {n},
      "hybrid_approach": {n}
    }
  }
}

```

**Verify:** Validate JSON parseable
**Output:** `[ok] Generated: metrics-summary.json`

---

## Generate Stage 5 State

```json
{
  "schema_version": "3.1.0",
  "chain_id": "{chain_id}",
  "stage": "common_artifacts",
  "timestamp": "{ISO-8601}",
  "stages_complete": [..., "common_artifacts"],
  "common_artifacts_complete": true,
  "artifacts_generated": [
    "EXECUTIVE-SUMMARY.md",
    "dependency-audit.json",
    "metrics-summary.json"
  ]
}

```

The CLI automatically updates `{analysis_dir}/state.json` when stages complete.

---

## Completion Marker

```text
===========================================================
  STAGE COMPLETE: COMMON_ARTIFACTS

  Generated:
    [ok] EXECUTIVE-SUMMARY.md
    [ok] dependency-audit.json
    [ok] metrics-summary.json

  Proceeding to Scope-Specific Artifacts...
===========================================================

STAGE_COMPLETE:COMMON_ARTIFACTS

```

---

---

## Next Stage

**[AUTO-CONTINUE]** Run the CLI command below NOW. Do NOT generate content without the next stage prompt.

```bash
civyk-hatch analyze-project
```

**CRITICAL: This is NOT the final stage. You MUST continue to Stage 6.**

The CLI auto-detects current stage and emits the correct next prompt based on scope:
- **Scope A:** Functional specs (legacy + target) and Technical specs
- **Scope B:** Abstraction assessment, migration plan, rollback procedure

**Do NOT analyze or generate artifacts until you run this command.**
