Agent skill

SwitchBot Smart Home CLI

by OpenWonderLabs in OpenWonderLabs/switchbot-openapi-cli

Teaches an agent to control SwitchBot devices safely through the switchbot CLI: bootstrap first, query real device data, read policy.yaml and respect safety tiers.

MITAuto-check: warningsProductivity & Automation

Install SwitchBot Smart Home CLI

The automated check flagged lines worth reading first. See the safety section below.

skills CLI
$ npx skills add OpenWonderLabs/switchbot-openapi-cli --skill switchbot -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install OpenWonderLabs/switchbot-openapi-cli switchbot --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/OpenWonderLabs/switchbot-openapi-cli.git skills-src && mkdir -p .claude/skills && cp -r skills-src/packages/codex-plugin/skills/switchbot .claude/skills/switchbot && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
switchbot
GitHub stars
133
Token cost
~2.2k tokens
SKILL.md length
907 words
Files
2 (incl. references)
Skills in repo
1
Repo updated
First seen
Licence
MIT

At a glance

Teaches an agent to control SwitchBot devices safely through the switchbot CLI: bootstrap first, query real device data, read policy.yaml and respect safety tiers.

  • Works in 6 steps: alias — policy.yaml alias map → . Most… → exact — device name == "bedroom light"… → prefix — name starts with the phrase. → …
  • Turning lights, plugs or curtains on and off through SwitchBot
  • SKILL.md covers Authority chain, Network requirements, Required bootstrap and Resolving a name to a device, plus 11 more sections
  • Calls npm

What it does

The skill lets an agent drive a user's SwitchBot smart home, covering lights, locks, curtains, sensors, plugs and IR appliances such as TVs, air conditioners and fans, through the switchbot CLI. Its rule is to query the CLI for ground truth and never guess commands, device IDs or parameter values. A table maps each question to the authoritative command: agent-bootstrap, capabilities, devices list, status and describe, scenes list, quota status, doctor, rules list and lint, and the plan commands.

Before any action the agent runs switchbot agent-bootstrap --compact, which returns the CLI version, safety tiers, name strategies, profile, quota, cached devices, a catalog and hints. It then reads policy.yaml from ~/.config/openclaw/switchbot, proceeding with default safety tiers and suggesting switchbot policy new if the file is missing. Plans can be drafted from an intent and run with per-step approval, and automation rules can be suggested and added to the policy with a dry run.

It also covers reading the user's AI MindClip recordings, todos and summaries. Setting up for Codex needs outbound internet to the npm registry and GitHub, and a reference file explains the config.toml fix if that fails.

When your agent uses it

  • Turning lights, plugs or curtains on and off through SwitchBot
  • Checking the status of a lock or sensor
  • Controlling a TV, air conditioner or fan through an IR remote device
  • Drafting and linting an automation rule for a device

Example prompts

  • “Turn off the living room lights with my SwitchBot setup.”
  • “What is my SwitchBot sensor reading right now?”
  • “Draft an automation rule that closes the bedroom curtains at sunset, and lint it.”

Requirements

  • The switchbot CLI
  • Outbound internet access to the npm registry and GitHub for switchbot codex setup

Workflow steps

6 steps, taken from the first numbered list in SKILL.md.

  1. alias — policy.yaml alias map → . Most reliable.
  2. exact — device name == "bedroom light" (case-insensitive).
  3. prefix — name starts with the phrase.
  4. substring — name contains the phrase.
  5. fuzzy — Levenshtein distance ≤ 2.
  6. require-unique — multiple matches at same tier → stop and ask. Never pick silently.

What it can do on your machine

Read from SKILL.md and the folder at commit 45f9a95. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • npm

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md. Its commands use npm, which can reach the network depending on how they are called.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

SwitchBot Smart Home CLI loads about 2.2k tokens when it runs, and up to ~2.5k if it reads all its reference files. Until then it costs about 79 tokens; SKILL.md has 907 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~79
When it runs · the whole SKILL.md, loaded when a task matches
~2.2k
With references · SKILL.md plus every file in references/, read only if the agent opens them
~2.5k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check: warnings

The automated check found patterns that need a careful read before installing.

  • WarningContains instruction-override wording (e.g. “without asking the user”)SKILL.md:192
    - Suggest flags that bypass safety tiers (`--skip-confirmation`, `--force`) unless the user named them explicitly.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from OpenWonderLabs/switchbot-openapi-cli at commit 45f9a95, republished under its MIT licence (© OpenWonderLabs). 907 words, ~2,156 tokens.

