The Anthropic Ecosystem Blueprint: How Open-Source Hook & MCP Kernels Turn Coding CLIs into Deterministic Engineering Teams Benni Alencar, chief AI systems architect at Benni OS, released an open-source suite of six composable packages that wrap Anthropic's Claude Code CLI in a deterministic control plane built on lifecycle hooks (PreToolUse, PostToolUse, Stop) and the Model Context Protocol. The packages—including claude-code-sovereign, agent-context-firewall, agent-budget-governor, agent-trace-replay, conductor-sdd, and claude-code-swarm—intercept tool calls in under a millisecond to block secret exfiltration and prompt injection, enforce spec contracts, isolate parallel agents in git worktrees, and produce SHA-256 audit logs with replay. Alencar argues probabilistic failure modes are not fixed with longer CLAUDE.md prompts but with deterministic enforcement at tool boundaries. By Benni Alencar — Chief AI Systems Architect at Benni OS https://benni-os.net . Canonical article & interactive benchmarks at benni-os.net https://benni-os.net/blog/en/anthropic-ecosystem-blueprint-hooks-mcp-kernels-deterministic-teams.html . Out of the box, Anthropic's Claude Code is an extraordinary single-developer terminal agent. Give it a clear prompt in a clean repository and it will read files, run tests, and ship patches. Yet the moment an enterprise tries to scale that single-prompt loop into a multi-developer, multi-agent engineering organization, four structural failure modes emerge: TODO stubs behind. .env secrets or running destructive shell commands. Workspace Collisions & Ephemeral Audits: Parallel agents editing the same working tree overwrite each other's files, while terminal scrollback leaves zero cryptographic proof of what actually happened. The Core Thesis: You do not fix probabilistic failure modes with longer CLAUDE.md prompts. You wrap the coding CLI in a deterministic control plane built from two native primitives: synchronous lifecycle hooks PreToolUse , PostToolUse , Stop and the Model Context Protocol MCP . The Benni OS Open-Source Suite decomposes this control plane into six composable, zero-lock-in packages designed specifically for Claude Code: claude-code-sovereign , agent-context-firewall , agent-budget-governor , agent-trace-replay , conductor-sdd , and claude-code-swarm . Instead of a monolithic wrapper that forks Claude Code, the Benni OS blueprint operates purely through Claude Code's official extension points. Hooks intercept every tool boundary on local CPU in sub-millisecond time, while MCP servers expose stateful coordination, Spec-Driven Development SDD contracts, bi-temporal memory, and offline time-travel replay. php flowchart TB OP "Engineering Lead / Spec Prompt" -- SDD "conductor-sdd MCP + Spec Gate " SDD -- |"Validated Contract & Tasks"| SWARM "claude-code-swarm Worktree Orchestrator " SWARM -- |"Isolated Git Worktrees"| W1 "Claude Code Worker 1" SWARM -- |"Isolated Git Worktrees"| W2 "Claude Code Worker 2" W1 -- |"PreToolUse < 1ms "| FW "agent-context-firewall + agent-budget-governor" W2 -- |"PreToolUse < 1ms "| FW FW -- |"Exit 2 Deny "| BLK "Blocked Before OS Execution" FW -- |"Exit 0 Allow "| KERNEL "claude-code-sovereign Runtime" KERNEL -- |"PostToolUse"| TRACE "agent-trace-replay SHA-256 JSONL " KERNEL -- |"MCP Read/Write"| MEM "Bi-Temporal Memory Graph MCP " KERNEL -- |"Stop Gate"| LOCK "AST & Spec Reality Lock" LOCK -- |"Defect Found"| W1 LOCK -- |"Verified Clean"| MERGE "Audited PR / Signed Merge" Every layer has a strict, non-overlapping responsibility. If a worker hallucinates an unapproved dependency, conductor-sdd catches the spec violation. If an untrusted README attempts prompt injection, agent-context-firewall kills the Bash call before the OS spawns a process. If a loop stalls, agent-budget-governor trips the circuit breaker. And when the run finishes, agent-trace-replay provides an immutable, $0.00-replayable SHA-256 audit log. Benni-OS/claude-code-sovereign https://github.com/Benni-OS/claude-code-sovereign is the central hook dispatcher and Reality Lock engine. It binds Python handlers to PreToolUse , PostToolUse , SubagentStop , and Stop . On Stop , it parses modified files via AST, rejects placeholder stubs TODO , NotImplementedError , and runs fast verification checks—forcing Claude Code to self-heal before returning control to the user. Operating synchronously inside PreToolUse , agent-context-firewall enforces taint tracking and egress policies across Bash , Read , Write , and MCP payloads. It blocks secret exfiltration .env , .pem , SSH keys, cloud credentials , flags encoded shell sinks, and neutralizes indirect prompt injection payloads before they touch the filesystem or network. Connected to PostToolUse and SubagentStop , agent-budget-governor maintains an atomic per-session and per-subagent ledger of input/output tokens and USD spend. When a worker or subagent tree approaches its configured ceiling e.g., max session usd: 5.00 , the next PreToolUse gate trips deterministically, preventing overnight API bill explosions. Benni-OS/agent-trace-replay https://github.com/Benni-OS/agent-trace-replay records every tool invocation, firewall decision, budget delta, and file diff into an append-only, content-addressed JSONL chain linked by SHA-256 parent hashes. Engineers can step backward and forward through any agent session offline at $0.00 token cost , or query specific failure frames over MCP. conductor-sdd replaces ad-hoc prompting with machine-verifiable specifications. Before code generation begins, an architecture spec is locked into .conductor/spec.json . Exposed as both an MCP server and a Stop hook validator, it guarantees that every implemented symbol, endpoint, and test assertion maps directly to an approved requirement—eliminating architectural drift. Scaling beyond one agent requires physical filesystem isolation. claude-code-swarm orchestrates parallel Claude Code workers inside dedicated git worktree sandboxes, preventing dirty-tree collisions. Shared state is synchronized via a bi-temporal memory MCP server that indexes facts by both valid time when a codebase invariant became true and transaction time when an agent recorded it , so parallel workers never act on stale architectural assumptions. Because the entire ecosystem relies on standard Anthropic configuration files, onboarding a repository requires only .claude/settings.json for deterministic lifecycle hooks and .mcp.json for stateful team coordination. { "hooks": { "PreToolUse": { "matcher": " ", "hooks": { "type": "command", "command": "agent-context-firewall check --strict && agent-budget-governor gate", "timeout": 1500 } } , "PostToolUse": { "matcher": " ", "hooks": { "type": "command", "command": "agent-budget-governor record && agent-trace-replay append", "timeout": 1500 } } , "SubagentStop": { "hooks": { "type": "command", "command": "agent-budget-governor rollup-subagent", "timeout": 2000 } } , "Stop": { "hooks": { "type": "command", "command": "claude-code-sovereign reality-lock && conductor-sdd verify", "timeout": 6000 } } } } { "mcpServers": { "conductor-sdd": { "command": "conductor-sdd", "args": "mcp-serve", "--spec", ".conductor/spec.json" }, "claude-code-swarm": { "command": "claude-code-swarm", "args": "mcp-serve", "--worktree-root", ".worktrees" }, "bitemporal-memory": { "command": "claude-code-sovereign", "args": "memory-mcp", "--db", ".sovereign/memory.sqlite" }, "agent-trace-replay": { "command": "agent-trace-replay", "args": "mcp-serve", "--traces-dir", ".sovereign/traces" } } } | Open-Source Package | Integration Surface | Deterministic Guarantee | Enterprise Failure Eliminated | |---|---|---|---| | claude-code-sovereign | Stop hook + Core Bus | AST & linter Reality Lock | Broken syntax, TODO stubs, false completions | | agent-context-firewall | PreToolUse < 1ms | Exit code 2 OS-level block | Indirect prompt injection & .env exfiltration | | agent-budget-governor | PreToolUse / PostToolUse / SubagentStop | Hard USD & token circuit breaker | Runaway retry loops & unbudgeted subagent spend | | agent-trace-replay | PostToolUse + MCP | SHA-256 content-addressed JSONL | Ephemeral logs & expensive live debugging | | conductor-sdd | MCP + Stop Gate | Spec-to-diff contract verification | Architectural drift & unrequested refactors | | claude-code-swarm | MCP + git worktree | Isolated branches + bi-temporal memory | Parallel file collisions & stale shared context | When five Claude Code workers operate in parallel across five git worktree directories, traditional vector stores fail because they flatten time. If Worker A refactors an authentication middleware at T1 while Worker B is mid-task on an endpoint that depends on the old signature, a naive RAG lookup returns conflicting truths. By pairing claude-code-swarm with a bi-temporal memory graph over MCP, every architectural fact carries both a valid from timestamp tied to commit/spec state and an ingested at timestamp. Workers query memory scoped to their worktree's base commit and active conductor-sdd contract—guaranteeing zero-drift coordination across the entire swarm. Explore the open-source repositories under Benni-OS , wire the hook & MCP kernels into your repository, and transform Claude Code into an auditable, zero-drift engineering organization. Explore Benni-OS on GitHub → Why do single-prompt coding CLIs fail at enterprise scale without hook and MCP kernels? Single-prompt CLIs rely on probabilistic compliance inside a shared context window. Without deterministic lifecycle hooks PreToolUse, PostToolUse, Stop , isolated git worktrees, and spec-driven contracts, multi-agent runs suffer from architectural drift, merge conflicts, runaway token spend, and silent security regressions. How do the six Benni OS open-source packages compose inside Claude Code? claude-code-sovereign acts as the core microkernel orchestrating lifecycle hooks; agent-context-firewall blocks prompt injection and secret exfiltration before execution; agent-budget-governor enforces hard USD and token circuit breakers; agent-trace-replay records SHA-256 trajectories for $0.00 offline replay; conductor-sdd enforces Spec-Driven Development contracts; and claude-code-swarm coordinates parallel agents in isolated git worktrees. What role does bi-temporal memory play in a deterministic engineering organization? Bi-temporal memory tracks both event time when an architectural decision or bug fix occurred in the codebase and ingestion time when the agent learned it . Exposed over MCP, it prevents stale context retrieval across branches and gives every swarm worker an accurate, conflict-free view of valid invariants. Can enterprises adopt individual components incrementally? Yes. Each package in the Benni OS Anthropic suite is modular and open-source. Teams typically start with claude-code-sovereign and agent-context-firewall for immediate PreToolUse protection and FinOps caps, then add conductor-sdd , agent-trace-replay , and claude-code-swarm as they scale to parallel multi-agent delivery. Single-prompt CLIs rely on probabilistic compliance inside a shared context window. Without deterministic lifecycle hooks PreToolUse , PostToolUse , Stop , isolated git worktrees, and spec-driven contracts, multi-agent runs suffer from architectural drift, merge conflicts, runaway token spend, and silent security regressions. claude-code-sovereign acts as the core microkernel orchestrating lifecycle hooks; agent-context-firewall blocks prompt injection and secret exfiltration before execution; agent-budget-governor enforces hard USD and token circuit breakers; agent-trace-replay records SHA-256 trajectories for $0.00 offline replay; conductor-sdd enforces Spec-Driven Development contracts; and claude-code-swarm coordinates parallel agents in isolated git worktrees. Bi-temporal memory tracks both event time when an architectural decision or bug fix occurred in the codebase and ingestion time when the agent learned it . Exposed over MCP, it prevents stale context retrieval across branches and gives every swarm worker an accurate, conflict-free view of valid invariants. Yes. Each package in the Benni OS Anthropic suite is modular and open-source. Teams typically start with claude-code-sovereign and agent-context-firewall for immediate PreToolUse protection and FinOps caps, then add conductor-sdd , agent-trace-replay , and claude-code-swarm as they scale to parallel multi-agent delivery.