Claude Code: Subsystems Guide

🇬🇧 English claude-codesubsystemsguideanalysisenglish
📋 Table of Contents (13 sections)
  1. Subsystems Guide
  2. Table of Contents
  3. Bridge (IDE Integration)
  4. MCP (Model Context Protocol)
  5. Permission System
  6. Plugin System
  7. Skill System
  8. Task System
  9. Memory System
  10. Coordinator (Multi-Agent)
  11. Voice System
  12. Service Layer
  13. See Also

Subsystems Guide

Detailed documentation of Claude Code’s major subsystems.


Table of Contents


Bridge (IDE Integration)

Location: src/bridge/

The bridge is a bidirectional communication layer connecting Claude Code’s CLI with IDE extensions (VS Code, JetBrains). It allows the CLI to run as a backend for IDE-based interfaces.

Architecture

┌──────────────────┐         ┌──────────────────────┐
│   IDE Extension  │◄───────►│   Bridge Layer       │
│  (VS Code, JB)   │  JWT    │  (src/bridge/)       │
│                  │  Auth   │                      │
│  - UI rendering  │         │  - Session mgmt      │
│  - File watching │         │  - Message routing    │
│  - Diff display  │         │  - Permission proxy   │
└──────────────────┘         └──────────┬───────────┘


                              ┌──────────────────────┐
                              │   Claude Code Core   │
                              │  (QueryEngine, Tools) │
                              └──────────────────────┘

Key Files

FilePurpose
bridgeMain.tsMain bridge loop — starts the bidirectional channel
bridgeMessaging.tsMessage protocol (serialize/deserialize)
bridgePermissionCallbacks.tsRoutes permission prompts to the IDE
bridgeApi.tsAPI surface exposed to the IDE
bridgeConfig.tsBridge configuration
replBridge.tsConnects the REPL session to the bridge
jwtUtils.tsJWT-based authentication between CLI and IDE
sessionRunner.tsManages bridge session execution
createSession.tsCreates new bridge sessions
trustedDevice.tsDevice trust verification
workSecret.tsWorkspace-scoped secrets
inboundMessages.tsHandles messages coming from the IDE
inboundAttachments.tsHandles file attachments from the IDE
types.tsTypeScript types for the bridge protocol

Feature Flag

The bridge is gated behind the BRIDGE_MODE feature flag and is stripped from non-IDE builds.


MCP (Model Context Protocol)

Location: src/services/mcp/

Claude Code acts as both an MCP client (consuming tools/resources from MCP servers) and can run as an MCP server (exposing its own tools via src/entrypoints/mcp.ts).

Client Features

  • Tool discovery — Enumerates tools from connected MCP servers
  • Resource browsing — Lists and reads MCP-exposed resources
  • Dynamic tool loadingToolSearchTool discovers tools at runtime
  • AuthenticationMcpAuthTool handles MCP server auth flows
  • Connectivity monitoringuseMcpConnectivityStatus hook tracks connection health

Server Mode

When launched via src/entrypoints/mcp.ts, Claude Code exposes its own tools and resources via the MCP protocol, allowing other AI agents to use Claude Code as a tool server.

ToolPurpose
MCPToolInvoke tools on connected MCP servers
ListMcpResourcesToolList available MCP resources
ReadMcpResourceToolRead a specific MCP resource
McpAuthToolAuthenticate with an MCP server
ToolSearchToolDiscover deferred tools from MCP servers

Configuration

MCP servers are configured via /mcp command or settings files. The server approval flow lives in src/services/mcpServerApproval.tsx.


Permission System

Location: src/hooks/toolPermission/

Every tool invocation passes through a centralized permission check before execution.

Permission Modes

ModeBehavior
defaultPrompts the user for each potentially destructive operation
planShows the full execution plan, asks once for batch approval
bypassPermissionsAuto-approves all operations (dangerous — for trusted environments)
autoML-based classifier automatically decides (experimental)

How It Works

  1. Tool is invoked by the Query Engine
  2. checkPermissions(input, context) is called on the tool
  3. Permission handler checks against configured rules
  4. If not auto-approved, user is prompted via terminal or IDE

Permission Rules

Rules use wildcard patterns to match tool invocations:

