Get the FREE Ultimate OpenClaw Setup Guide →

code-quality-gate

npx machina-cli add skill freitasp1/claude-code-skills/code-quality-gate --openclaw
Files (1)
SKILL.md
2.2 KB

Code Quality Gate

This skill prevents production failures through a 5-stage Quality Gate System.

The 5 Quality Gates

  1. Pre-Commit (local): TypeScript, Lint, Format - blocks commit on errors
  2. PR-Check (GitHub Actions): Unit Tests, Build - blocks merge on errors
  3. Preview Deploy: Vercel/Netlify Preview URL for visual review
  4. E2E Tests: Playwright against Preview, Lighthouse performance audit
  5. Production Deploy: Only when ALL gates pass

Critical Rules

  • CRITICAL: NEVER use continue-on-error: true for TypeScript checks in GitHub Actions!
  • Husky Setup: npm install -D husky lint-staged && npx husky init
  • Rollback: vercel rollback

Example: Pre-Commit Hook (.husky/pre-commit)

#!/bin/sh
npx lint-staged
npx tsc --noEmit

Example: lint-staged.config.js

module.exports = {
  '*.{ts,tsx}': ['eslint --fix', 'prettier --write'],
  '*.{json,md}': ['prettier --write'],
};

Example: GitHub Actions Workflow

name: Quality Gate
on: [push, pull_request]

jobs:
  quality:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: '20'
          cache: 'npm'

      - run: npm ci

      # Gate 1: TypeScript (NEVER skip!)
      - name: TypeScript Check
        run: npx tsc --noEmit

      # Gate 2: Linting
      - name: ESLint
        run: npm run lint

      # Gate 3: Unit Tests
      - name: Unit Tests
        run: npm run test

      # Gate 4: Build
      - name: Build
        run: npm run build

When to Activate

  • Code changes that touch production code
  • Deployment requests
  • PR reviews
  • Build failures (for debugging)

Real-World Impact

At fabrikIQ.com, this quality gate system caught:

  • 2 TypeScript errors that would have caused runtime crashes
  • 1 missing environment variable in the deploy
  • 3 performance regressions before they hit production

Source

git clone https://github.com/freitasp1/claude-code-skills/blob/main/skills/code-quality-gate/SKILL.mdView on GitHub

Overview

Code Quality Gate enforces automated checks before deployment using a five-stage system: Pre-Commit, PR-Check, Preview, E2E, and Production. It blocks risky changes until all gates pass, reducing production failures and rollbacks. The gates cover local checks, CI validations, visual previews, end-to-end testing, and production gating.

How This Skill Works

Gates run in sequence from local pre-commit to production deploy. Pre-Commit checks TypeScript, lint, and format and blocks commits on errors; PR-Check runs unit tests and builds and blocks merges on failures; Preview deploys a visual review URL; E2E tests run Playwright against the Preview and Lighthouse audits; Production deploy proceeds only if all gates pass.

When to Use It

  • Code changes that touch production code
  • Deployment requests
  • PR reviews
  • Build failures (for debugging)
  • Pre-release cycles requiring stability

Quick Start

  1. Step 1: Install Husky and lint-staged and initialize Husky
  2. Step 2: Create the pre-commit hook with lint-staged and tsc --noEmit
  3. Step 3: Add a GitHub Actions workflow that enforces TypeScript, lint, unit tests, and build, plus preview and E2E steps

Best Practices

  • Never use continue-on-error: true for TypeScript checks in GitHub Actions
  • Set up Husky and lint-staged for fast local feedback
  • Add a pre-commit hook that runs lint-staged and tsc --noEmit
  • Keep a rollback plan with vercel rollback
  • Align CI with the five gates and require all gates pass before production

Example Use Cases

  • At fabrikIQ.com, this quality gate system caught 2 TypeScript errors that would have caused runtime crashes
  • Detected 1 missing environment variable during deploy
  • Caught 3 performance regressions before they hit production
  • PR checks blocked a merge due to a failing unit test
  • A production deploy was halted by gate failures, triggering a rollback

Frequently Asked Questions

Add this skill to your agents
Sponsor this space

Reach thousands of developers