Why Clash rule-providers are useful for custom rules

A small custom rule list is easy to maintain while it lives in your local configuration. The maintenance burden changes once the list grows, several devices need the same policy, or you want to update rules without repeatedly editing and re-importing a full Clash profile. Rule providers separate the rule data from the main configuration: the profile declares where a list comes from, how to interpret it, where the client can cache it, and how often to refresh it. Your ordinary rules section then refers to the list by name with a RULE-SET entry.

This separation is useful for domain lists that change independently of proxy groups and DNS settings. For example, you might keep development services in one provider, media domains in another, and a carefully reviewed set of direct-connect exceptions in a third. The profile remains readable because its routing policy is visible in one place, while the list contents can be reviewed and updated separately. It also makes reuse easier: the same provider file can be referenced by multiple profiles, provided each profile defines a compatible provider and routing target.

A provider is not a new proxy group, an automatic traffic detector, or a guarantee that every matching request will use the same route forever. It supplies rules to the core; the main configuration still decides which group receives matching traffic, and rule order still determines which rule gets the first opportunity to match. That distinction matters when you investigate why a domain went DIRECT even though it appears in a remote list. The provider may have loaded correctly, but an earlier rule could have matched first.

ℹ Compatibility: Rule-provider fields and supported behaviors depend on the core bundled with your client. Check that the active core supports the syntax you plan to use; a familiar interface does not necessarily mean two Clash-based clients run identical core versions.

The examples below use Mihomo-style configuration. Check the documentation for your active core before copying them into a production profile, especially if you use an older Clash client or a fork with a different rule-provider implementation. Keep a known-good local copy of your profile before making changes, and test a new provider with a small list before moving an important traffic category to it.

Host and structure a rule list on GitHub

A public GitHub repository offers a convenient place to review and version-control custom lists. Create a repository or choose one you already maintain, then put each list in a clearly named directory. Use a descriptive filename such as domains.yaml rather than a name that reveals little about the policy. Separate lists by purpose rather than combining unrelated domains: a narrowly scoped provider is easier to inspect, test, and roll back when one entry causes an unexpected route.

The contents must agree with the provider’s declared behavior. For a domain provider, use domain entries in the format supported by your core; for instance, a suffix entry can represent a domain and its subdomains. A classical provider instead contains complete Clash rule expressions, such as a domain-suffix rule. Do not place classical rule expressions into a provider declared with domain behavior and expect the core to interpret them as interchangeable. The file format is part of the configuration contract, not just a stylistic choice.

payload:
  - "+.dev.example"
  - "+.packages.example"
  - "+.status.example"

The example is intentionally short. Replace the placeholder domains with entries you have a reason to route, and verify that each entry is valid for the behavior you selected. Avoid putting an entire vendor’s unrelated properties into a single broad suffix simply because it is easy to type. A vendor may use separate domains for authentication, documentation, downloads, and APIs; those services can have different routing requirements. Smaller lists make it easier to find the entry responsible when a service stops working.

After committing the file, construct its raw URL from the repository owner, repository name, branch, and file path. GitHub’s ordinary file page is designed for browsing and includes a user interface; the raw endpoint returns the file contents that a provider fetch expects. Confirm the URL in a private browser window or with a simple HTTP request. Check that the response contains the YAML payload rather than a sign-in page, a repository page, a not-found message, or an HTML error document. Public access is important for unauthenticated clients: do not assume a profile can use your personal GitHub login to retrieve a private repository.

A branch-based raw URL is convenient because a new commit can update the list without changing the profile. That convenience also means the content at the URL can change later. Review pull requests, inspect diffs, and keep commits attributable to a maintainer you trust. For a critical environment, consider pinning the provider to a reviewed revision and deliberately updating the reference when you approve a change. A mutable branch is operationally simple; a pinned revision gives you a clearer record of exactly which rules were deployed.

Treat the repository as a small configuration supply chain. Limit write access, protect the default branch where practical, and avoid accepting changes that have not been reviewed. A malformed list can prevent updates, while a syntactically valid but overbroad entry can silently redirect traffic. Keep a known-good commit available so you can restore it quickly. If multiple people maintain the list, document the purpose and expected format near the repository files, and use focused commits so a reviewer can understand whether a change adds one intended exception or rewrites the policy wholesale.

Configure refresh intervals and RULE-SET order

Declare the provider under rule-providers and reference its name from the main rules list. In this example, the provider uses a public raw URL, domain behavior, a local cache path, and a one-day refresh interval. The proxy group name is only an example: use a group that actually exists in your profile. A provider definition by itself does not route traffic; the corresponding RULE-SET line connects matching entries to a policy.

rule-providers:
  development:
    type: http
    behavior: domain
    url: "https://raw.githubusercontent.com/OWNER/REPO/refs/heads/main/rules/development.yaml"
    path: ./ruleset/development.yaml
    interval: 86400

rules:
  - RULE-SET,development,Developer-Proxy
  - MATCH,Other-Traffic

The interval is measured in seconds in this style of configuration, so 86400 represents one day. Set a cadence that fits the list’s rate of change rather than choosing the smallest value available. A frequently edited list may need a shorter refresh window; a stable list usually does not benefit from repeated downloads every few minutes. More frequent checks also create more requests and make a transient hosting or network issue more likely to coincide with an update attempt. Follow the active core’s documentation for the exact refresh semantics and defaults.

