r/ClaudeWorkflows • u/ClaudeAI-mod-bot • 7d ago
Selected Workflow [Workflow] Audit Git hooks configuration after launching worktree-isolated subagents
Audit Git hooks configuration after launching worktree-isolated subagents
Workflow value: 76/100
Status: active · Freshness: 70/100 · Confidence: 0.93 · Level: intermediate
Categories: Quality Control, Debugging, CLAUDE.md, Hooks, Skills, Subagents, Multi-Agent
Original source: r/ClaudeCode post/comment
What problem this solves
Detect and mitigate a reported Claude Code worktree-subagent behavior that rewrites a repository's shared Git hooks configuration.
Summary
Compare the Git hooks path and config modification time before and after launching a worktree-isolated subagent, then avoid that isolation mode or enforce policy and verification gates if the issue reproduces.
Why it is useful
Provides a repeatable, narrowly scoped diagnostic for a potentially consequential configuration change, with practical mitigation and verification options.
Workflow
- In a disposable clone, record
git config --show-origin --get core.hooksPathand the modification time of the main checkout's.git/config. - Launch a no-op subagent with
isolation: "worktree", then repeat the checks. Look for a relative hooks path changing to an absolute path. - If affected, avoid automatic worktree isolation; create a worktree manually or use a disposable clone for reviews.
- Consider a PreToolUse policy that denies worktree-isolated Agent calls and relevant Bash configuration writes.
- Check the expected hooks path and actual hook behavior before push or merge; use an independent CI merge gate where possible.
Tools / artifacts
- git config --show-origin --get core.hooksPath
- stat on .git/config
- git worktree add
- git clone --no-hardlinks
- PreToolUse hook
- core.hooksPath
Validation signals
- Author reports repeated config rewrites, including with a no-op subagent in a throwaway clone.
- Author reports inspecting the relevant behavior in the Claude Code 2.1.321 binary.
- The post provides before-and-after checks that readers can use to test their own installations.
Cautions
- Test in a disposable clone and preserve existing Git configuration.
- The
.git/configstat commands assume a main checkout; linked worktrees generally have a.gitfile instead. - A manually created worktree still shares repository configuration; avoid subsequently invoking the affected automatic isolation mode.
- A PreToolUse command filter needs careful implementation and should not be treated as a complete security boundary. A pre-push hook alone cannot enforce a gate if the hooks path is broken.
Limitations
- The claimed behavior is version-specific and has not been independently confirmed in the supplied material.
- The post does not provide an implementation for the proposed denial hook or CI gate.
- Husky exposure and missing-hook-directory behavior are identified as untested.
- A changed path and modification time are useful indicators but do not by themselves prove which process made the change.
Rate this workflow
Upvote this post if the workflow is useful, reproducible, or worth recommending.
Downvote if it is vague, outdated, unsafe, overhyped, or not reproducible.
Reply if it worked for you, failed, is outdated, or has a better alternative.
This post was generated automatically from the workflow library database.