Skip to content
Merged
9 changes: 9 additions & 0 deletions .changes/actionlint/feat-git-hooks-inspect-9e83d8f9.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
bump: minor
---

### Added

- `setup check inspect` lists what runs at each git hook stage in the repository, under whichever hook manager it uses (plain hooks, husky, Husky.Net, lefthook, git config hooks, or a hook no manager owns), and times this plugin's own entries that change no files, from installed copies that still match what the plugin ships, on the staged set, a message file or the branch against its upstream. Every other hook, an edited, forged or older copy, and a git config hook the repository disables is listed as not run, with the reason; a script path outside the work tree and the hooks directory is never followed. The installer's new `inspect` action is read-only.
- The git-hook installer detects Husky.Net (`.husky/task-runner.json`) as husky with `variant: "husky.net"`, so it installs as husky does, and `inspect` lists the Husky.Net tasks a `husky run --group` or `--name` line selects.
- Setup's `husky-config` decision says how to create a new `.husky/<event>` under Husky.Net: with `#!/bin/sh`, executable and staged at mode 100755, since git runs that file directly there and skips one that is not executable.
9 changes: 9 additions & 0 deletions .changes/bash-format/feat-git-hooks-inspect-e17b94e7.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
bump: minor
---

### Added

- `setup check inspect` lists what runs at each git hook stage in the repository, under whichever hook manager it uses (plain hooks, husky, Husky.Net, lefthook, git config hooks, or a hook no manager owns), and times this plugin's own entries that change no files, from installed copies that still match what the plugin ships, on the staged set, a message file or the branch against its upstream. Every other hook, an edited, forged or older copy, and a git config hook the repository disables is listed as not run, with the reason; a script path outside the work tree and the hooks directory is never followed. The installer's new `inspect` action is read-only.
- The git-hook installer detects Husky.Net (`.husky/task-runner.json`) as husky with `variant: "husky.net"`, so it installs as husky does, and `inspect` lists the Husky.Net tasks a `husky run --group` or `--name` line selects.
- Setup's `husky-config` decision says how to create a new `.husky/<event>` under Husky.Net: with `#!/bin/sh`, executable and staged at mode 100755, since git runs that file directly there and skips one that is not executable.
9 changes: 9 additions & 0 deletions .changes/code-tidying/feat-git-hooks-inspect-534a268d.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
bump: minor
---

### Added

- `setup check inspect` lists what runs at each git hook stage in the repository, under whichever hook manager it uses (plain hooks, husky, Husky.Net, lefthook, git config hooks, or a hook no manager owns), and times this plugin's own entries that change no files, from installed copies that still match what the plugin ships, on the staged set, a message file or the branch against its upstream. Every other hook, an edited, forged or older copy, and a git config hook the repository disables is listed as not run, with the reason; a script path outside the work tree and the hooks directory is never followed. The installer's new `inspect` action is read-only.
- The git-hook installer detects Husky.Net (`.husky/task-runner.json`) as husky with `variant: "husky.net"`, so it installs as husky does, and `inspect` lists the Husky.Net tasks a `husky run --group` or `--name` line selects.
- Setup's `husky-config` decision says how to create a new `.husky/<event>` under Husky.Net: with `#!/bin/sh`, executable and staged at mode 100755, since git runs that file directly there and skips one that is not executable.
9 changes: 9 additions & 0 deletions .changes/go-format/feat-git-hooks-inspect-e28a44d8.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
bump: minor
---

### Added

- `setup check inspect` lists what runs at each git hook stage in the repository, under whichever hook manager it uses (plain hooks, husky, Husky.Net, lefthook, git config hooks, or a hook no manager owns), and times this plugin's own entries that change no files, from installed copies that still match what the plugin ships, on the staged set, a message file or the branch against its upstream. Every other hook, an edited, forged or older copy, and a git config hook the repository disables is listed as not run, with the reason; a script path outside the work tree and the hooks directory is never followed. The installer's new `inspect` action is read-only.
- The git-hook installer detects Husky.Net (`.husky/task-runner.json`) as husky with `variant: "husky.net"`, so it installs as husky does, and `inspect` lists the Husky.Net tasks a `husky run --group` or `--name` line selects.
- Setup's `husky-config` decision says how to create a new `.husky/<event>` under Husky.Net: with `#!/bin/sh`, executable and staged at mode 100755, since git runs that file directly there and skips one that is not executable.
9 changes: 9 additions & 0 deletions .changes/guardrails/feat-git-hooks-inspect-e670076f.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
bump: minor
---

