Back to Skills

harmonyos-device-automation

Vision-driven HarmonyOS NEXT device automation using Midscene. Operates entirely from screenshots — no DOM or accessibility labels required. Can interact with all visible elements on screen regardless of technology stack. Control HarmonyOS devices with natural language commands via HDC. Perform taps, swipes, text input, app launches, screenshots, and more. Trigger keywords: harmony, harmonyos, 鸿蒙, hdc, huawei device, harmony app, harmony automation, harmony phone, harmony tablet, test harmony ap

269stars19forksUpdated 7/14/2026

Security Assessment

Medium Risk(50/100)

Detected risks:

Secret Exposure([SKILL.md] API_KEY=)
Sensitive File Access([SKILL.md] .env)
Security Score50/100

About harmonyos-device-automation

harmonyos-device-automation provides vision-driven automation of HarmonyOS NEXT devices using Midscene.js, driving the device over HDC (HarmonyOS Device Connector). It solves the problem of automating and QA-testing HarmonyOS apps without relying on the DOM or accessibility labels — the agent works entirely from screenshots, so it can interact with any visible element regardless of the underlying technology stack, using natural-language commands.

The skill runs each capability as a CLI command via `npx -y @midscene/harmony@1`, where every command maps to an MCP tool and the agent acts as the decision-making brain. Core commands include `connect` (optionally by deviceId), `launch` for a deterministic starting app or URL, `take_screenshot`, `act` for high-level natural-language interactions (tap, double-tap, long-press, type, scroll, drag, key presses, and system navigation like Back/Home/recent apps), `assert` for verifying that the visible screen satisfies a condition, and `runhdcshell` for lower-level device commands forwarded to `hdc shell`. Assertions can compare against reference images and emit custom failure messages for QA and CI logs. The skill enforces critical operating rules: never run Midscene commands in the background, run only one command at a time, and allow enough time for each command (AI inference plus screen interaction can take a minute or more) so the screenshot-analyze-act loop stays intact. It requires a vision-capable model configured through `MIDSCENE_MODEL_*` environment variables (examples include Gemini, Qwen 3.5, and Doubao Seed) and a working HDC installation.

The skill targets QA engineers and developers who need end-to-end, visual verification of apps on HarmonyOS/Huawei devices. Because it reasons from screenshots, it is especially useful when accessibility metadata is unavailable and when a human-like, screen-driven testing loop is required. Note that two-finger zoom is not available because the HarmonyOS automation layer does not expose multi-touch input.

FAQ

Does this skill require app source, DOM, or accessibility labels?

No. It operates entirely from screenshots using Midscene's visual grounding, so it can interact with any visible on-screen element regardless of the technology stack.

What are the critical execution rules?

Never run Midscene commands in the background, run only one command at a time, and allow enough time for each to finish (a typical command needs about a minute, and complex `act` commands can take longer). This keeps the screenshot-analyze-act loop working.

What must be configured before use?

A vision-capable model via `MIDSCENE_MODEL_API_KEY`, `MIDSCENE_MODEL_NAME`, `MIDSCENE_MODEL_BASE_URL`, and `MIDSCENE_MODEL_FAMILY` (as env vars or a `.env`), plus a working HDC installation verified with `hdc version` and `hdc list targets`.

What is the difference between `act` and `assert`?

`act` performs UI interactions from a natural-language instruction (tapping, typing, scrolling, navigating), while `assert` performs no actions and only verifies that the current screen satisfies a natural-language condition — ideal for validation and CI checks.

Are there interactions it cannot perform?

Two-finger zoom (multi-touch) is not available because the underlying HarmonyOS automation layer does not expose multi-touch input.

Install harmonyos-device-automation

Download and extract the skill files to your .claude/skills/ directory.

Quick Setup:

  1. Copy the skill folder to .claude/skills/
  2. Claude will automatically detect and use the skill