pre · ceo ~/landing opensource agent governance · MIT github ↗
# overview Claude Code agent governance & multi-agent bus
pre bus start && pre init ~/your-project --mode supervised

Govern every Claude Code tool call.
Orchestrate agents across machines on one control plane.

让 Claude Code 的每次工具调用都受控.
编排跨机 agent, 汇入同一个控制平面.

pre is a PreToolUse / Stop hook governance layer plus a Master / Node / Driver message bus for orchestrating multiple Claude Code agents — local and remote — under a single CEO-style control plane. Layered decisions (blacklist · whitelist · cache · LLM governor), an observer-only Stop hook, budget caps for freerun, and a zero-framework browser GUI.

git clone https://github.com/pre-ceo/pre.git && bash pre/scripts/install.sh
Python 3.11+ · stdlib-only core MIT license Zero framework GUI Red-green-deficient-friendly palette
# architecture control-plane.txt
Claude Code Agent
  │
  ├─ Tool call ─→ PreToolUse Hook  (0–8s)1. Blacklist        → ASK/DENY  (rm -rf, sudo, force-push, …)2. Supply-chain     → Governor, no cache (npm, node -e, ssh, …)3. Whitelist        → ALLOW    (git, ls, find, read in cwd, …)4. Cache            → reuse last governor verdict5. Governor (LLM)   → reads global rules + project rules
  │
  ├─ Stop ─→ Stop Hook  (passive observer) record stop log
  │     process pre/findings/{LEVEL}-{title}.md
  │     freerun/autonomous: block + tell agent to read pre/next.md
  │     supervised: passthrough
  │
  └─ Bus access
       Agent ──MCP stdio──▶ pre_mcp subprocess ──loopback HTTP──▶ Master
                            (4 tools: send_message / fetch_inbox /
                                       read_pane / cycle_state)

       Master (HTTP + WS) ◀──▶ Node(s) ◀──▶ Driver(s) ◀──▶ Agent process(es)
       Browser GUI (pre_ui) ◀── HTTP only ──▶ Master
# features 6 capabilities
01 / pretooluse
Layered tool-call governance [hook]
Every tool call flows through a 5-stage decision pipeline: blacklist → supply-chain → whitelist → cache → LLM governor. Dangerous patterns like rm -rf, force-push, curl | sh, supply-chain installs and inline node -e / python -c are surfaced as ASK in supervised mode and DENY in unattended modes.
02 / stop hook
Observer-only stop hook [passive]
Zero-latency Stop: records log, scans pre/findings/{LEVEL}-*.md the agent wrote, routes them through notification channels (severity-aware), and — in unattended modes — blocks once and points the agent at pre/next.md.
03 / multi-agent bus
Master / Node / Driver [bus]
One master (HTTP REST + WebSocket on loopback) talks to one or more nodes — each potentially on a different machine over an SSH tunnel. Each node hosts pluggable drivers that own the actual agent processes; the included driver wraps claude CLI sessions running in tmux.
04 / freerun safety
Budget caps & kill switch [safety]
Freerun isn't fire-and-forget: per-day caps on tokens, cost, runtime and LLM calls; event-driven loops only (no polling sleep); an allowlist that absorbs repeated patterns instead of dying on every ASK; and a kill switch that converts every freerun back to half-supervised in one call.
05 / mcp
Agent ↔ bus over MCP [mcp]
Agents reach the bus through a pre_mcp stdio subprocess — it enforces caller-identity prefix checks, cross-node read-pane denial, 60/min sliding-window rate limits, and structured audit logs before forwarding to master. Four tools: send_message · fetch_inbox · read_pane · cycle_state.
06 / findings
Agent-driven notifications [notify]
Agents write pre/findings/CRITICAL-*.md / WARNING-*.md / INFO-*.md when something deserves a human. Stop hook renders a report, tags the git tree (finding/{level}/{ts}), routes through configured channels and moves the file to processed/.
# loop-modes modes.tbl

Three loop modes for every degree of autonomy.

Switch a single agent's mode at runtime through the operator API (or the GUI). Modes change what PreToolUse does on dangerous verdicts and whether Stop blocks back to pre/next.md.

Mode PreToolUse danger Stop behavior Needs pre/next.md
[supervised] ASK user passthrough
[autonomous] DENY block + read pre/next.md yes
[freerun] DENY block + read pre/next.md yes
Situation Behavior
PreToolUse exceptionask
Stop hook exceptionpassthrough (never blocks)
Governor parse failureask
ask under autonomous / freerundeny (no human)
# quick-start install.sh — bash

Quick start — three steps, idempotent.

Python 3.11+. The hooks, master, node and scripts are stdlib-only; the optional pre_mcp subpackage needs the mcp SDK.

1
Clone & bootstrap (creates pre_rule/, clones pre_ui/, installs shims)
 export PRE_DIR=$HOME/your-path/pre
 git clone https://github.com/pre-ceo/pre.git "$PRE_DIR"
 cd "$PRE_DIR"
 bash scripts/install.sh
 uv add mcp                       # optional: install MCP SDK
2
Start master + local node (tmux-supervised)
 pre bus start
3
Wire your project to the hooks
 pre init /path/to/your-project --mode supervised
# creates ./pre/{agent_config.json, rules.md, next.md, findings/}
# merges PreToolUse + Stop hooks into ./.claude/settings.json

After that, every tool call from Claude Code in that project flows through the PreToolUse pipeline. The agent can also call MCP tools mcp__pre__send_message / fetch_inbox / read_pane / cycle_state to interact with the bus.

# findings findings/ — drop, get notified

Agents flag what humans should see.

Drop a markdown file in pre/findings/ and the Stop hook renders a report, tags the git tree, and routes through configured notification channels — severity decides the channel.

[INFO]
echo "details…" > pre/findings/INFO-coverage-up.md
[WARNING]
echo "details…" > pre/findings/WARNING-perf-regression.md
[CRITICAL]
echo "details…" > pre/findings/CRITICAL-something-broke.md
# browser-gui pre_ui — CEO operator console

CEO-style operator console — zero framework.

pre_ui is plain HTML + CSS + vanilla JS, served by a ~150-LOC stdlib reverse-proxy that puts the master and the static assets on the same origin — no CORS, no preflight. Polling-based, strict CSP, Bearer token in sessionStorage only.

./assets/gui-preview.png Replace this placeholder once the screenshot is generated.
See assets/IMAGE_PROMPTS.md for the GPT prompt.
# three-repos repo-trio.tbl

The deployment has three pieces.

pre_rule/ stays on your machine and is never pushed upstream by pre; you can git init it and sync it to a private remote yourself for multi-host setup.

Repo Role Source Personal data
pre code + control plane github.com/pre-ceo/pre no
pre_rule/ your rules + local runtime state created by install.sh from pre/templates/pre_rule/ yes (local; never pushed)
pre_ui browser GUI github.com/pre-ceo/pre_ui no