### Added

- `setup check inspect` lists what runs at each git hook stage in the repository, under whichever hook manager it uses (plain hooks, husky, Husky.Net, lefthook, git config hooks, or a hook no manager owns), and times this plugin's own entries that change no files, from installed copies that still match what the plugin ships, on the staged set, a message file or the branch against its upstream. Every other hook, an edited, forged or older copy, and a git config hook the repository disables is listed as not run, with the reason; a script path outside the work tree and the hooks directory is never followed. The installer's new `inspect` action is read-only.
- The git-hook installer detects Husky.Net (`.husky/task-runner.json`) as husky with `variant: "husky.net"`, so it installs as husky does, and `inspect` lists the Husky.Net tasks a `husky run --group` or `--name` line selects.
- Setup's `husky-config` decision says how to create a new `.husky/<event>` under Husky.Net: with `#!/bin/sh`, executable and staged at mode 100755, since git runs that file directly there and skips one that is not executable.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
bump: minor
---

### Added

- `setup check inspect` lists what runs at each git hook stage in the repository, under whichever hook manager it uses (plain hooks, husky, Husky.Net, lefthook, git config hooks, or a hook no manager owns), and times this plugin's own entries that change no files, from installed copies that still match what the plugin ships, on the staged set, a message file or the branch against its upstream. Every other hook, an edited, forged or older copy, and a git config hook the repository disables is listed as not run, with the reason; a script path outside the work tree and the hooks directory is never followed. The installer's new `inspect` action is read-only.
- The git-hook installer detects Husky.Net (`.husky/task-runner.json`) as husky with `variant: "husky.net"`, so it installs as husky does, and `inspect` lists the Husky.Net tasks a `husky run --group` or `--name` line selects.
- Setup's `husky-config` decision says how to create a new `.husky/<event>` under Husky.Net: with `#!/bin/sh`, executable and staged at mode 100755, since git runs that file directly there and skips one that is not executable.
9 changes: 9 additions & 0 deletions .changes/javascript-format/feat-git-hooks-inspect-d8c496e6.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
bump: minor
---

### Added

- `setup check inspect` lists what runs at each git hook stage in the repository, under whichever hook manager it uses (plain hooks, husky, Husky.Net, lefthook, git config hooks, or a hook no manager owns), and times this plugin's own entries that change no files, from installed copies that still match what the plugin ships, on the staged set, a message file or the branch against its upstream. Every other hook, an edited, forged or older copy, and a git config hook the repository disables is listed as not run, with the reason; a script path outside the work tree and the hooks directory is never followed. The installer's new `inspect` action is read-only.
- The git-hook installer detects Husky.Net (`.husky/task-runner.json`) as husky with `variant: "husky.net"`, so it installs as husky does, and `inspect` lists the Husky.Net tasks a `husky run --group` or `--name` line selects.
- Setup's `husky-config` decision says how to create a new `.husky/<event>` under Husky.Net: with `#!/bin/sh`, executable and staged at mode 100755, since git runs that file directly there and skips one that is not executable.
9 changes: 9 additions & 0 deletions .changes/markdown-format/feat-git-hooks-inspect-46218c3e.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
bump: minor
---

### Added

- `setup check inspect` lists what runs at each git hook stage in the repository, under whichever hook manager it uses (plain hooks, husky, Husky.Net, lefthook, git config hooks, or a hook no manager owns), and times this plugin's own entries that change no files, from installed copies that still match what the plugin ships, on the staged set, a message file or the branch against its upstream. Every other hook, an edited, forged or older copy, and a git config hook the repository disables is listed as not run, with the reason; a script path outside the work tree and the hooks directory is never followed. The installer's new `inspect` action is read-only.
- The git-hook installer detects Husky.Net (`.husky/task-runner.json`) as husky with `variant: "husky.net"`, so it installs as husky does, and `inspect` lists the Husky.Net tasks a `husky run --group` or `--name` line selects.
- Setup's `husky-config` decision says how to create a new `.husky/<event>` under Husky.Net: with `#!/bin/sh`, executable and staged at mode 100755, since git runs that file directly there and skips one that is not executable.
9 changes: 9 additions & 0 deletions .changes/powershell-format/feat-git-hooks-inspect-7c0c691f.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
bump: minor
---

