Claude Code Guard logo

Claude Code Guard

Community
xnydl
claude-code-guard

配置、维护或排查 Clash/Mihomo 下的 Claude Code 网络保护:Claude/Anthropic HTTP(S) 走专用入站与固定出口,默认单节点,可按明确授权启用固定主备;shell、脚本、远端数据库不拦。核对 wrapper、节点/链式代理、网络 Hook、macOS 沙箱,以及 Fingerprint Chromium Guarded 的 IP、时区、定位和代理 DNS。用户提到 Claude 防封、Seatbelt EPERM、节点漂移、DNS 泄漏或受保护指纹浏览器时使用;不保证不封号、绝对无泄漏或账号无法关联。

Overview

Publisherxnydl
Repositoryclaude-code-guard
Skill nameclaude-code-guard
Stars
31
Forks
1
Bundled files
37
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 37 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by xnydl on GitHub. Read the source before you install it.

Installation

Install the Claude Code Guard AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/xnydl/claude-code-guard/tree/main
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/xnydl/claude-code-guard.git \
  .claude/skills/claude-code-guard
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Claude Code Guard in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Claude Code Guard on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Claude Code Guard is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

Claude Code 网络保护 Skill

目标是可核验的路由约束,不是绕过服务条款或承诺账号安全。遵守服务适用地区与使用规则;不把节点名、住宅 IP 或第三方评分当作官方认可。复制步骤见 README.md。

流量分流(必须)

只保护 Claude Code / Claude CLI 发往 Claude、Anthropic 站点的 HTTP(S):HTTP_PROXY → 本地 gate → 专用入站 → 当前生效的 一个 最终叶子。默认固定单节点;只有用户明确指定主、备两个具体叶子和 Selector 路由根时,才启用受控主备切换。

不要拦截 shell、脚本、git、远端数据库客户端。它们通常不用 HTTP 代理,Seatbelt 应放行真实网络,由 Clash 规则模式把国内目标 DIRECT。只拒绝进程改 Mihomo 控制口。

HTTP CONNECT 默认真 Claude 走专用入站。用户当场授权的公司/国内域名后缀,才可以送到规则入站;不要复制另一台机器的域名列表,也不要为了数据库去放宽专用入站。改沙箱后必须重启 Claude,旧进程仍是旧规则。

先分清维护还是新装

  1. 维护已有环境优先:读 wrapper、Hook、沙箱、启动服务和浏览器入口。不能因为附带安装器就重新安装。

  2. 先读 维护与部署识别。目标机器可能使用 ~/.claude-guard/ 新布局或 ~/.local/claude-guard/ 旧布局;必须先审计并识别真实运行版本,不能互相覆盖。

  3. 用只读审计获取文件存在性、SHA-256 和有限设置:

    python3 "<SKILL>/scripts/ccg_audit.py"

    审计不调用网络、不读 Cookie/聊天/钥匙串、不证明流量安全。要记录浏览器启动器摘要时显式传 --browser-launcher "<已确认的脚本路径>"。

  4. 记录变更前摘要和用户已有选择,再做最小修改。仅更新 Skill 时,只改 Skill 源码/使用副本,不改运行中脚本、代理、账号资料或系统设置。

  5. 已有明确选择且与配置匹配时直接沿用。新出口未获选择、清理范围不清、需要停用保护或中断会话时才询问。

路由与节点规则

  • Clash 规则模式允许国内开发服务 DIRECT、Claude 走独立上游。TUN 开启不等于全部流量走代理;系统代理开关不能证明实际出口。Seatbelt 不拦 shell/脚本/远端库。
  • 任一时刻只能有一个生效的最终出口节点,按完整叶子名精确匹配。默认配置只保存单个 expected_node。主备是显式可选能力:只允许一个 primary_node 和一个 secondary_node,二者都必须是用户指定的具体、不同、非 DIRECT/REJECT/PASS 叶子,Selector 必须且只能直接包含这两个叶子;失败阈值限制为 2-5,严格探测间隔限制为 5-60 秒。不得扩展成节点白名单、负载均衡、随机选择或候选池轮换。支持单跳与链式代理;“单跳”不是 Clash DIRECT。
  • 从实际专用入站的 proxy 解析 Selector 的 now,再核对 dialer-proxy/入口依赖。允许 Selector 作为路由根,但最终出口必须等于当前唯一 expected_node。循环、缺失、DIRECT/REJECT/PASS 或无法确定的链路不能当作已验证。
  • 🤖 AI服务 可指向台湾 Selector,但不必是 CLI 专用入口的路由根。不能只看 UI,也不能假定旧策略组 claude-guard-exit 存在。
  • 固定节点不等于固定公网 IP。同一指定节点的新 TW 动态 IP 可更新 CLI 会话;其他任何叶子均不应放行。未启用主备时,换出口必须由用户明确重新指定并替换旧目标。启用主备时,只能从主切到预先指定的备用,不能临时追加第三节点。节点名、旗帜、显示延迟都不是地区证据。
  • 短时重试只能使用当前 expected_node,不能回退 DIRECT、系统代理或未指定节点。已有新鲜严格验证时,单次有界的控制口超时、trace 超时或 Anthropic 临时不可达可保留上一条已验证路由并立即复核,连续达阈值才关门;叶子漂移、地区不符、TUN/IPv6 或主备状态不一致仍立即拒绝。主节点连续失败达到阈值后,切换过程必须先置 switching=true 并关闭活动隧道,严格验证备用节点的实际路由、地区和 Anthropic 可达性后才能放行。失败必须读回确认回滚;无法确认时保持 blocked。默认不自动回切主节点。

