Clash Verge: How to Add Rules / Custom Rules (Rev v2.x current method)

If you searched for “Clash Verge add rules” or “custom rules”, you’ve probably hit the same trap as everyone else: you edited the config file, added your rules — and they all vanished after the next subscription update. This guide uses the current (v2.x) method so your rules survive subscription updates, with copy-paste examples.

This follows Clash Verge Rev (you should use Rev today — here’s why).

First principle: never edit the subscription file directly #

The subscription you import is downloaded as a YAML config file. Every subscription update re-downloads and overwrites that file — so any rule you typed into it is lost.

Likewise, the Rules tab in the left sidebar is read-only. It only shows the rules currently in effect; you cannot add rules there.

The correct ways are on the Profiles page:

MethodBest forNotes
Edit RuleMost peopleOpen via right-click on the profile card; add rules in a visual prepend/append editor (the official home of prepend-rules since v1.7.x)
Extended ScriptBatch / conditional logicJavaScript that modifies config.rules; most flexible

⚠️ Version note: in v1.6.x and earlier you wrote prepend-rules inside the “Merge” config; since v1.7.x the Extended Configuration is only for override/merge (DNS, ports, etc. — see Global Extended Configuration). Add rules via Edit Rule below.

Rule basics: types and match order #

A rule looks like: TYPE,MATCH,TARGET.

TypeMeaningExample
DOMAINExact domainDOMAIN,www.google.com,Proxy
DOMAIN-SUFFIXDomain suffix (most used)DOMAIN-SUFFIX,google.com,Proxy
DOMAIN-KEYWORDDomain contains keywordDOMAIN-KEYWORD,google,Proxy
DOMAIN-REGEXRegex domain (Mihomo)DOMAIN-REGEX,^.+\.google\.com$,Proxy
GEOSITEDomain category set (Mihomo)GEOSITE,category-ads-all,REJECT
IP-CIDRIPv4 rangeIP-CIDR,192.168.0.0/16,DIRECT,no-resolve
GEOIPIP by countryGEOIP,CN,DIRECT
PROCESS-NAMELocal process namePROCESS-NAME,Telegram.exe,Proxy
RULE-SETReference a rule set (below)RULE-SET,my-direct,DIRECT
MATCHCatch-all for everything leftMATCH,Proxy

The target (last field) is one of three: DIRECT, REJECT (block — for ad-blocking), or a proxy group name (⚠️ it must be a group that actually exists in your subscription, e.g. Proxy, Auto).

Match order: top to bottom, first match wins. Put a rule in prepend to make it win; MATCH is always the final catch-all (your subscription already has one — don’t duplicate it).

  1. Open the Profiles page and right-click the profile you use.
  2. Choose Edit Rule.
  3. Add your rules in the prepend area (highest priority, inserted before all other rules); put catch-all rules in append. One per line:
# force through proxy (replace "Proxy" with a real group name from your subscription)
DOMAIN-SUFFIX,openai.com,Proxy
DOMAIN-SUFFIX,githubusercontent.com,Proxy
# force direct (corporate intranet, banking, etc.)
DOMAIN-SUFFIX,mybank.com,DIRECT
IP-CIDR,192.168.0.0/16,DIRECT,no-resolve
# block ads / specific domains
DOMAIN-SUFFIX,doubleclick.net,REJECT
DOMAIN-KEYWORD,adservice,REJECT

Save, then refresh that profile. These edits are stored in the profile’s extended config, so updates won’t wipe them. Search your domain in the Rules tab to confirm.

Method 2: add rules via Extended Script (batch) #

For conditional or bulk edits, use an Extended Script (JavaScript, running on quickjs — no filesystem access). main(config) receives the config object and returns the modified one:

// right-click profile → edit (Extended Script), or use the Global Extended Script
function main(config) {
  const myRules = [
    "DOMAIN-SUFFIX,openai.com,Proxy",
    "DOMAIN-SUFFIX,claude.ai,Proxy",
    "DOMAIN-SUFFIX,doubleclick.net,REJECT",
  ];
  config.rules = [...myRules, ...(config.rules || [])]; // prepend = highest priority
  return config;
}

To apply rules to all subscriptions at once, put the script in the Global Extended Script (chain: Global Extended Configuration → Global Extended Script → Subscription Extended Configuration → Subscription Extended Script).

Advanced: manage large rule lists with RULE-SET #

To maintain hundreds of rules, define a rule-providers set and reference it with RULE-SET:

  • rule-providers is a map, so put it in the Extended Configuration (override/merge):
rule-providers:
  my-direct:
    type: http
    behavior: classical      # classical / domain / ipcidr — must match the list content
    url: "https://your-rule-list-url/direct.list"
    path: ./ruleset/my-direct.yaml
    interval: 86400
  • Then add a reference line in Edit Rule (prepend): RULE-SET,my-direct,DIRECT (or push it to config.rules in an Extended Script).

Rule differences: Clash Verge Rev vs the original #

  • Rev is based on Mihomo and is fully compatible with the original Clash.Meta rule syntax; your existing rules carry over.
  • Rev/Mihomo adds: GEOSITE, DOMAIN-REGEX, logical rules AND/OR/NOT, SUB-RULE, and more.
  • If a rule errors on Rev, check the Mihomo docs. Still on the original? Migrate to Rev.

Rule not working? Run through this checklist #

SymptomCause / fix
Rule added but nothing happensWrong target — use a real group name from your subscription (e.g. Auto), not a nonexistent PROXY
Rule ignoredOrder issue — move it into prepend
Rules gone after subscription updateYou edited the subscription file — use Edit Rule / Extended Script
Old prepend-rules does nothingRemoved from Extended Configuration in v1.7.x — use Edit Rule’s prepend
IP rule inaccurate or slowA pure-IP rule is missing no-resolve — append ,no-resolve
Edit never takes effectYou didn’t refresh — reselect the profile or reconnect the core