unifi-network-ops
Claude Code skills for auditing, tuning, and safely changing UniFi networks
(UDM / UDM Pro / UDM SE / Cloud Key) through the controller API.
These are distilled from a real performance-and-security engagement on a live 5-AP,
90-client site, including the parts that went wrong. Several sections exist specifically
because a confident, plausible conclusion turned out to be false and had to be retracted.
Install
In Claude Code, run:
/plugin marketplace add devondragon/unifi-network-ops
/plugin install unifi-network-ops@unifi-network-ops
That is the whole install. All four skills become available immediately and Claude loads
whichever one matches the task you are working on.
Alternative: manual symlink (if you would rather not use the plugin system)
git clone https://github.com/devondragon/unifi-network-ops ~/git/unifi-network-ops
for s in ~/git/unifi-network-ops/skills/*/; do
ln -s "$s" ~/.claude/skills/$(basename "$s")
done
Quick start
1. Create an API key
In the UniFi UI (verified on Network 10.4):
Settings → Control Plane → Integrations → Create API Key
Give it a name, create it, and copy the key immediately. It is shown once and cannot
be retrieved later. Keys are 32 characters.
One thing the UI does not tell you: although the key is presented as being for the
Integration API, it also works against the legacy /api/s/<site>/ and v2
/v2/api/site/<site>/ surfaces, which is where nearly all the useful data lives.
A few endpoints still refuse it (stat/event returns 404), and those need a local admin
login instead.
2. Store the key
Put it in a file that only you can read. Never paste it into a script, a prompt, or a
commit.
mkdir -p ~/.config/unifi
printf '%s' 'PASTE_KEY_HERE' > ~/.config/unifi/key
chmod 600 ~/.config/unifi/key
Then point the tooling at it, and set your gateway address:
export UNIFI_GW=192.168.1.1
export UNIFI_KEY_FILE=~/.config/unifi/key
UNIFI_KEY works too if you would rather pass the value directly, but a file keeps the
key out of your shell history and process list. Add both to your shell profile if you
will be doing this more than once.
Alternative: macOS Keychain (macOS only, opt-in)
If you are on macOS and would rather not keep the key on disk in cleartext, store it in
the login Keychain instead:
security add-generic-password -a "$USER" -s unifi-api-key -U -w
export UNIFI_KEY_KEYCHAIN=unifi-api-key
With -w last and no value after it, security prompts for the key instead of taking it
as an argument — so it stays out of your shell history and the process list, the same
reason the file above is preferred over inline UNIFI_KEY.
UNIFI_KEY_KEYCHAIN is the Keychain service name. The account defaults to $USER;
override it with UNIFI_KEY_KEYCHAIN_ACCOUNT if you stored it under a different one.
This is entirely opt-in. Leaving UNIFI_KEY_KEYCHAIN unset changes nothing, and the file
above stays the portable default — it is the only option that works on Linux and in
Docker. If UNIFI_KEY_KEYCHAIN is set but the lookup finds nothing, the scripts stop with
an error rather than quietly falling back to the file, so a revoked or renamed Keychain
item cannot be masked by a stale key on disk.
3. Confirm it works before anything else
KEY=$(cat ~/.config/unifi/key)
# Keychain instead? KEY=$(security find-generic-password -a "$USER" -s unifi-api-key -w)
curl -sk -o /dev/null -w '%{http_code}\n' \
-H "X-API-KEY: $KEY" \
"https://$UNIFI_GW/proxy/network/integration/v1/sites"
200 means you are good. 401 or 403 means the key is wrong or revoked. 000 means
you cannot reach the gateway at all, which is a different problem: check you are on the
same LAN.
4. Work through the skills in order
Invoke each skill explicitly with a slash command, then add your own prompt after it.
Claude can also load these automatically when your request matches, but invoking them by
name is worth doing here: you get a deterministic result and you can see that the right
skill loaded, which matters most at step 5 where the wrong answer reprovisions your APs.
The skill name depends on how you installed:
| Install method | Invoke as |
|---|
| Plugin (recommended) | /unifi-network-ops:capturing-a-unifi-baseline |
| Manual symlink | /capturing-a-unifi-baseline |
Examples below use the plugin form. Type / and start typing unifi to autocomplete.
Steps 1 through 4 are entirely read-only. You can run all of them against a production
network in the middle of the day without disturbing anything. Only step 5 writes.
1. /unifi-network-ops:capturing-a-unifi-baseline
capture a full baseline of my site before we change anything
2. /unifi-network-ops:tuning-unifi-wifi-rf
take a before reading of RF performance across all my APs