# Data flow — anthropics/claude-code

> Canonical page: https://codevetter.com/unpack/claude-code/data-flow

# Data flow — anthropics/claude-code

Scanned commit b486776a2eef0d3f39abaebaa3c03e378c7480b8 (2026-09-21). Generated by codevetter codevetter 1.12.0 on 2026-09-22.

Mod data never touches the network except telemetry's batch POST and security-guidance's model call. Instruction files, diffs, and settings move through the engine nouns $.fs, $.session, $.settings, $.process, $.store, and $.ui. Plugin hooks speak JSON on stdin/stdout. Issue bots speak the GitHub REST API with GITHUB_TOKEN and, separately, Statsig. Identity for analytics is read from ~/.claude.json (or CLAUDE_CONFIG_DIR) and account fields are only kept on an internal build.
- agents-md prompt.context input is e.instructionFiles (kinds managed, user, project, local, memory). It calls $.session.root and $.fs.ancestors, drops files already present by path or content, and returns next({...e, instructionFiles}). The engine, not the plugin, renders claudeMd. A hook above this mod has the last word because sec-default continues prompt.context to the append tier. — [mods/agents-md/README.md#L30-L41](https://github.com/anthropics/claude-code/blob/b486776a2eef0d3f39abaebaa3c03e378c7480b8/mods/agents-md/README.md#L30-L41) [mods/agents-md/hooks/register.ts#L99-L166](https://github.com/anthropics/claude-code/blob/b486776a2eef0d3f39abaebaa3c03e378c7480b8/mods/agents-md/hooks/register.ts#L99-L166) [mods/sec-default/hooks/register.ts#L22-L24](https://github.com/anthropics/claude-code/blob/b486776a2eef0d3f39abaebaa3c03e378c7480b8/mods/sec-default/hooks/register.ts#L22-L24)
- On Read, agents-md resolves ~ via HOME or USERPROFILE (profile first when cwd contains a backslash), walks ancestors below the live $.session.root, and appends Frames.nestedFrame entries onto result.context. Per-loop delivery is a Map from agent id to a Set of paths, copied on agent.spawn when fork is true. — [mods/agents-md/hooks/register.ts#L168-L304](https://github.com/anthropics/claude-code/blob/b486776a2eef0d3f39abaebaa3c03e378c7480b8/mods/agents-md/hooks/register.ts#L168-L304)
- telemetry register builds Sender in engine.create from the beneath engine: session.authorize/id/model/surfaces/cwd/repo, env.get of a large fixed name list, settings.read({source:'policy'}), fs.read/list/exists, process.run, clock.after/sleep, http.fetch, ui.log. log/mark call Entries.checkedFields/checkedMark then queue. flush runs on session.end, at BATCH_ROWS 100, or BATCH_WINDOW_MS 5000 after the first queued row. — [mods/telemetry/hooks/register.ts#L39-L351](https://github.com/anthropics/claude-code/blob/b486776a2eef0d3f39abaebaa3c03e378c7480b8/mods/telemetry/hooks/register.ts#L39-L351) [mods/telemetry/hooks/telemetry-of/telemetry-of.ts#L23-L190](https://github.com/anthropics/claude-code/blob/b486776a2eef0d3f39abaebaa3c03e378c7480b8/mods/telemetry/hooks/telemetry-of/telemetry-of.ts#L23-L190) [mods/telemetry/hooks/batching/batch-rows/batch-rows.ts](https://github.com/anthropics/claude-code/blob/b486776a2eef0d3f39abaebaa3c03e378c7480b8/mods/telemetry/hooks/batching/batch-rows/batch-rows.ts) [mods/telemetry/hooks/batching/batch-window-ms/batch-window-ms.ts](https://github.com/anthropics/claude-code/blob/b486776a2eef0d3f39abaebaa3c03e378c7480b8/mods/telemetry/hooks/batching/batch-window-ms/batch-window-ms.ts)
- Each telemetry batch re-reads switches. isAnalyticsOff returns true (send nothing) when NODE_ENV is test, DISABLE_TELEMETRY or CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC is set, DO_NOT_TRACK is truthy, an unmanaged third-party flag is on (CLAUDE_CODE_USE_BEDROCK, USE_VERTEX, USE_FOUNDRY, USE_ANTHROPIC_AWS, USE_ANTHROPIC_GOOGLE_CLOUD, USE_MANTLE) unless CLAUDE_CODE_PROVIDER_MANAGED_BY_HOST, a gateway is forced (CLAUDE_CODE_USE_GATEWAY or policy forceLoginMethod gateway / forceLoginGatewayUrl), or CLAUDE_CODE_CUSTOM_OAUTH_URL is set. Unreadable switches also send nothing. No authorization handle drops the batch. — [mods/telemetry/hooks/is-analytics-off/is-analytics-off.ts](https://github.com/anthropics/claude-code/blob/b486776a2eef0d3f39abaebaa3c03e378c7480b8/mods/telemetry/hooks/is-analytics-off/is-analytics-off.ts) [mods/telemetry/hooks/telemetry-of/telemetry-of.ts#L46-L140](https://github.com/anthropics/claude-code/blob/b486776a2eef0d3f39abaebaa3c03e378c7480b8/mods/telemetry/hooks/telemetry-of/telemetry-of.ts#L46-L140)
- The POST body is Entries.batchOf(rows) with session id, model, userType ant if USER_TYPE is ant else external, and a context gathered once. HTTP is method POST, Content-Type application/json, x-service-name claude-code, auth the authorize() handle, URL INGEST_URL. Retriable statuses (server error, 408, 429) sleep RETRY_DELAY_MS 500 and post once more. — [mods/telemetry/hooks/telemetry-of/telemetry-of.ts#L72-L140](https://github.com/anthropics/claude-code/blob/b486776a2eef0d3f39abaebaa3c03e378c7480b8/mods/telemetry/hooks/telemetry-of/telemetry-of.ts#L72-L140) [mods/telemetry/hooks/entries/ingest-url.ts](https://github.com/anthropics/claude-code/blob/b486776a2eef0d3f39abaebaa3c03e378c7480b8/mods/telemetry/hooks/entries/ingest-url.ts) [mods/telemetry/hooks/batching/retry-delay-ms/retry-delay-ms.ts](https://github.com/anthropics/claude-code/blob/b486776a2eef0d3f39abaebaa3c03e378c7480b8/mods/telemetry/hooks/batching/retry-delay-ms/retry-delay-ms.ts) [mods/telemetry/tests/register.test.ts#L32-L48](https://github.com/anthropics/claude-code/blob/b486776a2eef0d3f39abaebaa3c03e378c7480b8/mods/telemetry/tests/register.test.ts#L32-L48)
- Identity for a row is JSON.parse of globalConfigPath: CLAUDE_CONFIG_DIR or HOME or USERPROFILE plus .claude.json. identityOf reads record.userID and record.oauthAccount. A missing, unreadable, or non-JSON file yields an empty identity; the address is kept on an internal build alone. — [mods/telemetry/hooks/context/identity/global-config-path/global-config-path.ts](https://github.com/anthropics/claude-code/blob/b486776a2eef0d3f39abaebaa3c03e378c7480b8/mods/telemetry/hooks/context/identity/global-config-path/global-config-path.ts) [mods/telemetry/hooks/context/identity/identity-of.ts#L1-L40](https://github.com/anthropics/claude-code/blob/b486776a2eef0d3f39abaebaa3c03e378c7480b8/mods/telemetry/hooks/context/identity/identity-of.ts#L1-L40)
- Once per session, off Windows, telemetry runs one shell script via process.run: uname -s, uname -r, uname -m, then command -v for npm/yarn/pnpm and bun/deno/node. The register.ts call uses timeout Context.PROBE_TIMEOUT_MS. Env vars that name secrets, people, or hosts are recorded only as set-or-not (IsAnalyticsOff.isEnvSet). — [mods/telemetry/hooks/context/machine/probe-script/probe-script.ts](https://github.com/anthropics/claude-code/blob/b486776a2eef0d3f39abaebaa3c03e378c7480b8/mods/telemetry/hooks/context/machine/probe-script/probe-script.ts) [mods/telemetry/hooks/register.ts#L91-L100](https://github.com/anthropics/claude-code/blob/b486776a2eef0d3f39abaebaa3c03e378c7480b8/mods/telemetry/hooks/register.ts#L91-L100) [mods/telemetry/README.md#L45-L52](https://github.com/anthropics/claude-code/blob/b486776a2eef0d3f39abaebaa3c03e378c7480b8/mods/telemetry/README.md#L45-L52)
- Diff pins a git backend with one rev-parse in the session cwd, then every later git child is argv ['git', --git-dir=<gitDir>, --work-tree=<toplevel>, ...argv] with cwd toplevel, GIT_CHILD_ENV, and Limits.GIT_TIMEOUT_MS. backendOf asks INSTALLED_BACKEND_PROBES first (empty set as shipped) then Git.gitBackendOf. The chosen base mode is store.get/store.set keyed by repository toplevel. — [mods/diff/hooks/git/git-backend-of.ts#L13-L49](https://github.com/anthropics/claude-code/blob/b486776a2eef0d3f39abaebaa3c03e378c7480b8/mods/diff/hooks/git/git-backend-of.ts#L13-L49) [mods/diff/hooks/git/argv/pinned-lead-of/pinned-lead-of.ts](https://github.com/anthropics/claude-code/blob/b486776a2eef0d3f39abaebaa3c03e378c7480b8/mods/diff/hooks/git/argv/pinned-lead-of/pinned-lead-of.ts) [mods/diff/hooks/backend/backend-of.ts](https://github.com/anthropics/claude-code/blob/b486776a2eef0d3f39abaebaa3c03e378c7480b8/mods/diff/hooks/backend/backend-of.ts) [mods/diff/hooks/backend/installed-backend-probes.ts](https://github.com/anthropics/claude-code/blob/b486776a2eef0d3f39abaebaa3c03e378c7480b8/mods/diff/hooks/backend/installed-backend-probes.ts) [mods/diff/hooks/register.ts#L152-L168](https://github.com/anthropics/claude-code/blob/b486776a2eef0d3f39abaebaa3c03e378c7480b8/mods/diff/hooks/register.ts#L152-L168)
- Diff UI data flow: ui.render of Pane calls $.ui.resolve for Box, Text, Button, Select, Code and returns Views.paneView. ui.scroll on the docked pane updates model.place and returns {} so the engine window stays still. prompt.submit appends Ask.fittedAskTextOf to e.context when an ask is armed and the text fits under Limits.PROMPT_CONTEXT_MAX_CHARS; otherwise it disarms and sets a status line. — [mods/diff/hooks/register.ts#L710-L742](https://github.com/anthropics/claude-code/blob/b486776a2eef0d3f39abaebaa3c03e378c7480b8/mods/diff/hooks/register.ts#L710-L742) [mods/diff/hooks/register.ts#L857-L876](https://github.com/anthropics/claude-code/blob/b486776a2eef0d3f39abaebaa3c03e378c7480b8/mods/diff/hooks/register.ts#L857-L876) [mods/diff/hooks/register.ts#L967-L1012](https://github.com/anthropics/claude-code/blob/b486776a2eef0d3f39abaebaa3c03e378c7480b8/mods/diff/hooks/register.ts#L967-L1012)
- security-guidance main() reads one JSON object from stdin (session_id, tool_name, tool_input, hook_event_name, cwd). PostToolUse edits run check_patterns and may print hookSpecificOutput.additionalContext. Stop and git commit/push call the LLM path. llm.py posts to ANTHROPIC_BASE_URL (default https://api.anthropic.com) plus /v1/messages. Debug state goes to ~/.claude/security/log.txt (override SECURITY_GUIDANCE_DEBUG_LOG), rotating at 1 MB, and is not uploaded. — [plugins/security-guidance/hooks/security_reminder_hook.py#L2019-L2108](https://github.com/anthropics/claude-code/blob/b486776a2eef0d3f39abaebaa3c03e378c7480b8/plugins/security-guidance/hooks/security_reminder_hook.py#L2019-L2108) [plugins/security-guidance/hooks/llm.py#L93-L99](https://github.com/anthropics/claude-code/blob/b486776a2eef0d3f39abaebaa3c03e378c7480b8/plugins/security-guidance/hooks/llm.py#L93-L99) [plugins/security-guidance/hooks/llm.py#L420-L428](https://github.com/anthropics/claude-code/blob/b486776a2eef0d3f39abaebaa3c03e378c7480b8/plugins/security-guidance/hooks/llm.py#L420-L428) [plugins/security-guidance/README.md#L85-L94](https://github.com/anthropics/claude-code/blob/b486776a2eef0d3f39abaebaa3c03e378c7480b8/plugins/security-guidance/README.md#L85-L94)
- Org guidance for reviews is concatenated from ~/.claude/claude-security-guidance.md, <cwd>/.claude/claude-security-guidance.md, and the .local.md variant, capped so the tail drops first. Custom regex/substring rules load from security-patterns.yaml/json on the same three-level search. extensibility.load_for_session(cwd) runs once per hook invocation and failures are non-fatal. — [plugins/security-guidance/hooks/extensibility.py#L1-L33](https://github.com/anthropics/claude-code/blob/b486776a2eef0d3f39abaebaa3c03e378c7480b8/plugins/security-guidance/hooks/extensibility.py#L1-L33) [plugins/security-guidance/hooks/security_reminder_hook.py#L2050-L2053](https://github.com/anthropics/claude-code/blob/b486776a2eef0d3f39abaebaa3c03e378c7480b8/plugins/security-guidance/hooks/security_reminder_hook.py#L2050-L2053) [plugins/security-guidance/README.md#L62-L82](https://github.com/anthropics/claude-code/blob/b486776a2eef0d3f39abaebaa3c03e378c7480b8/plugins/security-guidance/README.md#L62-L82)
- hookify PreToolUse reads stdin JSON, maps tool_name Bash to event bash and Edit/Write/MultiEdit to event file, load_rules(event), and prints RuleEngine.evaluate_rules JSON. Import or runtime errors print a systemMessage and still sys.exit(0), so a broken hook does not deny the tool. — [plugins/hookify/hooks/pretooluse.py#L35-L70](https://github.com/anthropics/claude-code/blob/b486776a2eef0d3f39abaebaa3c03e378c7480b8/plugins/hookify/hooks/pretooluse.py#L35-L70) [plugins/hookify/core/rule_engine.py#L49-L94](https://github.com/anthropics/claude-code/blob/b486776a2eef0d3f39abaebaa3c03e378c7480b8/plugins/hookify/core/rule_engine.py#L49-L94)
- Issue label flow: a labeled event sets env LABEL and ISSUE_NUMBER; lifecycle-comment.ts looks up lifecycle and POSTs a comment to https://api.github.com/repos/${GITHUB_REPOSITORY}/issues/${n}/comments. sweep.ts pages /repos/{owner}/{repo}/issues, skips PRs, locked issues, assignees, and reactions +1 >= 10, then POSTs labels and later PATCH state closed. Triage is constrained to scripts/gh.sh, which forces GH_HOST=github.com and GH_REPO to a single owner/repo and rejects search qualifiers repo:, org:, and user:. — [scripts/lifecycle-comment.ts#L9-L40](https://github.com/anthropics/claude-code/blob/b486776a2eef0d3f39abaebaa3c03e378c7480b8/scripts/lifecycle-comment.ts#L9-L40) [scripts/sweep.ts#L15-L74](https://github.com/anthropics/claude-code/blob/b486776a2eef0d3f39abaebaa3c03e378c7480b8/scripts/sweep.ts#L15-L74) [scripts/gh.sh#L1-L80](https://github.com/anthropics/claude-code/blob/b486776a2eef0d3f39abaebaa3c03e378c7480b8/scripts/gh.sh#L1-L80) [.claude/commands/triage-issue.md#L14-L23](https://github.com/anthropics/claude-code/blob/b486776a2eef0d3f39abaebaa3c03e378c7480b8/.claude/commands/triage-issue.md#L14-L23)
- Statsig is a side channel, not the product telemetry mod. log-issue-events.yml curls https://events.statsigapi.net/v1/log_event on issue opened with statsig-api-key from STATSIG_API_KEY and metadata issue_number, repository, title, author, created_at. claude-dedupe-issues.yml logs github_duplicate_comment_added the same way and skips if the key is empty. auto-close-duplicates.yml passes STATSIG_API_KEY into the Bun script. — [.github/workflows/log-issue-events.yml#L1-L40](https://github.com/anthropics/claude-code/blob/b486776a2eef0d3f39abaebaa3c03e378c7480b8/.github/workflows/log-issue-events.yml#L1-L40) [.github/workflows/claude-dedupe-issues.yml#L46-L85](https://github.com/anthropics/claude-code/blob/b486776a2eef0d3f39abaebaa3c03e378c7480b8/.github/workflows/claude-dedupe-issues.yml#L46-L85) [.github/workflows/auto-close-duplicates.yml#L25-L31](https://github.com/anthropics/claude-code/blob/b486776a2eef0d3f39abaebaa3c03e378c7480b8/.github/workflows/auto-close-duplicates.yml#L25-L31)

Every claim links to its cited files at the pinned commit. Citations identify source evidence; they do not establish runtime correctness. Independent CodeVetter scan — not reviewed by upstream maintainers.

## Public product links

- [CodeVetter](https://codevetter.com/)
- [Download](https://codevetter.com/download)
- [Documentation](https://codevetter.com/docs/)
- [Source](https://github.com/Codevetter/codevetter)
