This page provides technical documentation of Claude Code's internal architecture and the subsystems that power its functionality. It covers the fundamental building blocks that enable agentic coding, multi-agent orchestration, permission management, and plugin extensibility.
For user-facing documentation on configuration and usage, see Configuration Management and CLI Commands & Interaction Modes. For details on specific subsystems, refer to the child pages listed in each section below.
Claude Code's architecture is organized around several core subsystems that work together to provide an agentic coding experience. The system follows a layered approach where the CLI interface routes user input through session management to the agent system, which orchestrates tool execution under permission controls while managing context windows and triggering lifecycle hooks.
Sources: CHANGELOG.md1-100 diagrams from context
| System | Primary Responsibility | Key Configuration |
|---|---|---|
| Agent System | Execute user requests, spawn subagents, manage task lifecycle | .claude/agents/*.md |
| Tool System | Provide capabilities (bash, file ops, web, MCP) | settings.json disallowedTools |
| Permission System | Control tool execution with allow/ask/deny rules | settings.json permission rules |
| Context Manager | Track token usage, trigger auto-compaction | Context window limits |
| Hook System | Inject custom behavior at lifecycle events | .claude/hooks/*.sh, plugin hooks |
| Plugin System | Discover and load extensions | marketplace.json, plugin.json |
| Skill System | Load custom slash commands | .claude/skills/*.md |
| MCP Integration | Connect to external tool servers | settings.json MCP servers |
Sources: CHANGELOG.md1-50 README.md1-73
This diagram shows how a user message flows through Claude Code's core systems, from input to execution. It maps natural language concepts to the actual execution path.
Sources: CHANGELOG.md241-320 CHANGELOG.md450-520
The agent system orchestrates all AI-powered operations, including spawning subagents for parallel work and managing background tasks. Agents can execute in isolated git worktrees and support multi-agent teams.
Key Features:
Task tool for parallel execution--worktree flag.claude/agents/*.md with frontmatterConfiguration Fields:
model: Override default model for agenttools: Restrict available toolsbackground: true: Auto-background executionisolation: "worktree": Use temporary git worktreememory: Scope for persistent memory (user/project/local)hooks: Agent-scoped lifecycle hooksFor detailed documentation, see Agent System & Subagents.
Sources: CHANGELOG.md5-8 CHANGELOG.md222-224 CHANGELOG.md563-567
Tools provide Claude with capabilities to interact with the development environment. The system includes built-in tools and supports external tools via MCP servers.
Built-in Tools:
| Tool Name | Purpose | Permission Required |
|---|---|---|
Bash | Execute shell commands | Bash(command pattern) |
Read | Read file contents | Read(path pattern) |
Write | Create new files | Write(path pattern) |
Edit | Modify existing files | Edit(path pattern) |
Task | Spawn subagent | Task or Task(AgentName) |
TaskUpdate | Manage background tasks | TaskUpdate |
TaskStop | Stop background task | TaskStop |
Search | Find in files (ripgrep) | Search |
Glob | List files matching pattern | Glob |
WebSearch | Search the web | WebSearch |
WebFetch | Fetch URL content | WebFetch |
LSP | Language server queries | LSP |
MCPSearch | Discover MCP tools | MCPSearch |
Tool Configuration:
disallowedTools in settings.json: Disable specific tools--tools CLI flag: Restrict tools in interactive modesandbox.enabled: Isolate Bash executionFor detailed documentation, see Tool System & Permissions.
Sources: CHANGELOG.md244-247 CHANGELOG.md318-319 CHANGELOG.md565-566
The permission system controls tool execution through a classifier that matches tool invocations against allow/ask/deny rules with wildcard pattern support.
Permission Decisions:
allow: Execute without promptingask: Prompt user for approvaldeny: Block executionRule Syntax:
Bash(*): Match all bash commandsBash(git *): Match commands starting with "git"Bash(* install): Match commands ending with "install"Read(/etc/*): Match files in /etc/Task(AgentName): Control specific agent spawningSettings Hierarchy:
managed-settings.json) - highest priority~/.claude/settings.json).claude/settings.json)settings.local.json)Enterprise Controls:
allowManagedPermissionRulesOnly: Force centralized rulesallowManagedHooksOnly: Prevent custom hooksstrictKnownMarketplaces: Block non-approved pluginsFor detailed documentation, see Tool System & Permissions.
Sources: CHANGELOG.md562 CHANGELOG.md449 CHANGELOG.md26-30
The context manager tracks token usage across the conversation and triggers automatic compaction when nearing limits. It handles both input and output tokens with reserve space for model responses.
Token Tracking:
Compaction Strategies:
/compact commandContext Optimization:
MCPSearch auto modeFor detailed documentation, see Context Window & Compaction.
Sources: CHANGELOG.md38 CHANGELOG.md314-315 CHANGELOG.md452-453 CHANGELOG.md458
Hooks provide lifecycle event interception points for custom behavior injection without modifying core logic. Hooks can be defined at multiple scopes and support both synchronous and asynchronous execution.
Hook Types:
| Hook Event | Trigger | Use Cases |
|---|---|---|
Setup | --init, --init-only, --maintenance flags | Repository setup, dependency installation |
SessionStart | Session begins | Load project context, configure environment |
ConfigChange | Settings files modified during session | Enterprise security auditing |
PreToolUse | Before tool execution | Security warnings, input validation |
PostToolUse | After tool execution | Logging, result processing |
TeammateIdle | Subagent waiting for work | Coordination logic |
TaskCompleted | Subagent finishes | Aggregate results |
Stop | Session ends | Cleanup, save state |
Hook Definition:
.claude/hooks/*.shhooks fieldplugin.jsononce: true for single executionHook Scope:
Hook Execution:
additionalContext return: Inject context to modelFor detailed documentation, see Hook System.
Sources: CHANGELOG.md424 CHANGELOG.md205-206 CHANGELOG.md24 CHANGELOG.md567 CHANGELOG.md90
MCP (Model Context Protocol) servers provide external tool integrations via HTTP, SSE, or stdio transports. Claude Code discovers tools dynamically and supports OAuth for authenticated servers.
Transport Types:
Server Features:
list_changed notifications for dynamic tool updatesConfiguration:
MCPSearch Tool:
auto:N (0-100%)For detailed documentation, see MCP Server Integration.
Sources: CHANGELOG.md106 CHANGELOG.md252 CHANGELOG.md458 CHANGELOG.md564
The plugin system enables extensibility through marketplace-distributed packages containing commands, agents, skills, hooks, and MCP server definitions.
Plugin Structure:
plugin.json: Metadata and component definitionsagents/*.md: Custom agent definitionsskills/*.md: Slash commandshooks/*.sh: Lifecycle hookssettings.json: Default plugin configurationDiscovery Paths:
marketplace.jsonextraKnownMarketplaces--add-dir directories: enabledPluginsPlugin Management:
claude plugin install <name>claude plugin enable/disable <name>Enterprise Controls:
strictKnownMarketplaces: Block non-approved sourcesFor detailed documentation, see Plugin System.
Sources: CHANGELOG.md9 CHANGELOG.md111-112 CHANGELOG.md120 CHANGELOG.md455
Skills provide custom slash commands defined in markdown files with YAML frontmatter. They support hot-reload, agent forking, and permission declarations.
Skill Definition (SKILL.md):
Discovery Locations:
~/.claude/skills/*.md.claude/skills/*.mdplugin.json--add-dir skills: Nested .claude/skills/Hot-Reload:
Variable Substitution:
${CLAUDE_SESSION_ID}: Current session ID$0, $1, etc.: Individual arguments$ARGUMENTS[0], $ARGUMENTS[1]: Indexed accessFor detailed documentation, see Skill System.
Sources: CHANGELOG.md542-543 CHANGELOG.md467 CHANGELOG.md438-439 CHANGELOG.md61-62
The sandbox provides isolated execution for bash commands with network access controls and command restrictions.
Sandbox Configuration:
Security Features:
Implementation:
Bash tool (not Read/Write/Edit).claude/skills directoryFor detailed documentation, see Sandbox Environment.
Sources: CHANGELOG.md186 CHANGELOG.md199 CHANGELOG.md240
Sources: CHANGELOG.md5-8 CHANGELOG.md116
Sources: CHANGELOG.md562 CHANGELOG.md26-30
Sources: CHANGELOG.md24 CHANGELOG.md555 CHANGELOG.md90
Claude Code uses a multi-level configuration system where settings cascade from enterprise to session scope.
Configuration Locations:
| Scope | Location | Use Case |
|---|---|---|
| Enterprise | C:\Program Files\ClaudeCode\managed-settings.json (Windows)/etc/claude/managed-settings.json (Unix) | Organizational policies |
| User | ~/.claude/settings.json | Personal preferences |
| Project | .claude/settings.json | Repository configuration |
| Local | .claude/settings.local.json | Machine-specific overrides |
| Session | Runtime memory | Temporary permission grants |
Sources: CHANGELOG.md536 CHANGELOG.md26-30
Claude Code maintains persistent memory across conversations with configurable scopes for different retention needs.
Memory Scopes:
| Scope | Storage Location | Lifetime | Use Case |
|---|---|---|---|
user | ~/.claude/memory/user/ | Permanent | User preferences, global facts |
project | .claude/memory/project/ | Per repository | Project-specific context |
local | .claude/memory/local/ | Machine-specific | Local environment details |
Memory Configuration:
memory: user / memory: project / memory: localSources: CHANGELOG.md207 CHANGELOG.md224
Sessions represent conversation continuity with support for resume, fork, and remote synchronization.
Session Operations:
--resume [id]: Continue previous session/fork: Branch conversation/clear: Reset conversation (preserves session)/rename [title]: Set custom session name--from-pr <number>: Resume PR-linked sessionSession Storage:
Remote Sessions:
/teleport: Resume remote session locallygh pr createSources: CHANGELOG.md279-280 CHANGELOG.md216-218 CHANGELOG.md359-361
Claude Code implements several performance optimizations to reduce latency and memory usage:
Startup Optimizations:
Runtime Optimizations:
Context Optimizations:
MCPSearchSources: CHANGELOG.md40 CHANGELOG.md25-27 CHANGELOG.md121-122 CHANGELOG.md265 CHANGELOG.md524
Refresh this wiki