Files
claude-code-source-code/docs/zh/03-卧底模式分析.md
sanbuphy de14c0ace8 Add source code analysis docs: telemetry, codenames, undercover mode, remote control, roadmap
5 bilingual (EN/ZH) analysis documents covering:
- Telemetry & privacy (opt-out-free data collection)
- Hidden features & model codenames (Tengu, Capybara, Fennec, Numbat)
- Undercover mode (AI attribution stripping in open-source)
- Remote control & killswitches (managed settings, feature flags)
- Future roadmap (Numbat model, KAIROS autonomous mode, voice input)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-31 19:41:11 +08:00

3.1 KiB
Raw Permalink Blame History

卧底模式分析

基于 Claude Code v2.1.88 反编译源码分析

什么是卧底模式?

卧底模式是 Anthropic 员工在公开/开源仓库贡献时的安全系统。激活后,它会剥离所有 AI 归属,指示模型将其贡献伪装为人类开发者编写。

来源: src/utils/undercover.ts

激活逻辑

// src/utils/undercover.ts:28-37
export function isUndercover(): boolean {
  if (process.env.USER_TYPE === 'ant') {
    if (isEnvTruthy(process.env.CLAUDE_CODE_UNDERCOVER)) return true
    // 自动模式:除非确认在白名单内部仓库,否则默认激活
    return getRepoClassCached() !== 'internal'
  }
  return false
}

关键特性:

  • 仅限内部: 只对 Anthropic 员工 (USER_TYPE === 'ant') 生效
  • 默认开启: 在所有仓库中激活,除非在内部白名单上
  • 无法强制关闭: "There is NO force-OFF. This guards against model codename leaks"
  • 外部构建: 被 bundler 死代码消除,永远不会执行

给模型的指令

## UNDERCOVER MODE — CRITICAL

You are operating UNDERCOVER in a PUBLIC/OPEN-SOURCE repository.
Do not blow your cover.

NEVER include in commit messages or PR descriptions:
- 内部模型代号(如 Capybara, Tengu 等动物名称)
- 未发布的模型版本号(如 opus-4-7, sonnet-4-8
- 内部仓库或项目名(如 claude-cli-internal
- 内部工具、Slack 频道或短链接
- "Claude Code" 这个词或任何你是 AI 的暗示
- 任何关于你是什么模型或版本的提示
- Co-Authored-By 行或任何其他归属

像人类开发者一样写 commit message。

好:
- "Fix race condition in file watcher initialization"

坏:
- "Fix bug found while testing with Claude Capybara"
- "Generated with Claude Code"
- "Co-Authored-By: Claude Opus 4.6 <…>"

关键词:"Do not blow your cover"(不要暴露你的掩护身份)。

归属系统

归属系统补充了卧底模式:

// src/utils/model/model.ts:386-392
function maskModelCodename(baseName: string): string {
  // capybara-v2-fast → cap*****-v2-fast
  const [codename = '', ...rest] = baseName.split('-')
  const masked = codename.slice(0, 3) + '*'.repeat(Math.max(0, codename.length - 3))
  return [masked, ...rest].join('-')
}

影响

对开源社区

当 Anthropic 员工用 Claude Code 参与开源项目时:

  1. 代码由 AI 编写,但 commit 看起来像是人类提交的
  2. 没有 "Co-Authored-By: Claude" 署名
  3. 没有 "Generated with Claude Code" 标记
  4. 项目维护者和社区无法识别 AI 生成的贡献
  5. 这可能违反开源社区关于 AI 贡献的透明度规范

对 Anthropic 的保护

主要声明的目的是防止意外泄露:

  • 内部模型代号(竞争情报)
  • 未发布的版本号(市场时机)
  • 内部基础设施细节(安全)

伦理考量

"不要暴露掩护" 的措辞将 AI 定位为卧底特工。在公开代码贡献中故意隐瞒 AI 作者身份引发了关于以下方面的质疑:

  • 开源社区的透明度
  • 是否符合项目贡献指南
  • 商业秘密保护与欺骗之间的界限