System Design Concepts
12 architectural patterns from Claude Code CLI — each explained with diagrams, source code, and AI-powered chat.
Plugin Architecture
Plugin / Extension Pattern
How Claude Code supports 45+ built-in tools plus unlimited external tools (via MCP) using a single extensible interface.
Streaming & Concurrent Execution
Concurrent Pool + State Machine
Managing parallel tool execution with result ordering guarantees while streaming progress to the UI in real time.
Permission Systems
Strategy Pattern + Rule Engine
Five-tier permission model combining glob rule matching, ML classification, and interactive prompting.
OAuth Token Lifecycle
Proactive Refresh + Secure Storage
PKCE OAuth flow with proactive token refresh, OS keychain storage, and startup prefetch.
Rate Limiting & Exponential Backoff
Exponential Backoff + Source-Aware Retry
Smart retry logic that distinguishes foreground user queries from background tasks to avoid amplifying capacity issues.
Immutable State Management
Single Source of Truth + Immutable Updates
Preventing UI flicker and bugs in a terminal app through deep immutability and append-only message logs.
Observer Pattern
Observer / Event Bus
Lifecycle hooks as a subprocess-based observer pattern — extensible without modifying core code.
Strategy Pattern
Strategy / Adapter Pattern
Swappable implementations for transports (MCP), sandboxes, and auth providers behind unified interfaces.
Factory Pattern
Factory / Registry Pattern
A central tool registry that produces Tool instances on demand — enabling dynamic loading and MCP tool injection.
Security Defense-in-Depth
Defense-in-Depth / Layered Security
Multiple independent security layers — AST analysis, SSRF guard, secret scanning, permissions, and sandboxing.
Context Window Management
LLM-as-Compressor
Using Claude itself to summarize conversation history and extend sessions beyond the token limit.
LRU Caching & Performance
LRU Cache / Memoization
File state caching, memoized selectors, and prompt caching to minimize redundant I/O and API costs.