Manage Karing split-routing rules from a terminal without clicking through the GUI. It updates Karing's visible custom rule, the selected outbound, and the currently running sing-box configuration as one transaction.
Karing's GUI is excellent for everyday use, but adding a custom routing rule takes several screens. This CLI makes the same change reproducible:
karing-rule add "Example direct" \
--outbound direct \
--domain-suffix example.comThere is also a built-in preset for NetEase UU Remote:
karing-rule preset uu-remote- Never toggles Karing's connection switch.
- Refuses non-local control API endpoints.
- Validates all three JSON documents before changing anything.
- Creates a timestamped local backup before every write.
- Uses atomic file replacement.
- Hot-reloads the sing-box core.
- Restores the previous files if reload fails.
- Does not print, copy, or upload subscriptions, node credentials, or the Karing control secret.
Backups stay inside Karing's configuration directory under
karing-rule-cli-backups/.
Python 3.10 or newer is required.
python3 -m pip install karing-rule-cliFor development:
git clone https://github.com/duevan07/karing-rule-cli.git
cd karing-rule-cli
python3 -m pip install -e .Check whether the local Karing installation is supported:
karing-rule doctorList rules and their selected outbound:
karing-rule listAdd or update a direct rule:
karing-rule add "My direct rule" \
--outbound direct \
--domain-suffix example.com \
--process-name ExampleAppRoute through the currently selected node:
karing-rule add "My proxy rule" \
--outbound current \
--domain-suffix example.orgRoute through a named node:
karing-rule add "My fixed route" \
--outbound "Japan-1" \
--domain-suffix example.jpRemove a rule:
karing-rule remove "My direct rule"Every command supports --json for agent and automation use. Set
KARING_CONFIG_DIR or pass --config-dir when automatic discovery does not
cover a platform or packaging format.
- macOS: tested against Karing's Group Container configuration layout.
- Windows and Linux: discovery paths are included but need community testing.
- Karing must be running for hot reload.
--no-reloadis available for offline maintenance.
Version 0.1 manages custom domain suffix, exact domain, IP CIDR, and process name matchers. It supports direct, automatic, current, and exact named outbounds.
Bug reports must not attach service_core.json, karing_subscribe.json, or
karing_subscribe_use.json; these files may contain private proxy credentials.
Use karing-rule --json doctor, which returns only non-secret diagnostics.
MIT