### Added

- `setup check inspect` lists what runs at each git hook stage in the repository, under whichever hook manager it uses (plain hooks, husky, Husky.Net, lefthook, git config hooks, or a hook no manager owns), and times this plugin's own entries that change no files, from installed copies that still match what the plugin ships, on the staged set, a message file or the branch against its upstream. Every other hook, an edited, forged or older copy, and a git config hook the repository disables is listed as not run, with the reason; a script path outside the work tree and the hooks directory is never followed. The installer's new `inspect` action is read-only.
- The git-hook installer detects Husky.Net (`.husky/task-runner.json`) as husky with `variant: "husky.net"`, so it installs as husky does, and `inspect` lists the Husky.Net tasks a `husky run --group` or `--name` line selects.
- Setup's `husky-config` decision says how to create a new `.husky/<event>` under Husky.Net: with `#!/bin/sh`, executable and staged at mode 100755, since git runs that file directly there and skips one that is not executable.
9 changes: 9 additions & 0 deletions .changes/python-format/feat-git-hooks-inspect-a8b1b962.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
bump: minor
---

### Added

- `setup check inspect` lists what runs at each git hook stage in the repository, under whichever hook manager it uses (plain hooks, husky, Husky.Net, lefthook, git config hooks, or a hook no manager owns), and times this plugin's own entries that change no files, from installed copies that still match what the plugin ships, on the staged set, a message file or the branch against its upstream. Every other hook, an edited, forged or older copy, and a git config hook the repository disables is listed as not run, with the reason; a script path outside the work tree and the hooks directory is never followed. The installer's new `inspect` action is read-only.
- The git-hook installer detects Husky.Net (`.husky/task-runner.json`) as husky with `variant: "husky.net"`, so it installs as husky does, and `inspect` lists the Husky.Net tasks a `husky run --group` or `--name` line selects.
- Setup's `husky-config` decision says how to create a new `.husky/<event>` under Husky.Net: with `#!/bin/sh`, executable and staged at mode 100755, since git runs that file directly there and skips one that is not executable.
9 changes: 9 additions & 0 deletions .changes/spelling/feat-git-hooks-inspect-f6f6d253.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
bump: minor
---

### Added

- `setup check inspect` lists what runs at each git hook stage in the repository, under whichever hook manager it uses (plain hooks, husky, Husky.Net, lefthook, git config hooks, or a hook no manager owns), and times this plugin's own entries that change no files, from installed copies that still match what the plugin ships, on the staged set, a message file or the branch against its upstream. Every other hook, an edited, forged or older copy, and a git config hook the repository disables is listed as not run, with the reason; a script path outside the work tree and the hooks directory is never followed. The installer's new `inspect` action is read-only.
- The git-hook installer detects Husky.Net (`.husky/task-runner.json`) as husky with `variant: "husky.net"`, so it installs as husky does, and `inspect` lists the Husky.Net tasks a `husky run --group` or `--name` line selects.
- Setup's `husky-config` decision says how to create a new `.husky/<event>` under Husky.Net: with `#!/bin/sh`, executable and staged at mode 100755, since git runs that file directly there and skips one that is not executable.
25 changes: 23 additions & 2 deletions docs/contracts/check-placement/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,9 @@ the consumer git floor moves.
### HookManager port

