Claude Skill

lov-clash-tun-doctor

Diagnose and repair application connectivity failures caused by Clash Verge Rev TUN routing, rule precedence, stale runtime state, proxy timeouts, or unusable IPv6 paths. Trigger for symptoms such as WeChat images failing to send, Moments images loading slowly, an app hanging aft

LLM Mart · 0 points · 17 views 0 listing impressions 0 install-command copies
Download lovstudio-skills-skills_clash-tun-doctor-0b16007.zip · 19 KB
This skill couldn't be refreshed from GitHub on the last check — you're seeing the last imported snapshot.

Install

skills CLI npx skills add https://github.com/lovstudio/skills/tree/main/skills/clash-tun-doctor
Claude Code claude plugin marketplace add https://llmmart.ai/marketplace.json && claude plugin install lovstudio-skills@llmmart
Git git clone https://github.com/lovstudio/skills.git

The skills CLI installs just this skill, for any of its supported agents. Claude Code installs the whole lovstudio/skills collection as a plugin from our marketplace. Git is the plain clone.

README

Clash 网络医生 · Clash Network Doctor

Version

基于最终运行态、实时连接和日志证据,诊断并修复 Clash Verge Rev TUN 导致的应用联网故障。

Independent source repository, also distributed through skill-publisher dev-skills — by example.com

适用场景

  • 开启 TUN 后微信图片发不出去。
  • 微信朋友圈图片加载很慢或完全不显示。
  • 应用被错误规则送进失效代理,持续 Loading。
  • 订阅中已经关闭 IPv6,但最终运行配置仍启用 IPv6。
  • Mihomo 日志出现 no route to host 或 context deadline exceeded。

Install

npx skills add skill-publisher/clash-tun-doctor-skill --all -g

The aggregate bundle remains available:

npx skills add skill-publisher/dev-skills --all -g

或使用 Claude Code 插件市场:

/plugin marketplace add skill-publisher/dev-skills
/plugin install dev-tools@lov-dev

依赖:macOS、Clash Verge Rev、Python 3.8+。诊断 CLI 只使用 Python 标准库。

Usage

SKILL_DIR="${SKILL_SKILLS_INSTALL_DIR:?Set SKILL_SKILLS_INSTALL_DIR}/lov-clash-tun-doctor"

# 只读诊断
python3 "$SKILL_DIR/scripts/clash_tun_doctor.py" diagnose --app wechat

# 从运行连接和近期轮转日志生成 DIRECT 清单
python3 "$SKILL_DIR/scripts/clash_tun_doctor.py" direct-list \
  --app miracleplus \
  --host apply.miracleplus.com \
  --output ./miracleplus-direct.yaml

# 合并进当前规则并在线热加载,全程保持 Clash 运行
python3 "$SKILL_DIR/scripts/clash_tun_doctor.py" direct-list \
  --app miracleplus \
  --host apply.miracleplus.com \
  --apply

# 预演修复
python3 "$SKILL_DIR/scripts/clash_tun_doctor.py" fix-wechat

# 备份、修复、重启并验证
python3 "$SKILL_DIR/scripts/clash_tun_doctor.py" fix-wechat --apply

# 回滚最近一次修复
python3 "$SKILL_DIR/scripts/clash_tun_doctor.py" rollback --apply

安全模型

  • 永远先诊断,后修改。
  • 修改命令默认 dry-run,必须显式传入 --apply。
  • 每次修改创建时间戳备份和文件映射清单。
  • DIRECT 清单与现有 prepend 合并,不覆盖用户已有规则。
  • 规则型修复通过 Mihomo Unix Socket 热加载,Clash Verge 保持运行。
  • 不修改订阅 URL,不输出代理密钥或控制器 Secret。
  • 修复后检查最终配置和 Mihomo 运行态,而不是只检查源配置。

Options

参数 默认值 说明
--data-dir 自动发现 Clash Verge Rev 数据目录。
--socket 自动发现 Mihomo 控制器 Unix Socket。
--app wechat 诊断时使用的应用过滤器。
--host — 明确加入清单的域名,可重复传入。
--output — 输出 Mihomo classical rule-provider YAML 清单。
--log-limit 4000 每段近期轮转日志读取的行数。
--apply false 明确授权修改或回滚。
--no-reload false 只持久化 DIRECT 清单,不热加载运行态。
--no-restart false 修改后不重启 Clash Verge。
--json false 输出 JSON 诊断结果。

