From the Inside Claude Code - The Claude Code Ecosystem architecture map
Both public entry points share one control-protocol engine
query() reaches Control Protocol Query through the Internal Client and ClaudeSDKClient uses it directly; the engine in turn depends on the transport, Message Parser, SDK MCP Bridge, Transcript Mirror Batcher, Task Compat, Errors and Types. Its run-end logic (session state, in-flight task ledger, a 10-minute ceiling) decides when stdin closes for both.
Impact: A change to when stdin closes, or to how a control request is answered, alters hooks, permissions and in-process MCP tools for every SDK user at once.
The engine is well commented with issue references (#1088, #1190), and test_run_end_subprocess.py exercises the run-end paths against a subprocess; keep changes here behind those tests.
The trail
Open on the mapMore from this board
- Optional SessionStore methods raise instead of being absent, so a change in Types reaches 13 modules
- The Lowerer is one struct spread over 38 files and 29,700 lines with no unit tests
- Day 1: start with marketplace.json, the contract everything else serves
- Every SDK module imports its exceptions from one file, _errors.py
- Partner MCP plugins launch unpinned packages on every user's machine
- PR-controlled agent config is restored from the base branch before Claude starts
- Control-protocol failures escape the SDK exception hierarchy
- The triage and dedupe agents are boxed in identity, tools and network
- Label decisions by the triage agent leave no reason a maintainer can see
- Spend and run length are bounded at the transport
- The subprocess transport carries five responsibilities in one file
- Command-line construction is hardened against argument injection
- Every agent-driven closure has a human override before it happens
- Skip for now: config-only integrations, CI plumbing and single-file plugins
- External-PR workflows never execute contributor code
- Channel servers keep bot tokens owner-only and refuse injected pairing requests