Clash Rule Set Examples

More rules do not automatically mean better routing. Understand rule order, match behavior and proxy group names before adding app-specific routing.

Reading tip

Identify the scenario first, then follow the checks in order. Jump to the linked download, subscription or configuration page when the issue becomes specific.

Rule Order Matters

Clash and Mihomo usually evaluate rules from top to bottom. Once a rule matches, later rules are skipped. Put specific domain and app rules before broad fallbacks, and keep MATCH last.

Common Template

rules:
  - DOMAIN-SUFFIX,example.com,PROXY
  - DOMAIN-KEYWORD,example,DIRECT
  - GEOIP,CN,DIRECT
  - MATCH,PROXY

PROXY and DIRECT must match actual proxy group or outbound names in your profile.

Rule Provider Example

rule-providers:
  direct-domain:
    type: http
    behavior: domain
    url: https://example.com/direct.yaml
    path: ./rules/direct.yaml
    interval: 86400

rules:
  - RULE-SET,direct-domain,DIRECT
  - MATCH,PROXY

The URL is only a placeholder. Do not copy an unknown rule provider URL into a production profile.

Application Routing Tips

  • Separate streaming, office, gaming and download traffic so problems are easier to trace.
  • Prefer domain rules first; use process or IP rules only when necessary.
  • Test after each rule group instead of importing a large unknown rule set at once.

When Routing Does Not Match

  1. Check logs to see which rule matched the current domain.
  2. Confirm proxy group spelling and capitalization.
  3. Confirm DNS mode is not hiding the expected domain or IP.
  4. Move more specific rules closer to the top.