hk migrate pre-commit
- Usage:
hk migrate pre-commit [FLAGS] - Effect: modifies state
Migrate from pre-commit (or prek) to hk
Reads a .pre-commit-config.yaml and writes an hk.pkl that runs the same hooks at the same git stages:
- Hooks from well-known repositories become hk builtins, for example
rufffrom astral-sh/ruff-pre-commit becomesBuiltins.ruff. - Local
system,script, andfailhooks become native hk steps with the same command and file filters. - Every other hook keeps running through prek or pre-commit, which reads the original config. This includes hooks whose
args,additional_dependencies, or filters a builtin cannot reproduce. Each of these steps has a comment explaining why it was not converted.
manual hooks run only with hk check and hk fix.
Flags
-c --config <CONFIG>— Path to .pre-commit-config.yamlDefault:
.pre-commit-config.yaml-f --force— Overwrite existing hk.pkl file-o --output <OUTPUT>— Output path for hk.pklDefault:
hk.pkl--runner <RUNNER>— Tool that runs hooks hk cannot convert. Defaults to pre-commit when only pre-commit is on PATH, otherwise prek.Choices:
prek,pre-commit--hk-pkl-root <HK_PKL_ROOT>— Root path for hk pkl files (e.g. "pkl" for a local checkout, or a package URL prefix). If set, the generated config uses {root}/Config.pkl and {root}/Builtins.pkl-h --help— Print help
Examples
Write to a separate file while evaluating a migration. Steps that still run through prek or pre-commit are marked with a comment explaining why.
hk migrate pre-commit --output hk.migrated.pkl
HK_FILE=./hk.migrated.pkl hk check --all --plan