kind: WavePipeline metadata: name: audit-dead-code-issue description: "Scan codebase for dead code and create a GitHub issue with findings" release: true requires: tools: - go - gh skills: - software-design input: source: cli example: "scan all packages for dead code and report findings" steps: - id: scan persona: navigator model: claude-haiku workspace: mount: - source: ./ target: /project mode: readonly exec: type: prompt source: | Scan for dead or redundant code: {{ input }} ## What to Look For 1. **Unused exports**: Exported functions, types, constants, or variables that are never referenced outside their package. 2. **Unreachable code**: Code after return/panic, impossible branches, dead switch cases. 3. **Orphaned files**: Files not imported by any other file in the project. 4. **Redundant code**: Duplicate functions, copy-paste blocks, wrappers that add no value. 5. **Stale tests**: Tests for functions that no longer exist, or tests that test nothing meaningful. 6. **Unused dependencies**: Imports that are no longer needed. 7. **Commented-out code**: Large blocks of commented code that should be deleted (git has history). 8. **Duplicate signatures**: Functions with identical signatures across packages that could be consolidated. ## Verification For each finding, verify it's truly dead: - Grep for all references across the entire codebase - Check for reflect-based or string-based usage - Check if it's part of an interface implementation - Check for build tag conditional compilation Produce a structured JSON result matching the contract schema. Only include findings with high or medium confidence. Skip low confidence. output_artifacts: - name: scan_results path: .wave/output/dead-code-scan.json type: json retry: policy: patient max_attempts: 2 handover: contract: type: json_schema source: .wave/output/dead-code-scan.json schema_path: .wave/contracts/dead-code-scan.schema.json on_failure: retry - id: compose-report persona: navigator model: claude-haiku dependencies: [scan] memory: inject_artifacts: - step: scan artifact: scan_results as: findings exec: type: prompt source: | Compose a dead code report as a GitHub-ready markdown file. ## Check for Findings If the scan found zero findings: - Write a short "No dead code found" message as the report - Write the issue result with skipped=true and reason="clean" ## Compose the Report Write the report as markdown: ``` ## Dead Code Report **Scan date**: **Findings**: ### Summary by Type | Type | Count | |------|-------| | unused_export | N | | unreachable | N | | ... | N | ### Summary by Suggested Action | Action | Count | |--------|-------| | remove | N | | consolidate | N | | investigate | N | ### Task List For each finding (sorted by confidence, high first): - [ ] **[DC-001]** (`type`, `confidence`) `location` — description Action: `suggested_action` | Safe to remove: `safe_to_remove` --- *Generated by [Wave](https://github.com/re-cinq/wave) dead-code-issue pipeline* ``` output_artifacts: - name: report path: .wave/output/report.md type: markdown handover: contract: type: non_empty_file source: .wave/output/report.md - id: create-issue persona: craftsman dependencies: [compose-report] memory: inject_artifacts: - step: scan artifact: scan_results as: findings - step: compose-report artifact: report as: report exec: type: prompt source: | Create a GitHub issue from the dead code report. If the report says "No dead code found", skip issue creation and exit with skipped=true in the result JSON. ## Detect Repository Run: `{{ forge.cli_tool }} repo view --json nameWithOwner --jq .nameWithOwner` ## Create the Issue ```bash {{ forge.cli_tool }} issue create \ --title "chore: dead code report" \ --body-file .wave/artifacts/report \ --label "code-quality" ``` If the `code-quality` label doesn't exist, create without labels. If any `{{ forge.cli_tool }}` command fails, log the error and continue. ## Capture Result Write a JSON status report matching the contract schema. Include the issue URL, number, title, and finding count from the scan results. output_artifacts: - name: issue-result path: .wave/output/issue-result.json type: json retry: policy: aggressive max_attempts: 2 handover: contract: type: json_schema source: .wave/output/issue-result.json schema_path: .wave/contracts/dead-code-issue-result.schema.json must_pass: true on_failure: retry outcomes: - type: issue extract_from: .wave/output/issue-result.json json_path: .issue.url label: "Dead Code Issue"