/clash-routes
查看指定进程的代理线路。通过 Mihomo API 查询当前活跃连接,显示进程匹配的规则和代理链路。用于确认某个进程(如 claude、chrome)走的是哪条订阅线路
$ npx -y skills add majiayu000/spellbook --skill clash-routes --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
- Fires itselfAuto-invocation. Claude auto-loads it when your prompt matches the work.Auto-invocation is when the right skill fires by itself at the right moment, driven by a FLOW.md router and a hook, instead of you invoking it by name. It is the difference between a skill being installed and a skill actually getting used.Read the full definition →
- You can call itInvoke it directly when you want it.
- Slash command
/clash-routes
Context preview
The summary Claude sees to decide when to auto-load this skill.
查看指定进程的代理线路。通过 Mihomo API 查询当前活跃连接,显示进程匹配的规则和代理链路。用于确认某个进程(如 claude、chrome)走的是哪条订阅线路
SKILL.md
clash-routes.SKILL.mdname: clash-routes
description: 查看指定进程的代理线路。通过 Mihomo API 查询当前活跃连接,显示进程匹配的规则和代理链路。用于确认某个进程(如 claude、chrome)走的是哪条订阅线路
allowed-tools: Bash
metadata:
argument-hint: "[进程名,默认显示全部]"
Clash 线路查看工具
查看当前活跃连接的代理线路信息,确认指定进程走的是哪条订阅/代理链。
用户传入的参数:$ARGUMENTS 如果用户没有传入参数,显示所有活跃连接(按进程分组)。
执行流程
第一步:获取 Mihomo API 凭证
读取 Clash Verge 配置获取 API 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}')
echo "Secret: ${SECRET:-(未找到)}"第二步:查询连接信息
优先使用 Unix socket,fallback 到 HTTP:
# Unix socket 方式(Clash Verge Rev)
SOCKET="/var/tmp/verge/verge-mihomo.sock"
if [ -S "$SOCKET" ]; then
CONNECTIONS=$(curl -s --unix-socket "$SOCKET" "http://localhost/connections" -H "Authorization: Bearer $SECRET" 2>/dev/null)
else
# HTTP fallback
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 "'\"")
[ -z "$CONTROLLER" ] && CONTROLLER="127.0.0.1:9090"
CONNECTIONS=$(curl -s "http://$CONTROLLER/connections" -H "Authorization: Bearer $SECRET" 2>/dev/null)
fi第三步:解析并展示线路
用 Python 解析 JSON,按进程分组显示:
import json, sys
data = json.loads(sys.stdin.read())
connections = data.get("connections", [])
# 过滤进程名(如果指定了参数)
process_filter = "参数中的进程名" # 从 $ARGUMENTS 获取
results = []
for conn in connections:
meta = conn.get("metadata", {})
process = meta.get("process", "unknown")
host = meta.get("host", "") or meta.get("destinationIP", "")
port = meta.get("destinationPort", "")
rule = conn.get("rule", "") + ("/" + conn.get("rulePayload", "") if conn.get("rulePayload") else "")
chains = conn.get("chains", [])
network = meta.get("network", "")
if process_filter and process_filter.lower() not in process.lower():
continue
results.append({
"process": process,
"host": f"{host}:{port}" if port else host,
"rule": rule,
"chains": " → ".join(reversed(chains)) if chains else "DIRECT",
"network": network.upper(),
})
# 按进程分组
from collections import defaultdict
grouped = defaultdict(list)
for r in results:
grouped[r["process"]].append(r)
for process, conns in sorted(grouped.items()):
print(f"\n{'='*60}")
print(f"进程: {process} ({len(conns)} 个连接)")
print(f"{'='*60}")
# 按链路去重统计
chain_stats = defaultdict(lambda: {"count": 0, "hosts": set()})
for c in conns:
key = f"{c['rule']} → {c['chains']}"
chain_stats[key]["count"] += 1
chain_stats[key]["hosts"].add(c["host"])
for route, info in sorted(chain_stats.items(), key=lambda x: -x[1]["count"]):
print(f" 线路: {route}")
print(f" 连接数: {info['count']}")
hosts = sorted(info["hosts"])
if len(hosts) <= 5:
print(f" 目标: {', '.join(hosts)}")
else:
print(f" 目标: {', '.join(hosts[:5])} ... (+{len(hosts)-5})")
print()完整的一键执行命令
将上面的步骤组合成一个完整的 bash 命令执行:
SECRET=$(grep '^secret:' "$HOME/Library/Application Support/io.github.clash-verge-rev.clash-verge-rev/clash-verge.yaml" 2>/dev/null | awk '{print $2}')
SOCKET="/var/tmp/verge/verge-mihomo.sock"
FILTER="$ARGUMENTS"
if [ -S "$SOCKET" ]; then
DATA=$(curl -s --unix-socket "$SOCKET" "http://localhost/connections" -H "Authorization: Bearer $SECRET" 2>/dev/null)
else
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 "'\"")
[ -z "$CONTROLLER" ] && CONTROLLER="127.0.0.1:9090"
DATA=$(curl -s "http://$CONTROLLER/connections" -H "Authorization: Bearer $SECRET" 2>/dev/null)
fi
if [ -z "$DATA" ] || echo "$DATA" | python3 -c "import sys,json; json.load(sys.stdin)" 2>/dev/null; [ $? -ne 0 ]; then
# 验证 JSON 有效性
:
fi
echo "$DATA" | python3 -c "
import json, sys
from collections import defaultdict
data = json.loads(sys.stdin.read())
conns = data.get('connections', [])
filt = '$FILTER'.strip().lower()
results = []
for c in conns:
m = c.get('metadata', {})
proc = m.get('process', 'unknown')
if filt and filt not in proc.lower():
continue
host = m.get('host', '') or m.get('destinationIP', '')
port = m.get('destinationPort', '')
rule = c.get('rule', '')
rp = c.get('rulePayload', '')
if rp:
rule += '/' + rp
chains = c.get('chains', [])
chain_str = ' → '.join(reversed(chains)) if chains else 'DIRECT'
results.append({'process': proc, 'host': f'{host}:{port}' if port else host, 'rule': rule, 'chains': chain_str})
grouped = defaultdict(list)
for r in results:
grouped[r['process']].append(r)
if not grouped:
target = filt if filt else '任何进程'
print(f'未找到 {target} 的活跃连接')
sys.exit(0)
total = sum(len(v) for v in grouped.values())
print(f'共 {total} 个活跃连接,涉及 {len(grouped)} 个进程')
for proc, pconns in sorted(grouped.items()):
print(f'\n{\"=\"*60}')
print(f'进程: {proc} ({len(pconns)} 个连接)')
print(f'{\"=\"*60}')
chain_stats = defaultdict(lambda: {'count': 0, 'hosts': set()})
for c in pconns:
key = f'{c[\"rule\"]} → {c[\"chains\"]}'
chain_stats[key]['count'] += 1
chain_stats[key]['hosts'].add(c['host'])
for route, info in sorted(chain_stats.items(), key=lambda x: -x[1]['count']):
print(f' 线路: {route}')
print(f' 连接数: {info[\"count\"]}')
hosts = sorted(info['hosts'])
if len(hosts) <= 5:
print(f' 目标: {\", \".join(hosts)}')
else:
print(f' 目标: {\", \".join(hosts[:5])} ... (+{len(hosts)-5})')
print()
"输出格式
按进程分组,每个进程显示:
- **线路**:匹配规则 → 代理链路(如 `ProcessName/claude → 🤖 AI → 🇯🇵 日本 东京`)
- **连接数**:该线路上的活跃连接数量
- **目标**:连接的目标域名/IP
使用示例
- `/clash-routes` - 查看所有进程的线路
- `/clash-routes claude` - 只看 claude 进程
- `/clash-routes chrome` - 只看 chrome 进程
Read more
name: clash-routes description: 查看指定进程的代理线路。通过 Mihomo API 查询当前活跃连接,显示进程匹配的规则和代理链路。用于确认某个进程(如 claude、chrome)走的是哪条订阅线路 allowed-tools: Bash metadata: argument-hint: "[进程名,默认显示全部]"
Clash 线路查看工具
查看当前活跃连接的代理线路信息,确认指定进程走的是哪条订阅/代理链。
用户传入的参数:$ARGUMENTS 如果用户没有传入参数,显示所有活跃连接(按进程分组)。
执行流程
第一步:获取 Mihomo API 凭证
读取 Clash Verge 配置获取 API 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}')
echo "Secret: ${SECRET:-(未找到)}"第二步:查询连接信息
优先使用 Unix socket,fallback 到 HTTP:
# Unix socket 方式(Clash Verge Rev)
SOCKET="/var/tmp/verge/verge-mihomo.sock"
if [ -S "$SOCKET" ]; then
CONNECTIONS=$(curl -s --unix-socket "$SOCKET" "http://localhost/connections" -H "Authorization: Bearer $SECRET" 2>/dev/null)
else
# HTTP fallback
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 "'\"")
[ -z "$CONTROLLER" ] && CONTROLLER="127.0.0.1:9090"
CONNECTIONS=$(curl -s "http://$CONTROLLER/connections" -H "Authorization: Bearer $SECRET" 2>/dev/null)
fi第三步:解析并展示线路
用 Python 解析 JSON,按进程分组显示:
import json, sys
data = json.loads(sys.stdin.read())
connections = data.get("connections", [])
# 过滤进程名(如果指定了参数)
process_filter = "参数中的进程名" # 从 $ARGUMENTS 获取
results = []
for conn in connections:
meta = conn.get("metadata", {})
process = meta.get("process", "unknown")
host = meta.get("host", "") or meta.get("destinationIP", "")
port = meta.get("destinationPort", "")
rule = conn.get("rule", "") + ("/" + conn.get("rulePayload", "") if conn.get("rulePayload") else "")
chains = conn.get("chains", [])
network = meta.get("network", "")
if process_filter and process_filter.lower() not in process.lower():
continue
results.append({
"process": process,
"host": f"{host}:{port}" if port else host,
"rule": rule,
"chains": " → ".join(reversed(chains)) if chains else "DIRECT",
"network": network.upper(),
})
# 按进程分组
from collections import defaultdict
grouped = defaultdict(list)
for r in results:
grouped[r["process"]].append(r)
for process, conns in sorted(grouped.items()):
print(f"\n{'='*60}")
print(f"进程: {process} ({len(conns)} 个连接)")
print(f"{'='*60}")
# 按链路去重统计
chain_stats = defaultdict(lambda: {"count": 0, "hosts": set()})
for c in conns:
key = f"{c['rule']} → {c['chains']}"
chain_stats[key]["count"] += 1
chain_stats[key]["hosts"].add(c["host"])
for route, info in sorted(chain_stats.items(), key=lambda x: -x[1]["count"]):
print(f" 线路: {route}")
print(f" 连接数: {info['count']}")
hosts = sorted(info["hosts"])
if len(hosts) <= 5:
print(f" 目标: {', '.join(hosts)}")
else:
print(f" 目标: {', '.join(hosts[:5])} ... (+{len(hosts)-5})")
print()完整的一键执行命令
将上面的步骤组合成一个完整的 bash 命令执行:
SECRET=$(grep '^secret:' "$HOME/Library/Application Support/io.github.clash-verge-rev.clash-verge-rev/clash-verge.yaml" 2>/dev/null | awk '{print $2}')
SOCKET="/var/tmp/verge/verge-mihomo.sock"
FILTER="$ARGUMENTS"
if [ -S "$SOCKET" ]; then
DATA=$(curl -s --unix-socket "$SOCKET" "http://localhost/connections" -H "Authorization: Bearer $SECRET" 2>/dev/null)
else
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 "'\"")
[ -z "$CONTROLLER" ] && CONTROLLER="127.0.0.1:9090"
DATA=$(curl -s "http://$CONTROLLER/connections" -H "Authorization: Bearer $SECRET" 2>/dev/null)
fi
if [ -z "$DATA" ] || echo "$DATA" | python3 -c "import sys,json; json.load(sys.stdin)" 2>/dev/null; [ $? -ne 0 ]; then
# 验证 JSON 有效性
:
fi
echo "$DATA" | python3 -c "
import json, sys
from collections import defaultdict
data = json.loads(sys.stdin.read())
conns = data.get('connections', [])
filt = '$FILTER'.strip().lower()
results = []
for c in conns:
m = c.get('metadata', {})
proc = m.get('process', 'unknown')
if filt and filt not in proc.lower():
continue
host = m.get('host', '') or m.get('destinationIP', '')
port = m.get('destinationPort', '')
rule = c.get('rule', '')
rp = c.get('rulePayload', '')
if rp:
rule += '/' + rp
chains = c.get('chains', [])
chain_str = ' → '.join(reversed(chains)) if chains else 'DIRECT'
results.append({'process': proc, 'host': f'{host}:{port}' if port else host, 'rule': rule, 'chains': chain_str})
grouped = defaultdict(list)
for r in results:
grouped[r['process']].append(r)
if not grouped:
target = filt if filt else '任何进程'
print(f'未找到 {target} 的活跃连接')
sys.exit(0)
total = sum(len(v) for v in grouped.values())
print(f'共 {total} 个活跃连接,涉及 {len(grouped)} 个进程')
for proc, pconns in sorted(grouped.items()):
print(f'\n{\"=\"*60}')
print(f'进程: {proc} ({len(pconns)} 个连接)')
print(f'{\"=\"*60}')
chain_stats = defaultdict(lambda: {'count': 0, 'hosts': set()})
for c in pconns:
key = f'{c[\"rule\"]} → {c[\"chains\"]}'
chain_stats[key]['count'] += 1
chain_stats[key]['hosts'].add(c['host'])
for route, info in sorted(chain_stats.items(), key=lambda x: -x[1]['count']):
print(f' 线路: {route}')
print(f' 连接数: {info[\"count\"]}')
hosts = sorted(info['hosts'])
if len(hosts) <= 5:
print(f' 目标: {\", \".join(hosts)}')
else:
print(f' 目标: {\", \".join(hosts[:5])} ... (+{len(hosts)-5})')
print()
"输出格式
按进程分组,每个进程显示:
- **线路**:匹配规则 → 代理链路(如 `ProcessName/claude → 🤖 AI → 🇯🇵 日本 东京`)
- **连接数**:该线路上的活跃连接数量
- **目标**:连接的目标域名/IP
使用示例
- `/clash-routes` - 查看所有进程的线路
- `/clash-routes claude` - 只看 claude 进程
- `/clash-routes chrome` - 只看 chrome 进程
Cross-runtime skills for Claude Code, Codex, and multi-agent workflows.
Repo: majiayu000/spellbook
Other skills on spellbook.
- /agentsmd-optimize
Audit AND optimize a CLAUDE.md / AGENTS.md instruction file — score it against the five high-leverage patterns, flag anti-patterns, then apply approved fixes in place. Use when the user says 优化 CLAUDE.md / 优化 AGENTS.md / optimize my agent doc / 帮我改 claudemd, or after an audit
Open skill - /agentsmd-scaffold
Generate or update repository-specific AGENTS.md instruction files from real repo evidence. Use when asked to create, design, scaffold, split, or improve root or scoped AGENTS.md files for Codex/Claude/agent workflows, especially when a repo needs directory-specific rules,
Open skill - /api-design
REST/GraphQL/gRPC API design best practices. Use when designing APIs, defining contracts, handling versioning. Covers OpenAPI 3.2, GraphQL Federation, gRPC streaming.
Open skill - /app-ui-design
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.
Open skill - /app-user-story-qa
End-to-end app feature inventory and user-story testing workflow with a canonical tracker. Use when the user asks to audit every feature, derive expected behavior from code, test user journeys, or explicitly fix and retest documented UX or logistical defects.
Open skill - /architecture-foundation
Design architecture foundations before implementation. Use when asked to design or refactor architecture, choose Rust/Go crate, package, module, runtime, workflow, or service boundaries, compare mature project architecture, prevent stacked one-off PRs, audit migration debt in
Open skill