Download SKILL.mdSave it as .claude/skills/switchbot/SKILL.md (or your agent's skills folder). This skill also uses 1 other file; get the full folder from GitHub.
name
switchbot
description
Use when the user mentions SwitchBot devices, smart-home automation, or asks about controlling lights, locks, curtains, sensors, plugs, or IR appliances (TV/AC/fan). Teaches the agent how to drive the authoritative `switchbot` CLI safely, read user preferences from `policy.yaml`, and respect safety tiers.

SwitchBot skill

Drive the user's SwitchBot smart home through the switchbot CLI. Always query the CLI for ground truth — never guess commands, deviceIds, or parameter values.


Authority chain

QuestionAuthoritative command
What can I do (cold start)?switchbot agent-bootstrap --compact --json
What commands exist?switchbot capabilities --json
What flags does this command take?switchbot <cmd> --help --json
What devices does the user have?switchbot devices list --json
What's this device doing right now?switchbot devices status <id> --json
What can I do with this specific device type?switchbot devices describe <id> --json
What scenes are configured?switchbot scenes list --json
What's on the user's AI MindClip (recordings, todos, daily/weekly summaries)?switchbot mindclip recordings/recording/summary/todos/daily/weekly/urgent-todos --json
What's in the user's policy.yaml?cat ~/.config/openclaw/switchbot/policy.yaml
Is my quota OK?switchbot quota status --json
Is the setup healthy?switchbot doctor --json
What automation rules are configured?switchbot rules list --json
Are the rules valid?switchbot rules lint
Draft an execution plan from intentswitchbot plan suggest --intent "..." --device <id>
Run a plan with per-step approvalswitchbot plan run <file> --require-approval
Draft an automation rule from intentswitchbot rules suggest --intent "..." --device <id>
Inject a rule into policy.yamlswitchbot policy add-rule [--dry-run] [--enable] (reads YAML from stdin)

Network requirements

switchbot codex setup requires outbound internet (npm registry + GitHub). If it fails with a network error, read references/codex-network.md for the ~/.codex/config.toml fix.


Required bootstrap

Before any action, run:

bash
switchbot agent-bootstrap --compact

The response contains: cliVersion, safetyTiers, nameStrategies, profile, quota, devices[] (cached, with deviceId/type/name/category/roomName), catalog, and hints[].

If devices look stale (user just added one), refresh with switchbot devices list --json.

Then read the user's policy:

bash
cat ~/.config/openclaw/switchbot/policy.yaml 2>/dev/null

If the file doesn't exist, proceed with default safety tiers and tell the user once they can create one with switchbot policy new.


Resolving a name to a device

When the user says "bedroom light", resolve in this order:

  1. alias — policy.yaml alias map → <deviceId>. Most reliable.
  2. exact — device name == "bedroom light" (case-insensitive).
  3. prefix — name starts with the phrase.
  4. substring — name contains the phrase.
  5. fuzzy — Levenshtein distance ≤ 2.
  6. require-unique — multiple matches at same tier → stop and ask. Never pick silently.

Safety gates

TierExamplesBehaviour
readstatus, list, quotaRun freely.
ir-fire-forgetIR power/AC/TV via HubRun; warn there is no device-side confirmation.
mutationturnOn/Off, setBrightness, setColorRun. Append to audit log.
destructivelock, unlock, delete scenes/webhooksRefuse by default. Confirm explicitly; prefer --dry-run first.
maintenance(reserved)Always confirm.

Policy overrides: confirmations.always_confirm forces confirmation; confirmations.never_confirm pre-approves (never add destructive actions). quiet_hours requires confirmation even for mutation.


Policy compliance

  1. Call policy_validate (with live: true) once per device-control session.
  2. Honour quiet_hours, always_confirm, and never_confirm from the validated policy.
  3. No policy file → proceed with default tiers.

Never write to policy.yaml without showing a diff and getting explicit approval.


Audit logging

Use audit_query and audit_stats MCP tools to review past activity. For a full audit trail with CLI, use switchbot --audit-log devices command <id> <cmd>.


Output modes

Always use --json when parsing output. Use --format=markdown for user-facing summaries. Never parse markdown or human tables programmatically — re-run with --json.


Credentials

First-time login: switchbot auth login (opens browser). Headless: add --no-open. Inspect the active keychain backend: switchbot auth keychain describe --json. Reset cache without touching credentials: switchbot reset [--all]. Never run auth login or auth keychain set on the user's behalf.


Show full SKILL.md (368 more words)Show less

Declarative automations (CLI ≥ 3.7.1)

When the user wants "when X, do Y", author a rule in policy.yaml instead of a shell loop. Check schema version first (head -1 policy.yaml, must be "0.2"; if "0.1" run switchbot policy migrate).

Start with dry_run: true:

yaml
automation:
  enabled: true
  rules:
    - name: "hallway motion at night"
      when: { source: mqtt, event: motion.detected, device: "hallway sensor" }
      conditions:
        - time_between: ["22:00", "07:00"]
      then:
        - { command: "devices command <id> turnOn", device: "hallway lamp" }
      throttle: { max_per: "10m" }
      dry_run: true

Trigger kinds: source: mqtt (shadow events), source: cron (schedule + optional days:), source: webhook (bearer-token HTTP). Conditions: time_between, {device, field, op, value}, all:, any:, not:.

The validator rejects any rule with a destructive action in then[]. Always start dry, confirm firings via switchbot rules tail --follow, then remove dry_run.

bash
switchbot policy validate
switchbot rules lint && switchbot rules reload

Semi-autonomous workflow — plan suggest + --require-approval

bash
switchbot plan suggest --intent "turn off all lights" --device <id1> --device <id2>
# Review/edit the generated JSON
switchbot plan run plan.json --require-approval

Non-destructive steps run automatically; destructive steps prompt once. Via MCP: call plan_suggest, then have the user run --require-approval in a TTY session.


Common pitfalls

  1. Don't parse help text. Always --help --json.
  2. Don't rely on --name picking one hit. Resolve the name yourself; pass deviceId directly.
  3. Check commands[] before calling a command. switchbot devices describe <id> --json — not every device supports every command.
  4. Quota counts attempts, not successes. Above 80%, slow down and batch.
  5. --json envelope — every response is {"schemaVersion":"1.1","data":...} or {"error":{...}}. Read .data, check .error first. Parsers that read top-level fields silently get undefined.

Error handling

json
{ "error": { "kind": "usage|auth|quota|network|upstream|internal", "message": "...", "hint": "..." } }
  • usage → you called something wrong; re-read help and retry.
  • auth → run switchbot doctor --section credentials.
  • quota → stop; resets at midnight UTC.
  • network → retry once, then surface.
  • upstream → relay verbatim.
  • internal → ask user to run switchbot doctor --json and file an issue.

Never retry destructive actions automatically. For mutation retries, use a local fingerprint {deviceId, command, args, minute-bucket} as an idempotency gate.


Things to never do

  • Ask the user for their SwitchBot token or secret.
  • Suggest flags that bypass safety tiers (--skip-confirmation, --force) unless the user named them explicitly.
  • Claim IR actions "succeeded" — IR is open-loop; say the signal was sent.
  • Write to policy.yaml without showing a diff and getting explicit approval.
  • Generate a rule with a destructive command in then[].
  • Arm a rule (dry_run: false) on first author without the user confirming firings.
  • Set automation.enabled: true without explicitly informing the user.
  • Run switchbot doctor --fix --yes without the user asking.

Version

Targets @switchbot/openapi-cli ≥ 3.7.1. If switchbot --version is older: npm update -g @switchbot/openapi-cli.

<!-- MAINTENANCE: Identical copy at plugins/switchbot/skills/switchbot/SKILL.md — keep both in sync. -->

© OpenWonderLabs, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 1 other file (references) in packages/codex-plugin/skills/switchbot of OpenWonderLabs/switchbot-openapi-cli.

  • SKILL.md
  • references/codex-network.md

Open the folder on GitHubat commit 45f9a95

Compare with similar skills

SwitchBot Smart Home CLI next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

SwitchBot Smart Home CLI compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
SwitchBot Smart Home CLI this skillOpenWonderLabs/switchbot-openapi-cli133—~2.2kAutomated safety check: WarnMIT
Skyvern Browser AutomationSkyvern-AI/skyvern23k—~2.9kAutomated safety check: PassAGPL-3.0
Feishu Bitable Managementop7418/CodePilot6.5k1 repos~1.7kAutomated safety check: PassCustom licence
CUAWright Web Task Automationmicrosoft/CUAWright6k—~2kAutomated safety check: NotesMIT
MoviePilot Downloader Operationjxxghp/MoviePilot12k—~4.4kAutomated safety check: PassGPL-3.0
Refly Skill Runnerrefly-ai/refly7.5k—~1.7kAutomated safety check: PassCustom licence

Similar skills

  • Skyvern Browser Automation

    Skyvern-AI/skyvern

    Picks the right Skyvern CLI command for a web task, from quick yes/no checks to reusable multi-page workflows, instead of falling back to plain page fetching.

    23k GitHub stars~2.9k tokensUpdated today
    Productivity & AutomationAuto-check passed
  • Creates, queries and edits Feishu Bitable tables through tool calls, covering records, fields, views and batch operations with the correct value format for each field type.

    6.5k GitHub starsUsed in 1 repo~1.7k tokens
    Productivity & AutomationAuto-check passed
  • Official

    Solves web tasks by driving a local Playwright browser one bash command at a time, saving a reusable script, screenshots and an action log for each run.

    6k GitHub stars~2k tokensUpdated yesterday
    Productivity & AutomationAuto-check: notes
  • Inspects, diagnoses and directly controls qBittorrent, Transmission or rTorrent downloaders configured in MoviePilot through a bundled Python helper.

    12k GitHub stars~4.4k tokensUpdated today
    Productivity & AutomationAuto-check passed
  • Refly Skill Runner

    refly-ai/refly

    Base skill for the Refly ecosystem: finds, runs and monitors workflow-backed skills through the refly command line, with the actual work done on the Refly backend.

    7.5k GitHub stars~1.7k tokensUpdated 2 mo ago
    Productivity & AutomationAuto-check passed
  • TreeSheets Agent Socket

    aardappel/treesheets

    Runs Lobster scripts against the document open in a running TreeSheets instance through its local agent socket, and returns the results or errors.

    3.2k GitHub stars~5.7k tokensUpdated today
    Productivity & AutomationAuto-check: notes

Questions about SwitchBot Smart Home CLI

What does SwitchBot Smart Home CLI do?

Teaches an agent to control SwitchBot devices safely through the switchbot CLI: bootstrap first, query real device data, read policy.yaml and respect safety tiers. The skill lets an agent drive a user's SwitchBot smart home, covering lights, locks, curtains, sensors, plugs and IR appliances such as TVs, air conditioners and fans, through the switchbot CLI. Its rule is to query the CLI for ground truth and never guess commands, device IDs or parameter values.

When should I use SwitchBot Smart Home CLI?

SwitchBot Smart Home CLI fits situations like: turning lights, plugs or curtains on and off through SwitchBot; checking the status of a lock or sensor; controlling a TV, air conditioner or fan through an IR remote device; drafting and linting an automation rule for a device.

How do I install SwitchBot Smart Home CLI in Claude Code?

Run `npx skills add OpenWonderLabs/switchbot-openapi-cli --skill switchbot -a claude-code`. Or copy the skill folder (packages/codex-plugin/skills/switchbot in OpenWonderLabs/switchbot-openapi-cli) into .claude/skills/switchbot in your project. Claude Code loads it when a task matches its description.

How do I install SwitchBot Smart Home CLI in Codex?

Run `npx skills add OpenWonderLabs/switchbot-openapi-cli --skill switchbot -a codex`. Or copy the skill folder (packages/codex-plugin/skills/switchbot in OpenWonderLabs/switchbot-openapi-cli) into .agents/skills/switchbot in your project. Codex loads it when a task matches its description.

Can I use SwitchBot Smart Home CLI in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add OpenWonderLabs/switchbot-openapi-cli --skill switchbot -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/switchbot, .gemini/skills/switchbot, .github/skills/switchbot and .opencode/skills/switchbot in your project.

What does SwitchBot Smart Home CLI need to run?

Going by SKILL.md and its folder, SwitchBot Smart Home CLI needs the command-line tools its instructions call (npm). Our summary lists: The switchbot CLI; Outbound internet access to the npm registry and GitHub for switchbot codex setup.

Does SwitchBot Smart Home CLI access the network?

SKILL.md contains no URLs. Its commands use npm, which can reach the network depending on how they are called. This is read from the text; nothing was executed.

Is SwitchBot Smart Home CLI safe to install?

Our automated static check of SKILL.md flagged 1 warning(s): contains instruction-override wording (e.g. “without asking the user”). Read the flagged lines before installing; the check is not a guarantee either way.

What licence does SwitchBot Smart Home CLI use?

SwitchBot Smart Home CLI is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does SwitchBot Smart Home CLI use?

About 2.2k tokens (SKILL.md is roughly 8.6k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 302 tokens, read only when the agent opens those files.

What are the alternatives to SwitchBot Smart Home CLI?

Skills that share tags, products or a category with SwitchBot Smart Home CLI: Skyvern Browser Automation (Skyvern-AI/skyvern, 23k stars), Feishu Bitable Management (op7418/CodePilot, 6.5k stars), CUAWright Web Task Automation (microsoft/CUAWright, 6k stars) and MoviePilot Downloader Operation (jxxghp/MoviePilot, 12k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains SwitchBot Smart Home CLI?

OpenWonderLabs (a GitHub organization) maintains it in OpenWonderLabs/switchbot-openapi-cli, which has 133 GitHub stars. The repository was last updated on August 18, 2026.

Source: OpenWonderLabs/switchbot-openapi-cli on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.