Skills clashctl-linux
Bootstrap, operate, and troubleshoot `nelvko/clash-for-linux-install` on Linux hosts. Use when Codex needs to initialize Clash or Mihomo on a machine that may not already be installed, follow a daily-use SOP with `clashctl` and `clashsub`, inspect or edit `.env`, `resources/mixin.yaml`, or `resources/runtime.yaml`, manage subscriptions, Tun mode, Web UI secrets, upgrades, and uninstall, or quickly diagnose startup, port, service, subscription-conversion, or network-access problems. This skill vendors a trimmed upstream project copy under `scripts/upstream-project/` and should first try fetching the latest GitHub repository, then fall back to copying the bundled project files when GitHub access is slow or unavailable.
git clone https://github.com/stvlynn/skills
T=$(mktemp -d) && git clone --depth=1 https://github.com/stvlynn/skills "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/clashctl-linux" ~/.claude/skills/stvlynn-skills-clashctl-linux && rm -rf "$T"
skills/clashctl-linux/SKILL.mdClash for Linux Install
Use this skill to initialize the project when it is missing, run the normal operator SOP when it is present, and shorten troubleshooting when something breaks.
Start Here
- Rebuild local state before making changes:
whoami echo "$SHELL" uname -m readlink /proc/1/exe command -v clashctl || true
- Locate the actual install root before editing files. Default is
, but the real path comes from the installed~/clashctl
..env - Decide which path applies:
- no installation detected: initialize first
- installation detected: follow the SOP sections below
- failure or drift detected: troubleshoot before making bigger changes
- Read references/project-map.md when you need exact file paths, bundled fallback details, or failure-mode notes.
Initialization Workflow
Always prefer the latest upstream repository first. Only fall back to the bundled copy under
scripts/upstream-project/ when GitHub access is slow, blocked, or unavailable.
Prepare a working tree with:
rm -rf /tmp/clash-for-linux-install git clone --depth 1 https://github.com/nelvko/clash-for-linux-install.git /tmp/clash-for-linux-install || { mkdir -p /tmp/clash-for-linux-install cp -R scripts/upstream-project/. /tmp/clash-for-linux-install/ } cd /tmp/clash-for-linux-install
Then:
- Review
and change only the values that matter for this host..env - Prefer
unless the user explicitly needs legacymihomo
.clash - Set
inCLASH_CONFIG_URL
or pass the subscription URL directly to.env
.install.sh - Run
.bash install.sh - Verify with
,clashctl status
, andclashui
.clashsecret
If the fallback copy was used, call out that it is a trimmed vendored upstream copy and may lag behind the current GitHub head.
Installed-State Workflow
When an installation already exists:
- Read the installed
first..env - Inspect these files in order:
resources/config.yamlresources/mixin.yamlresources/runtime.yamlresources/profiles.yaml
- Treat
as generated output. Do not hand-edit it unless the user explicitly wants a temporary experiment.runtime.yaml - Prefer the built-in wrappers over raw edits whenever a wrapper already exists.
Operator SOP
Daily control
: start the kernel and enable shell proxy variablesclashon
: stop the kernel and clear shell proxy variablesclashoff
: inspect statusclashstatus
: inspect logsclashlog
: toggle only shell proxy variablesclashproxy on|off
Subscription management
clashsub add '<url>'clashsub lsclashsub use <id>clashsub update [id]
only when validation or parser compatibility requires itclashsub update --convert [id]clashsub log
Quote any subscription URL that contains
&, ?, or other shell-sensitive characters.
Config management
Understand the merge model before editing anything:
is the active raw subscriptionconfig.yaml
contains the highest-priority local overridesmixin.yaml
is the merged runtime file actually passed to the kernelruntime.yaml
Use:
to edit mixin safelyclashmixin -e
to inspect the base subscriptionclashmixin -c
to inspect the effective runtime configclashmixin -r
Web UI and secrets
prints the effective local and public Web UI endpointsclashui
shows the current secretclashsecret
rotates the secret and restarts the serviceclashsecret <new_secret>
Tun mode
clashtunclashtun onclashtun off
Require elevated privileges before changing Tun mode. Turn Tun off before uninstalling.
Upgrade and uninstall
clashupgradeclashupgrade -vclashupgrade --releaseclashupgrade --alphabash uninstall.sh
Troubleshooting Workflow
Use this sequence:
- Confirm the install root, kernel choice, and init mode from
..env - Confirm required files exist under
andbin/
.resources/ - Confirm whether the kernel process is running.
- Read
instead of guessing ports or Web UI endpoints.resources/runtime.yaml - Inspect the newest available log:
for many root installs/var/log/<kernel>.log
forresources/<kernel>.log
or non-root installsnohup
- For subscription problems, inspect:
resources/temp.yamlresources/temp.yaml.rawbin/subconverter/latest.logresources/profiles.log
- For port conflicts, let the project auto-randomize and then re-check
orruntime.yaml
.clashui - For Tun failures, search the logs for:
Start TUN listening errorunsupported kernel versionTun adapter listening at
TUN listening iface
Operating Rules
- Always try the latest GitHub repository before using the bundled snapshot.
- Work from the prepared repo root when running
orinstall.sh
.uninstall.sh - Do not manually delete the install directory when
can revoke shell hooks, service definitions, and cron entries cleanly.uninstall.sh - Prefer wrappers over raw edits:
for subscriptionsclashsub
for custom rulesclashmixin
for the Web UI tokenclashsecret
for Tunclashtun
- Edit
only for installation-wide defaults such as kernel choice, install path, GitHub proxy, or subscription user agent..env
Bundled Resources
Trimmed vendored copy of the upstream project with the install scripts, command wrappers, init scripts, and required resources preserved. Use it as the fallback source forscripts/upstream-project/
when GitHub clone fails.cp -R scripts/upstream-project/. /tmp/clash-for-linux-install/
Read references/project-map.md whenever you need the exact file layout, bundled fallback details, command cheat sheet, or failure-mode map.