License

MIT

Skill manifest

Clash 网络医生 · Clash Network Doctor

Evidence-first diagnosis and reversible repair for application networking failures behind Clash Verge Rev TUN mode.

When to Use

  • An application works without TUN but fails, stalls, or loses media with TUN.
  • WeChat text works while image uploads or Moments images fail.
  • A rule change makes the symptom worse or the app remains stuck on Loading.
  • The subscription says ipv6: false, but runtime traffic still uses IPv6.
  • Clash logs contain no route to host, context deadline exceeded, or an unexpected rule/strategy for the affected process.

Do not use this skill for generic subscription acquisition, node purchasing, or bypassing organizational network policy.

Workflow (MANDATORY)

Step 0: Resolve the skill and Clash data directories

Resolve SKILL_DIR from the installed skill context. For manual execution:

export SKILL_DIR="/path/to/lov-clash-tun-doctor"

The CLI resolves the Clash Verge Rev data directory in this order:

  1. --data-dir
  2. SKILL_CLASH_TUN_DOCTOR_DATA_DIR
  3. macOS Clash Verge Rev default under ~/Library/Application Support/

Never hard-code a user's home directory.

Step 1: Diagnose before proposing a rule

Run the read-only command first:

python3 "$SKILL_DIR/scripts/clash_tun_doctor.py" diagnose --app wechat

Report concrete evidence from all available layers:

  • App-level config.yaml overrides.
  • Generated clash-verge.yaml top-level and DNS IPv6 values.
  • Runtime /configs, /rules, and /connections through Mihomo's Unix socket.
  • Recent service-log failures for the target application.

Treat screenshots and runtime state as truth. A rule saying DIRECT does not prove the connection succeeded.

Step 2: Choose the narrowest repair

Use references/troubleshooting.md to map evidence to a repair. For the proven WeChat pattern, use the built-in repair:

python3 "$SKILL_DIR/scripts/clash_tun_doctor.py" fix-wechat

This is a dry run. It previews:

  • Direct rules for the WeChat processes and media domains.
  • Disabling the app-level IPv6 override that can supersede subscription and extension settings.
  • The exact files that would be backed up and changed.

Do not route the whole application through a proxy merely because direct media failed. First check proxy health and IPv6 errors; a proxy timeout can turn one failed image into a fully stuck application.

For a browser site or application with multiple dependency hosts, generate one evidence-backed DIRECT list instead of adding domains one by one:

python3 "$SKILL_DIR/scripts/clash_tun_doctor.py" direct-list \
  --app miracleplus \
  --host apply.miracleplus.com \
  --output ./miracleplus-direct.yaml

The command reads active connections and recent rotated service logs, deduplicates hostnames, and includes only:

  • Hosts explicitly supplied with --host.
  • Hosts previously observed through a non-DIRECT route.
  • Hosts already maintained as explicit DIRECT rules.

Hosts observed only through a healthy DIRECT route are reported as ignored instead of bloating the explicit list.

Step 3: Apply only with user authorization

For a DIRECT list, preview first, then persist and hot-load it:

python3 "$SKILL_DIR/scripts/clash_tun_doctor.py" direct-list \
  --app miracleplus \
  --host apply.miracleplus.com \
  --apply

This path must merge with existing prepend rules, create a timestamped backup, update the generated config, hot-load Mihomo through its Unix socket, and verify every listed host as an exact DOMAIN -> DIRECT runtime rule. Keep Clash Verge running throughout this rule-only flow.

For the specialized WeChat IPv6 repair, run:

python3 "$SKILL_DIR/scripts/clash_tun_doctor.py" fix-wechat --apply

The command must:

  1. Stop Clash Verge before editing its generated global settings.
  2. Create a timestamped backup and manifest.
  3. Set the global IPv6 override to false.
  4. Prepend persistent WeChat DIRECT rules in the current profile's rule file.
  5. Restart Clash Verge and verify final/runtime state.

If verification fails, report the backup path and do not claim success.

