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
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 verdict │ 5. 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
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.
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.
claude
CLI sessions running in tmux.
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.
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/.
Three loop modes for every degree of autonomy.
三档 loop 模式, 覆盖各级自主度.
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 exception | ask |
| Stop hook exception | passthrough (never blocks) |
| Governor parse failure | ask |
| ask under autonomous / freerun | deny (no human) |
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.
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
❯ pre bus start
❯ 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.
Agents flag what humans should see.
让 agent 主动标出需要人看的事.
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.
CEO-style operator console — zero framework.
CEO 视角的运维控制台 — 零框架.
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.
See
assets/IMAGE_PROMPTS.md for the GPT prompt.
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 |