This project uses pre-commit to automatically validate code quality before committing changes. This catches issues early and prevents CI/CD failures.
# Run the setup script
./scripts/setup-pre-commit.shOr manually:
# Install pre-commit
brew install pre-commit # macOS
# OR
pip install pre-commit # Linux/Windows
# Install the git hooks
pre-commit installOr use the Makefile:
make pre-commit-installPre-commit hooks will automatically check:
- Trailing Whitespace - Removes trailing whitespace
- End of File - Ensures files end with a newline
- YAML/JSON Syntax - Validates syntax
- Large Files - Prevents committing files >1MB
- Merge Conflicts - Detects unresolved merge conflict markers
- Private Keys - Detects accidentally committed private keys
- Prettier - Formats JavaScript, TypeScript, JSON, YAML, and Markdown
- Markdown Linting - Validates Markdown syntax and style
- Structure Validation - Ensures required directories and files exist
- AGENTS.md Check - Validates AGENTS.md file exists and has content
Hooks run automatically on git commit:
git add .
git commit -m "Add new feature"
# Pre-commit hooks run automatically ✅Run hooks manually on all files:
# Run all hooks
pre-commit run --all-files
# Or use Makefile
make pre-commit-run
# Run specific hook
pre-commit run prettier --all-filesOnly use in emergencies:
git commit --no-verify -m "Emergency fix"# Auto-fix formatting issues
make format
# Then commit
git add .
git commit -m "Fix formatting"# Check markdown linting rules
cat .markdownlint.json
# Fix issues manually or adjust rules# Check which files/directories are missing
./scripts/pre-commit-validate-structure.sh
# Create missing directories/files as needed# Update to latest versions
pre-commit autoupdate
# Or use Makefile
make pre-commit-update
# Re-run on all files
pre-commit run --all-filesPre-commit configuration is in .pre-commit-config.yaml at the repository root.
Edit .pre-commit-config.yaml to:
- Add new hooks
- Modify hook arguments
- Change file patterns
- Adjust validation rules
Edit .markdownlint.json to customize markdown linting rules.
Pre-commit hooks mirror the GitHub Actions workflow validation:
- Same formatting checks
- Same linting rules
- Same structure validation
This ensures:
- ✅ Faster feedback (local vs CI)
- ✅ Fewer failed CI runs
- ✅ Consistent validation everywhere
- Always run pre-commit - Don't skip hooks unless absolutely necessary
- Fix issues locally - Faster than waiting for CI to fail
- Keep hooks updated - Run
make pre-commit-updatemonthly - Test before committing - Run
make validatefor full local validation
# Full local validation
make validate
# Just linting
make lint
# Just formatting check
make format-check
# Auto-fix formatting
make format
# Run tests
make testIf you encounter issues with pre-commit hooks:
- Check this documentation
- Run
make validateto see detailed errors - Check
.pre-commit-config.yamlconfiguration - Review GitHub Actions logs for comparison
- Pre-commit Documentation: https://pre-commit.com/
- Prettier: https://prettier.io/
- Markdownlint: https://github.com/DavidAnson/markdownlint