Step 4: Restart the affected application and verify the user path

Close stale connections or restart the affected application. Re-run diagnosis:

python3 "$SKILL_DIR/scripts/clash_tun_doctor.py" diagnose --app wechat --json

For the WeChat IPv6 failure, success requires all of the following:

  • Runtime ipv6 is false.
  • WeChat rules resolve to DIRECT.
  • New WeChat destinations are IPv4.
  • New logs no longer show WeChat no route to host errors.
  • The user can send an image and load Moments images.

Step 5: Roll back when needed

python3 "$SKILL_DIR/scripts/clash_tun_doctor.py" rollback --apply

Rollback restores the newest backup by default. Never delete backups automatically.

CLI Reference

Command / option Default Description
diagnose — Read configuration, runtime state, connections, and logs.
direct-list — Discover, export, or apply an evidence-backed DIRECT host list.
fix-wechat dry run Preview or apply the proven WeChat repair.
rollback dry run Preview or restore the latest repair backup.
--data-dir PATH auto Clash Verge Rev application data directory.
--socket PATH <data-dir>/mihomo.sock fallback Mihomo controller Unix socket; standard /tmp/verge/verge-mihomo.sock is auto-detected.
--app NAME wechat Application filter used by diagnosis.
--host HOST — Seed an exact host in a DIRECT list; repeatable.
--output PATH — Save a Mihomo classical rule-provider YAML list.
--log-limit N 4000 Recent lines inspected in each rotated service log.
--apply false Authorize filesystem changes and restart/restore actions.
--no-reload false Persist a DIRECT list without runtime hot-load.
--no-restart false Apply changes without restarting Clash Verge.
--json false Emit machine-readable diagnosis output.

Dependencies

Python 3.8+ standard library only.

Runtime context (shared)

运行前读取本 Skill 包的 skill.yaml,由宿主提供 skill-runtime/v1 上下文。字段解析顺序为:当前请求、项目上下文、个人 Preferences、品牌 Profile、通用默认值。

  • 只使用 Manifest 声明的字段;Profile 保存公开品牌事实,Preferences 保存个人工作偏好。
  • required: true 字段缺失时,按 Manifest 的问题配置向用户提出一个聚焦问题;用户明确同意后再保存回答。
  • 报错提供可复制的 context_id、字段路径与来源,诊断内容避开秘密、完整私人路径和原始配置。

通用反馈闭环

用户在 Skill 驱动任务中提出修改意见时,继续当前产物前必须执行:

  1. 先判断意见是 task-specific(仅本次)还是 reusable(可跨任务复用)。
  2. task-specific 只修改当前任务,不改 Skill。
  3. reusable 先确定作用域:领域规则先更新对应 canonical Skill;适用于所有 Skill 的规则先更新共享规范。
  4. 完成规则更新、版本、lint 与分发核验后,再把修改应用到当前任务。
  5. reusable 修改会使此前的“确认”“继续”“发吧”失效;完成当前产物修改和回读后必须停下,等待用户下一步指示,不自动进入发布、提交或其他外部写入。
