Claude Code Source Notes

Claude Code Source Notes

This English edition follows one task through the Claude Code runtime first, then zooms into memory, context, tools, permissions, MCP, subagents, hooks, transcript, resume, and prompt cache. Each article is grounded in the public mirror and official documentation.

The English pages are written as standalone articles, not route stubs. Use the language switch on any article to jump to the matching Chinese version.

Source Notes · Part I Follow One Task Through the Claude Code Runtime

Build the source-reading route first: CLI, REPL, queue, query loop, model stream, tool gates, transcript, and resume.

Source Notes · Part II Memory Is a Long-Lived Instruction Layer

Trace CLAUDE.md, auto memory, session memory, agent memory, and user context projection into the next request.

Source Notes · Part III Context Is Not Just a Summary

Separate memory, transcript, compact, microcompact, and model-visible projection instead of calling everything context.

Source Notes · Part IV Tools Are Runtime Contracts

Read the path from model tool_use to validated local work and paired tool_result.

Source Notes · Part V Permissions Are the Side-Effect Brake

Follow allow, deny, ask, hooks, permission requests, and denied tool results through the tool path.

Source Notes · Part VI Commands, Skills, and MCP Feed the Same Capability Pool

Read how slash commands, skills, plugins, MCP prompts, and MCP tools enter the current command table and tool pool.

Source Notes · Part VII Subagents and Forks Are Context Projections

Compare normal subagents with fork paths, worker tool scope, cache-stable prefixes, and context isolation.

Source Notes · Part VIII Hooks Are Runtime Gates

Place hooks back into the turn lifecycle: prompt, tool, stop, compact, session, and subagent boundaries.

Source Notes · Part IX Resume Rebuilds Runtime State

Separate UI messages, durable transcript, API view, content replacement, and restored runtime state.

Source Notes · Part X Prompt Cache Is Request-Shape Discipline

Tie cache_control, stable prefixes, fork suffixes, microcompact, replacement state, and cache-break detection into one performance story.