|
| 1 | +--- |
| 2 | +name: quality-scan |
| 3 | +description: Scans the codebase for bugs, logic errors, caching issues, and workflow problems using specialized agents. Use when preparing for release, investigating quality issues, or running pre-merge checks. |
| 4 | +user-invocable: true |
| 5 | +allowed-tools: Task, Bash, Read, Grep, Glob, AskUserQuestion |
| 6 | +--- |
| 7 | + |
| 8 | +# quality-scan |
| 9 | + |
| 10 | +Perform comprehensive quality analysis across the codebase using specialized agents. Clean up junk files first, then scan and generate a prioritized report with actionable fixes. |
| 11 | + |
| 12 | +## Scan Types |
| 13 | + |
| 14 | +1. **critical** - Crashes, security vulnerabilities, resource leaks, data corruption |
| 15 | +2. **logic** - Algorithm errors, edge cases, type guards, off-by-one errors |
| 16 | +3. **cache** - Cache staleness, race conditions, invalidation bugs |
| 17 | +4. **workflow** - Build scripts, CI issues, cross-platform compatibility |
| 18 | +5. **workflow-optimization** - CI optimization (build-required conditions on cached builds) |
| 19 | +6. **security** - GitHub Actions workflow security (zizmor scanner) |
| 20 | +7. **documentation** - README accuracy, outdated docs, missing documentation |
| 21 | +8. **patch-format** - Patch file format validation |
| 22 | + |
| 23 | +Agent prompts for each scan type are in `reference.md`. |
| 24 | + |
| 25 | +## Process |
| 26 | + |
| 27 | +### Phase 1: Validate Environment |
| 28 | + |
| 29 | +```bash |
| 30 | +git status |
| 31 | +``` |
| 32 | + |
| 33 | +Warn about uncommitted changes but continue (scanning is read-only). |
| 34 | + |
| 35 | +### Phase 2: Update Dependencies |
| 36 | + |
| 37 | +```bash |
| 38 | +pnpm run update |
| 39 | +``` |
| 40 | + |
| 41 | +Only update the current repository. Continue even if update fails. |
| 42 | + |
| 43 | +### Phase 3: Install zizmor |
| 44 | + |
| 45 | +Install zizmor for GitHub Actions security scanning, respecting the `minimumReleaseAge` from `.pnpmrc` (default 10080 minutes = 7 days). Query GitHub releases, find the latest stable release older than the threshold, and install via pipx/uvx. Skip the security scan if no release meets the age requirement. |
| 46 | + |
| 47 | +### Phase 4: Repository Cleanup |
| 48 | + |
| 49 | +Find and remove junk files (with user confirmation via AskUserQuestion): |
| 50 | +- SCREAMING_TEXT.md files outside `.claude/` and `docs/` |
| 51 | +- Test files in wrong locations |
| 52 | +- Temp files (`.tmp`, `.DS_Store`, `*~`, `*.swp`, `*.bak`) |
| 53 | +- Log files in root/package directories |
| 54 | + |
| 55 | +### Phase 5: Structural Validation |
| 56 | + |
| 57 | +```bash |
| 58 | +node scripts/check-consistency.mjs |
| 59 | +``` |
| 60 | + |
| 61 | +Report errors as Critical findings. Warnings are Low findings. |
| 62 | + |
| 63 | +### Phase 6: Determine Scan Scope |
| 64 | + |
| 65 | +Ask user which scans to run using AskUserQuestion (multiSelect). Default: all scans. |
| 66 | + |
| 67 | +### Phase 7: Execute Scans |
| 68 | + |
| 69 | +For each enabled scan type, spawn a Task agent with the corresponding prompt from `reference.md`. Run sequentially in priority order: critical, logic, cache, workflow, then others. |
| 70 | + |
| 71 | +Each agent reports findings as: |
| 72 | +- File: path:line |
| 73 | +- Issue, Severity, Pattern, Trigger, Fix, Impact |
| 74 | + |
| 75 | +### Phase 8: Aggregate and Report |
| 76 | + |
| 77 | +- Deduplicate findings across scan types |
| 78 | +- Sort by severity: Critical > High > Medium > Low |
| 79 | +- Generate markdown report with file:line references, suggested fixes, and coverage metrics |
| 80 | +- Offer to save to `reports/quality-scan-YYYY-MM-DD.md` |
| 81 | + |
| 82 | +### Phase 9: Summary |
| 83 | + |
| 84 | +Report final metrics: dependency updates, structural validation results, cleanup stats, scan counts, and total findings by severity. |
0 commit comments