分层、重试和验收读 保护边界。涉及浏览器新装、维护、登录入口、节点/IP、时区定位或 DNS/WebRTC 时,必须读 Fingerprint Chromium Guarded,以 Chromium 流程为准,不再部署或启动 Camoufox 浏览器。

系统/普通浏览器/CLI 的 DNS 排查与代理解析部署,另读 Clash 代理 DNS。区分接管、上游传输和节点引导解析;浏览器检测通过不能代替 CLI 验证。此版本的 DNS 适配仅针对 Clash/Mihomo,不新增其他 VPN 后端。

已有部署的维护约束

以下须按目标机器的实际选择核对,不是其他客户的新装默认值:

  • 保留规则分流、任一时刻唯一生效出口、动态 IP 兼容和会话恢复;只有用户已明确选择时才保留固定主备,不扩展成节点池。
  • 保留用户已明确选择的权限模式;若使用 --permission-mode bypassPermissions,显式参数优先。它放宽工具权限,不增强网络保护;新装不擅自开启。
  • 不要设置 CLAUDE_CODE_DISABLE_MOUSE。鼠标转义码先排查 TTY/raw mode、退出清理及后台进程读写终端,不用禁用鼠标掩盖问题。
  • 用 Claude 进程 BROWSER 指向 claude-fingerprint-chromium,由受保护的 Fingerprint Chromium Guarded 应用接收登录地址;不裸开其内置 Chromium,不退回 Camoufox/普通 Chrome,不改系统默认浏览器。
  • 保留 Chromium 独立 profile 与 device.json 的固定 seed,不导入其他浏览器 Cookie、密码或登录资料。浏览器钉住启动时验证的公网 IP;同叶子 IP 变化须阻断后重开以同步 GeoIP,不照搬 CLI 的动态 IP 更新行为。
  • 不因更新 CLI/Skill 自动清凭证、聊天、Cookie 或重置指纹;读 清理边界。

新环境或迁移

先读 客户端与旧模板。探测系统、真实客户端、代理/控制端口和已有部署,不复制作者节点/端口/路径:

python3 "<SKILL>/scripts/ccg_detect.py" --list

原始探测 JSON 可能含控制器 secret,不能原样发布。新环境默认只让用户确认一个完整叶子名。用户明确要求主备时,再确认一个备用叶子和一个 Selector 路由根;不能从地区或测速结果自动挑节点,也不能把 Selector 成员整体当作白名单。只能检测端口时不能声称已验证最终节点。

附带 ccg_install.py、ccg_guard.py、ccg_gate.py 和 ccg_failover.py 是通用模板,不等同现用本机策略。默认仍为单节点;同时提供 --secondary-node 与 --ai-group 才生成主备配置。不要用模板回滚或覆盖已有部署;安装器会拒绝覆盖发现的保护文件/已有 Hook。新环境也先做能力差异审查、适配及隔离测试,再按授权部署。

验收与交付

  • 语法/单测 → 比较文件 → 只读路由核对 → 无账号的独立拒绝路径测试。
  • 用户允许影响连接后才能切节点、关 TUN 或断网测试;不打断正在运行的任务。
  • 测试错误节点、错误地区、控制器失联、上游断开、IPv6/DNS、备用 loopback 代理及长连接;启用主备时还要测试切换屏障、备用探测失败、回滚失败、活动隧道关闭和不会自动回切;没测的写“未验证”。
  • DNS 分别验证 UDP/TCP 接管、加密上游的实际连接链、普通浏览器与 CLI,以及节点引导例外。TYPE64(SVCB)/TYPE65(HTTPS)仅为辅助校验,不自动屏蔽;空 Answer 不证明无泄漏。全系统断路防护需单独授权和验收。
  • --fast 不证明地区;Hook 存在不证明每条 HTTP 请求被检查;启动器路径不证明当前进程受沙箱限制。
  • 更新 CLI 只更新真实二进制,保留 wrapper/Hook/设置/服务。用前后摘要证明保护文件未改;没有前置摘要就不能宣称“哈希证明未改”。
  • 更新 Skill 后运行 scripts/test_skill.py。用户明确要求发布到 GitHub 时才提交并推送该仓库。

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Claude Code Guard AI skill do?

配置、维护或排查 Clash/Mihomo 下的 Claude Code 网络保护:Claude/Anthropic HTTP(S) 走专用入站与固定出口,默认单节点,可按明确授权启用固定主备;shell、脚本、远端数据库不拦。核对 wrapper、节点/链式代理、网络 Hook、macOS 沙箱,以及 Fingerprint Chromium Guarded 的 IP、时区、定位和代理 DNS。用户提到 Claude 防封、Seatbelt EPERM、节点漂移、DNS 泄漏或受保护指纹浏览器时使用;不保证不封号、绝对无泄漏或账号无法关联。

Why use Claude Code Guard on TypingMind?

Because you install it once and use it with any model. Claude Code Guard is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Claude Code Guard in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/xnydl/claude-code-guard/tree/main. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Claude Code Guard?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Claude Code Guard?

As many as you like. As long as a model supports skills, you can use Claude Code Guard with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Claude Code Guard AI skill free?

It is published on GitHub by xnydl. Check the repository for licensing terms. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