Repository navigation
Closed
Labels
contract:hook-managerTool capability: git-hook managers under the secure setup (install target, sandbox / host homes)family:setupsetup-* skillsgood first issueGood for newcomers
Description
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) readsgit 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 plugincaptainhook/hook-installer, which runs on every composer command.
A~/.claude/bin/captainhookshim 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 usesdirname(__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.jsonat the root; hook markercaptainhook.
What to do
- Implement the
hooks-path-envstrategy in the shim and generator, if hook-manager: add an overcommit adapter #1821 has not already. - Since the shim cannot reach
vendor/binor the composer plugin, decide and document the operator-facing path (for example,captainhook installrun as~/.claude/bin/captainhookwith the real binary resolved fromvendor/bin, or a documented one-time command). - Add the
captainhookadapter totools/hook-manager/registry.jsonand runtools/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-pytestand the affected tests pass.
Metadata
Metadata
Assignees
Labels
contract:hook-managerTool capability: git-hook managers under the secure setup (install target, sandbox / host homes)family:setupsetup-* skillsgood first issueGood for newcomers
Activity
Kaap10 commentedon Nov 15, 2026
The CaptainHook adapter, documentation, and test suite were merged in PR #1899 (commit 7ca3873). Closing this issue as completed.