This skill enforces code quality by running linting, type checking, tests, and security audits before commits or deployments.
npx playbooks add skill atman36/ai-vibe-prompts --skill quality-gates
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.
Auto-invoke when:
Essential checks that run before every commit.
Comprehensive checks before pushing to remote.
Complete validation before production deployment.
Purpose: Enforce code style and catch common errors
Tools: Bash, Read
Process:
.eslintrc, eslint.config.biome.json "scripts": {
"lint": "eslint .",
"lint:fix": "eslint . --fix"
}
# Try to run lint script
npm run lint
# If fails, try direct commands
npx eslint . || npx biome check .
npm run lint:fix || npx eslint . --fix
Success Criteria: Zero linting errors (warnings acceptable)
Purpose: Verify type safety and catch type errors
Tools: Bash, Read, Grep
Process:
tsconfig.jsonstrict: truenoImplicitAny, strictNullChecks, etc. # Try to run typecheck script
npm run typecheck || npm run type-check
# If no script, run directly
npx tsc --noEmit
Success Criteria: Zero type errors
Purpose: Verify code functionality and prevent regressions
Tools: Bash, Read, Grep
Process:
vitest.config.*, vitest in dependenciesjest.config.*, jest in dependencies--test flag with Node.js 20+ # Use Grep to find test files
find . -name "*.test.*" -o -name "*.spec.*" | wc -l
# Run unit tests (fast)
npm run test || npm run test:unit
# Or direct command
npx vitest run || npx jest --ci
npm run test:coverage
# Check if meets threshold (e.g., 80%)
Success Criteria:
Purpose: Ensure code compiles and builds without errors
Tools: Bash
Process:
next buildvite buildwebpack --mode productiontsc npm run build
dist/, build/, .next/ # Remove build artifacts to save space
rm -rf dist/ build/ .next/
Success Criteria: Build completes with exit code 0
Purpose: Identify known vulnerabilities in dependencies
Tools: Bash, Read
Process:
npm audit --json || pnpm audit --json
npm audit fix
# or
npm audit fix --force # (if safe)
Success Criteria:
Purpose: Flag overly complex code that may need refactoring
Tools: Grep, Bash
Process:
# 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:
Purpose: Ensure commit quality and prevent sensitive data leaks
Tools: Bash, Grep
Process:
# 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$"
type(scope): description # Flag files > 1MB
git diff --cached --name-only | xargs ls -lh | awk '$5 > 1000000'
Success Criteria:
Run gates in order, stop on first failure:
Lint → TypeCheck → Test → Build → Audit
Run independent gates simultaneously:
[Lint + TypeCheck + Test] → Build → Audit
Run only relevant gates based on changes:
.ts/.tsx files changed → TypeCheck# 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!
Check if installed:
test -d .husky && echo "Husky installed" || echo "Husky not found"
Suggest installation if missing:
npm install --save-dev husky lint-staged
npx husky init
Configure .husky/pre-commit:
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"
# Run quality gates
npm run lint
npm run typecheck
npm run test
If no hooks, prompt user:
⚠️ No pre-commit hooks detected.
Would you like me to run quality gates before committing? (Recommended)
eslint --fix or biome check --applyprettier --write npm audit fix# Skip hooks for emergency fixes only
git commit --no-verify -m "emergency: fix critical bug"
{
"qualityGates": {
"coverage": {
"minimum": 80,
"enabled": true
},
"audit": {
"level": "moderate",
"enabled": true
},
"complexity": {
"maxLines": 500,
"maxDepth": 5
}
}
}
If no config found, use sensible defaults:
codebase-analysis - Use to detect available quality toolsgit-workflow - Integrate with commit/push processci-cd-setup - Configure gates for CI pipelineWeekly roundup of top Claude Code skills, MCP servers, and AI coding tips.