fnosp/fnos-dsh/harmony-automation
Claude Code and agent skill by fnosp/fnos-dsh
- community
Checking that the SKILL.md file is still in the repository.
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 a…
Install
npx vskill@latest install fnosp/fnos-dsh/harmony-automationSKILL.md
The same SKILL.md was published earlier as web-infra-dev/midscene-skills/harmony-automation.
HarmonyOS Device Automation
CRITICAL RULES — VIOLATIONS WILL BREAK THE WORKFLOW:1. Never run midscene commands in the background. Each command must run synchronously so you can read its output (especially screenshots) before deciding the next action. Background execution breaks the screenshot-analyze-act loop.2. Run only one midscene command at a time. Wait for the previous command to finish, read the screenshot, then decide the next action. Never chain multiple commands together.3. Allow enough time for each command to complete. Midscene commands involve AI inference and screen interaction, which can take longer than typical shell commands. A typical command needs about 1 minute; complexactcommands may need even longer.
Automate HarmonyOS NEXT devices using npx -y @midscene/harmony@1. Each CLI command maps directly to an MCP tool — you (the AI agent) act as the brain, deciding which actions to take based on screenshots.
What act Can Do
Inside a single act call on HarmonyOS, Midscene can tap, double-tap, long-press, type, clear text, scroll, drag items, press keys, and use system navigation such as Back, Home, or recent apps while working from the current visible screen. Two-finger zoom is not available because the underlying HarmonyOS automation layer does not expose multi-touch input.
Prerequisites
Midscene requires models with strong visual grounding capabilities. The following environment variables must be configured — either as system environment variables or in a .env file in the current working directory (Midscene loads .env automatically):
Example: Gemini (Gemini-3-Flash)
Example: Qwen 3.5
Example: Doubao Seed 2.0 Lite
Commonly used models: Doubao Seed 2.0 Lite, Qwen 3.5, Zhipu GLM-4.6V, Gemini-3-Pro, Gemini-3-Flash.
If the model is not configured, ask the user to set it up. See Model Configuration for supported providers.
HDC Setup
HDC (HarmonyOS Device Connector) must be installed and accessible. Common setup:
- Install via DevEco Studio
- Or set
HDC_HOMEenvironment variable to point to the HDC directory
Verify HDC is working:
Commands
Connect to Device
Launch an App or URL
Use the dedicated launch step when you want a deterministic starting point before the rest of the task:
Run a Raw HarmonyOS Shell Command
Use this when the task needs lower-level device control that is not best expressed as a visible UI interaction:
This is forwarded to hdc shell on the connected device. In practice, the underlying command is hdc -t <deviceId> shell hidumper -s RenderService -a screen.
Take Screenshot
After taking a screenshot, read the saved image file to understand the current screen state before deciding the next action.
Perform Action
Use act to interact with the device and get the result. It autonomously handles all UI interactions internally — tapping, typing, scrolling, swiping, waiting, and navigating — so you should give it complex, high-level tasks as a whole rather than breaking them into small steps. Describe what you want to do and the desired effect in natural language:
Assert Current Screen State
Use assert to verify that the current screen satisfies a natural language condition. It does not perform UI actions; it checks the visible screen state and passes only when the assertion is true. Use this for validation, QA checks, and final state verification after act.
By default a failed assertion throws an AI-generated reason. Pass --message to throw a custom error message instead, which is useful for surfacing the intended outcome in QA and CI logs.
When the assertion needs to compare against a reference image (icon, logo, screenshot), pass --image for the URL/path and --image-name for its display name. Each --image may be an http(s) link, a data: URI, or a local file path. Repeat both flags in matching order when you need to attach more than one image. Add --convertHttpImage2Base64 true when the model cannot reach the URL directly. Requires @midscene/harmony@1.9.0+.
Record and Assert Transient UI
Use a recording when the state to verify may disappear before a current-screen assertion runs, such as a toast, loading banner, animation, or transition:
Pass target flags, capture flags, and --output to record start, then wait for Recording. Press Ctrl+C to stop and save. Keep the recorder as a foreground process in its dedicated terminal; never add shell &. Perform the interaction manually or from a second terminal, send Ctrl+C to the recorder, and wait until it prints the saved path before asserting. HarmonyOS recording uses periodic screenshots. Optional capture flags are --interval-ms, --max-frames, and --watchdog-ms; --max-frames caps sampled frames, and the manifest may contain one additional final representative frame. The default watchdog finalizes and saves the recording after five minutes, while --watchdog-ms 0 disables that safety limit. The output is a JSON manifest plus an adjacent <name>.frames image directory, not an encoded video or archive. The manifest contains relative JPEG/PNG paths and no base64 image bodies. Keep or move the JSON file and image directory together, and pass the JSON path to assert --record. Use ordinary assert without --record when only the current screen matters.
Use a Reference Image for Precise Targeting
When the user provides a screenshot, icon, logo, or reference image and wants an exact visual match, prefer tap --locate instead of a generic act --prompt. Pass --locate as JSON. The prompt describes the target, images supplies named reference images, and convertHttpImage2Base64: true is useful when the image URL may not be directly accessible to the model.
The same locate JSON shape also works for other commands that accept a locate parameter.
Disconnect
Consume Report Files
The generated HTML report is recommended for human reading first. It includes step-by-step execution details and replay videos for each operation, which makes it much easier to understand what happened and troubleshoot problems.
If another skill or tool needs to consume the report, first convert it with report-tool from the same platform CLI package. Prefer Markdown for LLM-based workflows. Use JSON when the report needs to be processed programmatically.
Workflow Pattern
Since CLI commands are stateless between invocations, follow this pattern:
- Connect to establish a session
- Launch the target app and take screenshot to see the current state, make sure the app is launched and visible on the screen.
- Execute action using
actto perform the desired action or target-driven instructions. Useassertfor the resulting screen state, or keeprecord start --output ...running in a dedicated terminal during transient-state workflows, stop it with Ctrl+C, and then useassert --record. - Disconnect when done
Best Practices
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingplugins/dsh-midscene-plugin/skills/harmony-automation/SKILL.md
Popularity
- Repository stars
- 71
- Repository forks
- 9
- 7-day trend score
- 0
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/fnosp/fnos-dsh/harmony-automation)