Receber por email
← Voltar para o catálogo

quality-gates

Execute verificações de qualidade abrangentes, incluindo linting, verificação de tipo, testes e auditorias de segurança, antes de commits ou implantações.

367estrelas
Atualizado há 4 meses

Ver no GitHub ↗

Como adicionar

/plugin marketplace add aiskillstore/marketplace

O comando exato pode variar conforme o repositório. Confira o README no GitHub.

Para o autor da skill

Cole no README do seu repo

Mostra que sua skill está catalogada na Skillteca, gera backlink e tráfego rastreável.

[![Skillteca](https://www.skillteca.com.br/api/badge/quality-gates-aiskillstore/svg)](https://www.skillteca.com.br/skills/quality-gates-aiskillstore)

Skills relacionadas

Ver todas de Desenvolvimento →

Alerta por categoria

Receba novas skills de Desenvolvimento toda segunda

1 email curto, só com as skills novas de Desenvolvimento. 4 minutos de leitura, sem spam, cancela com 1 clique.

Você confirma o email no primeiro envio. Sem spam. Cancela com 1 clique.

Ler descrição completa

Quality Gates Skill

Objective

Enforce code quality standards by running automated checks that must pass before code can be committed, merged, or deployed. Acts as a guardian ensuring consistent quality across the codebase.

When to Use This Skill

Auto-invoke when:

  • User completes feature implementation
  • Before creating commits or pull requests
  • User asks to "test", "validate", "check quality", or "verify"
  • Before deployment or release
  • After significant refactoring

Quality Gate Levels

Level 1: Pre-Commit Gates (Fast, < 30 seconds)

Essential checks that run before every commit.

Level 2: Pre-Push Gates (Moderate, < 2 minutes)

Comprehensive checks before pushing to remote.

Level 3: Pre-Deploy Gates (Thorough, < 5 minutes)

Complete validation before production deployment.

Gate Execution Workflow

Gate 1: Linting (JavaScript/TypeScript)

Purpose: Enforce code style and catch common errors

Tools: Bash, Read

Process:

  1. Detect linter by checking for:
  2. ESLint: .eslintrc*, eslint.config.*
  3. Biome: biome.json
  4. None: Skip this gate
  1. Read package.json to find lint script:

``json "scripts": { "lint": "eslint .", "lint:fix": "eslint . --fix" } ``

  1. Execute linter:

```bash # Try to run lint script npm run lint

# If fails, try direct commands npx eslint . || npx biome check . ```

  1. Parse results:
  2. Exit code 0: ✅ PASS
  3. Exit code non-zero: ❌ FAIL
  4. Extract error count and file locations
  1. Auto-fix attempt (if failures found):

``bash npm run lint:fix || npx eslint . --fix ``

Success Criteria: Zero linting errors (warnings acceptable)

Gate 2: Type Checking (TypeScript)

Purpose: Verify type safety and catch type errors

Tools: Bash, Read, Grep

Process:

  1. Detect TypeScript by checking for:
  2. tsconfig.json
  3. TypeScript in dependencies
  1. Read tsconfig.json to check strictness:
  2. strict: true
  3. noImplicitAny, strictNullChecks, etc.
  1. Execute type checker:

```bash # Try to run typecheck script npm run typecheck || npm run type-check

# If no script, run directly npx tsc --noEmit ```

  1. Parse results:
  2. Exit code 0: ✅ PASS
  3. Exit code non-zero: ❌ FAIL
  4. Extract error count and locations

Success Criteria: Zero type errors

Gate 3: Unit & Integration Tests

Purpose: Verify code functionality and prevent regressions

Tools: Bash, Read, Grep

Process:

  1. Detect test framework:
  2. Vitest: vitest.config.*, vitest in dependencies
  3. Jest: jest.config.*, jest in dependencies
  4. Native test: --test flag with Node.js 20+
  1. Count test files:

``bash # Use Grep to find test files find . -name ".test." -o -name ".spec." | wc -l ``

  1. Execute tests:

```bash # Run unit tests (fast) npm run test || npm run test:unit

# Or direct command npx vitest run || npx jest --ci ```

  1. Parse results:
  2. Total tests run
  3. Passed / Failed / Skipped
  4. Coverage percentage (if available)
  1. Coverage check (if configured):

```bash npm run test:coverage

# Check if meets threshold (e.g., 80%) ```

Success Criteria:

  • All tests pass (100%)
  • Coverage ≥ configured threshold (if set)

Gate 4: Build Verification

Purpose: Ensure code compiles and builds without errors

Tools: Bash

Process:

  1. Detect build system:
  2. Next.js: next build
  3. Vite: vite build
  4. Webpack: webpack --mode production
  5. TypeScript: tsc
  1. Execute build:

``bash npm run build ``

  1. Check build artifacts:
  2. Verify output directory exists: dist/, build/, .next/
  3. Check for build errors in logs
  1. Clean up (optional):

``bash # Remove build artifacts to save space rm -rf dist/ build/ .next/ ``

Success Criteria: Build completes with exit code 0

Gate 5: Security Audit

Purpose: Identify known vulnerabilities in dependencies

Tools: Bash, Read

Process:

  1. Run npm/pnpm audit:

``bash npm audit --json || pnpm audit --json ``

  1. Parse audit results:
  2. Critical vulnerabilities: 0
  3. High vulnerabilities: 0
  4. Moderate vulnerabilities: < threshold
  5. Low vulnerabilities: informational
  1. Check for specific vulnerabilities:
  2. Prototype pollution
  3. Remote code execution (RCE)
  4. SQL injection
  5. Cross-site scripting (XSS)
  1. Suggest fixes:

``bash npm audit fix # or npm audit fix --force # (if safe) ``

Success Criteria:

  • Zero critical/high vulnerabilities
  • Moderate vulnerabilities acknowledged or fixed

Gate 6: Code Complexity Analysis (Optional)

Purpose: Flag overly complex code that may need refactoring

Tools: Grep, Bash

Process:

  1. Detect code complexity tools:
  2. eslint-plugin-complexity
  3. SonarQube
  4. CodeClimate
  1. Basic complexity checks:

```bash # Find files with excessive lines find src -name "*.{ts,tsx,js,jsx}" -exec wc -l {} \; | awk '$1 > 500'

# Find deeply nested code (>5 levels) grep -rn "^[[:space:]]\{20,\}" src/

# Count TODO/FIXME grep -rn "TODO\|FIXME\|HACK" src/ | wc -l ```

Success Criteria:

  • No files > 500 lines (warning only)
  • No nesting > 5 levels (warning only)

Gate 7: Git Pre-Commit Checks

Purpose: Ensure commit quality and prevent sensitive data leaks

Tools: Bash, Grep

Process:

  1. Check for sensitive data:

```bash # Search for API keys, secrets, tokens git diff --cached | grep -i "api[_-]key\|secret\|password\|token"

# Check for .env files being committed git diff --cached --name-only | grep "\.env$" ```

  1. Validate commit message (if Conventional Commits):
  2. Format: type(scope): description
  3. Types: feat, fix, docs, style, refactor, test, chore
  1. Check file sizes:

``bash # Flag files > 1MB git diff --cached --name-only | xargs ls -lh | awk '$5 > 1000000' ``

Success Criteria:

  • No secrets in diff
  • No .env files
  • No large files (> 1MB)

Execution Strategy

Sequential Execution (Default)

Run gates in order, stop on first failure:

Lint → TypeCheck → Test → Build → Audit

Parallel Execution (Fast Mode)

Run independent gates simultaneously:

[Lint + TypeCheck + Test] → Build → Audit

Selective Execution

Run only relevant gates based on changes:

  • .ts/.tsx files changed → TypeCheck
  • Dependencies updated → Audit
  • Test files changed → Tests only

Output Format

# Quality Gate Results

## Summary
✅ 5/7 Gates Passed | ❌ 2/7 Gates Failed

## Gate Details

### ✅ Gate 1: Linting
- **Status**: PASS
- **Duration**: 3.2s
- **Details**: 0 errors, 2 warnings

### ❌ Gate 2: Type Checking
- **Status**: FAIL
- **Duration**: 5.1s
- **Errors**: 3 type errors found
  - `src/components/Button.tsx:15` - Property 'onClick' is missing
  - `src/utils/api.ts:42` - Type 'string' is not assignable to type 'number'
  - `src/hooks/useAuth.ts:8` - Cannot find name 'User'

### ✅ Gate 3: Tests
- **Status**: PASS
- **Duration**: 12.4s
- **Tests**: 124 passed, 0 failed, 2 skipped
- **Coverage**: 87% (target: 80%)

### ⏭️ Gate 4: Build
- **Status**: SKIPPED (previous gate failed)

### ⏭️ Gate 5: Security Audit
- **Status**: SKIPPED (previous gate failed)

## Action Required
Fix the 3 type errors in Gate 2 before proceeding.

## Recommendations
1. Run `npm run typecheck` locally to see full error details
2. Consider adding pre-commit hooks to catch these earlier
3. Current code coverage (87%) exceeds target - excellent work!

Integration with Git Hooks

Setup Husky + lint-staged (Recommended)

Check if installed:

test -d .husky && echo "Husky installed" || echo "Husky not found"

Suggest installation if missing:

npm install --save-dev husky lint-staged
np
Compartilhar X LinkedIn