Skip to content

Feature Request: init to take optional --lang and --framework parameters #1161

@cleder

Description

@cleder

🚀 Feature Request: init command with optional --lang and --framework parameters

Summary

It is requested that the prek initialization command (init) be extended to accept optional --lang (language) and --framework parameters. This would allow the tool to automatically scaffold a more relevant and production-ready initial configuration file (.pre-commit-config.yaml) based on the project's primary technology stack.

Motivation

Many languages and frameworks have popular, community-standard custom linters, formatters, and code quality tools (e.g., black for Python, eslint for JavaScript/React, go fmt for Go).

Currently, setting up a new project requires the user to manually:

  1. Identify the recommended quality tools for their stack.
  2. Look up the corresponding pre-commit hook repository URLs, revisions, and arguments.
  3. Manually edit the .pre-commit-config.yaml file.

Implementing the --lang/--framework parameters would drastically simplify onboarding, encourage the adoption of best practices, and reduce boilerplate, allowing developers to set up a comprehensive quality gate with a single command.

Proposed Command Examples

# Initialize with standard Python hooks (e.g., black, flake8/ruff, isort)
pre-commit init --lang=python

# Initialize with JavaScript hooks, including React-specific linters (e.g., eslint + react-hooks plugin)
pre-commit init --lang=javascript --framework=react

# Initialize for a simple Go project (e.g., go fmt, go vet)
pre-commit init --lang go

# rust with bevy game engine (cargo fmt, clippy, bevy cli)
pre-commit init --lang=rust --framework=bevy

This will be of course a very OPINIONATED choice, but we can iterate on it over time ;-)

Metadata

Metadata

Assignees

No one assigned

    Labels

    ideaJust an idea

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions