Hook output leaks across git worktrees in multi-agent setup

Resolved 💬 3 comments Opened Jan 1, 2026 by nazt Closed Feb 16, 2026

Summary

When running multiple Claude Code sessions in git worktrees (multi-agent setup), hook output from one session leaks to other sessions.

Environment

  • Multiple git worktrees: main, agents/1, agents/2, etc.
  • Each worktree has its own Claude Code session
  • Shared plugin hooks across worktrees

Steps to Reproduce

  1. Set up git worktrees:

``bash
git worktree add agents/1 -b agents/1
git worktree add agents/2 -b agents/2
``

  1. Install a plugin with Stop hook (e.g., ralph-local)
  1. Run Claude Code in main worktree, trigger Stop hook that outputs text
  1. Observe: Other worktree sessions (agents/1, agents/2) receive the hook output as <system-reminder> even though they didn't trigger it

Expected Behavior

Hook output should be scoped to the session that triggered it. Other sessions in different worktrees should not receive messages from hooks triggered by other sessions.

Actual Behavior

Hook output is broadcast to ALL running Claude Code sessions, regardless of which $CLAUDE_PROJECT_DIR triggered the hook.

Example

Main agent runs Ralph loop, outputs:

COMPLETED:
- [x] Fix dashboard
- [x] Index markdown

Agent 3 (different worktree) receives:

<system-reminder>
Stop:Callback hook blocking error from command: "callback": 
COMPLETED:
- [x] Fix dashboard
- [x] Index markdown
</system-reminder>

Impact

  • Confuses agents in multi-agent setups
  • Leaks context between isolated sessions
  • Makes it hard to maintain agent separation

Suggested Fix

Scope hook output to the session/worktree that triggered it, possibly by checking $CLAUDE_PROJECT_DIR matches.

---
🤖 Generated with Claude Code

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