Clash Verge rule routing fix
When to use
Use this when:
- The task is on the user's macOS home environment with Clash Verge Rev / Mihomo.
- The user wants a direct routing fix, a complete copyable YAML block, or a targeted change for OpenAI/ChatGPT/Codex provider/Google/Gemini/Yuque/domestic-vs-foreign routing.
- You need to distinguish bad node behavior from bad rule order.
Do not use this when:
- The task is not on this Mac or not using the same Clash Verge Rev layout.
- The user only wants a status check; use
skills/macos-clash-atrust-network-check/SKILL.mdfirst. - The request is really about editing aTrust internals rather than Clash routing.
Inputs / context to gather
- Confirm the active proxy port in this session with
scutil --proxyand/or current evidence. This memory set has seen both127.0.0.1:7890and127.0.0.1:7897. - Identify the exact traffic goal:
- OpenAI / ChatGPT should use
🔰 选择节点 - Codex provider
39.170.58.150:8888should beDIRECT - Domestic services like Yuque / WPS / QQ / WeChat / Apple China should be
DIRECT - Google / Gemini should use
🔰 选择节点
- OpenAI / ChatGPT should use
- Find the persistent profile file(s) under
~/Library/Application Support/io.github.clash-verge-rev.clash-verge-rev/profiles/, especiallyMerge.yamlor the current generated profile such asr4jYYhuWOj2w.yaml. - Locate runtime evidence:
clash-verge.yaml/tmp/verge/verge-mihomo.socklogs/service/service_latest.log
Procedure
- Inspect the current rule placement before editing.
- Read the relevant
profiles/*.yamlfile(s). - Check whether explicit direct/proxy rules already exist and whether they are in
prependor are being shadowed by a subscriptionMATCH.
- Read the relevant
- Decide the minimal rule set needed.
- For Codex provider, prefer
IP-CIDR,39.170.58.150/32,DIRECT,no-resolve. - For OpenAI/ChatGPT family, include
openai.com,chatgpt.com,oaistatic.com,oaiusercontent.com, and optionallychatgpt.livekit.cloud. - For Google/Gemini, include
google.com,googleapis.com,gstatic.com,googleusercontent.com,gvt1.com,gvt2.com,developers.google.com,gemini.google.com. - For domestic direct routing, include
yuque.com,kdocs.cn,wps.cn,qq.com,weixin.qq.com,icloud.com.cn, and related business domains when relevant.
- For Codex provider, prefer
- Put explicit routing in
prepend, notappend.- Keep direct or proxy rules that must beat
MATCHnear the top. - Avoid adding a new
append: MATCHif the subscription already provides a catch-all.
- Keep direct or proxy rules that must beat
- Provide the change in the user’s preferred form.
- If you are editing locally, update the persistent profile file with the minimal validated change set.
- If the user wants a copyable config, return a complete syntax-safe block rather than a partial snippet.
- Reload or re-read the runtime config if the environment supports it.
- Verify the edited rules appear in
clash-verge.yaml. - If node health is in question, inspect
/proxiesthrough/tmp/verge/verge-mihomo.sockand note the current🔰 选择节点.
- Verify the edited rules appear in
- Validate with destination-specific checks.
api.openai.com/v1/modelsthrough the proxy should return a fast401 Unauthorized.39.170.58.150:8888should return401quickly and logs should showmatch IPCIDR(39.170.58.150/32) using DIRECT.- Yuque should show
match DomainSuffix(yuque.com) using DIRECTand ideally return200. - OpenAI/ChatGPT/Google should show
using 🔰 选择节点.
Efficiency plan
- Start with the user’s routing goal and inspect only the one or two profile files that actually feed the current runtime config.
- Prefer log validation over broad retesting; Mihomo logs answer "which rule won?" faster than repeated curl experiments.
- Use a small proven rule set first, then expand only if the user names more services.
- Stop once the logs show the intended rule match and the destination-specific success criterion is met.
Pitfalls and fixes
- Rules in
appenddo nothing- Likely cause: the subscription’s existing
MATCHcatches traffic first. - Fix: move explicit direct/proxy rules into
prepend.
- Likely cause: the subscription’s existing
- The YAML "保存不了,报错了"
- Likely cause: incomplete snippet or invalid structure for this profile layout.
- Fix: return a complete copyable block with minimal validated changes.
- OpenAI still looks broken after the edit
- Likely cause: you used the wrong success criterion or the wrong port/current profile.
- Fix: verify the active proxy port, then check for a fast
401fromapi.openai.com/v1/modelsand confirm the Mihomo log showsmatch DomainSuffix(openai.com) using 🔰 选择节点.
- Codex provider still feels slow even though the provider IP is reachable
- Likely cause: the provider endpoint is being sent through the proxy instead of
DIRECT. - Fix: confirm
IP-CIDR,39.170.58.150/32,DIRECT,no-resolvewins in logs.
- Likely cause: the provider endpoint is being sent through the proxy instead of
- Node problems and rule problems are getting mixed together
- Likely cause: a healthy port or successful reload is being mistaken for healthy routing.
- Fix: validate both rule match and node quality; inspect
/proxiesif requests still stall.
Verification checklist
- You identified the active proxy port and current profile file before editing.
- Any must-win routing rules were placed in
prepend. - You preserved the domestic direct / foreign proxy intent when that was the user’s goal.
- You validated with the right success signal for the target service, not a generic HTTP check.
- If you claimed the fix persists, you updated the persistent profile file rather than only the runtime config.