Skip to content

hook-manager: add a lefthook adapter #1822

Closed

Description

@potiuk

The hook-manager contract (#1819) defines how the secure agent setup integrates a git-hook manager: where its install puts the hook, how its home is split between sandboxed and host runs, and how the setup detects that a repository uses it.
prek is the only adapter so far.
This issue adds lefthook (Go, also distributed through npm).

What the source says (lefthook v2.2.2)

  • Install target. lefthook install writes to git rev-parse --path-format=absolute --git-path hooks (internal/git/wrapper/paths.go:7-14), which honours core.hooksPath and resolves the common dir in a linked worktree.
    Before writing, it reads core.hooksPath with scoped git config --local and --global reads, and refuses when one is set:
    core.hooksPath is set globally to '…' Custom hooks paths are not supported by default. (internal/command/install.go:511-589).
  • Two flags to watch.
    --force installs into the global directory, over the dispatcher (Installing hooks anyway in '%s').
    --reset-hooks-path runs git config --global --unset-all core.hooksPath (install.go:592-606), which removes the whole-user setup.
  • Fix. GIT_CONFIG_GLOBAL=/dev/null lefthook install: the scoped global read sees nothing, and --git-path hooks then resolves to the common dir.
    A GIT_CONFIG_COUNT override does not help: scoped reads ignore it.
  • Trigger. The CLI, plus an npm postinstall that runs lefthook install (packaging/registries/npm/lefthook/postinstall.js; skipped under CI).
    A ~/.claude/bin/lefthook shim does not catch the npm path, because npm puts node_modules/.bin first on PATH.
    lefthook run also re-syncs hooks when the config changes; with a global path set it only logs Skipping hook sync (install.go:159-230).
  • Home. None. Remote configs are cloned into <git-path info>/lefthook-remotes (internal/git/remote.go:21-23), inside .git, so there is no home split.
  • Generated hook. Honours LEFTHOOK=0, LEFTHOOK_BIN, LEFTHOOK_VERBOSE; embeds os.Executable() as a fallback (internal/templates/hook.tmpl, templates.go:39-55); the hook name is baked in and it does not depend on $0, so it is safe behind the dispatcher.
  • Detection. Configs lefthook.yml, lefthook.yaml, .lefthook.yml, lefthook.toml, lefthook.json and their -local variants: confirm the exact list from internal/config/ before writing it into the registry.

What to do

  1. Add a hide-global-config install strategy to the shim and the generator, if hook-manager: add a pre-commit adapter #1820 has not already; add a shim test.
  2. Add the lefthook adapter to tools/hook-manager/registry.json with no home, and run tools/dev/sync-hook-managers.py.
  3. Add an agent-guard guard that blocks lefthook install --reset-hooks-path (and -r) and lefthook install --force when the global core.hooksPath is the framework's.
  4. Document the npm postinstall gap in the contract's adapter table: the shim covers the CLI only.
    Optionally propose a fix (for example, the session-start hook noticing hooks in the shared dir that are not the dispatcher).

Acceptance

  • lefthook install through ~/.claude/bin/lefthook succeeds under a global core.hooksPath and writes to the common dir, including in a linked worktree.
  • The guard blocks the two destructive flags, with a test.
  • prek run --all-files --skip workspace-pytest and the affected tests pass.

Activity

  1. added
    good first issue
    family:setup
    contract:hook-manager
    on Oct 25, 2026
  2. Anurag-S1ngh commented on Oct 26, 2026

    @Anurag-S1ngh
    Contributor

    Hi, I'd like to take this issue. Could you assign it to me?

  3. potiuk commented on Oct 26, 2026

    @potiuk
    MemberAuthor

    Go ahead. We do not assign issues.

  4. added
    family:docs
    family:ci
    capability:platform
    substrate:sandbox
    substrate:action-guard
    substrate:framework-dev
    on Oct 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    capability:platformcontract:hook-managerfamily:cifamily:docsfamily:setupfamily:toolsgood first issuesubstrate:action-guardsubstrate:framework-devsubstrate:sandbox

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions