You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Create an optional set of hooks that enforce a pure orchestration model: the main Claude Code thread becomes a pure orchestrator and is blocked from doing any actual work. All coding, testing, file operations, and other work must be delegated to subagents.
Motivation
Currently, Claude Code can perform work directly in the main thread or delegate to subagents. This leads to:
Inconsistent patterns where some work is done inline vs delegated
Harder to enforce separation of concerns
Difficult to track which agent actually performed work
An orchestrator-only mode would:
Force clean separation: orchestration vs execution
Enable better telemetry and observability
Potentially improve quality by always using specialized subagents
Make it easier to reason about agent behavior
Proposed Solution
Hook-Based Enforcement
Create new PreToolUse handlers that intercept "work" tools when in orchestrator mode:
Block: Edit, Write, Bash (coding commands), direct code modifications
classOrchestratorModeHandler(Handler):
def__init__(self) ->None:
super().__init__(
name="orchestrator-mode",
priority=15, # Early, before work happensterminal=True
)
defmatches(self, hook_input: dict) ->bool:
tool_name=hook_input.get("tool_name")
# Return True if tool is "work" that should be delegatedreturntool_namein ["Edit", "Write", "Bash", ...]
defhandle(self, hook_input: dict) ->HookResult:
returnHookResult(
decision="deny",
reason="Orchestrator mode: Please use Task tool to spawn subagent for this work",
context={"blocked_tool": hook_input.get("tool_name")}
)
Summary
Create an optional set of hooks that enforce a pure orchestration model: the main Claude Code thread becomes a pure orchestrator and is blocked from doing any actual work. All coding, testing, file operations, and other work must be delegated to subagents.
Motivation
Currently, Claude Code can perform work directly in the main thread or delegate to subagents. This leads to:
An orchestrator-only mode would:
Proposed Solution
Hook-Based Enforcement
Create new PreToolUse handlers that intercept "work" tools when in orchestrator mode:
Edit,Write,Bash(coding commands), direct code modificationsTask(subagent spawning),Read,Glob,Grep(read-only exploration)AskUserQuestion, communication toolsThe hooks would be optional - users opt-in via config:
Research Phase
Use the new debug infrastructure (
scripts/debug_hooks.sh) to:Example debug session:
Implementation Phases
Phase 1: Research & Design
Phase 2: Handler Implementation
handlers/pre_tool_use/orchestrator_mode.pyPhase 3: Validation
Technical Details
Tools Classification (Initial Draft)
Block (work tools):
Edit,Write,NotebookEdit- file modificationsBashwith certain patterns - code execution, git commits, etc.Allow (orchestration tools):
Task- subagent spawningRead,Glob,Grep- exploration/researchAskUserQuestion- user interactionTaskCreate,TaskUpdate,TaskList- task managementContext-Dependent:
Bashfor read-only operations (git log, ls, etc.) - maybe allow?Handler Structure
Config Schema
Extend
.claude/hooks-daemon.yaml:Next Steps
scripts/debug_hooks.shto capture 10+ real workflow sessionsReferences
CLAUDE/DEBUGGING_HOOKS.mdCLAUDE/HANDLER_DEVELOPMENT.mdhandlers/pre_tool_use/destructive_git.pydaemon/events.pyLabels
enhancement, handlers, research-needed