Configuration Featured Clash Beginner Guide Clash vs VPN Proxy Basics

Build Clash Rule Providers on GitHub: Advanced YAML Setup

November 9, 2026 Updated November 9, 2026 Approx. 12 min read

Why Use a GitHub-Hosted Rule Provider?

As a Clash configuration grows, its routing rules tend to spread across the main profile, local overrides, and notes copied from different sources. That can make small changes difficult to review and risky to deploy: a missing comma may prevent the configuration from loading, while a rule placed too low in the list may never take effect. A rule provider gives you a separate, maintained file of rules that Clash can fetch and refresh without requiring you to rewrite the rule list in your main configuration each time.

GitHub is a practical place to host a provider because it gives you version history, a clear way to review changes, and a stable raw-file URL. You can keep a focused set of rules in a repository, update them through commits, and point a Mihomo-based client at the published file. This is useful for personal domain lists, work services, development tools, or a carefully reviewed set of destinations that should use a particular policy group.

A provider does not create a policy group or decide by itself whether traffic is proxied. It supplies matching rules; the main configuration connects that provider to an action such as DIRECT, REJECT, or a named proxy group. Keeping those responsibilities separate makes the setup easier to understand: the provider says what to match, and the main profile says what to do with a match.

Design Goal

Keep custom rules readable, reviewable, and independently updateable while leaving your existing proxy groups and subscription settings intact.

This guide uses a public GitHub repository and a Mihomo-compatible YAML configuration. The examples are intended for Clash Verge Rev and other clients that run Mihomo or support the same rule-provider syntax. Older or different Clash cores may not implement every provider option in the same way, so confirm your active core and validate the profile before relying on a new configuration.

1Create and Publish the YAML Rule File

Start by creating a repository for configuration data, or choose an existing repository where you can manage your own files. A simple layout keeps the provider separate from unrelated documentation and makes the raw URL easy to identify:

my-clash-rules/ └── rules/ └── work-domains.yaml

For a provider with behavior: domain, the remote file is a YAML document containing a payload list. Each entry is a domain-oriented rule. For example:

payload: - DOMAIN-SUFFIX,corp.example - DOMAIN,portal.example.net - DOMAIN-KEYWORD,dev-console

Replace the example names with domains you are authorized to route. Keep each list item as a quoted or unquoted YAML string, and use a comma between the rule type and its value. The domain behavior is intended for domain matching; do not place IP ranges or complete rules that include a policy action in this list. If the provider needs IP network entries or full rule lines, choose the matching provider behavior supported by your core and structure the payload accordingly.

Publish a Raw File URL

Commit the file to the branch you intend to use, such as main. Open the file on GitHub and use its raw-file view, or construct the URL using the owner, repository, branch, and exact path. A typical URL looks like this:

https://raw.githubusercontent.com/OWNER/REPOSITORY/main/rules/work-domains.yaml

Use the raw URL rather than the normal GitHub page URL. A normal page returns GitHub’s HTML interface, not the YAML contents expected by the provider loader. Check the raw URL in a browser or with a command-line request before adding it to Clash. The response should show the YAML file itself, without a login screen, HTML wrapper, or repository error page.

Pro Tip: Keep the URL Stable

Use a deliberate branch and file path. Renaming the repository, changing the branch, or moving the YAML file requires updating every configuration that references its raw URL.

Public raw files are convenient, but they are visible to anyone who knows the URL and may be cached by intermediary systems. Do not put subscription links, credentials, private addresses, access tokens, or other secrets in a rule repository. A private repository may require authentication that a standard rule-provider URL cannot supply automatically; do not assume that a browser session logged in to GitHub means the Clash core can access the same file.

Before publishing, inspect the file for accidental private information and confirm that the repository’s license and any reused rule content permit your intended use. A concise README can explain what the list covers, how to contribute, and when it was last checked. The README is for maintainers; the provider URL should still point directly to the YAML file.

2Configure the Provider in Mihomo YAML

Add the provider definition to the top level of the active configuration, alongside sections such as proxy-groups and rules. Provider names are identifiers: use a short name made of letters, numbers, and hyphens, and reference that exact name in the rule list. This example downloads the GitHub-hosted domain list once per day:

rule-providers: work-domains: type: http behavior: domain url: https://raw.githubusercontent.com/OWNER/REPOSITORY/main/rules/work-domains.yaml path: ./ruleset/work-domains.yaml interval: 86400 rules: - RULE-SET,work-domains,Work - MATCH,PROXY

Replace OWNER, REPOSITORY, and Work with your actual GitHub account or organization, repository, and an existing policy group. The type: http setting tells Mihomo to retrieve the provider over HTTP or HTTPS. behavior: domain tells the core how to interpret the payload. The path is a local cache file managed by the core; it is not a path inside the GitHub repository. The interval is expressed in seconds, so 86400 represents 24 hours.

The policy name at the end of RULE-SET must already exist in your configuration. If your group is named Proxy, Auto, or something else, use that exact spelling instead of Work. You can also route a provider to DIRECT or REJECT when appropriate. The provider entry only defines how to retrieve and parse the list; the rule line determines the routing action.

Understand Rule Order and Refresh Intervals

Clash evaluates rules from top to bottom and applies the first matching rule. Put a specific custom provider above broader rules that could match the same traffic. For example, a custom entry intended to use the Work group should appear before a broad catch-all rule such as MATCH,PROXY. If an earlier rule already catches the domain, the provider may load correctly but never be selected for that request.

Choose an interval that fits how often the list changes. A daily interval is a reasonable starting point for a personal list that is updated occasionally. A very short interval creates unnecessary requests and may make troubleshooting more confusing, especially when a remote file is temporarily unavailable. An interval is a refresh schedule, not a promise that a change will appear instantly. After committing an update, use the client’s provider update control or wait for the next refresh, then check the provider’s status.

