百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
C

claude_code_annotated

> 编程语言
开源

claudecode 曝光了部分代码解析

195 stars0 点赞1 次浏览
访问官网GitHub

工具介绍

claudecode 曝光了部分代码解析

cc的代码分析.

scripts: scripts\build.mjs 用于构建最后的cc程序

vendor: 第三方依赖. vendor\audio-capture-src\index.ts 音频模块. vendor\url-handler-src\index.ts url处理模块.只有苹果有用.别人点击了url就返回url地址字符串. src\assistant\sessionHistory.ts 会话话历史模块.

Claude Code v2.1.88 — Source Code Analysis

Disclaimer: All source code in this repository is the intellectual property of Anthropic and Claude. This repository is provided strictly for technical research, study, and educational exchange among enthusiasts. Commercial use is strictly prohibited. No individual, organization, or entity may use this content for commercial purposes, profit-making activities, illegal activities, or any other unauthorized scenarios. If any content infringes upon your legal rights, intellectual property, or other interests, please contact us and we will verify and remove it immediately.

Extracted from npm package @anthropic-ai/claude-code version 2.1.88. The published package ships a single bundled cli.js (~12MB). The src/ directory in this repo contains the unbundled TypeScript source extracted from the npm tarball.

Language: English | 中文


Table of Contents

  • Deep Analysis Reports (docs/) — Telemetry, codenames, undercover mode, remote control, future roadmap
  • Missing Modules Notice — 108 feature-gated modules not in the npm package
  • Architecture Overview — Entry → Query Engine → Tools/Services/State
  • Tool System & Permissions — 40+ tools, permission flow, sub-agents
  • The 12 Progressive Harness Mechanisms — How Claude Code layers production features on the agent loop
  • Build Notes — Why this source isn't directly compilable

Deep Analysis Reports (docs/)

Source code analysis reports derived from decompiled v2.1.88. Bilingual (EN/ZH).

…

Click any filename above to jump to the full report.

# Topic Key Findings
01 Telemetry & Privacy Two analytics sinks (1P → Anthropic, Datadog). Environment fingerprint, process metrics, repo hash on every event. No UI-exposed opt-out for 1st-party logging. OTEL_LOG_TOOL_DETAILS=1 enables full tool input capture.
02 Hidden Features & Codenames Animal codenames (Capybara v8, Tengu, Fennec→Opus 4.6, Numbat next). Feature flags use random word pairs (tengu_frond_boric) to obscure purpose. Internal users get better prompts, verification agents, and effort anchors. Hidden commands: /btw, /stickers.
03 Undercover Mode Anthropic employees auto-enter undercover mode in public repos. Model instructed: "Do not blow your cover" — strip all AI attribution, write commits "as a human developer would." No force-OFF exists. Raises transparency questions for open-source communities.
04 Remote Control Hourly polling of /api/claude_code/settings. Dangerous changes show blocking dialog — reject = app exits. 6+ killswitches (bypass permissions, fast mode, voice mode, analytics sink). GrowthBook flags can change any user's behavior without consent.
05 Future Roadmap Numbat codename confirmed. Opus 4.7 / Sonnet 4.8 in development. KAIROS = fully autonomous agent mode with `` heartbeats, push notifications, PR subscriptions. Voice mode (push-to-talk) ready but gated. 17 unreleased tools found.

Missing Modules Notice (108 modules)

This source is incomplete. 108 modules referenced by feature()-gated branches are not included in the npm package. They exist only in Anthropic's internal monorepo and were dead-code-eliminated at compile time. They cannot be recovered from cli.js, sdk-tools.d.ts, or any published artifact.

Anthropic Internal Code (~70 modules, never published)

These modules have no source files anywhere in the npm package. They are internal Anthropic infrastructure.

Click to expand full list

Module Purpose Feature Gate
daemon/main.js Background daemon supervisor DAEMON
daemon/workerRegistry.js Daemon worker registry DAEMON
proactive/index.js Proactive notification system PROACTIVE
contextCollapse/index.js Context collapse service (experimental) CONTEXT_COLLAPSE
contextCollapse/operations.js Collapse operations CONTEXT_COLLAPSE
contextCollapse/persist.js Collapse persistence CONTEXT_COLLAPSE
skillSearch/featureCheck.js Remote skill feature check EXPERIMENTAL_SKILL_SEARCH
skillSearch/remoteSkillLoader.js Remote skill loader EXPERIMENTAL_SKILL_SEARCH
skillSearch/remoteSkillState.js Remote skill state EXPERIMENTAL_SKILL_SEARCH
skillSearch/telemetry.js Skill search telemetry EXPERIMENTAL_SKILL_SEARCH
skillSearch/localSearch.js Local skill search EXPERIMENTAL_SKILL_SEARCH
skillSearch/prefetch.js Skill prefetch EXPERIMENTAL_SKILL_SEARCH
coordinator/workerAgent.js Multi-agent coordinator worker COORDINATOR_MODE
bridge/peerSessions.js Bridge peer session management BRIDGE_MODE
assistant/index.js Kairos assistant mode KAIROS
assistant/AssistantSessionChooser.js Assistant session picker KAIROS
compact/reactiveCompact.js Reactive context compaction CACHED_MICROCOMPACT
compact/snipCompact.js Snip-based compaction HISTORY_SNIP
compact/snipProjection.js Snip projection HISTORY_SNIP
compact/cachedMCConfig.js Cached micro-compact config CACHED_MICROCOMPACT
sessionTranscript/sessionTranscript.js Session transcript service TRANSCRIPT_CLASSIFIER
commands/agents-platform/index.js Internal agents platform ant (internal)
commands/assistant/index.js Assistant command KAIROS
commands/buddy/index.js Buddy system notifications BUDDY
commands/fork/index.js Fork subagent command FORK_SUBAGENT
commands/peers/index.js Multi-peer commands BRIDGE_MODE
commands/proactive.js Proactive command PROACTIVE
commands/remoteControlServer/index.js Remote control server DAEMON + BRIDGE_MODE
commands/subscribe-pr.js GitHub PR subscription KAIROS_GITHUB_WEBHOOKS
commands/torch.js Internal debug tool TORCH
commands/workflows/index.js Workflow commands WORKFLOW_SCRIPTS
jobs/classifier.js Internal job classifier TEMPLATES
memdir/memoryShapeTelemetry.js Memory shape telemetry MEMORY_SHAPE_TELEMETRY
services/sessionTranscript/sessionTranscript.js Session transcript TRANSCRIPT_CLASSIFIER
tasks/LocalWorkflowTask/LocalWorkflowTask.js Local workflow task WORKFLOW_SCRIPTS
protectedNamespace.js Internal namespace guard ant (internal)
protectedNamespace.js (envUtils) Protected namespace runtime ant (internal)
coreTypes.generated.js Generated core types ant (internal)
devtools.js Internal dev tools ant (internal)
attributionHooks.js Internal attribution hooks COMMIT_ATTRIBUTION
systemThemeWatcher.js System theme watcher AUTO_THEME
udsClient.js / udsMessaging.js UDS messaging client UDS_INBOX
systemThemeWatcher.js Theme watcher AUTO_THEME

