# anthropics/claude-code architecture

> Architecture diagram of the GitHub repository anthropics/claude-code, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/anthropics/claude-code
- Repository: https://github.com/anthropics/claude-code
- Video tour (about a minute): https://gitdiagram.com/anthropics/claude-code/video

## Overview

Claude Code is an agentic coding tool used from a terminal, IDE, or GitHub mention to help with coding, explanations, routine tasks, and Git workflows (README). The supplied tree is a set of hook modules, not the CLI’s main runtime entry point, so this map focuses on evidenced product subsystems rather than inventing a top-level execution chain. It includes Git diff/pane support, agent instruction-file handling, security and privacy hooks, and telemetry-related modules. Several subsystem details are known only from paths or README claims; those are shown without speculative internal links.

Main entry points: [`mods/diff/hooks/git/probes/repository-of/repository-of.ts`](https://github.com/anthropics/claude-code/blob/main/mods/diff/hooks/git/probes/repository-of/repository-of.ts) (Repository probe), [`mods/sec-default/hooks/register.ts`](https://github.com/anthropics/claude-code/blob/main/mods/sec-default/hooks/register.ts) (Security defaults), [`mods/diff/hooks/git/probes/tag-pre-session.ts`](https://github.com/anthropics/claude-code/blob/main/mods/diff/hooks/git/probes/tag-pre-session.ts) (Pre-session tagging), [`mods/privacy/hooks/register.ts`](https://github.com/anthropics/claude-code/blob/main/mods/privacy/hooks/register.ts) (Privacy hooks)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_git["Git and diff"]
  node_diff_register["Diff hooks<br/>[register.ts]"]
  node_repo_probe["Repository probe<br/>[repository-of.ts]"]
  node_git_types["Git data types"]
  node_path_check["Absolute-path check"]
  node_repo_lines["Repository line count"]
  node_presession["Pre-session tagging<br/>[tag-pre-session.ts]"]
  node_dating["File dating"]
  node_dirty_start["Start dirty state"]
end

subgraph group_agents["Agent instructions"]
  node_agents_register["Agents MD hooks<br/>[register.ts]"]
end

subgraph group_policy["Security and privacy"]
  node_sec_register["Security defaults<br/>[register.ts]"]
  node_admission["Admission checks"]
  node_identity_refusal["Identity refusal"]
  node_managed_mods["Managed-mod policy"]
  node_privacy_register["Privacy hooks<br/>[register.ts]"]
  node_outbound["Outbound inspection"]
end

subgraph group_telemetry["Telemetry and tools"]
  node_telemetry_register["Telemetry hooks<br/>[register.ts]"]
  node_ingest_url["Event ingest address<br/>[ingest-url.ts]"]
  node_easel_register["Easel hooks<br/>[register.ts]"]
  node_query["Tool query extraction<br/>[query-of.ts]"]
  node_json["JSON value lookup"]
end

node_developer(("Developer"))

node_developer -->|"uses coding tool"| node_agents_register
node_repo_probe -->|"uses types"| node_git_types
node_repo_probe -->|"validates paths"| node_path_check
node_repo_probe -->|"checks line count"| node_repo_lines
node_presession -->|"gets dates"| node_dating
node_presession -->|"checks prior dirt"| node_dirty_start
node_sec_register -->|"uses checks"| node_admission
node_sec_register -->|"refuses identity"| node_identity_refusal
node_sec_register -->|"enforces policy"| node_managed_mods
node_privacy_register -->|"inspects outgoing text"| node_outbound
node_query -->|"reads values"| node_json

click node_diff_register "https://github.com/anthropics/claude-code/blob/main/mods/diff/hooks/register.ts"
click node_repo_probe "https://github.com/anthropics/claude-code/blob/main/mods/diff/hooks/git/probes/repository-of/repository-of.ts"
click node_git_types "https://github.com/anthropics/claude-code/tree/main/mods/diff/hooks/git/types"
click node_path_check "https://github.com/anthropics/claude-code/tree/main/mods/diff/hooks/git/probes/is-absolute-path"
click node_repo_lines "https://github.com/anthropics/claude-code/tree/main/mods/diff/hooks/git/probes/repository-lines"
click node_presession "https://github.com/anthropics/claude-code/blob/main/mods/diff/hooks/git/probes/tag-pre-session.ts"
click node_dating "https://github.com/anthropics/claude-code/tree/main/mods/diff/hooks/git/probes/datings-of"
click node_dirty_start "https://github.com/anthropics/claude-code/tree/main/mods/diff/hooks/git/probes/was-dirty-at-start"
click node_agents_register "https://github.com/anthropics/claude-code/blob/main/mods/agents-md/hooks/register.ts"
click node_sec_register "https://github.com/anthropics/claude-code/blob/main/mods/sec-default/hooks/register.ts"
click node_admission "https://github.com/anthropics/claude-code/tree/main/mods/sec-default/hooks/admission-failure"
click node_identity_refusal "https://github.com/anthropics/claude-code/tree/main/mods/sec-default/hooks/identity-refusal"
click node_managed_mods "https://github.com/anthropics/claude-code/tree/main/mods/sec-default/hooks/managed-mods-only-refusal"
click node_privacy_register "https://github.com/anthropics/claude-code/blob/main/mods/privacy/hooks/register.ts"
click node_outbound "https://github.com/anthropics/claude-code/tree/main/mods/privacy/hooks/outbound"
click node_telemetry_register "https://github.com/anthropics/claude-code/blob/main/mods/telemetry/hooks/register.ts"
click node_ingest_url "https://github.com/anthropics/claude-code/blob/main/mods/telemetry/hooks/entries/ingest-url.ts"
click node_easel_register "https://github.com/anthropics/claude-code/blob/main/mods/easel/hooks/register.ts"
click node_query "https://github.com/anthropics/claude-code/blob/main/mods/easel/hooks/shell/query-of/query-of.ts"
click node_json "https://github.com/anthropics/claude-code/tree/main/mods/easel/hooks/core/json"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_diff_register,node_repo_probe,node_git_types,node_path_check,node_repo_lines,node_presession,node_dating,node_dirty_start toneBlue
class node_agents_register toneAmber
class node_sec_register,node_admission,node_identity_refusal,node_managed_mods,node_privacy_register,node_outbound toneMint
class node_telemetry_register,node_ingest_url,node_easel_register,node_query,node_json toneRose
class node_developer toneIndigo
```

## Components

### Git and diff

- [Diff hooks](https://github.com/anthropics/claude-code/blob/main/mods/diff/hooks/register.ts): `mods/diff/hooks/register.ts`
- [Repository probe](https://github.com/anthropics/claude-code/blob/main/mods/diff/hooks/git/probes/repository-of/repository-of.ts): `mods/diff/hooks/git/probes/repository-of/repository-of.ts`
- [Git data types](https://github.com/anthropics/claude-code/tree/main/mods/diff/hooks/git/types): `mods/diff/hooks/git/types`
- [Absolute-path check](https://github.com/anthropics/claude-code/tree/main/mods/diff/hooks/git/probes/is-absolute-path): `mods/diff/hooks/git/probes/is-absolute-path`
- [Repository line count](https://github.com/anthropics/claude-code/tree/main/mods/diff/hooks/git/probes/repository-lines): `mods/diff/hooks/git/probes/repository-lines`
- [Pre-session tagging](https://github.com/anthropics/claude-code/blob/main/mods/diff/hooks/git/probes/tag-pre-session.ts): `mods/diff/hooks/git/probes/tag-pre-session.ts`
- [File dating](https://github.com/anthropics/claude-code/tree/main/mods/diff/hooks/git/probes/datings-of): `mods/diff/hooks/git/probes/datings-of`
- [Start dirty state](https://github.com/anthropics/claude-code/tree/main/mods/diff/hooks/git/probes/was-dirty-at-start): `mods/diff/hooks/git/probes/was-dirty-at-start`

### Agent instructions

- [Agents MD hooks](https://github.com/anthropics/claude-code/blob/main/mods/agents-md/hooks/register.ts): `mods/agents-md/hooks/register.ts`

### Security and privacy

- [Security defaults](https://github.com/anthropics/claude-code/blob/main/mods/sec-default/hooks/register.ts): `mods/sec-default/hooks/register.ts`
- [Admission checks](https://github.com/anthropics/claude-code/tree/main/mods/sec-default/hooks/admission-failure): `mods/sec-default/hooks/admission-failure`
- [Identity refusal](https://github.com/anthropics/claude-code/tree/main/mods/sec-default/hooks/identity-refusal): `mods/sec-default/hooks/identity-refusal`
- [Managed-mod policy](https://github.com/anthropics/claude-code/tree/main/mods/sec-default/hooks/managed-mods-only-refusal): `mods/sec-default/hooks/managed-mods-only-refusal`
- [Privacy hooks](https://github.com/anthropics/claude-code/blob/main/mods/privacy/hooks/register.ts): `mods/privacy/hooks/register.ts`
- [Outbound inspection](https://github.com/anthropics/claude-code/tree/main/mods/privacy/hooks/outbound): `mods/privacy/hooks/outbound`

### Telemetry and tools

- [Telemetry hooks](https://github.com/anthropics/claude-code/blob/main/mods/telemetry/hooks/register.ts): `mods/telemetry/hooks/register.ts`
- [Event ingest address](https://github.com/anthropics/claude-code/blob/main/mods/telemetry/hooks/entries/ingest-url.ts): `mods/telemetry/hooks/entries/ingest-url.ts`
- [Easel hooks](https://github.com/anthropics/claude-code/blob/main/mods/easel/hooks/register.ts): `mods/easel/hooks/register.ts`
- [Tool query extraction](https://github.com/anthropics/claude-code/blob/main/mods/easel/hooks/shell/query-of/query-of.ts): `mods/easel/hooks/shell/query-of/query-of.ts`
- [JSON value lookup](https://github.com/anthropics/claude-code/tree/main/mods/easel/hooks/core/json): `mods/easel/hooks/core/json`

### Other components

- **Developer**

## Connections

- Developer → Agents MD hooks: uses coding tool (evidence: `README.md`)
- Repository probe → Git data types: uses types (evidence: `mods/diff/hooks/git/probes/repository-of/repository-of.ts`)
- Repository probe → Absolute-path check: validates paths (evidence: `mods/diff/hooks/git/probes/repository-of/repository-of.ts`)
- Repository probe → Repository line count: checks line count (evidence: `mods/diff/hooks/git/probes/repository-of/repository-of.ts`)
- Pre-session tagging → File dating: gets dates (evidence: `mods/diff/hooks/git/probes/tag-pre-session.ts`)
- Pre-session tagging → Start dirty state: checks prior dirt (evidence: `mods/diff/hooks/git/probes/tag-pre-session.ts`)
- Security defaults → Admission checks: uses checks (evidence: `mods/sec-default/hooks/register.ts`)
- Security defaults → Identity refusal: refuses identity (evidence: `mods/sec-default/hooks/register.ts`)
- Security defaults → Managed-mod policy: enforces policy (evidence: `mods/sec-default/hooks/register.ts`)
- Privacy hooks → Outbound inspection: inspects outgoing text (evidence: `mods/privacy/hooks/register.ts`)
- Tool query extraction → JSON value lookup: reads values (evidence: `mods/easel/hooks/shell/query-of/query-of.ts`)