Files (skills)
  • references
    • troubleshooting.md 2.5 KB
      Loading…
    • user-config.md 1.6 KB
      Loading…
  • scripts
    • clash_tun_doctor.py 29.4 KB
      Loading…
  • tests
    • test_clash_tun_doctor.py 4.2 KB
      Loading…
  • .gitignore 78 B · in bundle
  • CHANGELOG.md 629 B
    Loading…
  • LICENSE 1 KB · in bundle
  • README.md 3.2 KB
    # Clash 网络医生 · Clash Network Doctor
    
    ![Version](https://img.shields.io/badge/version-0.3.0-CC785C)
    
    基于最终运行态、实时连接和日志证据,诊断并修复 Clash Verge Rev TUN 导致的应用联网故障。
    
    Independent source repository, also distributed through [skill-publisher dev-skills](https://example.com/skills/dev-skills) — by [example.com](https://example.com)
    
    ## 适用场景
    
    - 开启 TUN 后微信图片发不出去。
    - 微信朋友圈图片加载很慢或完全不显示。
    - 应用被错误规则送进失效代理,持续 Loading。
    - 订阅中已经关闭 IPv6,但最终运行配置仍启用 IPv6。
    - Mihomo 日志出现 `no route to host` 或 `context deadline exceeded`。
    
    ## Install
    
    ```bash
    npx skills add skill-publisher/clash-tun-doctor-skill --all -g
    ```
    
    The aggregate bundle remains available:
    
    ```bash
    npx skills add skill-publisher/dev-skills --all -g
    ```
    
    或使用 Claude Code 插件市场:
    
    ```text
    /plugin marketplace add skill-publisher/dev-skills
    /plugin install dev-tools@lov-dev
    ```
    
    依赖:macOS、Clash Verge Rev、Python 3.8+。诊断 CLI 只使用 Python 标准库。
    
    ## Usage
    
    ```bash
    SKILL_DIR="${SKILL_SKILLS_INSTALL_DIR:?Set SKILL_SKILLS_INSTALL_DIR}/lov-clash-tun-doctor"
    
    # 只读诊断
    python3 "$SKILL_DIR/scripts/clash_tun_doctor.py" diagnose --app wechat
    
    # 从运行连接和近期轮转日志生成 DIRECT 清单
    python3 "$SKILL_DIR/scripts/clash_tun_doctor.py" direct-list \
      --app miracleplus \
      --host apply.miracleplus.com \
      --output ./miracleplus-direct.yaml
    
    # 合并进当前规则并在线热加载,全程保持 Clash 运行
    python3 "$SKILL_DIR/scripts/clash_tun_doctor.py" direct-list \
      --app miracleplus \
      --host apply.miracleplus.com \
      --apply
    
    # 预演修复
    python3 "$SKILL_DIR/scripts/clash_tun_doctor.py" fix-wechat
    
    # 备份、修复、重启并验证
    python3 "$SKILL_DIR/scripts/clash_tun_doctor.py" fix-wechat --apply
    
    # 回滚最近一次修复
    python3 "$SKILL_DIR/scripts/clash_tun_doctor.py" rollback --apply
    ```
    
    ## 安全模型
    
    - 永远先诊断,后修改。
    - 修改命令默认 dry-run,必须显式传入 `--apply`。
    - 每次修改创建时间戳备份和文件映射清单。
    - DIRECT 清单与现有 `prepend` 合并,不覆盖用户已有规则。
    - 规则型修复通过 Mihomo Unix Socket 热加载,Clash Verge 保持运行。
    - 不修改订阅 URL,不输出代理密钥或控制器 Secret。
    - 修复后检查最终配置和 Mihomo 运行态,而不是只检查源配置。
    
    ## Options
    
    | 参数 | 默认值 | 说明 |
    |---|---|---|
    | `--data-dir` | 自动发现 | Clash Verge Rev 数据目录。 |
    | `--socket` | 自动发现 | Mihomo 控制器 Unix Socket。 |
    | `--app` | `wechat` | 诊断时使用的应用过滤器。 |
    | `--host` | — | 明确加入清单的域名,可重复传入。 |
    | `--output` | — | 输出 Mihomo classical rule-provider YAML 清单。 |
    | `--log-limit` | `4000` | 每段近期轮转日志读取的行数。 |
    | `--apply` | false | 明确授权修改或回滚。 |
    | `--no-reload` | false | 只持久化 DIRECT 清单,不热加载运行态。 |
    | `--no-restart` | false | 修改后不重启 Clash Verge。 |
    | `--json` | false | 输出 JSON 诊断结果。 |
    
    ## License
    
    MIT
    
  • SKILL.md 8 KB
    ---
    name: lov-clash-tun-doctor
    description: >
      Diagnose and repair application connectivity failures caused by Clash Verge
      Rev TUN routing, rule precedence, stale runtime state, proxy timeouts, or
      unusable IPv6 paths. Trigger for symptoms such as WeChat images failing to
      send, Moments images loading slowly, an app hanging after TUN is enabled, or
      requests unexpectedly matching DIRECT/proxy rules. Also trigger when the user
      mentions "Clash TUN 排障", "微信图片发不出去", "朋友圈图片加载慢",
      "修复微信 TUN 网络", or "diagnose Clash TUN app connectivity".
    license: MIT
    metadata:
      author: contributors
      version: "0.3.0"
      tags: clash mihomo tun network diagnostics wechat macos
    ---
    
    # Clash 网络医生 · Clash Network Doctor
    
    Evidence-first diagnosis and reversible repair for application networking
    failures behind Clash Verge Rev TUN mode.
    
    ## When to Use
    
    - An application works without TUN but fails, stalls, or loses media with TUN.
    - WeChat text works while image uploads or Moments images fail.
    - A rule change makes the symptom worse or the app remains stuck on Loading.
    - The subscription says `ipv6: false`, but runtime traffic still uses IPv6.
    - Clash logs contain `no route to host`, `context deadline exceeded`, or an
      unexpected rule/strategy for the affected process.
    
    Do not use this skill for generic subscription acquisition, node purchasing,
    or bypassing organizational network policy.
    
    ## Workflow (MANDATORY)
    
    ### Step 0: Resolve the skill and Clash data directories
    
    Resolve `SKILL_DIR` from the installed skill context. For manual execution:
    
    ```bash
    export SKILL_DIR="/path/to/lov-clash-tun-doctor"
    ```
    
    The CLI resolves the Clash Verge Rev data directory in this order:
    
    1. `--data-dir`
    2. `SKILL_CLASH_TUN_DOCTOR_DATA_DIR`
    3. macOS Clash Verge Rev default under `~/Library/Application Support/`
    
    Never hard-code a user's home directory.
    
    ### Step 1: Diagnose before proposing a rule
    
    Run the read-only command first:
    
    ```bash
    python3 "$SKILL_DIR/scripts/clash_tun_doctor.py" diagnose --app wechat
    ```
    
    Report concrete evidence from all available layers:
    
    - App-level `config.yaml` overrides.
    - Generated `clash-verge.yaml` top-level and DNS IPv6 values.
    - Runtime `/configs`, `/rules`, and `/connections` through Mihomo's Unix socket.
    - Recent service-log failures for the target application.
    
    Treat screenshots and runtime state as truth. A rule saying `DIRECT` does not
    prove the connection succeeded.
    
    ### Step 2: Choose the narrowest repair
    
    Use `references/troubleshooting.md` to map evidence to a repair. For the proven
    WeChat pattern, use the built-in repair:
    
    ```bash
    python3 "$SKILL_DIR/scripts/clash_tun_doctor.py" fix-wechat
    ```
    
    This is a dry run. It previews:
    
    - Direct rules for the WeChat processes and media domains.
    - Disabling the app-level IPv6 override that can supersede subscription and
      extension settings.
    - The exact files that would be backed up and changed.
    
    Do not route the whole application through a proxy merely because direct media
    failed. First check proxy health and IPv6 errors; a proxy timeout can turn one
    failed image into a fully stuck application.
    
    For a browser site or application with multiple dependency hosts, generate one
    evidence-backed DIRECT list instead of adding domains one by one:
    
    ```bash
    python3 "$SKILL_DIR/scripts/clash_tun_doctor.py" direct-list \
      --app miracleplus \
      --host apply.miracleplus.com \
      --output ./miracleplus-direct.yaml
    ```
    
    The command reads active connections and recent rotated service logs, deduplicates
    hostnames, and includes only:
    
    - Hosts explicitly supplied with `--host`.
    - Hosts previously observed through a non-DIRECT route.
    - Hosts already maintained as explicit DIRECT rules.
    
    Hosts observed only through a healthy DIRECT route are reported as ignored
    instead of bloating the explicit list.
    
    ### Step 3: Apply only with user authorization
    
    For a DIRECT list, preview first, then persist and hot-load it:
    
    ```bash
    python3 "$SKILL_DIR/scripts/clash_tun_doctor.py" direct-list \
      --app miracleplus \
      --host apply.miracleplus.com \
      --apply
    ```
    
    This path must merge with existing `prepend` rules, create a timestamped backup,
    update the generated config, hot-load Mihomo through its Unix socket, and verify
    every listed host as an exact `DOMAIN -> DIRECT` runtime rule. Keep Clash Verge
    running throughout this rule-only flow.
    
    For the specialized WeChat IPv6 repair, run:
    
    ```bash
    python3 "$SKILL_DIR/scripts/clash_tun_doctor.py" fix-wechat --apply
    ```
    
    The command must:
    
    1. Stop Clash Verge before editing its generated global settings.
    2. Create a timestamped backup and manifest.
    3. Set the global IPv6 override to `false`.
    4. Prepend persistent WeChat `DIRECT` rules in the current profile's rule file.
    5. Restart Clash Verge and verify final/runtime state.
    
    If verification fails, report the backup path and do not claim success.
    
    ### Step 4: Restart the affected application and verify the user path
    
    Close stale connections or restart the affected application. Re-run diagnosis:
    
    ```bash
    python3 "$SKILL_DIR/scripts/clash_tun_doctor.py" diagnose --app wechat --json
    ```
    
    For the WeChat IPv6 failure, success requires all of the following:
    
    - Runtime `ipv6` is `false`.
    - WeChat rules resolve to `DIRECT`.
    - New WeChat destinations are IPv4.
    - New logs no longer show WeChat `no route to host` errors.
    - The user can send an image and load Moments images.
    
    ### Step 5: Roll back when needed
    
    ```bash
    python3 "$SKILL_DIR/scripts/clash_tun_doctor.py" rollback --apply
    ```
    
    Rollback restores the newest backup by default. Never delete backups
    automatically.
    
    ## CLI Reference
    
    | Command / option | Default | Description |
    |---|---|---|
    | `diagnose` | — | Read configuration, runtime state, connections, and logs. |
    | `direct-list` | — | Discover, export, or apply an evidence-backed DIRECT host list. |
    | `fix-wechat` | dry run | Preview or apply the proven WeChat repair. |
    | `rollback` | dry run | Preview or restore the latest repair backup. |
    | `--data-dir PATH` | auto | Clash Verge Rev application data directory. |
    | `--socket PATH` | `<data-dir>/mihomo.sock` fallback | Mihomo controller Unix socket; standard `/tmp/verge/verge-mihomo.sock` is auto-detected. |
    | `--app NAME` | `wechat` | Application filter used by diagnosis. |
    | `--host HOST` | — | Seed an exact host in a DIRECT list; repeatable. |
    | `--output PATH` | — | Save a Mihomo classical rule-provider YAML list. |
    | `--log-limit N` | `4000` | Recent lines inspected in each rotated service log. |
    | `--apply` | false | Authorize filesystem changes and restart/restore actions. |
    | `--no-reload` | false | Persist a DIRECT list without runtime hot-load. |
    | `--no-restart` | false | Apply changes without restarting Clash Verge. |
    | `--json` | false | Emit machine-readable diagnosis output. |
    
    ## Dependencies
    
    Python 3.8+ standard library only.
    
    ## Runtime context (shared)
    
    运行前读取本 Skill 包的 `skill.yaml`,由宿主提供 `skill-runtime/v1` 上下文。字段解析顺序为:当前请求、项目上下文、个人 Preferences、品牌 Profile、通用默认值。
    
    - 只使用 Manifest 声明的字段;Profile 保存公开品牌事实,Preferences 保存个人工作偏好。
    - `required: true` 字段缺失时,按 Manifest 的问题配置向用户提出一个聚焦问题;用户明确同意后再保存回答。
    - 报错提供可复制的 `context_id`、字段路径与来源,诊断内容避开秘密、完整私人路径和原始配置。
    
    ## 通用反馈闭环
    
    用户在 Skill 驱动任务中提出修改意见时,继续当前产物前必须执行:
    
    1. 先判断意见是 `task-specific`(仅本次)还是 `reusable`(可跨任务复用)。
    2. `task-specific` 只修改当前任务,不改 Skill。
    3. `reusable` 先确定作用域:领域规则先更新对应 canonical Skill;适用于所有 Skill 的规则先更新共享规范。
    4. 完成规则更新、版本、lint 与分发核验后,再把修改应用到当前任务。
    5. `reusable` 修改会使此前的“确认”“继续”“发吧”失效;完成当前产物修改和回读后必须停下,等待用户下一步指示,不自动进入发布、提交或其他外部写入。
    
  • skill.yaml 846 B
    Loading…

Comments (0)

Sign in to join the conversation.

No comments yet.

Reviews (0)

No reviews yet.