Clash Verge Auto Switch
This skill gives Codex a reliable workflow for Clash Verge Rev and Mihomo proxy switching on macOS. It is meant for users who want a concrete node selected from a selector group, not just a passive health check.
When To Use It
Use this skill when the user asks to:
- - speed test Clash Verge or Mihomo nodes
- switch the currently used Clash selector groups to the fastest node
- diagnose why the Clash controller cannot be reached
- install or remove a timed automatic switch job on macOS
Quick Start
Run the main script:
CODEBLOCK0
By default it auto-discovers the current active selector chain from the live Clash controller. To inspect what it found:
CODEBLOCK1
Target explicit groups:
CODEBLOCK2
Dry-run without changing selections:
CODEBLOCK3
Workflow
- 1. Check whether the Mihomo controller is reachable.
- If the user did not name target groups, inspect the live
/proxies tree and auto-discover groups from the current active selection chain. - Expand
url-test, fallback, and load-balance groups into leaf proxies, but do not rewrite nested selector groups unless the user explicitly targets them. - Test candidate proxies with the controller delay API and switch the selector group to the lowest-latency healthy node.
- Report the winning node, measured latency, and whether a switch happened.
Group Discovery
- - Default mode is
--group-scope current, which follows the currently selected chain from the live Clash proxy tree. - Use
--group-scope top-level when you want all top-level selector groups discovered from the current controller session. - Use
--group-scope all when you want every selector group in the current Clash instance. - Use explicit
--group flags when the user wants exact control.
Scheduling
For a true custom-minute schedule on macOS, use the bundled launchd installer instead of Codex automations because Codex recurring schedules only support hourly intervals.
Install:
CODEBLOCK4
Remove:
CODEBLOCK5
Notes
- - Read runtime-notes.md when you need the generic controller discovery and group-detection rules.
- If the controller is offline, ask the user whether Clash Verge should be opened first or run the script with
--launch-if-needed.
Clash Verge 自动切换
此技能为Codex提供了一套在macOS上可靠切换Clash Verge Rev和Mihomo代理的工作流程。它适用于希望从选择器组中选定具体节点,而非仅依赖被动健康检查的用户。
使用场景
当用户提出以下请求时使用此技能:
- - 对Clash Verge或Mihomo节点进行速度测试
- 将当前使用的Clash选择器组切换至最快节点
- 诊断无法连接Clash控制器的原因
- 在macOS上安装或移除定时自动切换任务
快速开始
运行主脚本:
bash
/usr/bin/python3 ~/.codex/skills/clash-verge-auto-switch/scripts/switch_fastest.py
默认情况下,它会从运行中的Clash控制器自动发现当前活跃的选择器链。如需查看发现结果:
bash
/usr/bin/python3 ~/.codex/skills/clash-verge-auto-switch/scripts/switch_fastest.py --list-groups
指定目标组:
bash
/usr/bin/python3 ~/.codex/skills/clash-verge-auto-switch/scripts/switch_fastest.py \
--group Proxy \
--group ChatGPT
仅模拟运行,不实际更改选择:
bash
/usr/bin/python3 ~/.codex/skills/clash-verge-auto-switch/scripts/switch_fastest.py --dry-run
工作流程
- 1. 检查Mihomo控制器是否可达。
- 若用户未指定目标组,则检查运行中的/proxies树,从当前活跃选择链自动发现组。
- 将url-test、fallback和load-balance组展开为叶子节点,但除非用户明确指定,否则不重写嵌套的选择器组。
- 通过控制器延迟API测试候选节点,并将选择器组切换至延迟最低的健康节点。
- 报告获胜节点、测量延迟以及是否发生切换。
组发现
- - 默认模式为--group-scope current,即跟随运行中Clash代理树的当前选择链。
- 如需从当前控制器会话中发现所有顶级选择器组,使用--group-scope top-level。
- 如需发现当前Clash实例中的每一个选择器组,使用--group-scope all。
- 当用户需要精确控制时,使用显式的--group标志。
定时任务
如需在macOS上设置自定义分钟级定时任务,请使用附带的launchd安装程序,而非Codex自动化功能,因为Codex的周期性调度仅支持小时级间隔。
安装:
bash
~/.codex/skills/clash-verge-auto-switch/scripts/installlaunchagent.sh \
--interval-minutes 30 \
--group-scope current
移除:
bash
~/.codex/skills/clash-verge-auto-switch/scripts/uninstalllaunchagent.sh
注意事项
- - 如需通用的控制器发现和组检测规则,请阅读runtime-notes.md。
- 如果控制器离线,请询问用户是否应先打开Clash Verge,或使用--launch-if-needed参数运行脚本。