Skip to content

hook-manager: add a CaptainHook adapter #1824

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 CaptainHook (PHP).

What the source says (CaptainHook 5.29.2, sebastianfeldmann/git 3.16.0)

  • Install target. Repository::getHooksDir() (Repository.php:117-157) reads git config --get core.hooksPath (Command/Config/Get.php:53), so it sees the global value.
    An absolute value is used as-is, so under the whole-user setup it installs into ~/.claude/git-hooks/, over the dispatcher.
    The only refusal is for /dev/null (Installer.php:291-296).
    A relative value is joined to the repository root; ~ is not expanded.
  • Worktrees are broken today. Without core.hooksPath, a linked worktree's hooks dir is built as root + / + the absolute gitdir (Repository.php:88-101), a path that does not exist and is not the common dir.
  • Fix. Run the install with
    GIT_CONFIG_COUNT=1 GIT_CONFIG_KEY_0=core.hooksPath GIT_CONFIG_VALUE_0="$(git rev-parse --path-format=absolute --git-common-dir)/hooks".
    That also fixes worktrees. Use the absolute path, never an empty value.
  • Trigger. vendor/bin/captainhook install, or the composer plugin captainhook/hook-installer, which runs on every composer command.
    A ~/.claude/bin/captainhook shim catches neither.
  • Home. None.
  • Generated hook. The shell template uses repository-relative paths to the binary and config (Hook/Template/Local/Shell.php:41-62), so it relies on git running hooks from the top level (the dispatcher keeps that).
    The PHP template uses dirname(__DIR__, 2).'/.git' (Local/PHP.php:84), so it depends on where the hook file sits; check it still works from the common dir in a worktree.
    Skip: CAPTAINHOOK_SKIP_HOOKS=1.
  • Detection. captainhook.json at the root; hook marker captainhook.

What to do

  1. Implement the hooks-path-env strategy in the shim and generator, if hook-manager: add an overcommit adapter #1821 has not already.
  2. Since the shim cannot reach vendor/bin or the composer plugin, decide and document the operator-facing path (for example, captainhook install run as ~/.claude/bin/captainhook with the real binary resolved from vendor/bin, or a documented one-time command).
  3. Add the captainhook adapter to tools/hook-manager/registry.json and run tools/dev/sync-hook-managers.py; add tests.

Acceptance

  • The documented install writes to the common dir under a global core.hooksPath, including in a linked worktree, and leaves ~/.claude/git-hooks/ untouched.
  • 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. Kaap10 commented on Nov 15, 2026

    @Kaap10
    Member

    The CaptainHook adapter, documentation, and test suite were merged in PR #1899 (commit 7ca3873). Closing this issue as completed.

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

    contract:hook-managerfamily:setupgood first issue

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions