9-language quality gate validation: linting, formatting, type checking, and test execution. Validates code changes meet quality standards before completion. Use when: (1) after code implementation, (2) before PR creation, (3) as part of /orchestrator Step 6, (4) manual quality check. Triggers: /gates, 'quality gates', 'run validation', 'check quality', 'validate code'.
✅ Results: Resultados de linters, formatters, type checkers, tests
✅ Errors: Errores encontrados por categoría
✅ Recommendations: Acciones correctivas sugeridas
✅ Next Steps: Qué hacer según el resultado
Generación Manual (Opcional)
# Al inicio
source .claude/lib/action-report-lib.sh
start_action_report "gates" "Running quality gates on src/"
# Ejecutar validaciones
if ! npx tsc --noEmit; then
record_error "TypeScript errors found"
fi
if ! npx eslint .; then
record_error "ESLint violations found"
fi
if ! npm test; then
record_error "Test failures found"
fi
# Al completar
if [[ ${#CURRENT_ACTION_ERRORS[@]} -eq 0 ]]; then
complete_action_report \
"success" \
"All quality gates passed" \
"Safe to commit: git commit -m 'chore: pass quality gates'"
else
complete_action_report \
"failed" \
"Quality gates failed" \
"Fix errors and run /gates again"
fi
Ver Reportes Anteriores
# Listar todos los reportes de gates
ls -lt docs/actions/gates/
# Ver el reporte más reciente
cat $(ls -t docs/actions/gates/*.md | head -1)
# Buscar reportes fallidos
grep -l "Status: FAILED" docs/actions/gates/*.md
# Ver tendencia de calidad
grep -c "Status: COMPLETED" docs/actions/gates/*.md
grep -c "Status: FAILED" docs/actions/gates/*.md
Integración CI/CD
Los metadatos JSON permiten integración con pipelines:
# En tu CI pipeline
source .claude/lib/action-report-generator.sh
# Ejecutar gates
/gates
# Obtener resultado del último reporte
latest_report=$(find_latest_report "gates")
status=$(grep "Status:" "$latest_report" | awk '{print $2}')
if [[ "$status" != "COMPLETED" ]]; then
echo "Quality gates failed - blocking commit"
exit 1
fi
The /gates quality stages can be wired as the backpressure mechanism for /autoresearch experiments. When autoresearch modifies code to optimize a metric, gates ensure the optimization does not introduce regressions in correctness, quality, or security.
Mapping Gates Stages to checks.sh
Each /gates stage maps directly to content you can place in the autoresearch checks.sh file:
Gates Stage
checks.sh Content
Purpose
CORRECTNESS
tsc --noEmit && cargo check && go vet ./...
Syntax and type checks - reject experiments that break compilation
QUALITY
npx eslint . --max-warnings=0 && ruff check .
Lint + complexity - reject experiments that degrade code quality
SECURITY
semgrep --config=auto --error && gitleaks detect
Security scan - reject experiments that introduce vulnerabilities
CONSISTENCY
npx prettier --check . && black --check .
Formatting - advisory, does not block experiments
Template: checks.sh Using Gates
#!/usr/bin/env bash
# checks.sh - Autoresearch backpressure via /gates stages
# Place this file alongside your autoresearch target directory.
# Autoresearch runs this AFTER every experiment. Non-zero exit = discard change.
set -euo pipefail
# Stage 1: CORRECTNESS (blocking)
# Ensures the experiment did not break type safety or compilation.
echo "[checks] Stage 1: CORRECTNESS"
npx tsc --noEmit 2>&1 || exit 1
# Stage 2: QUALITY (blocking)
# Ensures the experiment did not introduce lint violations or increase complexity.
echo "[checks] Stage 2: QUALITY"
npx eslint . --max-warnings=0 2>&1 || exit 1
# Stage 3: SECURITY (blocking)
# Ensures the experiment did not introduce security vulnerabilities.
echo "[checks] Stage 3: SECURITY"
if command -v semgrep &>/dev/null; then
semgrep --config=auto --error --quiet 2>&1 || exit 1
fi
# Stage 4: TESTS (blocking)
# Ensures existing tests still pass after the experiment.
echo "[checks] Stage 4: TESTS"
npm test 2>&1 || exit 1
echo "[checks] All gates passed"
exit 0
How It Works
/autoresearch loop iteration:
1. HYPOTHESIZE -> MODIFY -> COMMIT
2. RUN metric command (e.g., "npm run build")
3. RUN checks.sh <-- /gates stages act as guardrails
- If checks.sh fails -> DISCARD experiment (git reset)
- If checks.sh passes -> EVALUATE metric delta
4. Keep improvement or discard regression
Backpressure Levels
Configure which gates stages to enforce based on experiment risk: