Files
claude-code-source-code/docs/ja/03-アンダーカバーモード.md
2026-04-01 18:55:02 +08:00

111 lines
4.8 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# アンダーカバーモード分析
> インターネット上で公開されている資料やコミュニティの議論をもとに整理した Claude Code v2.1.88 分析レポート。
## アンダーカバーモードとは
アンダーカバーモードは、公式社員が外部/オープンソースリポジトリで作業する際に使用する安全保護メカニズムです。有効化すると、内部固有の AI モデル情報や帰属表示が隠され、コミットされたコードが人間の開発者の貢献と同じように見えるようになります。これは主に、内部の機密情報や未公開モデルの名称がオープンソースコミュニティに漏洩するのを防ぐためのものです。
出典: `src/utils/undercover.ts`
## 有効化条件
```typescript
// 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
// Auto: 内部リポジトリと確認されない限り自動有効化
return getRepoClassCached() !== 'internal'
}
return false
}
```
主な特性:
- **内部専用**: 公式社員(`USER_TYPE === 'ant'`)のみ対象
- **デフォルト有効**: 内部許可リストにないすべてのリポジトリで自動有効化
- **強制無効化不可**: "There is NO force-OFF. This guards against model codename leaks"
- **外部ビルド**: バンドラーによりデッドコード除去され、実行されない
## モデルに渡されるプロンプト
```typescript
// src/utils/undercover.ts:39-69
export function getUndercoverInstructions(): string {
return `## UNDERCOVER MODE — CRITICAL
You are operating UNDERCOVER in a PUBLIC/OPEN-SOURCE repository. Your commit
messages, PR titles, and PR bodies MUST NOT contain ANY Anthropic-internal
information. Do not blow your cover.
NEVER include in commit messages or PR descriptions:
- Internal model codenames (animal names like Capybara, Tengu, etc.)
- Unreleased model version numbers (e.g., opus-4-7, sonnet-4-8)
- Internal repo or project names (e.g., claude-cli-internal, anthropics/…)
- Internal tooling, Slack channels, or short links (e.g., go/cc, #claude-code-…)
- The phrase "Claude Code" or any mention that you are an AI
- Any hint of what model or version you are
- Co-Authored-By lines or any other attribution
Write commit messages as a human developer would — describe only what the code
change does.
GOOD:
- "Fix race condition in file watcher initialization"
- "Add support for custom key bindings"
BAD (never write these):
- "Fix bug found while testing with Claude Capybara"
- "1-shotted by claude-opus-4-6"
- "Generated with Claude Code"
- "Co-Authored-By: Claude Opus 4.6 <…>"`
}
```
## 帰属表示システム
帰属表示システム(`src/utils/attribution.ts``src/utils/commitAttribution.ts`)はアンダーカバーモードを補完する:
```typescript
// src/utils/attribution.ts:70-72
// @[MODEL LAUNCH]: 以下のハードコードされたフォールバックモデル名を更新
// (コードネーム漏洩防止用)。
// 外部リポジトリでは、認識されないモデルは "Claude Opus 4.6" にフォールバック。
```
```typescript
// src/utils/model/model.ts:386-392
function maskModelCodename(baseName: string): string {
// e.g. 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('-')
}
```
## 示唆
### オープンソースへの影響
公式社員がClaude Codeでオープンソースプロジェクトにコントリビュートする場合:
1. AIがコードを書くが、コミットは人間が書いたものとして表示される
2. "Co-Authored-By: Claude"の帰属表示がない
3. "Generated with Claude Code"のマーカーがない
4. プロジェクトメンテナーやコミュニティはAI生成のコントリビュートを識別できない
5. AIコントリビュートに関するオープンソースの透明性規範に抵触する可能性がある
### 公式保護目的
主な目的は以下の偶発的漏洩の防止:
- 内部モデルコードネーム(競争情報)
- 未公開バージョン番号(市場タイミング)
- 内部インフラの詳細(セキュリティ)
### 倫理的考察
"Do not blow your cover正体を明かすな"という表現はAIを潜入工作員として位置づけている。公開コードコントリビュートにおけるAI著作の意図的な隠匿は以下の問題を提起する:
- オープンソースコミュニティにおける透明性
- プロジェクトコントリビュートガイドラインの遵守
- 営業秘密保護と欺瞞の境界線