Do not remove the main configuration’s existing rules when adding a provider. Merge the new top-level section carefully, check indentation, and retain a final fallback rule if your profile depends on one. YAML uses spaces for indentation; tabs and incorrectly aligned keys can cause a parse error or place a setting under the wrong parent. Keep the provider block at the same indentation level as other top-level keys.

Core Compatibility

Rule-provider options are core-dependent. If a client reports an unsupported field or behavior, check which core is active and consult the documentation for that core before changing the provider syntax.

3Manage Rule Changes with Git

Once the provider is working, treat the repository as configuration code rather than a disposable text paste. Git gives you a record of what changed and when, which makes it much easier to identify the source of a routing regression. Before editing the list, decide whether a change is an addition, correction, or removal. Keep commits focused so that a later review can connect a behavior change to a small, understandable diff.

A practical maintenance cycle is to edit the YAML, review the diff, validate the syntax, and then commit the change. For a command-line workflow, the basic sequence is:

git add rules/work-domains.yaml git diff --cached git commit -m "Update work domain rules" git push origin main

On GitHub’s website, the same discipline applies: inspect the proposed change before selecting the commit action, and use a message that describes the update. For a shared list, use a pull request or another review step instead of allowing unreviewed edits to reach the branch used by active clients. That gives maintainers a chance to catch overly broad suffixes, accidental deletions, malformed YAML, and unrelated changes.

Test additions with a narrow scope. Add one or a few rules, update the provider, and verify the affected destination before expanding the list. A rule such as DOMAIN-KEYWORD,example may match more hosts than expected; a precise DOMAIN or DOMAIN-SUFFIX entry is often easier to reason about. Keep the provider focused, and separate unrelated categories into different files when they need different policies or update schedules.

Consider how clients behave when the remote file cannot be reached. The local path gives the core a place to store provider data, but you should still test the profile after initial setup and keep a known-good configuration backup. If an update introduces bad rules, use Git history to revert the relevant commit, then trigger a provider refresh. Reverting the source file alone does not necessarily change a client’s cached copy until the provider is fetched again.

For a team, document ownership and review expectations. State who can approve changes, whether domain requests need an explanation, and how emergency removals are handled. Avoid putting personal notes inside the payload, where the parser may treat them as invalid entries; keep commentary in the repository README or in commit messages. A smaller, reviewed list is usually safer than an unbounded collection copied from multiple sources.

Setting or practice Purpose Practical starting point
behavior Defines the rule format expected in the payload Use domain for domain-only entries
interval Controls how often the remote provider is refreshed 86400 seconds for a daily refresh
Git commits Record and explain changes to the rule list Keep each commit focused and review its diff
Rule order Determines which matching action is applied first Place specific provider rules before broad matches

4Diagnose Loading and Matching Errors

If a provider does not work, separate the problem into three checks: can the core fetch the file, can it parse the payload, and does the loaded rule match the traffic you are testing? These are different failure points. A successful browser visit only confirms that your browser can access the URL; it does not prove that the client core has loaded the provider, accepted its YAML structure, or selected the corresponding rule.

Check the URL and Remote Access

Start with the raw URL. Confirm that the owner, repository, branch, and file path are exact, including capitalization. A URL that points to a GitHub HTML page, a deleted file, or a branch that no longer exists will not provide the expected YAML. Open the provider panel or core log in your Clash client and look for HTTP errors, timeouts, or access failures. If the repository is private, verify that the client has a supported way to authenticate; a logged-in web browser does not automatically pass GitHub credentials to Mihomo.

If the file loads in a browser but the client times out, check whether the active core can reach GitHub through the current network and proxy setup. A DNS issue, firewall, captive portal, or temporary network failure can prevent retrieval. Retry after connectivity is restored and use the client’s update action to distinguish a stale provider from a URL that consistently fails.

Check YAML and Rule Matching

For a parse error, review indentation and the payload structure first. A domain provider file should contain a valid YAML list under payload, and each entry should use a rule type compatible with behavior: domain. Do not accidentally paste the main profile’s rules: section into the provider file. Also avoid tabs, stray punctuation, and unmatched quotation marks. If the profile loads but the provider does not, inspect the provider-specific error rather than assuming that the whole YAML file is malformed.

When the provider shows as loaded but traffic follows another route, verify the exact provider name in RULE-SET, the destination policy group, and the rule order. Confirm that the policy group exists and that the tested domain actually matches an entry. A suffix rule matches subdomains as well as the base domain, while an exact domain rule targets only the listed hostname. A spelling difference, a different hostname used by the application, or a broader rule earlier in the list can explain an apparently ignored entry.

Use the client’s connection or request details to inspect the hostname and matched rule for a real request. Test one destination at a time, update the provider after modifying its remote file, and allow for DNS or application caching. If you are unsure whether the provider or another rule is responsible, temporarily use a narrowly scoped test domain in a separate test profile rather than changing a broad production rule. Once behavior is confirmed, remove the test entry and keep the final provider focused.

A Reliable Troubleshooting Order

Check the raw URL, provider download status, YAML payload, provider name, policy group, and rule order—in that sequence. This avoids changing routing rules to compensate for a file that never loaded.

A GitHub-hosted rule provider is most useful when it stays small, predictable, and easy to review. Begin with a public raw YAML file, validate the payload, connect it to an existing policy group, and confirm the result in the client’s logs. Then use Git history and a sensible refresh interval to maintain it over time. With those habits in place, custom routing rules can evolve without turning the main Clash profile into a long, difficult-to-audit list.

Download Clash for Free – Get Started Now →