
clash-routes
查看本机进程的 Mihomo 实时代理链。当用户问 Claude、Codex、Gemini、ChatGPT、 浏览器或其他进程走哪个代理时使用。只读。Profile 拓扑和写入使用 clash-doctor, 出口 IP 质量使用 ip-check。
- Installs
- 67
- Last 24h
- —
- Trending rank
- —
- Security
- Not audited
Install
Works with every agent the skills CLI supports.
npx skills add https://github.com/majiayu000/spellbook --skill clash-routes- 01
Install
Run the command in your project. The CLI asks which agents to install for.
- 02
Describe the task
Ask your agent for something this skill covers. It loads clash-routes automatically when relevant.
- 03
Review the result
The agent follows the SKILL.md steps, scripts and references bundled with the skill.
SKILL.md
The instructions your agent reads when the skill is triggered.
Clash 线路查看工具
查看本机当前活跃连接,确认指定进程命中的规则、策略组与真实出口。不接受 SSH 参数;远程机器应先通过 Tailscale SSH 登录,再在目标机器执行同一只读流程。
用户传入的参数:$ARGUMENTS。没有参数时列出所有活跃连接。诊断 Gemini、ChatGPT 或浏览器流量时,先不加过滤获取实际 metadata.process,再使用观察到的进程名;不要假定它们属于 claude。
获取凭证
读取 Clash Verge 配置,但不要打印 secret:
SECRET=$(grep '^secret:' "$HOME/Library/Application Support/io.github.clash-verge-rev.clash-verge-rev/clash-verge.yaml" 2>/dev/null | awk '{print $2}')
[ -z "$SECRET" ] && SECRET=$(grep '^secret:' "$HOME/.config/clash/config.yaml" 2>/dev/null | awk '{print $2}')
[ -n "$SECRET" ] && echo "API secret: configured" || echo "API secret: not configured"
查询与回退
请求成功才采用该 endpoint。/tmp socket 存在但失效时继续尝试 /var/tmp,最后尝试配置的 HTTP controller。所有 endpoint 都失败时明确报错,不返回空数据。
request_connections() {
for socket_path in \
/tmp/verge/verge-mihomo.sock \
/var/tmp/verge/verge-mihomo.sock
do
[ -S "$socket_path" ] || continue
if curl --fail --silent --show-error \
--unix-socket "$socket_path" \
"http://localhost/connections" \
-H "Authorization: Bearer $SECRET"
then
return 0
fi
done
controller=$(grep '^external-controller:' "$HOME/Library/Application Support/io.github.clash-verge-rev.clash-verge-rev/clash-verge.yaml" 2>/dev/null | awk '{print $2}' | tr -d "'\"")
[ -n "$controller" ] || controller="127.0.0.1:9090"
curl --fail --silent --show-error \
"http://$controller/connections" \
-H "Authorization: Bearer $SECRET"
}
if ! DATA=$(request_connections); then
echo "无法从 Mihomo Unix socket 或 HTTP controller 获取连接数据" >&2
exit 1
fi
if ! printf '%s' "$DATA" | python3 -c 'import json, sys; value=json.load(sys.stdin); assert isinstance(value.get("connections"), list)' 2>/dev/null; then
echo "Mihomo 返回了无效的 connections JSON" >&2
exit 1
fi
解析并展示
通过环境变量传递过滤值,避免把用户输入插进 Python 源码:
printf '%s' "$DATA" | FILTER="$ARGUMENTS" python3 -c '
import json
import os
import sys
from collections import defaultdict
data = json.load(sys.stdin)
process_filter = os.environ.get("FILTER", "").strip().lower()
results = []
for connection in data.get("connections", []):
metadata = connection.get("metadata", {})
process = metadata.get("process", "unknown")
if process_filter and process_filter not in process.lower():
continue
host = metadata.get("host", "") or metadata.get("destinationIP", "")
port = metadata.get("destinationPort", "")
rule = connection.get("rule", "")
payload = connection.get("rulePayload", "")
if payload:
rule += "/" + payload
chains = connection.get("chains", [])
chain_text = " → ".join(reversed(chains)) if chains else "DIRECT"
results.append({
"process": process,
"host": f"{host}:{port}" if port else host,
"rule": rule,
"chain": chain_text,
})
grouped = defaultdict(list)
for result in results:
grouped[result["process"]].append(result)
if not grouped:
target = process_filter or "任何进程"
print(f"未找到 {target} 的活跃连接")
raise SystemExit(0)
for process, connections in sorted(grouped.items()):
print(f"\n进程: {process} ({len(connections)} 个连接)")
route_stats = defaultdict(lambda: {"count": 0, "hosts": set()})
for connection in connections:
key = "{} → {}".format(connection["rule"], connection["chain"])
route_stats[key]["count"] += 1
route_stats[key]["hosts"].add(connection["host"])
for route, info in sorted(route_stats.items(), key=lambda item: -item[1]["count"]):
hosts = sorted(info["hosts"])
shown = ", ".join(hosts[:5])
suffix = f" ... (+{len(hosts) - 5})" if len(hosts) > 5 else ""
print(f" 线路: {route}")
print(" 连接数: {}".format(info["count"]))
print(f" 目标: {shown}{suffix}")
'
解释结果
chains[-1]是命中的策略组,chains[0]是真实出口;展示时反转为“策略组 → 出口”。- Claude 常见进程是
claude或Claude Helper;Codex CLI 常见进程是codex。 - Gemini CLI、ChatGPT 桌面端和浏览器的进程名以未过滤连接表为准。
- Host 只有裸 IP 时,检查
sniffer.parse-pure-ip和系统 DNS 是否绕过 Clash,不要直接改 AI 策略组。 - 当前 profile 不是预期 Hub,或出口仍是原始订阅节点时,报告 drift;本 skill 不修改 YAML。
完成条件
- 至少一个 Mihomo endpoint 返回合法 connections JSON。
- 输出明确显示进程、规则、策略组和出口,或明确说明目标进程当前没有活跃连接。
- 全程只读且没有打印 API secret。
FAQ
What does the clash-routes skill do?
查看本机进程的 Mihomo 实时代理链。当用户问 Claude、Codex、Gemini、ChatGPT、 浏览器或其他进程走哪个代理时使用。只读。Profile 拓扑和写入使用 clash-doctor, 出口 IP 质量使用 ip-check。
How do I install clash-routes?
Run npx skills add https://github.com/majiayu000/spellbook --skill clash-routes in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/clash-routes/ (personal) or .claude/skills/clash-routes/ (project).
Which AI agents can use clash-routes?
Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.
Is clash-routes safe to install?
No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.
Who maintains clash-routes?
It is published by majiayu000 in majiayu000/spellbook. It has 67 recorded installs.
More from majiayu000/spellbook
github-trending
majiayu000/spellbook
GitHub Trending 探索与分析。用于发现热门开源项目、技术趋势、开发者偏好,帮助理解技术社区的兴趣走向。使用场景包括“看看今天 GitHub 什么火了”、“Rust 最近热门项目”、“AI 领域趋势日报”、“这个方向有没有值得关注的开源项目”、“帮我做个 GitHub trending 分析”。
app-ui-design
majiayu000/spellbook
Mobile app UI design expert for iOS and Android. Use when designing app interfaces, creating design systems, ensuring accessibility, or following platform guidelines. Covers Material Design 3, Human Interface Guidelines, color theory, typography, and 2025 trends.
harmonyos-app
majiayu000/spellbook
HarmonyOS application development expert. Use when building HarmonyOS apps with ArkTS, ArkUI, Stage model, and distributed capabilities. Covers HarmonyOS NEXT (API 12+) best practices.
product-discovery
majiayu000/spellbook
Product discovery and market research expert. Use when validating product ideas, conducting market research, user interviews, competitive analysis, or opportunity assessment. Covers JTBD, Kano model, and Value Proposition Canvas.
technical-spec
majiayu000/spellbook
Open the skill to read its SKILL.md instructions.
Popular ai & agents skills
google-agents-cli-publish
google/agents-cli
This skill should be used when the user wants to "publish an agent", "publish my ADK agent", "register an agent with Gemini", "publish to Gemini" (formerly Gemini Enterprise), or needs guidance on the agents-cli publish gemini command. Also use when the user wants to "manage agents in Agent Registry", "list/update/delete registered agents", or "register an MCP server". Covers ADK vs A2A registration modes, programmatic and interactive usage, flag reference, auto-detection from deployment metadata, Agent Registry fleet management, and troubleshooting. Part of the agents-cli skills suite. Do NOT use for deployment (use google-agents-cli-deploy).
google-agents-cli-eval
google/agents-cli
This skill should be used when the user wants to "run an evaluation", "evaluate my agent", "evaluate my ADK agent", "write an eval dataset", "analyze eval failures", "compare eval results", "optimize agent", or needs guidance on the Gemini platform eval methodology and the Quality Flywheel. Covers eval metrics, dataset schema, LLM-as-judge scoring, and common failure causes. Applies to any agents-cli project, whatever framework the agent is written in. Do NOT use for agent API code patterns (ADK: use google-agents-cli-adk-code), deployment (use google-agents-cli-deploy), or project scaffolding (use google-agents-cli-scaffold).
skill-creator
anthropics/skills
Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy.
codex-pet
prime-skills/runcomfy-agent-skills
Codex Pet generator on RunComfy. Build a Codex-compatible Codex Pet spritesheet.webp + pet.json from a single reference image, drop it into ${CODEXHOME:-$HOME/.codex}/pets/ / and Codex picks it up as a custom Codex Pet next to the 8 built-ins. This skill produces the exact Codex Pet atlas Codex expects (1536x1872 PNG/WebP, 8 cols x 9 rows, 192x208 cells, 9 animation states — idle, running-right, running-left, waving, jumping, failed, waiting, running, review). Calls OpenAI GPT Image 2 edit ONCE via the local RunComfy CLI as runcomfy run openai/gpt-image-2/edit to produce a canonical Codex Pet pose, then assembles all 9 animation rows programmatically with ImageMagick micro-transforms — no Codex Pro, no $imagegen, no OPENAIAPIKEY required, only RUNCOMFYTOKEN. Triggers on "codex pet", "create codex pet", "make codex pet", "hatch codex pet", "/hatch image", "desktop pet codex", "codex pets", "spritesheet.webp", or any explicit ask to build a custom pet for OpenAI Codex.
full-output-enforcement
leonxlnx/taste-skill
Overrides default LLM truncation behavior. Enforces complete code generation, bans placeholder patterns, and handles token-limit splits cleanly. Apply to any task requiring exhaustive, unabridged output.
executing-plans
obra/superpowers
Use when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is available