--- source_keys: - context7-pre-commit-com - pre-commit-com --- # Installing hooks into `.git/hooks/` Reached from `SKILL.md`'s Route table when the user asks to install or set up hooks. Self-contained. Only run this flow when the user explicitly asks for it. Installing rewrites their clone's `.git/hooks/`; it is never a side effect of another request. ## Gate — existing hook files Check `ls .git/hooks/` first. With hook files already there, `pre-commit install` does not refuse — it silently enters migration mode and runs both. Only `-f` replaces them, and `pre-commit uninstall` cannot restore whatever `-f` overwrote. So when hook files are present, put the choice to the user in these terms, including the irreversibility, and wait for an answer before passing `-f`: > "Existing hook files found in `.git/hooks/`. Plain `pre-commit install` runs both; `-f` overwrites them permanently and `pre-commit uninstall` cannot restore them. Plain install, or overwrite?" ## Install ```bash pre-commit install ``` Re-run with `-t` flags when `default_install_hook_types` changed, or when hooks in a non-default stage never fire — a hook whose stage was never installed cannot run: ```bash pre-commit install -t pre-commit -t pre-push -t commit-msg ```