{"versions":{"0.1.0":{"name":"claude-cn-flag-check","version":"0.1.0","description":"Check whether Claude Code would covertly flag your environment as a China user (timezone + relay-hostname region marking). Reproduces the client's bundled detection logic for self-audit.","keywords":["claude","claude-code","anthropic","privacy","steganography","region-detection","self-check","cli"],"homepage":"https://github.com/shellus/claude-cn-flag-check#readme","bugs":{"url":"https://github.com/shellus/claude-cn-flag-check/issues"},"repository":{"type":"git","url":"git+https://github.com/shellus/claude-cn-flag-check.git"},"license":"MIT","author":{"name":"shellus","email":"353358601@qq.com"},"type":"commonjs","main":"src/index.js","bin":{"claude-cn-flag-check":"bin/cli.js"},"scripts":{"test":"node --test","start":"node bin/cli.js"},"engines":{"node":">=18"},"gitHead":"926df6b4252f4d16adf882bf68502556c1761152","_id":"claude-cn-flag-check@0.1.0","_nodeVersion":"24.15.0","_npmVersion":"11.12.1","dist":{"integrity":"sha512-P+I0+ENROJ7e1fHLlBW2i8JtraO60f/ZhspTbeF4KGd0oWeGoq65zxc2YdvM68FH6sdL0RyW6fZGhN5NFhJeLA==","shasum":"c69dfa5d3a09767ae146274eec537f1dc4894a67","tarball":"http://123.232.10.234:8212/nexus/content/groups/npm-public/claude-cn-flag-check/-/claude-cn-flag-check-0.1.0.tgz","fileCount":11,"unpackedSize":66735,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCICgvCH6c+jEquq08VyNTk/qRN2gyikltqC+EH9muzrZ/AiBwP0On+vq4xByoiXdWhUqOIg10bwLtsm2DClZzc3A1Vw=="}],"size":25127},"_npmUser":{"name":"anonymous","email":"353358601@qq.com"},"directories":{},"maintainers":[{"name":"anonymous","email":"353358601@qq.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/claude-cn-flag-check_0.1.0_1783074491159_0.47889618512540744"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2026-07-03T10:28:11.315Z","publish_time":1783074491315,"_source_registry_name":"default","contributors":[]}},"dist-tags":{"latest":"0.1.0"},"name":"claude-cn-flag-check","time":{"created":"2026-07-03T10:28:21.597Z","modified":"2026-07-03T10:28:22.188Z","0.1.0":"2026-07-03T10:28:11.315Z"},"readme":"# claude-cn-flag-check\n\n> Would Claude Code covertly flag **your** environment as a \"China user\"? Run one command and find out.\n\n[中文说明 →](./README.zh-CN.md)\n\nIn mid-2026 a [reverse-engineering report](https://www.reddit.com/r/) revealed that Claude Code (the `@anthropic-ai/claude-code` CLI, from **v2.1.91**) silently detects whether a request likely comes from mainland China and encodes the verdict into the system prompt using **Unicode steganography** — with no telemetry field and no mention in the release notes. Anthropic [confirmed it](https://www.ithome.com/0/971/118.htm) as an \"experimental\" anti-resale / anti-distillation measure and said it would be removed.\n\nThis tool does **real detection by default**: it runs Claude Code once against a\nlocal endpoint and reads the marker it *actually* emits — not a prediction. It\ncan also fall back to reproducing the logic locally (`--no-capture`) for a\ncomputed estimate. It reads nothing but your own environment; nothing is uploaded.\n\nIt is **verified against `@anthropic-ai/claude-code@2.1.170`**: the domain / keyword lists are de-obfuscated straight from the installed binary at runtime, so the answer matches the version you actually run.\n\n## How the detection actually works\n\nThe check only runs when you point Claude Code at a **third-party endpoint** via `ANTHROPIC_BASE_URL` (a relay/proxy). On the official `api.anthropic.com`, or with no base URL set, it is skipped entirely — *your timezone is irrelevant there*. When it does run, three orthogonal signals are computed:\n\n| Signal | Source | How it is encoded in `Today's date is …` |\n|---|---|---|\n| `cnTZ` | System timezone is `Asia/Shanghai` or `Asia/Urumqi` | Date separator `-` → `/` (e.g. `2026-07-03` → `2026/07/03`) |\n| `known` | Relay hostname matches a built-in **147-entry domain list** (exact or subdomain; the list includes a bare `cn`, so **any `*.cn` host matches**) | Apostrophe → `U+2019` |\n| `labKw` | Relay hostname contains a Chinese **AI-lab keyword** (`deepseek`, `moonshot`, `dashscope`, …) | Apostrophe → `U+02BC` |\n| both `known` + `labKw` | — | Apostrophe → `U+02B9` |\n\nThe apostrophe in `Today's` and the date separator together form a 2–3 bit marker that the server reads back — visually identical to the normal line in any editor.\n\n## Install\n\n```bash\nnpm install -g claude-cn-flag-check\n# or run once without installing:\nnpx claude-cn-flag-check\n```\n\nRequires Node.js ≥ 18. (Node is already present if you have Claude Code installed.)\n\n## Usage\n\nCheck your current environment:\n\n```bash\nclaude-cn-flag-check\n```\n\nThe CLI lists every detection item, reveals each result with a short scan\nanimation (like a web scanner), then prints a **0-100 risk score** and a verdict.\nOutput is in Chinese (the primary user base); `--json` keeps English keys.\nExample (a China timezone behind a listed relay - the worst case, abridged):\n\n```\n检测项(4 项区域信号)\n  ⚑ 端点类型  第三方中转 · 触发地区检测\n  ✗ 系统时区 (权重 40)  命中 · 中国时区,把日期分隔符 - 改成 /\n  ✗ 中转域名清单 (权重 35)  命中 · 撇号被改成 U+2019\n  ✓ AI 实验室关键词 (权重 25)  未命中\n\n  风险分  75/100  [高]\n\n✗ 会被识别为中国大陆请求。进入封号风控队列的可能性:高\n```\n\n### Risk score\n\nOnly the three real CLI signals count toward the score (browser signals like\nfonts or `navigator.language` are irrelevant to the CLI and are excluded).\n`marked` stays a deterministic yes/no; the score grades severity:\n\n| Signal | Weight |\n|---|---|\n| `cnTZ` - China timezone (leaks even through a proxy) | 40 |\n| `known` - relay host on the domain list | 35 |\n| `labKw` - relay host contains an AI-lab keyword | 25 |\n\nLevels: `safe` (0) · `low` (1-30) · `medium` (31-60) · `high` (61-100). A\nfirst-party endpoint always scores 0.\n\nThe process **exits `1` when you would be flagged**, `0` when you are clean — so you can gate a startup script:\n\n```bash\nclaude-cn-flag-check >/dev/null || echo \"⚠️  this shell would be marked by Claude Code\"\n```\n\n### What-if checks\n\nTest a hypothetical relay or timezone without changing your environment:\n\n```bash\nclaude-cn-flag-check --base-url https://my-relay.example.com --tz Asia/Tokyo\n```\n\n### Options\n\n| Flag | Meaning |\n|---|---|\n| `--base-url <url>` | Check a hypothetical `ANTHROPIC_BASE_URL` |\n| `--tz <zone>` | Check a hypothetical IANA timezone |\n| `--assume-first-party` | Simulate `_CLAUDE_CODE_ASSUME_FIRST_PARTY_BASE_URL=1` |\n| `--snapshot` | Use the bundled list snapshot, skip live extraction |\n| `--binary <path>` | Path to the `claude` binary to extract lists from |\n| `--show-list` | Print the decoded domain / lab-keyword lists |\n| `--json` | Machine-readable output |\n| `-h`, `--help` / `-v`, `--version` | — |\n\n## Reducing your risk\n\n- **Timezone (`cnTZ`)** — launch Claude Code with a non-China zone: `TZ=Asia/Tokyo claude`. This is the single most effective fix, because your OS timezone leaks even through a proxy.\n- **Relay hostname (`known` / `labKw`)** — use a relay whose hostname is not on the list and does not contain an AI-lab keyword or a `.cn` suffix. Self-hosting on a neutral domain avoids both.\n- **Disable entirely** — `_CLAUDE_CODE_ASSUME_FIRST_PARTY_BASE_URL=1` turns the whole mechanism off (it tells the client to treat your base URL as first-party). Understand the implication before relying on it.\n\n## Use as a library\n\n```js\nconst { check, isClaudeChinaUser } = require('claude-cn-flag-check');\n\nisClaudeChinaUser();                                  // boolean, current env\ncheck({ baseUrl: 'https://r.example.com', timezone: 'Asia/Shanghai' });\n// → { marked, signals: { cnTZ, known, labKw }, carrier: { dateLine, ... }, features: [...] }\n```\n\n## Real detection (default)\n\nBy default the tool performs a genuine capture rather than a prediction:\n\n1. It resolves your real relay host from config (see below).\n2. It writes a throwaway `CLAUDE_CONFIG_DIR` pointing `ANTHROPIC_BASE_URL` at a\n   local capture server, and temporarily maps the real relay host →\n   `127.0.0.1` in `/etc/hosts` (backed up and restored, with signal handlers)\n   so Claude Code still sees the **real hostname** while the request lands\n   locally.\n3. It runs `claude -p` once and reads the `Today's date is …` line from the\n   actual request body, extracting the observed apostrophe + date separator.\n\nThis needs **root** (to touch `/etc/hosts`) and a working `claude` binary. No\nreal credentials are used — the request is intercepted locally — and your real\n`~/.claude` is never modified. Reports show `真实捕获 ✓` (observed) vs\n`计算预测` (computed).\n\n- `--no-capture` — skip the run, use the computed reproduction instead.\n- What-if checks (`--base-url` / `--tz`) and first-party endpoints are always\n  computed / certain (nothing to observe).\n\n## Config resolution (evidence-based)\n\nThe tool does **not** trust the current process's environment variables alone —\nthose reflect whatever shell spawned it, so `claude` and `claude-cn-flag-check`\nrun from different shells can disagree. Instead it resolves what Claude Code\nwill *actually* use and prints every source it checked:\n\n- **`ANTHROPIC_BASE_URL`** — merged from `env` blocks across enterprise managed\n  settings, `~/.claude/settings.json`, project `.claude/settings.json`, and\n  `.claude/settings.local.json`, then the live process env (session-dependent,\n  flagged as such). This is why a relay configured only in `settings.json` is\n  correctly detected even when your interactive shell has nothing exported.\n- **Timezone** — a `TZ` override from those same `env` blocks, otherwise the\n  system zone from `/etc/localtime` (or `/etc/timezone`).\n\n`--base-url` / `--tz` still override everything for what-if checks. The\n`--json` output includes the full `resolution` evidence trail. (`ANTHROPIC_AUTH_TOKEN`\nand other secrets are never read or printed.)\n\n## How it stays accurate\n\nBy default the lists are extracted from your installed binary at runtime: the tool scans for the XOR-encoded base64 blobs, brute-forces the single-byte key, and validates the decode against known sentinel domains — so it keeps working across minified releases. If extraction fails it falls back to a version-stamped snapshot (currently `2.1.170`: 147 domains, 11 keywords).\n\n## Disclaimer\n\nFor transparency and self-audit only. Based on public reverse-engineering; not an official Anthropic statement, and behavior may change between Claude Code versions (Anthropic announced removal of this mechanism). Verify against your own installed version with `--show-list`.\n\n## License\n\nMIT © shellus","users":{}}