pre-commit-validation
Ensures all quality checks pass locally before committing changes. Use this skill to validate code quality, tests, and type checking before creating commits to catch issues early and avoid CI failures.
Best use case
pre-commit-validation is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Ensures all quality checks pass locally before committing changes. Use this skill to validate code quality, tests, and type checking before creating commits to catch issues early and avoid CI failures.
Teams using pre-commit-validation should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/pre-commit-validation/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How pre-commit-validation Compares
| Feature / Agent | pre-commit-validation | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Ensures all quality checks pass locally before committing changes. Use this skill to validate code quality, tests, and type checking before creating commits to catch issues early and avoid CI failures.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
Related Guides
SKILL.md Source
# Pre-Commit Validation This skill ensures code quality and test coverage before committing changes to the repository. ## Purpose Run comprehensive validation locally before committing to: - Catch issues early (before CI runs) - Ensure all tests pass - Verify code quality (linting, formatting, type checking) - Maintain code coverage standards - Reduce CI failures and iteration time ## Validation Checklist Before creating any commit, ensure ALL of the following pass: ### 1. Run Tests ```bash # Run all tests pytest tests/ # Or with coverage (recommended) pytest tests/ --cov=src --cov-report=term ``` **Requirements:** - ✅ All tests must pass (exit code 0) - ✅ No test failures or errors - ✅ Coverage should not decrease (if checking coverage) ### 2. Run Code Quality Checks ```bash # Check formatting black --check src/ tests/ # Check linting ruff check src/ tests/ # Check types mypy src/ --strict --explicit-package-bases ``` **Requirements:** - ✅ All checks must pass (exit code 0) - ✅ No formatting issues - ✅ No linting errors - ✅ No type errors ### 3. Run Pre-commit Hooks (Optional but Recommended) ```bash # Run all pre-commit hooks manually pre-commit run --all-files ``` **Note**: Pre-commit hooks run automatically on `git commit`, but running them manually gives faster feedback. ## Workflow Integration ### When to Use This Skill Use this skill in the following scenarios: 1. **Before any commit**: Always run validation before creating a commit 2. **After implementing features**: Before committing new code 3. **After refactoring**: Before committing refactored code 4. **Before pushing**: As a final check before pushing to remote 5. **When pre-commit is skipped**: If using `git commit --no-verify`, run validation manually ### Integration with Phase Implementation When implementing features following the phase-implementation skill: 1. Implement code changes 2. **Run pre-commit validation** (this skill) 3. Fix any issues found 4. Repeat validation until all checks pass 5. Commit changes (following commit-format skill) 6. Push to GitHub ## Quick Validation Command For convenience, you can run all checks in sequence: ```bash # Run all validation checks pytest tests/ --cov=src --cov-report=term && \ black --check src/ tests/ && \ ruff check src/ tests/ && \ mypy src/ --strict --explicit-package-bases ``` If all commands succeed (exit code 0), you're ready to commit. ## Auto-fix Common Issues Many issues can be auto-fixed: ```bash # Auto-fix formatting black src/ tests/ # Auto-fix linting issues (many can be fixed automatically) ruff check --fix src/ tests/ ``` After auto-fixing, re-run validation to ensure everything passes. ## Handling Failures ### Test Failures 1. **Review test output**: Understand why tests are failing 2. **Fix the code**: Address the root cause 3. **Re-run tests**: Verify the fix works 4. **Run full test suite**: Ensure no regressions ### Code Quality Failures 1. **Formatting issues**: Run `black src/ tests/` to auto-fix 2. **Linting errors**: Run `ruff check --fix src/ tests/` to auto-fix many issues 3. **Type errors**: Fix type annotations or add type ignores (with justification) 4. **Re-run checks**: Verify all issues are resolved ### Coverage Decreases 1. **Review coverage report**: Identify uncovered code 2. **Add tests**: Write tests for uncovered code paths 3. **Verify coverage**: Ensure coverage meets or exceeds threshold (80%) ## Best Practices 1. **Run validation frequently**: Don't wait until the end - validate after each logical change 2. **Fix issues immediately**: Address problems as soon as they're found 3. **Don't skip validation**: Even for small commits, run at least basic checks 4. **Use pre-commit hooks**: They provide automatic validation, but manual checks are still valuable 5. **Check coverage regularly**: Ensure test coverage doesn't regress ## Relationship to CI/CD **Important**: Local validation does NOT replace CI/CD checks. - **Local validation** (this skill): Fast feedback, catch issues early - **CI/CD pipeline**: Final gate, runs on all pushes and PRs Even if local validation passes, CI may still catch: - Environment-specific issues - Issues missed locally - Integration problems However, running validation locally: - Reduces CI failures - Provides faster feedback - Saves CI resources - Improves development workflow ## Exceptions ### When to Skip Validation Validation should only be skipped in exceptional circumstances: 1. **WIP commits**: Work-in-progress commits with `[WIP]` prefix (but still validate before final commit) 2. **Merge commits**: Usually safe to skip (CI will validate) 3. **Documentation-only changes**: May skip type checking, but still run formatting/linting **Note**: Even in exceptions, consider running at least formatting checks to maintain code quality. ## See Also - [Development Workflow](docs/DEVELOPMENT.md#development-workflow) - General development guidelines - [Pre-commit Hooks Setup](docs/DEVELOPMENT.md#pre-commit-hooks-setup) - Automatic validation setup - [Commit Message Conventions](docs/DEVELOPMENT.md#commit-message-conventions) - Commit format guidelines
Related Skills
commit-format
Ensures all git commits follow the Conventional Commits specification with consistent types and scopes. Use this skill when making any commit to maintain consistent commit message format, improve git history readability, and enable automatic changelog generation.
test-writing
Defines patterns for writing tests, including subsection tests for incremental development and acceptance criteria verification. Use when writing any tests to ensure consistent naming, structure, and coverage patterns.
subsection-implementation
Complete workflow for implementing a single subsection from the implementation plan. Orchestrates all project skills to ensure consistent, high-quality implementation with full test coverage. Use when implementing any subsection (e.g., 5.1.1, 5.2.3) to automate the entire workflow from requirements to commit.
si
Short alias for /subsection-implementation. Implements a single subsection from docs/implementation-plan.md with full automation. Usage: /si 5.1.1
phase-implementation
Guides implementation of features following an established workflow pattern. Use when implementing any feature to ensure consistent process: read requirements, create todos, implement code, write tests, update documentation, commit and push.
implementation-plan-updates
Defines the pattern for updating project documentation when completing features. Use when marking features as complete to ensure consistent documentation of implementation status, test coverage, and deliverables.
api-endpoint-implementation
Defines patterns for implementing FastAPI REST endpoints, including route definition, request/response models, error handling, and integration tests. Use when implementing any API endpoint to ensure consistency and best practices across endpoints.
skill-validation-gf3
Skill Validation GF(3) - SLAVE (-1)
pentest-exploit-validation
Proof-driven exploitation with 4-level evidence system, bypass exhaustion protocol, mandatory evidence checklists, and strict EXPLOITED/POTENTIAL/FALSE_POSITIVE classification.
merkle-proof-validation
Merkle Proof Validation Skill
implementing-continuous-security-validation-with-bas
Deploy Breach and Attack Simulation tools to continuously validate security control effectiveness by safely emulating real-world attack techniques across the kill chain.
implementing-api-schema-validation-security
Implement API schema validation using OpenAPI specifications and JSON Schema to enforce input/output contracts and prevent injection, data exposure, and mass assignment attacks.