Skip to content

enforce-precommit

enforce-precommit sets up a pre-commit framework that enforces the project’s standards at the git layer — the one checkpoint every commit passes through, whoever (or whatever) made it. It closes the gap that an agent’s own hooks can’t cover.

What it solves

Octopus’s loop-level hooks (auto-format, typecheck, block-no-verify, …) only fire inside an agent session. A commit made by a human typing directly, or by a different tool like Copilot, slips past them entirely — and that’s exactly where unformatted, untyped, or no-verify commits leak into history. A pre-commit framework moves the gate to git itself, so the guarantee no longer depends on how the change was made.

How it works

  • Aligned with your rules — it detects the project’s stack from file extensions and infers the right checks from rules/common/*, so the gate enforces the same standards the agent follows.
  • Standard tooling — it writes .pre-commit-config.yaml by default, with lefthook.yml / .husky/ as documented alternatives.
  • Idempotent and respectful — it merges hook entries by id rather than overwriting, so re-running it never clobbers config you added by hand. Extend it per-project with enforce-precommit.local.md.

It is one layer of defense-in-depth: it pairs with enforce-ide (the editor surface), the guardrails bundle (the agent loop), and the quality CI template.

When to use

Setting up a repo, or hardening one where commits bypass the agent’s own checks. If you also want the conventions reinforced in the editor before the commit, add enforce-ide.