xgg — CLI for Claude Code and Codex
A CLI that controls Mijia devices through the cloud and writes Xiaomi gateway automation rules that the agent verifies in logs.
Install in Claude Code, Codex and OpenClaw
Other ways to install
Access and checks
How we reviewBroad access. The tool can change data, run commands or handle secrets.
- Changes the state of real devices and home automation rules on behalf of your Mijia account.
- Stores cloud authorization in a file shared with `mijia-api`.
- Updates the CLI and skill from npm on its own.
This is third-party code. Review the repository files before installing.
What it does
xgg, a TypeScript command-line program, joins two channels: the Mijia cloud for devices and a Xiaomi Central Hub gateway (the enthusiast edition) for automation rules. Through the cloud the agent reads and changes device properties and runs actions and scenes. Through the gateway it creates, validates and enables rules and reads variables and the execution log. Output is JSON by default and errors suggest the next step. Before a write the program saves the original value, reads it back and can restore it. New rules are created disabled. Login to Mijia uses a QR code from the app, and the gateway login code is obtained by the agent through the cloud authorization.
Who it is for. Owners of a Mijia smart home with a Xiaomi Central Hub gateway who hand device work and automation rules to an agent.
Good fit when
- A lamp, socket or climate unit should be checked and switched from an agent chat.
- An automation rule with variables, timers and conditions is easier to describe in words than to build by hand.
- A broken automation is diagnosed by the agent from the log and execution trace.
- Before a new automation, an inventory of the home's devices and rules is made.
Not a fit when
- There is no Xiaomi Central Hub gateway: without it only cloud device control remains.
- The home runs on Home Assistant or another platform: xgg talks only to Mijia and the Xiaomi gateway.
- The devices or gateway are not yours: the program is meant for personal lawful use.
Example request
List my Mijia home devices, read the living room lamp state and propose a disabled rule that turns the light off at night.Limitations
The project is unofficial and unaffiliated with Xiaomi, and the Mijia cloud protocol is borrowed from the third-party mijia-api project. Available features depend on the device, firmware and account rights. The author verified gateway login on one model, and compatibility with others is unconfirmed. The gateway must be reachable on the local network. Documentation is in Chinese and the license is GPL-3.0. Auto-update of the CLI and skill is on by default and is switched off with `XGG_AUTO_UPDATE=0`.
How to disable. Run `xgg cloud logout`: it deletes the cloud authorization file shared with `mijia-api`, which will then also need a new login. Then remove the `@eyaeya/xgg-cli` package and the `xgg-rule-authoring` skill from the agent's skills directory. Disable enabled rules on the gateway separately.
FAQ
How do I sign in to Mijia?
`xgg cloud login` returns a QR code to confirm in the Mijia app. Scan again if the authorization was revoked or expired.
Do I need the gateway IP?
No. The address is found from the cloud device list and an identifier, and the agent gets the six-digit login code itself. Manual code entry remains a fallback.
How is writing protected?
The value is saved before a write and read after. If the write status is unknown the command is not resent automatically. Rules are created disabled and `lint --strict` runs before enabling.
How does it update?
With `xgg update`. A background check also runs once a day before read-only commands. Switch it off with `XGG_AUTO_UPDATE=0`.
What works without a gateway?
Cloud control: homes, rooms, devices, properties, actions, scenes, consumables and statistics, plus smart speakers.
How do I install xgg?
Run npx skillfoxx add cli/xgg in a terminal.
Discussion
No questions or reviews yet.
README in short
The README describes two packages, `@eyaeya/xgg-core` and `@eyaeya/xgg-cli`, support for 25 node types in the rule graph and QR cloud authorization. In the test report, 16 of 17 reversible write candidates passed restore of the original value.