DevTools Logo

pre-commit Config Generator

pre-commit Config Generator

Compose an annotated .pre-commit-config.yaml from a curated hook catalog.

Runs in your browser
5 hooks · 4 repos
Try an example

Hook catalog

20 available
Format
Lint
Hygiene
Security
Selected hook settings
black
ruff
trailing-whitespace
end-of-file-fixer
detect-secrets

.pre-commit-config.yaml

37 lines · 991 chars
# Generated with the pre-commit config generator
# Run: pre-commit autoupdate to refresh revs
default_language_version:
  python: python3.12
repos:
  - repo: https://github.com/psf/black
    rev: 24.10.0
    hooks:
      - id: black
        # Python formatter
        args: [--line-length=88]
        files: '\.py$'
        stages: [pre-commit]
  - repo: https://github.com/astral-sh/ruff-pre-commit
    rev: v0.8.0
    hooks:
      - id: ruff
        # Python linter
        args: [--fix]
        files: '\.py$'
        stages: [pre-commit]
  - repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v5.0.0
    hooks:
      - id: trailing-whitespace
        # Strip trailing whitespace
        stages: [pre-commit]
      - id: end-of-file-fixer
        # Ensure one trailing newline
        stages: [pre-commit]
  - repo: https://github.com/Yelp/detect-secrets
    rev: v1.5.0
    hooks:
      - id: detect-secrets
        # Entropy-based secret scanner
        stages: [pre-commit]

$ pip install pre-commit

$ pre-commit install

$ pre-commit run --all-files

Details

A working pre-commit setup needs canonical repository URLs, pinned revs and arguments that match the upstream hook version. This tool ships a curated catalog of formatters, linters, hygiene fixers and secret scanners; select the hooks you want and it emits a grouped, annotated config with a default Python version, per-hook args, file scopes and stages. Heavy scanners are flagged for pre-push. The bootstrap commands are shown alongside the YAML, and a note reminds you to run pre-commit autoupdate later.

Python web repo

black + ruff + trailing-whitespace + end-of-file-fixer + detect-secrets

A balanced starter set that formats and lints Python while catching secrets.

Security-first

detect-private-key + bandit + gitleaks (stages: [pre-push])

Heavy scans are staged at pre-push so commits stay fast.

File scoping

prettier with files: '\.(js|ts|md|json|css)$'

Formatters only touch the file types they understand.

About this tool

pre-commit Config Generator runs entirely in your browser on DevTools — no signup, no upload.

What this tool does not do

  • pre-commit Config Generator is a free in-browser utility, not a hosted API, and keeps no server-side history.

How to use this tool

  1. Set your options

    Choose the options pre-commit Config Generator should use.

  2. Generate

    Press the generate action; each run produces fresh output.

  3. Copy or export the result

    Copy or download the generated result. pre-commit Config Generator keeps no server-side history, so save what you need before leaving the page.

Frequently asked questions

What is a rev and why pin it?

A rev is the git tag or commit of the hook repository that pre-commit installs. Pinning it makes every developer run the same hook version, so CI does not suddenly fail when a linter changes upstream. The catalog seeds known-good version tags; run pre-commit autoupdate when you are ready to move forward.

How do I run hooks on all files once?

After installing the hook with pre-commit install, run pre-commit run --all-files. It applies every configured hook to the whole repository instead of only staged changes, which is the right way to bootstrap a config on an existing project.

Can one hook target only some files?

Yes. Each selected hook has files and exclude glob fields. The catalog seeds sensible defaults — black uses \.py$, prettier targets JS/TS/Markdown/JSON/CSS, and shellcheck only .sh files — so hooks do not waste time on files they cannot parse.

What are stages (pre-commit vs pre-push)?

Stages decide when a hook runs. pre-commit is the default and should stay quick; pre-push is a good home for heavier scans such as gitleaks or trufflehog that would make every commit slow. The generator warns when a heavy hook is left on the commit stage.

How do I skip hooks temporarily?

Use git commit --no-verify for a single commit or SKIP=hook-id git commit to skip specific hooks. Skipping should be an exception: fix the underlying issue or adjust the hook's files/exclude scope instead of disabling checks permanently.

Does the generator install or run hooks?

No. It only writes YAML text in your browser. Installation and execution happen locally when you run the three bootstrap commands it shows.