skillfed

pre-commit-hooks

Some out-of-the-box hooks for pre-commit.

pre-commit-hooks v6.0.0 1.8M downloads/30d#3,496 on PyPI6,660
Permissive license MIT Active released

What it is and what it does

pre-commit-hooks is a collection of ready-to-use hooks designed to run within the pre-commit framework, catching common issues before code is committed. It provides validators for file syntax (YAML, JSON, XML, TOML), checks for problematic patterns (merge conflicts, debug statements, private keys), enforces file standards (line endings, trailing whitespace, shebangs), and prevents specific mistakes like committing large files or to protected branches.

The package depends on ruamel.yaml and tomli for parsing configuration and data files. It's designed to be dropped into a pre-commit configuration file and requires Python 3.9 or later. Each hook is a standalone command that can be selectively enabled or configured with arguments, making it flexible for different project needs without requiring custom hook development.

Use it for:

  • Prevent accidental commits of large binary files or datasets by enforcing a size limit before they reach the repository.
  • Validate YAML and JSON configuration files for syntax errors before they are committed, catching typos early.
  • Detect and block commits containing AWS credentials, private keys, or other sensitive credentials.
  • Enforce consistent file formatting (line endings, trailing whitespace, newline at end of file) across a team.
  • Block direct commits to protected branches like main or production to enforce code review workflows.
  • Check Python files for common mistakes like debug statements or breakpoint() calls left in code.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Provides a collection of reusable pre-commit hooks for common code quality and file validation checks, integrated with the pre-commit framework.

Yes. pre-commit-hooks is a mature, actively maintained package with low install friction and no known vulnerabilities. It solves a real problem—automating repetitive code quality checks at commit time—and integrates seamlessly into existing pre-commit workflows. The permissive MIT license and broad hook coverage make it a practical choice for most projects.

Install

pre-commit-hooks on PyPI

pip

pip install pre-commit-hooks

uv

uv add pre-commit-hooks

poetry

poetry add pre-commit-hooks

Installing pre-commit-hooks

Before you install

Low install friction with only two runtime dependencies (ruamel.yaml and tomli). Actively maintained with a recent release and 6660 repository stars, indicating stable community adoption.

License in practice

MIT license is permissive, allowing use in both open-source and commercial projects with minimal restrictions.

Quickstart

# Add to .pre-commit-config.yaml
- repo: https://github.com/pre-commit/pre-commit-hooks
  rev: v6.0.0
  hooks:
    - id: trailing-whitespace
    - id: check-yaml
    - id: check-json

Requires pre-commit framework to be installed and initialized in your repository; hooks run as part of the pre-commit workflow, not standalone.

Verify before relying

  • Whether all hooks work equally well across CPython and PyPy implementations despite both being listed as supported.
  • Performance impact when running multiple hooks on large repositories or with many staged files.

Package facts

License MIT (permissive)
Python support supports the current Python release (>=3.9)
Install friction low — pure-Python wheel
Runtime dependencies 2 — ruamel.yaml, tomli
Maintenance actively maintained — 370 days since the last release
Last repo commit
First released
Downloads 1,841,828/month — #3,496 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: pre_commit_hooks-6.0.0-py2.py3-none-any.whl

Programming Language :: Python :: 3Programming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: Implementation :: CPythonProgramming Language :: Python :: Implementation :: PyPy

Tags

pre-commit hooksgit hooks for code qualityfile validation hooksyaml json xml syntax checkingprevent large files commitcode linting hooksgit commit checks
git-workflowcode-qualityautomation

More Quality Assurance packages