A GUI & CLI tool to add SOCKS5 proxy chains to Clash configurations
Features • Download • GUI • CLI • Building
- Dual Chain Groups - Creates both Chain-Auto (fastest auto-select) and Chain-Selector (manual) groups
- Rules Rewrite - Selectively redirect Clash rules to use chain proxies (Chain-Selector / Chain-Auto)
- Custom Rules - Inject custom domain routing rules (e.g., Lark/飞书 → DIRECT) with saveable presets
- Proxy Pool - Manage multiple SOCKS5 upstream proxies with health checking
- File Watching - Auto re-apply when Clash config changes externally
- CLI Support - Full command-line interface (
ccp) for scripting and automation - Cross-platform - Windows, macOS, Linux
Traffic flow: You → Clash → VPN Node → Your SOCKS5 Proxy → Internet
- Add your SOCKS5 proxy to the Proxy Pool
- Select Clash config file
- Configure Rules Rewrite - Choose which rule groups to redirect through chain proxies
- Add Custom Rules (optional) - Route specific domains to DIRECT or other groups
- Click Apply - Creates chain relays, selector groups, rewrites rules, and injects custom rules
Download the latest release from Releases:
| Platform | File | Note |
|---|---|---|
| Windows | *-setup.exe |
NSIS Installer (Recommended) |
| Windows | *-portable.zip |
Portable version |
| macOS | *.dmg |
Drag to Applications |
| Linux | clash-chain-patcher-linux |
chmod +x and run |
xattr -cr /Applications/Clash\ Chain\ Patcher.appFill in Host, Port, User, Pass, click + Add.
Click Select to choose your Clash YAML config file.
After loading a config, the Rules Rewrite panel auto-detects all proxy groups referenced in rules:
- Click the check (✓) to enable/disable a group for rewriting
- Click the target button to cycle through:
Keep→Chain-Selector→Chain-Auto - Non-DIRECT/REJECT groups are auto-checked with Chain-Selector by default
Expand the Custom Rules panel to add domain-specific routing exceptions:
- Enter domains (comma-separated, e.g.
lark.com,feishu.cn) - Click Type to cycle:
SUFFIX(domain suffix) →KEYWORD(contains) →EXACT(exact match) - Click Target to cycle through available groups:
DIRECT, config groups,Chain-Selector,Chain-Auto - Click + Add to add the rule
Use case: When using a US SOCKS5 proxy chain, services like Lark/飞书 (blocked in the US) should go DIRECT.
Presets: Save your custom rules as named presets for reuse — enter a name and click Save. Click Load to load a saved preset.
Click Apply. The tool will:
- Create relay chains for each proxy node
- Create Chain-Selector and Chain-Auto groups
- Rewrite checked rules to point to the selected chain group
- Inject custom rules at the top of the rules section (highest priority)
The CLI binary is called ccp (Clash Chain Patcher).
ccp info config.yamlOutput:
Rules: 3 groups, 630 total rules
Group Rules
--------------------------------------------------
Proxy 371
DIRECT 233
REJECT 26
Proxy nodes: 45
Proxy groups: 5
# Auto-detect main group and replace with Chain-Selector
ccp apply config.yaml -p host:port:user:pass -r auto
# Specify target explicitly
ccp apply config.yaml -p host:port -r "Proxy=Chain-Selector"
# Multiple rewrites
ccp apply config.yaml -p user:pass@host:port \
-r "Proxy=Chain-Selector" \
-r "Streaming=Chain-Auto"# Inject custom domain rules (highest priority, prepended to rules section)
ccp apply config.yaml -p host:port:user:pass -r auto \
--custom-rule "DOMAIN-KEYWORD:lark,feishu:DIRECT"
# Multiple custom rules
ccp apply config.yaml -p host:port -r auto \
--custom-rule "DOMAIN-KEYWORD:lark,feishu:DIRECT" \
--custom-rule "DOMAIN-SUFFIX,larksuite.com,DIRECT"
# Use a saved preset
ccp apply config.yaml -p host:port -r auto --preset lark-directCustom rule formats:
- Colon format (multi-domain):
TYPE:domain1,domain2:GROUP - Comma format (single):
TYPE,domain,GROUP - Types:
DOMAIN-SUFFIX/DOMAIN-KEYWORD/DOMAIN(or short:SUFFIX/KEYWORD/EXACT)
# Create a reusable preset
ccp preset create lark-direct \
--rule "DOMAIN-KEYWORD,lark,DIRECT" \
--rule "DOMAIN-KEYWORD,feishu,DIRECT" \
--rule "DOMAIN-SUFFIX,larksuite.com,DIRECT"
# List all presets
ccp preset list
# Show preset details
ccp preset show lark-direct
# Delete a preset
ccp preset delete lark-directPresets are saved in ~/.config/clash-chain-patcher/config.json.
ccp rules config.yaml -r auto
ccp rules config.yaml -r "Proxy=Chain-Auto"ccp apply [OPTIONS] --proxy <PROXY> <CONFIG>
Options:
-p, --proxy <PROXY> SOCKS5 proxy string
-r, --rewrite <REWRITE> Rule rewrite (repeatable), or "auto"
--custom-rule <RULE> Custom rule to inject (repeatable)
--preset <NAME> Apply a saved preset (repeatable)
--no-backup Skip creating backup
--suffix <SUFFIX> Chain suffix [default: -Chain]
Original config:
proxies:
- name: "Tokyo-01"
type: vmess
server: example.com
proxy-groups:
- name: "Proxy"
type: select
proxies: ["Tokyo-01"]
rules:
- DOMAIN,google.com,Proxy
- MATCH,ProxyAfter ccp apply config.yaml -p 1.2.3.4:1080 -r auto --custom-rule "DOMAIN-KEYWORD:lark,feishu:DIRECT":
proxies:
- name: "Local-Chain-Proxy"
type: socks5
server: 1.2.3.4
port: 1080
- name: "Tokyo-01"
type: vmess
server: example.com
proxy-groups:
- name: "Chain-Selector"
type: select
proxies: ["Tokyo-01-Chain"]
- name: "Chain-Auto"
type: url-test
proxies: ["Tokyo-01-Chain"]
url: "http://www.gstatic.com/generate_204"
interval: 300
- name: "Proxy"
type: select
proxies: ["Chain-Selector", "Chain-Auto", "Tokyo-01"]
- name: "Tokyo-01-Chain"
type: relay
proxies: ["Tokyo-01", "Local-Chain-Proxy"]
rules:
- DOMAIN-KEYWORD,lark,DIRECT # custom rule (highest priority)
- DOMAIN-KEYWORD,feishu,DIRECT # custom rule
- DOMAIN,google.com,Chain-Selector # was: Proxy
- MATCH,Chain-Selector # was: Proxy- Rust 1.70+
git clone https://github.com/user/clash-chain-patcher.git
cd clash-chain-patcher
# Build GUI
cargo build --release --bin clash-chain-patcher
# Build CLI
cargo build --release --bin ccp- GUI: Makepad - Rust native UI framework
- CLI: clap - Command-line argument parser
- YAML: serde_yaml
- File dialogs: rfd
This software is provided for educational and research purposes only.
- Intended solely for learning network technologies and personal research
- Users are responsible for ensuring compliance with applicable laws
- The author assumes no liability for misuse or consequences
Use at your own risk.
MIT License

