1. Why rule providers are better than a growing inline rules list
If your Clash profile has accumulated a long sequence of domain exceptions, application routes, and hand-maintained IP ranges, the problem is no longer just how to write one more rule. It is how to keep the whole list understandable, reviewable, and safe to update. A rule provider lets Mihomo load a set of rules from a separate file and refer to that set by name in the main profile. The profile stays focused on policy—what to route, and to which group—while the provider file holds the matching entries.
That separation becomes useful as soon as a ruleset has its own release cycle. A team might update a work-service domain list without touching the rest of the proxy profile. A household might maintain a small set of local exceptions while keeping a larger, shared list in a Git repository. In both cases, a provider creates a clear boundary: the main configuration decides where matching traffic goes; the ruleset decides what traffic matches.
Providers are not a magic way to make every profile safer or simpler. An upstream file can become unavailable, change without review, or contain a rule that shadows a more specific route. A broad domain rule can also match more traffic than its author intended. Treat a ruleset as a small piece of operational code: give it a purpose, review changes, validate its format, and test the resulting route before relying on it.
This workflow targets Mihomo-compatible Clash profiles, including profiles managed with clients such as Clash Verge Rev. Client interfaces differ, but the underlying concepts are the same: configure a provider, reference it with a RULE-SET rule, and place that rule correctly in the ordered rule list. Confirm that your installed core supports the provider options you use; a graphical client and its bundled Mihomo version may not update at the same time.
2. Understand the provider fields and rule-file format
A remote HTTP provider needs a type, a matching behavior, a source URL, a local cache path, and an update interval. The behavior tells Mihomo how to interpret the entries. For example, a domain provider is intended for domain-oriented entries, while a classical provider can contain complete Clash-style rules such as DOMAIN-SUFFIX or PROCESS-NAME. Choose the narrowest behavior that fits the rules you actually need; do not label a mixed list as a domain-only set simply because many of its entries are domains.
The path is a local location used for the downloaded provider data. Keep it inside a directory that survives profile reloads and is writable by the core. Relative paths are convenient, but their resolution depends on the way the client launches Mihomo and on the profile’s working directory. If a provider fails to load despite a reachable URL, check the client’s logs for the resolved file location and filesystem permissions before rewriting the rules.
A YAML ruleset commonly wraps its entries in a payload list. Indentation is structural: use spaces, not tabs, and keep each list item at the same indentation level. When a provider uses a text format instead, follow the format expected by that provider and the core version in use. Do not mix a YAML document containing payload with a plain-text list unless the provider configuration explicitly declares the matching format.
rule-providers:
engineering-sites:
type: http
behavior: classical
url: "https://raw.githubusercontent.com/example-org/network-rules/main/rules/engineering.yaml"
path: ./rule-providers/engineering.yaml
interval: 86400
rules:
- RULE-SET,engineering-sites,Work
- MATCH,General
The names in the example are placeholders. Replace the organization, repository, branch, file path, and policy group with values that exist in your own setup. The provider name, here engineering-sites, is the identifier used by RULE-SET; it is not the URL or the local filename. Keep provider names stable and descriptive, because a rename requires changing every reference in the main rules list.
A corresponding classical YAML file might look like this:
payload:
- DOMAIN-SUFFIX,docs.example.org
- DOMAIN,packages.example.org
- DOMAIN-KEYWORD,engineering-portal
Use exact hostnames or carefully chosen suffixes where possible. A suffix rule for a parent domain can include many subdomains, including services you did not intend to route through the same group. A keyword rule is broader still: it can match a hostname because a character sequence appears within it. Before publishing a rule, write down one hostname it should match and one similar hostname it must not match. That simple negative test often catches an overly broad entry before it affects the whole profile.
3. Host a maintainable ruleset on GitHub
For a small public ruleset, a GitHub repository provides useful history, review, and rollback without requiring a separate server. Keep the provider file in a predictable directory, such as rules/, and use a raw-content URL that points directly to the file rather than to the GitHub page used to browse it. A browser page may return HTML; Mihomo needs the ruleset itself. Test the URL in a browser or with a command-line HTTP client and confirm that the response is the expected file, not a sign-in page, error document, or repository landing page.
A branch URL such as one ending in /main/rules/engineering.yaml follows the latest committed content on that branch. This is convenient when you want routine changes to roll out automatically, but it also means that an approved update can reach clients at the next refresh without another profile edit. A URL pinned to a commit is more reproducible: it makes the selected version explicit, but you must update the reference deliberately when you approve a new ruleset revision. Pick one model intentionally rather than assuming that a mutable branch is equivalent to a release.
A practical repository layout might separate rules by purpose instead of putting unrelated entries in a single file. For example, keep work services, locally maintained exceptions, and test fixtures distinct if they have different owners or review expectations. Avoid splitting a list so finely that every small edit requires changes across many files; the point is to make ownership and review clearer, not to create administrative overhead.
- Use descriptive filenames. Names such as
work-services.yamlcommunicate scope better thanlist2.yaml. - Review changes as diffs. A pull request makes additions, removals, and accidental broadening visible before they reach clients.
- Keep the repository free of secrets. A public raw URL is not an access-control system. Never place subscription links, credentials, private hostnames, or tokens in a public ruleset.
- Document intended scope. A short README can identify the owner, rule format, update policy, and examples of what the list should and should not match.
- Retain a rollback path. Git history lets you restore a known-good version quickly if a newly merged rule causes unexpected routing.
If your ruleset must remain private, do not assume that a normal GitHub raw URL will work in a proxy provider configuration. Authentication requirements and supported request headers vary by core version and client integration. Use only a method that your Mihomo build explicitly supports, keep credentials out of committed YAML, and test access from the same environment that runs the core. For a simple team workflow, publishing a reviewed, non-sensitive ruleset to a controlled public repository is often easier to operate than distributing embedded credentials.
4. Connect the provider to the profile without breaking rule order
Declaring a provider only makes the named ruleset available. It does not route matching traffic until the main rules list references it. The action after RULE-SET must name a policy group or another valid action for the profile, and that target must exist. If the policy group is called Work in the provider rule but the profile actually defines Work-Proxy, the configuration may fail validation or behave differently from what you intended.
Rule order matters because Clash evaluates rules from top to bottom and uses the first match. Place a provider rule after any deliberate, more-specific exceptions that should win, but before broad catch-all rules that would otherwise consume the traffic first. A provider placed beneath MATCH is effectively unreachable. Likewise, putting a broad provider above a precise DOMAIN rule can cause that precise exception never to be evaluated.
A maintainable profile usually makes this precedence visible rather than relying on readers to infer it. Group rules by intent, add short comments where the ordering is not obvious, and keep the final catch-all near the bottom. For example, you might put a critical local service exception first, then a team provider, then general categories, and finally the fallback. The exact order depends on your policy; the important part is that each earlier rule is there for a reason.
rules:
# Explicit exception: this host must not follow the team provider.
- DOMAIN,build-cache.example.org,DIRECT
# Shared engineering destinations.
- RULE-SET,engineering-sites,Work
# Other profile rules belong here.
- MATCH,General
Do not duplicate the same entries in both the provider and the main profile unless there is a documented reason. Duplicate rules make it harder to understand which copy controls the result and increase the chance that two lists drift apart. If an exception must override a provider match, put the exception earlier and explain why; do not silently maintain two competing versions of the same hostname.
Be deliberate about the policy group, too. A provider is a matching mechanism, not a proxy node, encryption layer, or guarantee of reachability. Routing a domain to a group does not ensure that the group has a healthy node, that DNS resolves as expected, or that the destination accepts the connection. When investigating a failure, distinguish “the rule matched the intended provider” from “the selected proxy path successfully reached the service.”
5. Set update expectations, validate, and troubleshoot with evidence
The interval value is expressed in seconds and determines how often an HTTP provider is refreshed. An interval of 86400 requests a daily refresh; it does not mean the file is fetched for every connection. Choose an interval that reflects how often the list needs to change and how dependable the source is. Very frequent polling creates unnecessary requests and can make a temporary GitHub or network issue more visible, while an excessively long interval delays fixes. The local cached file can help the core continue using previously downloaded data, but do not assume that every client handles a missing or invalid first download in exactly the same way.
Before deploying a change, validate the complete profile with the Mihomo core version used by the target client. Use the core’s supported configuration-check command, consult its current help output for the exact flags, and inspect the logs after launch. A syntax check catches malformed YAML and many configuration errors, but it cannot prove that a remote URL will remain available or that a provider rule matches only the intended traffic. Perform a live test as well: generate a connection to a hostname in the list, inspect the connection details in the client, and confirm both the matched rule and selected policy.
When a provider appears not to work, narrow the diagnosis in this order:
- Check the provider status and logs. Look for download errors, parse failures, update timestamps, or an unexpected local path.
- Open the source URL directly. Verify that it returns the raw ruleset and that the file has the expected YAML or text structure.
- Check the rule name and reference. The provider key in
rule-providersmust match the name used byRULE-SET. - Check rule order. Confirm that no earlier rule matches the test connection and that the provider appears above the catch-all.
- Check the destination policy. Ensure the named group exists and has a usable route for the destination.
- Test a known positive and a known negative. Confirm one hostname that should match and a similar one that should not.
For teams, make the review workflow part of the configuration design. Ask the reviewer to assess scope and precedence, not merely YAML formatting. In the change description, state why each rule is needed, what traffic it is expected to match, which policy should receive it, and how the author tested it. After merging, observe the client logs and connection view before considering the update complete. If the result is wrong, revert the ruleset commit or point the profile back to the last known-good revision rather than adding hurried compensating rules at the bottom.
6. Make the ruleset a small, testable release
A useful version-control workflow does not need a large automation system. Start with a branch for each change, keep the diff focused, and ask someone familiar with the routing intent to review it. A pull request can include a brief test matrix: the hostname expected to match, a nearby hostname expected not to match, the intended policy group, and the Mihomo version used for validation. This turns a vague “updated the list” commit into a change another person can actually evaluate.
For a frequently changing list, separate everyday additions from structural changes. Adding one confirmed hostname is not the same risk as replacing a domain-suffix rule with a keyword rule or changing the provider behavior. Call out changes that broaden the match surface, alter the source URL, or modify the update cadence. If several people contribute, name an owner who can decide whether a proposed rule belongs in the shared provider or in an individual profile.
A sensible rollout can be gradual. First test the new revision in a disposable or low-impact profile; next verify the connection details on the primary device; then allow the shared profile to follow the update. Keep the previous revision available until the new one has been observed in normal use. This is particularly valuable when multiple devices refresh at different times: one laptop may be using the new provider while a phone still has the cached version, so record which revision or commit was tested when comparing behavior.
The result is not merely a shorter main YAML file. It is a routing system where changes have an owner, a review trail, a defined matching scope, and a recovery path. That discipline matters more than whether the rules live in one provider or five. Start with one narrowly scoped list, confirm that its matches and exclusions are correct, and split it further only when separate ownership or update schedules justify the extra moving parts.
Compared with editing a single large profile by hand, a provider-backed workflow makes review and rollback easier; compared with copying an opaque third-party list, a repository you control makes every change visible. Clash still requires careful ordering and testing, but named providers, cached files, and Git history give you concrete tools to manage those risks. If you want a client that can load and inspect Mihomo-compatible profiles while you build this workflow, download a Clash client and start with a small ruleset you can verify.
Ready to get started?
Choose a compatible Clash client, then test your provider-backed ruleset with a clear rollback path.
Use Mihomo-compatible clients to manage profiles, providers, and routing rules across your devices.
Free Download