Pre-Commit Quality Checking
Scannednpx machina-cli add skill Hildegaardchiasmal966/claude-skills/pre-commit-quality --openclawPre-Commit Quality Checking
Automates the mandatory checklist from .claude/modules/code-review-standards.md.
Quick Workflow
When ready to commit, run these checks in order:
- Build verification:
npm run build - Test verification:
npm test - Pattern validation:
bash .claude/skills/pre-commit-quality/scripts/validate-patterns.sh
All three must pass before committing.
Step-by-Step Process
Step 1: Run Build
npm run build
Must pass with zero errors. If build fails:
- Fix TypeScript errors shown in output
- Rerun build until it passes
- See typescript-standards.md for type safety patterns
Step 2: Run Tests
npm test
All tests must pass. If tests fail:
- Review failing test output
- Fix the issues causing failures
- Rerun tests until all pass
- See testing-standards.md for testing patterns
Step 3: Validate Patterns
bash .claude/skills/pre-commit-quality/scripts/validate-patterns.sh
No violations allowed. Script checks for:
anytypes (use specific types orunknown)- Wrong Supabase client in wrong environment
console.login production code
If validation fails, fix the reported issues and rerun.
Complete Review Checklist
For the full pre-commit checklist, see:
- code-review-standards.md - Complete checklist
- nextjs-patterns.md - Next.js patterns
- supabase-security.md - Supabase security
- anti-patterns.md - What to avoid
Common Issues and Fixes
Build Fails: TypeScript Errors
- Check for missing types
- Ensure imports are correct
- Fix any
anytypes to specific types
Tests Fail
- Read the test output carefully
- Fix the code causing the failure
- Ensure all test files are updated
Pattern Validation Fails
any types found:
- Replace with specific type:
Recipe,User, etc. - Use
unknownif type is truly unknown - Add type guards for union types
Wrong Supabase client:
- Server Components:
import { createClient } from '@/lib/supabase/server' - Client Components:
import { createClient } from '@/lib/supabase/client'
console.log found:
- Remove from production code
- Use proper logging if needed
- console.log is fine in test files
After All Checks Pass
Once all checks pass:
- Stage your changes:
git add . - Commit with descriptive message
- See CLAUDE.md for commit message format
Philosophy
This skill enforces quality standards without you having to remember every check. It references the documentation in modules/ for the "why" and "what", while providing the "how" to validate.
Source
git clone https://github.com/Hildegaardchiasmal966/claude-skills/blob/master/pre-commit-quality/SKILL.mdView on GitHub Overview
This skill automates the mandatory checklist from code-review-standards.md and runs three verifications before commits: build, tests, and pattern validation. It ensures code meets project standards and reduces defect-prone commits.
How This Skill Works
When triggered, it executes npm run build, npm test, and a Bash script to validate patterns at .claude/skills/pre-commit-quality/scripts/validate-patterns.sh. All three must pass before the commit proceeds; otherwise the issues must be fixed and the checks re-run.
When to Use It
- Before committing code changes on a feature or bugfix branch
- When you need to verify code quality meets project standards on demand
- Before opening a pull request to ensure baseline checks pass
- After making changes that touch TypeScript types or tests
- When a maintainer asks you to validate quality against code-review-standards
Quick Start
- Step 1: Run Build: npm run build
- Step 2: Run Tests: npm test
- Step 3: Validate Patterns: bash .claude/skills/pre-commit-quality/scripts/validate-patterns.sh
Best Practices
- Follow the Quick Workflow order: Build, then Test, then Pattern Validation
- Ensure a clean build with zero errors before proceeding
- Rerun all checks after any fix or change
- Review test outputs and error messages carefully
- Consult the referenced standards docs for patterns and anti-patterns
Example Use Cases
- On a feature branch, run the checks before committing to catch issues early
- After updating code to fix a test failure, re-run the tests
- Before pushing to a shared repo, validate patterns to avoid production risks
- When migrating code to TypeScript types, ensure no 'any' types slip through
- If a CI job flags a violation, use this workflow to fix locally