Lan Proxy Gateway Ops
Apps & Automationlan-proxy-gateway-opsLan Proxy Gateway Ops is an Agent Skill for apps & automation published in the Tght1211/lan-proxy-gateway repository on GitHub: a SKILL.md instruction file an AI agent can load to do this task.
Use when operating or configuring the lan-proxy-gateway CLI (the `gateway` binary) non-interactively — setting the proxy source/subscription, switching nodes, toggling TUN/adblock/traffic mode, adding routing rules, reading status, or starting/stopping the LAN gateway from a script or AI agent without driving the interactive TUI.
How to use this skill
Bring this guide into your coding agent with a prompt tailored to the tool you use.
- Open your project in Codex.
- Copy and paste the prompt below.
- Review files and risks before approving any action.
Inspect the Agent Skill at https://github.com/Tght1211/lan-proxy-gateway/blob/HEAD/skills/lan-proxy-gateway-ops/SKILL.md and all supporting files. Report provenance, permissions, scripts, dependencies, and security risks. Propose an exact installation into .agents/skills/lan-proxy-gateway-ops, but wait for my approval before writing files or running scripts.
Copying this prompt does not install or run the skill. Review third-party files before use.
LAN Proxy Gateway Ops
Overview
lan-proxy-gateway (binary: gateway) turns a Mac/Linux/Windows machine into a LAN transparent proxy gateway on top of mihomo. It can be driven entirely from the command line — no interactive TUI required. Every config write saves gateway.yaml and hot-reloads mihomo if it is running, so changes apply live.
This skill is the command reference for operating it headlessly.
Workflow
- Read current state:
gateway status --jsonandgateway config show --json. - Change config with
gateway config ...(orgateway node ...at runtime). - Verify by re-reading status/config.
All read + config commands work without root. Only start/stop/restart need root.
Command Reference
Read state (no root, machine-readable with --json)
gateway status --json— running, mode, TUN, adblock, source type, portsgateway config show --json— full config incl. source url/path/server, custom rulesgateway node list --json— proxy groups, their nodes, and the current pick (needs the gateway running)
--json output uses stable snake_case keys (running, gateway_mode, tun, …). node/config show errors are printed to stderr with a non-zero exit code (e.g. 网关未运行,先 gateway start).
Set the proxy source
gateway config source --type subscription --url <URL>gateway config source --type file --path <clash.yaml>gateway config source --type external --server 127.0.0.1 --port 7890 --kind http(chain behind a local Clash/Verge)gateway config source --type remote --server <host> --port <p> --kind socks5 --user <u> --pass <pw>gateway config source --type none(all direct)
Toggle behavior
gateway config mode <rule|global|direct>gateway config tun <on|off>gateway config adblock <on|off>gateway config gateway-mode <tun|forward>(restarts mihomo)
Custom routing rules
gateway config rule add <direct|proxy|reject> <RULE>—<RULE>is any mihomo rule body:DOMAIN-SUFFIX,openai.com,DOMAIN,api.foo.com,IP-CIDR,10.0.0.0/8,PROCESS-NAME,Cursor,GEOIP,CN, etc.gateway config rule list --jsongateway config rule rm <direct|proxy|reject> <index>— index comes fromrule list
Switch nodes at runtime (needs the gateway running)
gateway node listgateway node switch "<group>" "<node>"— quote names; groups/nodes contain spaces & emoji
Lifecycle
gateway install— first-run wizard: downloads mihomo + GeoIP, guides initial setupgateway start/gateway stop/gateway restart— needs root (TUN, IP forwarding, firewall)gateway service install|uninstall|status— OS service for auto-start on boot
Privileges
start/stop/restart change the host network stack (TUN device, IP forwarding, pf/iptables) and need root. status, config *, and node * do not. If passwordless sudo is available, run sudo gateway start directly; otherwise tell the user to run it themselves. Never assume the machine should proxy its own traffic — check gateway config show (tun, gateway_mode) first.
Common Mistakes
- Driving the interactive TUI (
gatewaywith no args) by piping keystrokes — fragile. Use the headlessconfig/nodecommands above instead. - Running
node list/switchwhen the gateway is stopped — they need mihomo's running API; start first. - Forgetting to quote group/node names in
node switch— they contain spaces and emoji. - Editing
gateway.yamlby hand while the gateway runs — preferconfigcommands so the change hot-reloads cleanly.
Scenarios
For end-to-end recipes (LAN onboarding, point to a subscription then pick a node, local-machine bypass, health/recovery), read references/scenarios.md.