# brefledev/stop-subagent-fanout architecture

> Architecture diagram of the GitHub repository brefledev/stop-subagent-fanout, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/brefledev/stop-subagent-fanout
- Repository: https://github.com/brefledev/stop-subagent-fanout

## Overview

stop-subagent-fanout is a small Claude Code hook and installer. The main workflow is: install the gate and configure a PreToolUse matcher, then Claude Code invokes the gate before matching tool calls; the gate returns an approval decision and records an audit entry. The README documents the human prompt and environment override. Runtime behavior is supported by the sampled scripts; configuration and prompt behavior are also documented in the README.

Main entry points: [`subagent-gate.mjs`](https://github.com/brefledev/stop-subagent-fanout/blob/main/subagent-gate.mjs) (Gate script), [`install.mjs`](https://github.com/brefledev/stop-subagent-fanout/blob/main/install.mjs) (Installer), [`settings.example.json`](https://github.com/brefledev/stop-subagent-fanout/blob/main/settings.example.json) (Hook example)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_setup["Project setup"]
  node_installer["Installer<br/>[install.mjs]"]
  node_example["Hook example"]
  node_settings["Project settings"]
end

subgraph group_gate["Spawn gate"]
  node_gate_script["Gate script<br/>[subagent-gate.mjs]"]
  node_session_env["Session environment"]
  node_audit_log["Decision log"]
end

node_user(("Project owner"))
node_claude(("Claude Code"))

node_user -->|"runs"| node_installer
node_installer -->|"copies"| node_gate_script
node_installer -->|"updates"| node_settings
node_example -.->|"merge manually"| node_settings
node_settings -->|"configures hooks"| node_claude
node_claude -->|"invokes before tool"| node_gate_script
node_claude -->|"pipes hook JSON"| node_gate_script
node_session_env -->|"provides override"| node_gate_script
node_gate_script -->|"returns decision"| node_claude
node_gate_script -->|"appends decisions"| node_audit_log
node_claude -->|"prompts for approval"| node_user

click node_installer "https://github.com/brefledev/stop-subagent-fanout/blob/main/install.mjs"
click node_example "https://github.com/brefledev/stop-subagent-fanout/blob/main/settings.example.json"
click node_gate_script "https://github.com/brefledev/stop-subagent-fanout/blob/main/subagent-gate.mjs"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_installer,node_example,node_settings toneBlue
class node_gate_script,node_session_env,node_audit_log toneAmber
class node_user,node_claude toneIndigo
```

## Components

### Project setup

- [Installer](https://github.com/brefledev/stop-subagent-fanout/blob/main/install.mjs): `install.mjs`
- [Hook example](https://github.com/brefledev/stop-subagent-fanout/blob/main/settings.example.json): `settings.example.json`
- **Project settings**

### Spawn gate

- [Gate script](https://github.com/brefledev/stop-subagent-fanout/blob/main/subagent-gate.mjs): `subagent-gate.mjs`
- **Session environment**
- **Decision log**

### Other components

- **Project owner**
- **Claude Code**

## Connections

- Project owner → Installer: runs
- Installer → Gate script: copies
- Installer → Project settings: updates
- Hook example → Project settings: merge manually
- Project settings → Claude Code: configures hooks
- Claude Code → Gate script: invokes before tool
- Claude Code → Gate script: pipes hook JSON
- Session environment → Gate script: provides override
- Gate script → Claude Code: returns decision
- Gate script → Decision log: appends decisions
- Claude Code → Project owner: prompts for approval