The path identifies the local file used for the provider. Choose a distinct, descriptive path for each provider and ensure the core can write to its parent directory. Reusing one cache path for several providers can produce confusing results, particularly when they have different formats or update schedules. Relative paths are commonly resolved from the core’s working or configuration directory, which may not be the folder you expect when a GUI manages profiles. If a provider works on one device but fails on another, compare the actual profile location, permissions, and core logs rather than assuming the YAML itself is different.

Rule order is a policy decision. Clash evaluates the rules from top to bottom and uses the first matching rule, so put a provider reference before a broader rule that would otherwise catch the same traffic. If a general domain suffix rule appears first, a narrower provider entry may never get a chance to select its intended group. Conversely, placing every provider at the very top without considering exceptions can override a deliberate local rule. Write down the intended precedence: for example, local safety exceptions first, narrowly scoped custom providers next, built-in or general categories after that, and a final catch-all last.

A provider match also depends on the kind of information the rule engine evaluates. Domain rules are useful when the request is identified by a hostname; they do not automatically describe every IP address a service may use. IP-based policies need an appropriate IP-CIDR provider behavior and compatible entries. Classical providers can express multiple rule types, but they need correctly formatted rules and should be used only when that flexibility is necessary. Do not switch behaviors merely to silence an error: first identify what the list contains and what kind of match you actually need.

When you add a provider to an existing profile, preserve the existing policy unless you mean to change it. A useful test is to inspect one domain that should match, one similar domain that should not, and one domain handled by a broader rule. Check the active connection or rule log to confirm which rule was selected and which proxy group was used. This catches two common mistakes: the provider is loaded but placed too low in the order, or it matches as intended but points to a group name that does not represent the route you expected.

Diagnose provider loading and update failures

Start by separating configuration parsing from network retrieval. If the profile fails to load or reports a YAML error, inspect indentation, quote characters, commas, and nesting before investigating GitHub connectivity. The provider must be nested under the right top-level key, and the RULE-SET reference must use the exact provider name defined above. YAML indentation is meaningful; a key shifted one level can change the configuration structure even when the text looks nearly correct at a glance.

If the profile loads but the provider is missing or marked unhealthy, inspect the core’s logs and test the raw URL independently. A 404 usually points to a wrong owner, repository, branch, or path. An HTML response instead of the expected YAML may mean you used the ordinary GitHub page or reached an error page. A timeout can indicate DNS trouble, a blocked or unavailable route, a temporary hosting issue, or a client that cannot reach the endpoint through its current network. Confirm that the URL is publicly accessible and that the file is committed to the branch named in the URL.

Next, check the local cache and filesystem permissions. A valid remote file can still fail to become an active provider if the core cannot create or update the configured cache path. GUI clients may run the core from a managed directory, use a generated profile, or restrict access to files outside an application folder. Confirm the resolved location in the client’s logs where possible, then choose a writable path supported by the client. Avoid manually editing a generated cache file as a permanent fix: the next refresh may overwrite it, and the source of truth remains the remote list.

If an update succeeds but traffic takes an unexpected route, verify the full chain rather than repeatedly changing the URL. Confirm that the active profile includes the provider definition, the provider has loaded the latest entries, the matching rule appears before competing broad rules, and the target proxy group exists. Then inspect the connection details for the hostname or IP actually used by the application. A browser may contact a separate API, identity, or content-delivery domain that is not in the list you tested. The visible website name alone is not proof that every request uses that hostname.

Stale content deserves its own check. A successful fetch does not necessarily mean the file changed; the repository may still contain the old commit, the URL may point to another branch, or a local cache may not yet have refreshed. Compare the expected entry with the file served at the raw URL, then review the provider’s update status and refresh interval. If the client offers a manual provider update action, use it after verifying the source URL, and read the resulting log message. Repeatedly restarting the whole client can obscure whether the failure came from fetching, parsing, caching, or rule evaluation.

Keep changes reversible while diagnosing. Save a copy of the last working profile, make one targeted change at a time, and test the same representative connections after each change. If a recent list update caused a regression, revert the repository commit or temporarily remove that provider reference to establish whether it is responsible. Record the affected URL, core version, provider behavior, refresh interval, and relevant log message. That evidence is more useful than a vague report that “custom rules stopped working,” especially when the failure only appears on one client or one network.

⚠ Review remote changes: A remote provider can change routing without a full profile edit. Treat list updates as policy changes: review the diff, protect the source repository, and retain a rollback point before relying on automatic refresh in a shared or managed environment.

A custom provider workflow is most reliable when the list is small enough to understand, the hosting URL is tested, the declared behavior matches the payload, and the rule order expresses a deliberate policy. Some lightweight clients make remote lists harder to audit or offer fewer details about core errors; hand-editing a large local profile can be just as difficult to keep consistent across devices. Clash V.CORE provides a practical place to manage Clash-based profiles and inspect routing behavior while you refine that workflow. If you want to test your GitHub-hosted rule sets in a maintained client, download Clash V.CORE and begin with a backed-up profile and one focused provider.