Catsler

Clash Clean — Development skill for Claude Code

Development community

macOS/Clash Verge 诊断与最小恢复 Claude Code skill:检查 TUN、Mihomo、fake-IP DNS、订阅 HTTP 状态和活动节点延迟;不打印凭据,不删除订阅.

How to install Clash Clean

This entry records only its repository, not the path inside it, so there is no exact command to give. Open Catsler/clash-clean and copy the folder into ~/.claude/skills/, or the file into ~/.claude/agents/.

What Clash Clean does

macOS/Clash Verge 诊断与最小恢复 Claude Code skill:检查 TUN、Mihomo、fake-IP DNS、订阅 HTTP 状态和活动节点延迟;不打印凭据,不删除订阅。

Alternatives in Development

  • Clean Worktree (Interactive) — Interactive cleanup of worktrees: lists merged/stale branches and asks confirmation before deleting 25.5k ★
  • System Cache Cleanup — Clean temporary files and caches to free disk space: $ARGUMENTS 23.4k ★
  • Jupyter Notebook — Create clean, reproducible Jupyter notebooks for experiments and tutorials 14.6k ★

README

clean-clash

面向 macOS Clash Verge Rev / Mihomo 的 Claude Code skill,用于分层诊断代理无流量、TUN 状态异常、fake-IP 导致的节点超时,以及 provider DNS 合并配置问题。

**安全定位:** 本项目是诊断与最小恢复工具,不是订阅破解器,也不会绕过服务商的封禁、白名单或账户策略。

能解决什么

症状 检查或修复
TUN 开关、Mihomo 进程、utun 设备或路由状态不一致 diagnose.sh 输出分层状态
节点连接目标变成 198.18.x.x 并超时 检查 provider fake-IP 排除项与 proxy DNS
provider 节点域名被 fake-IP 解析 fix-provider-dns.sh 生成最小 merge 修复
当前 selector 节点是否能做延迟测试 通过 Mihomo Unix API 检查活动节点
订阅 endpoint 返回 2xx、403 或连接失败 只读检查 HTTP 状态,不打印 URL
macOS DNS 缓存可能陈旧 flush-dns.sh --apply 显式刷新

不能解决什么

  • 服务商账户失效、IP 白名单、服务端封禁或订阅 token 失效;
  • 恢复或猜测订阅 URL、token、UUID、密码;
  • 任意设计代理规则、修改生成的 clash-verge.yaml;
  • 自动启用需要特权的 TUN;请在 Clash Verge UI 中开启并确认;
  • 无确认地停止进程、删除缓存、删除日志或“完整清理”。

订阅 HTTP `403` 只表示远程 endpoint 拒绝当前请求,不能证明缓存中的节点全部失效;工具不会因为 403 删除本地 profile。

前置条件

  • macOS(DNS 刷新脚本仅支持 Darwin);
  • Clash Verge Rev / Mihomo 已安装并运行;
  • Python 3.10+ 与 PyYAML;
  • 诊断 TUN 需要 pgrep、ifconfig、route;
  • 节点检查需要 Mihomo Unix socket(默认 /tmp/verge/verge-mihomo.sock);
  • 订阅检查需要网络,但不会把 URL 输出到终端。

安装依赖:

python3 -m pip install -r requirements.txt

安装为 Claude Code skill

将仓库目录复制到 Claude Code skills 目录(或使用你自己的 skill 管理方式):

mkdir -p ~/.claude/skills/clean-clash
cp SKILL.md ~/.claude/skills/clean-clash/
cp -R scripts ~/.claude/skills/clean-clash/

脚本也可以直接从 checkout 目录运行。

渐进式诊断

工作流状态机为:

IDLE → DIAG → FIX → RELOAD → VERIFY → DONE / ERROR

先只读诊断:

scripts/diagnose.sh --dry-run

指定本地 provider 规则(配置文件必须放在仓库外):

export CLEAN_CLASH_PROVIDER_CONFIG="$HOME/.config/clean-clash/providers.yaml"
scripts/diagnose.sh --dry-run --provider-config "$CLEAN_CLASH_PROVIDER_CONFIG"

诊断输出重点关注:

  1. tun 与 UI 持久化开关是否一致;
  2. verge-mihomo、utun1024、fake-IP 路由和 Unix socket 是否存在;
  3. 当前配置是否为 fake-IP,以及 provider 节点域名是否已排除;
  4. 订阅 HTTP 状态与活动节点延迟是否独立正常。

默认诊断快照写入用户目录下的 `~/Library/Application Support/clean-clash/state`;使用 `--dry-run` 不写状态。可通过 `CLEAN_CLASH_STATE_DIR` 改到其他位置。