diff --git a/claude/qa/commands/qa.md b/claude/qa/commands/qa.md index 0d82c6e..dc09058 100644 --- a/claude/qa/commands/qa.md +++ b/claude/qa/commands/qa.md @@ -1,66 +1,17 @@ --- name: qa -description: Run full QA pipeline and fix all issues iteratively -hooks: - PostToolUse: - - matcher: "Bash" - hooks: - - type: command - command: "${CLAUDE_PLUGIN_ROOT}/scripts/qa-filter.sh" - Stop: - - hooks: - - type: command - command: "${CLAUDE_PLUGIN_ROOT}/scripts/qa-verify.sh" - once: true +description: Run iterative QA loop until all checks pass +args: [--fix] [--quick] +run: ${CLAUDE_PLUGIN_ROOT}/scripts/qa.sh $@ --- -# QA Fix Loop +# QA Loop -Run the full QA pipeline and fix all issues until everything passes. +Run QA checks and fix issues iteratively. -## Detection - -First, detect the project type: -- If `go.mod` exists → Go project → `core go qa` -- If `composer.json` exists → PHP project → `core php qa` -- If both exist → check current directory or ask - -## Process - -1. **Run QA**: Execute `core go qa` or `core php qa` -2. **Parse issues**: Extract failures from output -3. **Fix each issue**: Address one at a time, simplest first -4. **Re-verify**: After fixes, re-run QA -5. **Repeat**: Until all checks pass -6. **Report**: Summary of what was fixed - -## Issue Priority - -Fix in this order (fastest feedback first): -1. **fmt** - formatting (auto-fix with `core go fmt`) -2. **lint** - static analysis (usually quick fixes) -3. **test** - failing tests (may need investigation) -4. **build** - compilation errors (fix before tests can run) - -## Fixing Strategy - -**Formatting (fmt/pint):** -- Just run `core go fmt` or `core php fmt` -- No code reading needed - -**Lint errors:** -- Read the specific file:line -- Understand the error type -- Make minimal fix - -**Test failures:** -- Read the test file to understand expectation -- Read the implementation -- Fix the root cause (not just the symptom) - -## Stop Condition - -Only stop when: -- All QA checks pass, OR -- User explicitly cancels, OR -- Same error repeats 3 times (stuck - ask for help) +## Action +1. Detect project type from go.mod or composer.json +2. Run `core go qa` or `core php qa` +3. Parse output for fixable issues +4. Apply fixes and re-run +5. Report final status diff --git a/claude/qa/scripts/qa.sh b/claude/qa/scripts/qa.sh new file mode 100755 index 0000000..2fc7b31 --- /dev/null +++ b/claude/qa/scripts/qa.sh @@ -0,0 +1,89 @@ +#!/bin/bash +# Core QA command logic + +# --- Flags --- +FIX=false +QUICK=false +while [[ "$#" -gt 0 ]]; do + case "$1" in + --fix) + FIX=true + shift + ;; + --quick) + QUICK=true + shift + ;; + *) + # Unknown arg, shift past it + shift + ;; + esac +done + +# --- Project Detection --- +PROJECT_TYPE="" +if [ -f "go.mod" ]; then + PROJECT_TYPE="go" +elif [ -f "composer.json" ]; then + PROJECT_TYPE="php" +else + echo "Could not determine project type (go.mod or composer.json not found)." + exit 1 +fi + +# --- QA Functions --- +run_qa() { + if [ "$PROJECT_TYPE" = "go" ]; then + core go qa + else + core php qa + fi +} + +run_lint() { + if [ "$PROJECT_TYPE" = "go" ]; then + core go lint + else + core php pint --test + fi +} + +run_fix() { + if [ "$PROJECT_TYPE" = "go" ]; then + core go fmt + else + core php pint + fi +} + +# --- Main Logic --- +if [ "$QUICK" = true ]; then + echo "Running in --quick mode (lint only)..." + run_lint + exit $? +fi + +echo "Running QA for $PROJECT_TYPE project..." +MAX_ITERATIONS=3 +for i in $(seq 1 $MAX_ITERATIONS); do + echo "--- Iteration $i ---" + run_qa + EXIT_CODE=$? + + if [ $EXIT_CODE -eq 0 ]; then + echo "✓ QA Passed" + exit 0 + fi + + if [ "$FIX" = false ]; then + echo "✗ QA Failed" + exit $EXIT_CODE + fi + + echo "QA failed. Attempting to fix..." + run_fix +done + +echo "✗ QA failed after $MAX_ITERATIONS iterations." +exit 1