Hand-writing hundreds of rules is unrealistic. Rule providers externalize rules into standalone files - community-maintained, auto-updating - referenced by a single RULE-SET line. This is a Premium-core feature, built into Clash for Windows.

Basic structure

rule-providers:
  cn-domains:
    type: http
    behavior: domain
    url: "https://example.com/rules/cn-domains.yaml"
    path: ./ruleset/cn-domains.yaml
    interval: 86400

rules:
  - RULE-SET,cn-domains,DIRECT
  - GEOIP,CN,DIRECT
  - MATCH,Select
  • type: http downloads from the URL and refreshes every interval seconds; type: file reads a local file.
  • path is the local cache location - each provider needs a distinct path or they overwrite each other.

The three behaviors

behaviorFile contentsEquivalent rules
domainPlain domain list (+.google.com)DOMAIN / DOMAIN-SUFFIX
ipcidrPlain CIDR list (8.8.8.0/24)IP-CIDR
classicalFull rule lines (type,content)Any mixture

The behavior must match the file's actual format, or the whole set silently does nothing - the number-one cause of "my rule set isn't working".

Community-maintained sets

Widely used collections (e.g. Loyalsoldier/clash-rules) offer well-categorized, daily-updated domain and IP lists. When choosing, look at update frequency, category granularity, and whether domain/ipcidr formats are provided separately. Combining the usual categories (cn, proxy, reject, private, telegram, …) yields a mature routing setup - full example in the classic split guide.

Updates and debugging

  • Provider status is visible in the client; provider ... initial failed in the logs means the download failed.
  • The rule-set URL itself may require the proxy: connect through any working node first, then reload the profile.
Tip: RULE-SET lines and ordinary rules mix freely, still top-down. Put personal rules above the RULE-SET lines to override individual entries.