{"id":4174,"library":"pre-commit-hooks","title":"pre-commit-hooks","description":"pre-commit-hooks provides a collection of frequently used Git hooks for the `pre-commit` framework, facilitating code quality checks such as trailing whitespace, end-of-file fixers, JSON/YAML validation, and detection of large files. Currently at version 6.0.0, the library releases updates periodically, often alongside the `pre-commit` framework itself, to introduce new hooks, fix issues, or update Python version requirements.","status":"active","version":"6.0.0","language":"en","source_language":"en","source_url":"https://github.com/pre-commit/pre-commit-hooks","tags":["pre-commit","git-hooks","code-quality","linting","formatting","development-tools"],"install":[{"cmd":"pip install pre-commit","lang":"bash","label":"Install pre-commit framework"},{"cmd":"pre-commit install","lang":"bash","label":"Install git hooks in your repository"}],"dependencies":[],"imports":[{"note":"The 'pre-commit-hooks' package provides executables for the `pre-commit` framework, not Python modules intended for direct import.","symbol":"pre-commit-hooks","correct":"This library is not imported directly into Python code. Its hooks are configured in a .pre-commit-config.yaml file for use with the `pre-commit` framework."}],"quickstart":{"code":"# 1. Create a .pre-commit-config.yaml in your repository root\n# Example content:\n# .pre-commit-config.yaml\n---\nrepos:\n  - repo: https://github.com/pre-commit/pre-commit-hooks\n    rev: v6.0.0 # Use the latest version or a specific tag\n    hooks:\n      - id: trailing-whitespace\n      - id: end-of-file-fixer\n      - id: check-yaml\n      - id: check-json\n      - id: check-added-large-files\n      - id: debug-statements\n\n# 2. Install pre-commit (if not already installed)\n# pip install pre-commit\n\n# 3. Install the git hooks in your repository\n# pre-commit install\n\n# 4. (Optional) Manually run all hooks against all files\n# pre-commit run --all-files\n\n# Hooks will now run automatically on `git commit`","lang":"yaml","description":"To use `pre-commit-hooks`, you first need the `pre-commit` framework installed. Then, configure your desired hooks in a `.pre-commit-config.yaml` file in your repository root and install the git hooks. This example demonstrates a basic configuration using common hooks from the v6.0.0 release."},"warnings":[{"fix":"Upgrade your Python environment to 3.9 or later. If you need to use an older Python version, pin `pre-commit-hooks` to a version prior to 6.0.0 (e.g., `rev: v5.0.0`).","message":"Version 6.0.0 of pre-commit-hooks requires Python 3.9 or newer. Ensure your environment meets this requirement when upgrading.","severity":"breaking","affected_versions":">=6.0.0"},{"fix":"For `check-byte-order-marker`, migrate to `fix-byte-order-marker`. For `fix-encoding-pragma`, consider using `pyupgrade` or a similar tool.","message":"The hooks `check-byte-order-marker` and `fix-encoding-pragma` were removed in v6.0.0. `fix-encoding-pragma` was deprecated in v4.6.0.","severity":"breaking","affected_versions":">=6.0.0"},{"fix":"Review your `file-contents-sorter` hook configuration. If both arguments are present, remove one or adjust your workflow to achieve the desired sorting behavior in two separate steps if necessary.","message":"The `file-contents-sorter` hook in v6.0.0 disallows the simultaneous use of `--unique` and `--ignore-case` arguments.","severity":"breaking","affected_versions":">=6.0.0"},{"fix":"Remove `check-docstring-first` from your `.pre-commit-config.yaml`. Consider using other tools for docstring validation if needed.","message":"The `check-docstring-first` hook is fundamentally flawed and has been deprecated without a direct replacement.","severity":"deprecated","affected_versions":"All versions"},{"fix":"Ensure `pre-commit` is installed (`pip install pre-commit`) and then run `pre-commit install` in your repository to activate the hooks. Refer to the quickstart example for configuration.","message":"This library is a collection of hooks for the `pre-commit` framework. It must be configured via a `.pre-commit-config.yaml` file and requires `pre-commit` to be installed and initialized in your repository (via `pre-commit install`).","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}