.claude/skills/gates/SKILL.md
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'.
npx skillsauth add alfredolopez80/multi-agent-ralph-loop gatesInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Comprehensive quality validation across 9 programming languages with TLDR-assisted analysis.
~/.claude/settings.json or CLI/env varsANTHROPIC_DEFAULT_*_MODEL env vars/gates # Run all quality gates
ralph gates # Via CLI
ralph gates src/ # Specific directory
IMPORTANT: Use LSP for efficient type checking instead of reading entire files.
tsc --noEmit# Type check a specific file (TypeScript)
LSP:
server: typescript-language-server
action: diagnostics
file: src/auth/login.ts
# Get hover information for a symbol
LSP:
server: typescript-language-server
action: hover
file: src/auth/login.ts
line: 42
character: 10
# Find all references
LSP:
server: typescript-language-server
action: references
file: src/auth/login.ts
line: 42
character: 10
# Python type checking with pyright
LSP:
server: pyright
action: diagnostics
file: src/auth/login.py
| Method | Tokens Used | Speed | Use Case |
|--------|-------------|-------|----------|
| tsc --noEmit | HIGH (reads all files) | Slow | Full project check |
| LSP diagnostics | LOW (indexed access) | Fast | Single file check |
| LSP hover | MINIMAL | Instant | Quick type lookup |
AUTOMATIC - Detect project languages efficiently:
# Get codebase structure to detect languages (95% token savings)
tldr structure . > /tmp/project-structure.md
# From structure, identify:
# - Primary language(s)
# - Config files present
# - Test frameworks used
| Language | Linter | Formatter | Types | |----------|--------|-----------|-------| | TypeScript | ESLint | Prettier | tsc | | JavaScript | ESLint | Prettier | - | | Python | Ruff | Black | mypy | | Rust | Clippy | rustfmt | cargo check | | Go | golint | gofmt | go vet | | Java | Checkstyle | google-java-format | - | | Ruby | RuboCop | - | Sorbet | | PHP | PHP_CodeSniffer | php-cs-fixer | PHPStan | | Solidity | Solhint | prettier-solidity | - |
# Auto-detect based on file extensions and config files
# Per-language linting
npx eslint src/ # TypeScript/JavaScript
ruff check . # Python
cargo clippy # Rust
golangci-lint run # Go
npx prettier --check . # JS/TS
black --check . # Python
rustfmt --check src/ # Rust
gofmt -l . # Go
npx tsc --noEmit # TypeScript
mypy . # Python
cargo check # Rust
go vet ./... # Go
npm test # Node projects
pytest # Python
cargo test # Rust
go test ./... # Go
| Code | Meaning | |------|---------| | 0 | All gates passed | | 1 | Lint errors | | 2 | Format errors | | 3 | Type errors | | 4 | Test failures |
ralph gates --minimal # Lint only
ralph gates # Lint + Format + Types
ralph gates --full # Lint + Format + Types + Tests
quality-gates.sh (PostToolUse)| Phase | TLDR Command | Purpose |
|-------|--------------|---------|
| Language detection | tldr structure . | Identify languages |
| Error context | tldr context $FILE . | Understand failing code |
| Impact analysis | tldr deps $FILE . | Find related tests |
Optimal Scenario: Integrated (Agent Teams + Custom Subagents)
Quality gates use Agent Teams coordination with specialized ralph-tester agents for parallel quality validation.
| Subagent | Role in Gates |
|----------|---------------|
| ralph-tester | Execute test suites in parallel |
| ralph-reviewer | Analyze code quality issues |
| ralph-coder | Apply auto-fixes for linting/formatting |
When Agent Teams is active, gates run in parallel across subagents:
TeammateIdle: Triggers before agent goes idleTaskCompleted: Validates gate completionLos resultados de /gates generan reportes automáticos completos:
Cuando /gates completa, se genera automáticamente:
docs/actions/gates/{timestamp}.md.claude/metadata/actions/gates/{timestamp}.jsonCada reporte incluye:
# 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
# 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
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.
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 |
#!/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
/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
Configure which gates stages to enforce based on experiment risk:
| Risk Level | Stages in checks.sh | Use Case | |---|---|---| | Low (prompt tuning, config) | CORRECTNESS only | Non-code experiments | | Medium (refactoring, optimization) | CORRECTNESS + QUALITY + TESTS | Standard code experiments | | High (security-adjacent, API changes) | All four stages | Experiments touching auth, crypto, APIs |
#!/usr/bin/env bash
set -euo pipefail
# CORRECTNESS
echo "[checks] CORRECTNESS"
python -m py_compile "$TARGET_FILE" || exit 1
mypy . --ignore-missing-imports 2>&1 || exit 1
# QUALITY
echo "[checks] QUALITY"
ruff check . 2>&1 || exit 1
# SECURITY
echo "[checks] SECURITY"
if command -v semgrep &>/dev/null; then
semgrep --config=auto --error --quiet 2>&1 || exit 1
fi
# TESTS
echo "[checks] TESTS"
pytest --tb=short 2>&1 || exit 1
exit 0
See master table: docs/reference/anti-rationalization.md
| Excuse | Rebuttal | |---|---| | "It's just a warning, not an error" | Warnings become errors in production. Fix them. | | "Security scan is too strict" | Security scan catches what you missed. | | "Type errors are false positives" | Type errors are real until proven false. Investigate. | | "Linting is style, not substance" | Consistency IS substance in team projects. | | "I'll pass gates after the PR" | Gates run BEFORE completion, not after. |
development
Living knowledge base management. Actions: search (query vault), save (store learning), index (update indices), compile (raw->wiki->rules graduation), init (create vault structure). Follows Karpathy pipeline: ingest->compile->query. Use when: (1) searching accumulated knowledge, (2) saving learnings, (3) compiling raw notes into wiki, (4) initializing a new vault. Triggers: /vault, 'vault search', 'knowledge base', 'save learning'.
testing
Produce a verifiable technical specification before coding. 6 mandatory sections: Interfaces, Behaviors, Invariants (from Aristotle Phase 2), File Plan, Test Plan, Exit Criteria (executable bash commands + expected results). Use when: (1) before implementing features with complexity > 4, (2) as Step 1.5 in orchestrator workflow, (3) when requirements need formalization. Triggers: /spec, 'create spec', 'write specification', 'technical spec'.
testing
Pre-launch shipping checklist orchestrating /gates, /security, /browser-test, /perf. Ensures nothing ships without passing all quality checks. Use when: (1) before deploying, (2) before merging to main, (3) before release. Triggers: /ship, 'ship it', 'ready to deploy', 'pre-launch check'.
development
Performance optimization skill. Core Web Vitals via Lighthouse, bundle size analysis, metrics tracking over time. Use when: (1) optimizing frontend performance, (2) analyzing bundle size, (3) tracking metrics regression. Triggers: /perf, 'performance audit', 'core web vitals', 'bundle size'.