Skip to content

Pre Commit Quality Gate

Josemalyson Oliveira edited this page Jun 27, 2026 · 1 revision

Pre-Commit Quality Gate

Auto-generated 14-step pre-commit pipelines for any tech stack.


Overview

Shift-left quality gate that fingerprints a project's stack and generates a fail-fast pipeline with 14 ordered steps (cheap to expensive).

When to Use

  • Setting up pre-commit hooks
  • Enforcing code quality
  • Automating code review
  • Standardizing workflows

Trigger Phrases

  • "Set up pre-commit hooks"
  • "Add quality gate"
  • "Enforce code standards"
  • "Automate code review"

How It Works

1. Fingerprint

Scan working directory for:

  • Manifests (go.mod, package.json, pom.xml, pyproject.toml)
  • Configs (tsconfig.json, .eslintrc, etc.)
  • Conventions (existing hooks, CI pipelines)
  • Lock files (go.sum, package-lock.json)

2. Load Reference

Match language-specific tool mappings:

  • go.md — Go tools
  • python.md — Python tools
  • nodejs.md — Node.js tools
  • java.md — Java tools

3. Generate Pipeline

Fill template.sh with concrete tools from fingerprint + reference.

4. Install & Verify

# Create hooks directory
mkdir -p .githooks

# Make executable
chmod +x .githooks/pre-commit

# Set git hooks path
git config core.hooksPath .githooks

# Dry run
.git/hooks/pre-commit --dry-run

The 14 Steps

# Category Purpose Mode
-1 Secret scanner Gitleaks — credential leak prevention fail
0 Branch name Git Flow / trunk-based validation fail
1 Formatter Style normalization (gofmt, ruff, prettier) fail
2 Linter Static quality (golangci-lint, ruff, eslint) fail
3 Security scan Dependency vulnerabilities fail
4 Dead code Unreachable code detection fail
5 Modernizer Modern idioms (report-only) warn
6 Convention guards Team architectural rules fail
7 Module hygiene Lock files and manifest integrity fail
8 Tests + coverage Unit suite + threshold (90% default) fail
9 Race/concurrency Data races, async bugs fail
10 Integration tests End-to-end flows fail
11 Mutation tests Test suite quality fail
12 Performance tests Latency/throughput fail
13 Schema pipeline Stub regeneration fail
14 Build validation Production Dockerfile (OFF by default) fail

Supported Languages

Go

Category Tool
Formatter gofmt
Linter golangci-lint
Security govulncheck
Dead code deadcode
Modernizer modernize
Tests go test
Race go test -race
Performance k6

Python

Category Tool
Formatter ruff format
Linter ruff + mypy
Security bandit + safety
Dead code vulture
Modernizer pyupgrade
Tests pytest
Mutation mutmut
Performance locust

Node.js

Category Tool
Formatter prettier
Linter eslint + tsc
Security npm audit
Dead code knip
Modernizer --
Tests jest/vitest
Mutation stryker
Performance k6

Java

Category Tool
Formatter google-java-format/spotless
Linter checkstyle
Security OWASP dependency-check
Dead code spotbugs
Modernizer --
Tests JaCoCo
Mutation pitest
Performance gatling

Configuration

Skip Steps

# Skip specific steps
SKIP=5,11 git commit -m "feat: add feature"

# Skip all tests
SKIP=8,9,10 git commit -m "wip: work in progress"

Environment Variables

# Coverage threshold
export COVERAGE_THRESHOLD=80

# Mutation score threshold
export MUTATION_THRESHOLD=70

Customization

Add Convention Guards

Edit pre-commit-quality-gate-doc.md to add custom rules:

# Step 6: Convention guards
echo "Checking architectural rules..."
if ! grep -r "TODO" src/; then
  echo "❌ Found TODO comments"
  exit 1
fi

Modify Pipeline Order

Edit template.sh to reorder steps based on your needs.


References


Last updated: June 2026

Clone this wiki locally