Skip to main content

pre-commit Integration

drep can install native Git hooks itself, or it can run as a published hook inside an existing pre-commit configuration.

Choose one hook owner

ApproachBest whenInstall
Native Git hooksThe repository does not already use pre-commitdrep init
pre-commit frameworkThe repository already centralizes hooks in .pre-commit-config.yamlAdd the drep repository and hook IDs

Do not install both versions of the same stage: that makes one commit or push run the same review twice.

Published hooks

yaml
repos:
  - repo: https://github.com/slb350/drep
    rev: v3.1.0
    hooks:
      - id: drep-check-push   # pre-push: what the push touches
      # - id: drep-check      # pre-commit: staged files
      # - id: drep-lint-docs  # staged Markdown, rule-based
Hook IDStageCommand
drep-checkpre-commitdrep check --staged
drep-check-pushpre-pushdrep check --push-gate --pre-commit-push
drep-check-allmanual/defaultdrep check
drep-lint-docspre-commitdrep lint-docs --fail-on error

Automatic trigger coverage

The v3.1.0 published manifest selects the code hooks automatically only for Python, JavaScript/JSX, TypeScript/TSX, Go, and Rust file types. A commit or push containing only another registered language, including Lua, does not select those framework hooks. Use drep's native hooks when every drep-registered language must trigger automatically.

Install hook stages

bash
pre-commit install
pre-commit install --hook-type pre-push

Why the pre-push adapter matters

pre-commit normally passes changed filenames to hooks. For drep that would select whole-file mode, so a one-line follow-up fix could re-review all surrounding code. --pre-commit-push instead reads PRE_COMMIT_FROM_REF and PRE_COMMIT_TO_REF, preserving diff-hunk review of the actual push.

--push-gate also performs the cache-warming reconnect handshake. A successful cold review exits 3 and asks for a new git push; the retry opens a fresh remote connection and uses the cached review.

Isolated Rust environment

The published hooks use language: rust. pre-commit builds drep from the pinned release into its own environment, so consumers do not need a separately installed binary for the hook itself.

Run hooks manually

bash
pre-commit run drep-check --all-files
pre-commit run drep-lint-docs --all-files

Markdown is independent

drep-lint-docs is rule-based, needs no LLM or drep.toml, and blocks only error-severity rendering defects by default.