Feature-Gated Tools (~20 modules, DCE'd from bundle)

These tools have type signatures in sdk-tools.d.ts but their implementations were stripped at compile time.

Click to expand full list

Tool Purpose Feature Gate
REPLTool Interactive REPL (VM sandbox) ant (internal)
SnipTool Context snipping HISTORY_SNIP
SleepTool Sleep/delay in agent loop PROACTIVE / KAIROS
MonitorTool MCP monitoring MONITOR_TOOL
OverflowTestTool Overflow testing OVERFLOW_TEST_TOOL
WorkflowTool Workflow execution WORKFLOW_SCRIPTS
WebBrowserTool Browser automation WEB_BROWSER_TOOL
TerminalCaptureTool Terminal capture TERMINAL_PANEL
TungstenTool Internal perf monitoring ant (internal)
VerifyPlanExecutionTool Plan verification CLAUDE_CODE_VERIFY_PLAN
SendUserFileTool Send files to users KAIROS
SubscribePRTool GitHub PR subscription KAIROS_GITHUB_WEBHOOKS
SuggestBackgroundPRTool Suggest background PRs KAIROS
PushNotificationTool Push notifications KAIROS
CtxInspectTool Context inspection CONTEXT_COLLAPSE
ListPeersTool List active peers UDS_INBOX
DiscoverSkillsTool Skill discovery EXPERIMENTAL_SKILL_SEARCH

Text/Prompt Assets (~6 files)

These are internal prompt templates and documentation, never published.

Click to expand

File Purpose
yolo-classifier-prompts/auto_mode_system_prompt.txt Auto-mode system prompt for classifier
yolo-classifier-prompts/permissions_anthropic.txt Anthropic-internal permission prompt
yolo-classifier-prompts/permissions_external.txt External user permission prompt
verify/SKILL.md Verification skill documentation
verify/examples/cli.md CLI verification examples
verify/examples/server.md Server verification examples

Why They're Missing

  Anthropic Internal Monorepo              Published npm Package
  ──────────────────────────               ─────────────────────
  feature('DAEMON') → true    ──build──→   feature('DAEMON') → false
  ↓                                         ↓
  daemon/main.js  ← INCLUDED    ──bundle─→  daemon/main.js  ← DELETED (DCE)
  tools/REPLTool  ← INCLUDED    ──bundle─→  tools/REPLTool  ← DELETED (DCE)
  proactive/      ← INCLUDED    ──bundle─→  (referenced but absent from src/)

Bun's feature() is a compile-time intrinsic:

  • Returns true in Anthropic's internal build → code is kept in the bundle
  • Returns false in the published build → code is dead-code-eliminated
  • The 108 modules simply do not exist anywhere in the published artifact

Copyright & Disclaimer

Copyright (c) Anthropic. All rights reserved.

All source code in this repository is the intellectual property of Anthropic and Claude.
This repository is provided strictly for technical research and educational purposes.
Commercial use is strictly prohibited.

If you are the copyright owner and believe this repository infringes your rights,
please contact the repository owner for immediate removal.

Stats

Item Count
Source files (.ts/.tsx) ~1,884
Lines of code ~512,664
Largest single file query.ts (~785KB)
Built-in tools ~40+
Slash commands ~80+
Dependencies (node_modules) ~192 packages
Runtime Bun (compiled to Node.js >= 18 bundle)

The Agent Pattern

…

Directory Reference

…

Architecture Overview

…

Data Flow: A Single Query Lifecycle

…

Tool System Architecture

…

Complete Tool Inventory

…

Permission System

…

Sub-Agent & Multi-Agent Architecture

…

Context Management (Compact System)

…

MCP (Model Context Protocol) Integration

…

Bridge Layer (Claude Desktop / Remote)

…

Session Persistence

…

Feature Flag System

…

State Management

…

The 12 Progressive Harness Mechanisms

This source code demonstrates 12 layered mechanisms that a production AI agent harness needs beyond the basic loop. Each builds on the previous:

…

Key Design Patterns

Pattern Where Purpose
AsyncGenerator streaming `QueryEngin

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

TypeScript

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言