# ClaudePedia > The Claude Code encyclopedia: architecture patterns, guides, and reference reverse-engineered from Claude Code's source. 23 curated pages covering the agent loop, tools, memory, prompts, safety, streaming, multi-agent coordination, MCP, hooks, and observability. Every page below is available as both an HTML article (linked) and raw markdown (same URL with `.md` appended, e.g. `/docs/agent-loop.md`). For the full corpus concatenated into one document, see [llms-full.txt](/llms-full.txt). ## Guides - [Build Your First Agent](https://claudepedia.dev/docs/quickstart.md): Go from zero to a working agent mental model (the loop, one tool, and termination) in a single page. - [Design a Custom Tool](https://claudepedia.dev/docs/design-a-custom-tool.md): How to build a production-ready agent tool from scratch: schema, concurrency class, behavioral flags, and dispatch wiring. - [Manage Conversation Context](https://claudepedia.dev/docs/manage-conversation-context.md): How to keep your agent's context window from overflowing. Covers recognizing the symptoms, applying cheap trims before expensive summarization, and tracking token budgets. - [Add MCP to Your Agent](https://claudepedia.dev/docs/add-mcp-to-your-agent.md): How to connect an external MCP server and make its tools available to your agent. Covers transport selection, tool bridging, and dispatch integration. - [Build a Multi-Agent System](https://claudepedia.dev/docs/build-a-multi-agent-system.md): How to split a single agent into a coordinator and specialized workers. Covers the delegation pattern, context isolation, tool partitioning, and result synthesis. - [Implement Permission Controls](https://claudepedia.dev/docs/implement-permission-controls.md): How to add a permission layer to your agent. Covers the cascade model, permission modes, bypass-immune checks, and session grants. - [Debug Your Agent](https://claudepedia.dev/docs/debug-your-agent.md): How to find out what your agent is doing wrong. Covers structured event logging, cost tracking, session tracing, and the signatures of common failure patterns. - [Stream Agent Responses](https://claudepedia.dev/docs/stream-agent-responses.md): How to add streaming to your agent loop so users see output as it generates. Covers typed events, the producer-consumer pipeline, and backpressure handling. - [Extend with Hooks](https://claudepedia.dev/docs/extend-with-hooks.md): How to add lifecycle hooks to your agent without modifying core loop code. Covers the four execution modes, condition-based filtering, and error isolation. ## Core Systems - [Agent Loop Architecture](https://claudepedia.dev/docs/agent-loop.md): How the core two-state machine drives every agent system, from the generator pattern through graceful cancellation, termination strategies, and error recovery. - [Tool System Design](https://claudepedia.dev/docs/tool-system.md): How tools are defined, registered, and dispatched in agent systems, covering concurrency partitioning, execution lifecycle, behavioral flags, dynamic tool sets, and the production patterns that make tool dispatch safe at scale. - [Prompt Architecture](https://claudepedia.dev/docs/prompt-architecture.md): How the static/dynamic boundary in agent prompts affects cost, latency, and consistency, with the full assembly pipeline, five-level priority chain, memory injection, and production insights for cache management. - [Memory and Context](https://claudepedia.dev/docs/memory-and-context.md): How agent systems manage what the LLM sees, covering compaction pipeline internals, fact extraction subsystem, long-term storage with a closed taxonomy, and production insights for running memory management at scale. - [Error Recovery and Resilience](https://claudepedia.dev/docs/error-recovery.md): How agent systems handle failure through a tiered escalation ladder, retryability classification, query-source partitioning, and a tool error pipeline that keeps the agent loop running even when individual tools fail. - [Safety and Permissions](https://claudepedia.dev/docs/safety-and-permissions.md): How a six-source permission cascade, five permission modes, and three resolution handlers keep agents within bounds, with denial tracking, shadow rule detection, and multi-agent permission forwarding. - [Streaming and Events](https://claudepedia.dev/docs/streaming-and-events.md): How event-driven streaming delivers agent results as they happen, through typed events, producer-consumer pipelines, priority-based dispatch, capture/bubble phases, and a screen-diffing output model. - [Multi-Agent Coordination](https://claudepedia.dev/docs/multi-agent-coordination.md): Why production multi-agent systems use delegation (not distribution): one coordinator decides what to do, specialist workers decide how. Covers spawning backends, file-based mailbox communication, session reconnection, and production trade-offs. ## Advanced Patterns - [Command and Plugin Systems](https://claudepedia.dev/docs/command-and-plugin-systems.md): How to build a scalable command registry that supports 100+ commands through metadata-first registration, lazy loading, and multi-source merging. - [Hooks and Extension Points](https://claudepedia.dev/docs/hooks-and-extensions.md): How typed interceptors modify agent behavior at 27+ lifecycle events without touching core loop code: four execution modes, condition syntax, and error isolation. - [MCP Integration](https://claudepedia.dev/docs/mcp-integration.md): How the Model Context Protocol turns external services into agent tools: transport selection, tool bridging, and connection lifecycle management. - [Observability and Debugging](https://claudepedia.dev/docs/observability-and-debugging.md): Three independent observability layers for agent systems: structured event logging, per-model cost tracking, and session tracing with span hierarchy, each answering a different debugging question. - [The Advisor Strategy](https://claudepedia.dev/docs/advisor-strategy.md): How to boost agentic task performance without running a frontier model end-to-end: pair a fast executor (Sonnet/Haiku) with an Opus advisor that intervenes only at decision points. ## Reference - [Pattern Index](https://claudepedia.dev/docs/pattern-index.md): Complete catalog of 84 named patterns across all ClaudePedia pages, searchable by domain, tags, and keyword. - [Glossary](https://claudepedia.dev/docs/glossary.md): Definitions of every domain-specific term used across ClaudePedia, with cross-references to the page that explains each term in depth.