Bash(git *)           # Allow all git commands without prompt
Bash(npm test)        # Allow 'npm test' specifically
FileEdit(/src/*)      # Allow edits to anything under src/
FileRead(*)           # Allow reading any file

Key Files

FilePath
Permission contextsrc/hooks/toolPermission/PermissionContext.ts
Permission handlerssrc/hooks/toolPermission/handlers/
Permission loggingsrc/hooks/toolPermission/permissionLogging.ts
Permission typessrc/types/permissions.ts

Plugin System

Location: src/plugins/, src/services/plugins/

Claude Code supports installable plugins that can extend its capabilities.

Structure

ComponentLocationPurpose
Plugin loadersrc/services/plugins/Discovers and loads plugins
Built-in pluginssrc/plugins/builtinPlugins.tsPlugins that ship with Claude Code
Bundled pluginssrc/plugins/bundled/Plugin code bundled into the binary
Plugin typessrc/types/plugin.tsTypeScript types for plugin API

Plugin Lifecycle

  1. Discovery — Scans plugin directories and marketplace
  2. Installation — Downloaded and registered (/plugin command)
  3. Loading — Initialized at startup or on-demand
  4. Execution — Plugins can contribute tools, commands, and prompts
  5. Auto-updateusePluginAutoupdateNotification handles updates
CommandPurpose
/pluginInstall, remove, or manage plugins
/reload-pluginsReload all installed plugins

Skill System

Location: src/skills/

Skills are reusable, named workflows that bundle prompts and tool configurations for specific tasks.

Structure

ComponentLocationPurpose
Bundled skillssrc/skills/bundled/Skills that ship with Claude Code
Skill loadersrc/skills/loadSkillsDir.tsLoads skills from disk
MCP skill builderssrc/skills/mcpSkillBuilders.tsCreates skills from MCP resources
Skill registrysrc/skills/bundledSkills.tsRegistration of all bundled skills

Bundled Skills (16)

SkillPurpose
batchBatch operations across multiple files
claudeApiDirect Anthropic API interaction
claudeInChromeChrome extension integration
debugDebugging workflows
keybindingsKeybinding configuration
loopIterative refinement loops
loremIpsumGenerate placeholder text
rememberPersist information to memory
scheduleRemoteAgentsSchedule agents for remote execution
simplifySimplify complex code
skillifyCreate new skills from workflows
stuckGet unstuck when blocked
updateConfigModify configuration programmatically
verify / verifyContentVerify code correctness

Execution

Skills are invoked via the SkillTool or the /skills command. Users can also create custom skills.


Task System

Location: src/tasks/

Manages background and parallel work items — shell tasks, agent tasks, and teammate agents.

Task Types

TypeLocationPurpose
LocalShellTaskLocalShellTask/Background shell command execution
LocalAgentTaskLocalAgentTask/Sub-agent running locally
RemoteAgentTaskRemoteAgentTask/Agent running on a remote machine
InProcessTeammateTaskInProcessTeammateTask/Parallel teammate agent
DreamTaskDreamTask/Background “dreaming” process
LocalMainSessionTaskLocalMainSessionTask.tsMain session as a task

Task Tools

ToolPurpose
TaskCreateToolCreate a new background task
TaskUpdateToolUpdate task status
TaskGetToolRetrieve task details
TaskListToolList all tasks
TaskOutputToolGet task output
TaskStopToolStop a running task

Memory System

Location: src/memdir/

Claude Code’s persistent memory system, based on CLAUDE.md files.

Memory Hierarchy

ScopeLocationPurpose
Project memoryCLAUDE.md in project rootProject-specific facts, conventions
User memory~/.claude/CLAUDE.mdUser preferences, cross-project
Extracted memoriessrc/services/extractMemories/Auto-extracted from conversations
Team memory syncsrc/services/teamMemorySync/Shared team knowledge
  • /memory command for managing memories
  • remember skill for persisting information
  • useMemoryUsage hook for tracking memory size

Coordinator (Multi-Agent)

Location: src/coordinator/

Orchestrates multiple agents working in parallel on different aspects of a task.

How It Works

  • coordinatorMode.ts manages the coordinator lifecycle
  • TeamCreateTool and TeamDeleteTool manage agent teams
  • SendMessageTool enables inter-agent communication
  • AgentTool spawns sub-agents

Gated behind the COORDINATOR_MODE feature flag.


Voice System

Location: src/voice/

Voice input/output support for hands-free interaction.

Components

FileLocationPurpose
Voice servicesrc/services/voice.tsCore voice processing
STT streamingsrc/services/voiceStreamSTT.tsSpeech-to-text streaming
Key termssrc/services/voiceKeyterms.tsDomain-specific vocabulary
Voice hookssrc/hooks/useVoice.ts, useVoiceEnabled.ts, useVoiceIntegration.tsxReact hooks
Voice commandsrc/commands/voice//voice slash command

Gated behind the VOICE_MODE feature flag.


Service Layer

Location: src/services/

External integrations and shared services.

ServicePathPurpose
APIapi/Anthropic SDK client, file uploads, bootstrap
MCPmcp/MCP client connections and tool discovery
OAuthoauth/OAuth 2.0 authentication flow
LSPlsp/Language Server Protocol manager
Analyticsanalytics/GrowthBook feature flags, telemetry
Pluginsplugins/Plugin loader and marketplace
Compactcompact/Conversation context compression
Policy LimitspolicyLimits/Organization rate limits/quota
Remote SettingsremoteManagedSettings/Enterprise managed settings sync
Token EstimationtokenEstimation.tsToken count estimation
Team MemoryteamMemorySync/Team knowledge synchronization
Tipstips/Contextual usage tips
Agent SummaryAgentSummary/Agent work summaries
Prompt SuggestionPromptSuggestion/Suggested follow-up prompts
Session MemorySessionMemory/Session-level memory
Magic DocsMagicDocs/Documentation generation
Auto DreamautoDream/Background ideation
x402x402/x402 payment protocol

See Also

← Back to claudecodeanalysis