```text
detect(repo) -> { manager: "lefthook"|"husky"|"plain"|"conflict", evidence[] }
detect(repo) -> { manager: "lefthook"|"husky"|"plain"|"conflict", evidence[], variant? }
list(repo) -> [{ entryId, event, scope, stamp }]
inspect(repo, runs?) -> { manager, variant?, evidence[], hooksDir, stages[{ event, installed, hookFile, items[] }] } # read-only
plan(repo, entries, scope) -> { actions[], decisions[] }
copy(repo, entry, scope) -> "installed" | "refreshed" | "unchanged" | "blocked" | "unsafe-path" | "stage-failed" # plugin-owned files only
decline(repo, entryId) -> sets the git config --local key (--global: the global one)
Expand All @@ -230,7 +231,27 @@ decline(repo, entryId) -> sets the git config --local key (--global: the
(D1). Entry names, events and scopes are manager-neutral; each manager's file format stays inside
its adapter. `detect` also recognizes other hook managers (the pre-commit framework, simple-git-hooks,
overcommit, husky v4) and returns them as conflict decisions. A set `core.hooksPath` is treated as
husky or foreign, never as plain.
husky or foreign, never as plain. A `.husky/task-runner.json` marks Husky.Net: `detect` returns
`husky` with `variant: "husky.net"`, since Husky.Net runs `.husky/<event>` as husky does and the
husky adapter drives it. One difference: Husky.Net points `core.hooksPath` at `.husky` itself, so
git runs `.husky/<event>` directly and skips it unless it is executable.

**`inspect`.** For each git hook stage, `inspect` lists every item that runs, under whichever
manager the repository uses: plain dispatcher markers and a chained `<event>.pre-checks`, each
command line of `.husky/<event>` (and the Husky.Net tasks a `husky run --group` or `--name` line
selects), the lefthook jobs `lefthook dump` reports, git config hooks (the events left after an
empty-value reset; one with `hook.<name>.enabled=false` is reported disabled), and any other hook
file. `installed` says whether git finds an executable hook file for the stage. An item that is a
stamped entry copy names its plugin and entry; a script path from a command, marker or lefthook
job is followed only inside the work tree or the hooks directory. Only the calling plugin's own entries, on their own event, that
rewrite nothing and whose tools are present are run, and only from an installed copy whose script,
lib and assets hash to what the plugin ships now: a stamp alone proves nothing, so an edited or
forged copy is never run and an older one gets a refresh hint. They run on the staged set (`pre-commit`),
a message file outside the repository (`commit-msg`) or the branch against its upstream
(`pre-push`), and get `measured: { medianMs, minMs, maxMs, runs, input, exitCodes }`; every other
item gets `notMeasured` with the reason. `inspect` itself writes nothing in the repository; a
timed entry does only what it does in a real hook run. Its numbers feed
the [duration budgets](#duration-budgets) for placing a check.

**`hooks-path-owned`.** When `core.hooksPath` hands the local hooks directory to another tool (any
value except the plain shared `.githooks`), `plan` returns only one decision,
Expand Down
8 changes: 8 additions & 0 deletions docs/contracts/check-placement/adopting-git-hooks.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ Committed config does not install itself: every clone runs the manager's install

- lefthook: `lefthook install`.
- husky: the project's package install, which runs husky's setup.
- Husky.Net: `dotnet tool restore`, then `dotnet husky install`.
- plain git hooks: `git config core.hooksPath .githooks`.

A clone that skips this step gets no hooks, so for a team with authors outside Claude Code prefer
Expand All @@ -59,6 +60,13 @@ or pushing on a branch you do not trust, read its diff to `lefthook.yml`, `lefth
`.lefthook/`, `.lefthook-local/`, `.husky/` and `.githooks/`
([details](README.md#where-installed-copies-live)).

## See what runs at each stage

`/<plugin>:setup check inspect` lists every hook each stage runs, under whichever manager the
repository uses, with the plugin's own entries timed and every other hook marked not run with the
reason. Compare the times with the [duration budgets](README.md#duration-budgets) before placing a
new check ([`inspect`](README.md#hookmanager-port)).

## Decline

A decline is a git config key, never committed. It silences the session-start drift line for that
Expand Down
2 changes: 1 addition & 1 deletion lib/git-hooks/git-hook-decisions.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ owns.

| Kind | What you do |
|---|---|
| `lefthook-config`, `husky-config` | Merge `snippet` into `file`, keeping the user's own jobs, comments and order; create the file when absent. For a TOML or JSON lefthook config, write the same job in that format. |
| `lefthook-config`, `husky-config` | Merge `snippet` into `file`, keeping the user's own jobs, comments and order; create the file when absent. For a TOML or JSON lefthook config, write the same job in that format. When `detect` reports `variant: "husky.net"` and you create `.husky/<event>`, start it with `#!/bin/sh`, make it executable and stage it at mode 100755: Husky.Net points `core.hooksPath` at `.husky`, so git runs the file directly and skips one that is not executable. |
| `lefthook-install` | Run `lefthook install` so the manager's hooks exist in this clone. |
| `husky-install` | Tell the user to run the project's install so husky's hooks exist in this clone. |
| `husky-shared-only` | Say husky has no per-clone hooks and offer `scope=shared`. |
Expand Down
Loading
Loading