Adds AI-powered UI testing to Vitest projects via Midscene. Supports Web (Playwright), Android, and iOS with natural-language interactions. Scaffolds, converts, and helps create/update/debug/run E2E tests.
Ships in web-infra-dev-midscene-skills-1. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
| Module | Role |
|---|---|
| Vitest | TypeScript test framework. Provides describe/it/expect/hooks for test organization, assertions, and lifecycle. |
| Midscene | AI-driven UI automation. Interacts with UI elements via natural language — no fragile selectors. Core API: aiAct. |
Supported platforms:
WebTest (Playwright Chromium): ctx.agent + ctx.pageAndroidTest (ADB + scrcpy): ctx.agent onlyIOSTest (WebDriverAgent): ctx.agent onlybash scripts/clone-boilerplate.sh
The boilerplate at ~/.midscene/boilerplate/vitest-all-platforms-demo/ is the canonical reference for project structure, configs, platform context classes, and test conventions. Compare the current project against it. If anything is missing, ask the user which platform(s) they need (Web / Android / iOS), then fill in what's missing using the boilerplate as the target state. Only include files for the requested platform(s). Do NOT overwrite existing configs or files. Copy .env.example from the boilerplate as .env if it doesn't exist, and prompt the user to fill in the env vars.
It contains mandatory rules for using aiAct — the primary API for all UI operations. Do NOT skip this step.
Use the boilerplate's e2e/ directory and src/context/ as reference for patterns and conventions. Before running tests, ensure dependencies are installed and .env is configured. When debugging failures, check troubleshooting.md.
ctx.agent is a platform-specific agent instance. All methods return Promises.
PlaywrightAgent from @midscene/web/playwrightAndroidAgent from @midscene/androidIOSAgent from @midscene/iosAll three agents share the same AI methods below.
aiAct for User-Described StepsWhen the user describes a UI action or state confirmation in natural language, you MUST use
aiActto implement it. Do NOT decompose user instructions intoaiTap/aiInput/aiAssertor other fine-grained APIs. Pass the user's intent directly toaiActand let Midscene's AI handle the planning and execution.
// User says: "type iPhone in the search box and click search"
// WRONG — manually decomposing into fine-grained APIs
await ctx.agent.aiInput('search box', { value: 'iPhone' });
await ctx.agent.aiTap('search button');
// CORRECT — pass intent directly to aiAct
await ctx.agent.aiAct('type "iPhone" in the search box, then click the search button');
Assertions, data extraction, and waiting should also be done via aiAct — it handles all of these. Do NOT use aiAssert, aiQuery, aiWaitFor, aiTap, or aiInput separately.
aiAct is the primary API for all UI operations and state confirmations. It accepts natural language instructions and autonomously plans and executes multi-step interactions.
// UI operations
await ctx.agent.aiAct('type "iPhone" in the search box, then click the search button');
await ctx.agent.aiAct('hover over the user avatar in the top right');
// State confirmations / assertions — also use aiAct
await ctx.agent.aiAct('verify the page shows "Login successful"');
await ctx.agent.aiAct('verify the error message is visible');
When an aiAct prompt asks Midscene to upload files, pass fileChooserAllowedDir explicitly. Use the smallest directory containing that test case's fixtures, and refer to files relative to it in the prompt. Do not use the project root or a home directory. Replace ./fixtures below with the fixture directory relative to the test process working directory.
await ctx.agent.aiAct(
'click the upload button and upload avatar.png',
{ fileChooserAllowedDir: './fixtures' },
);
Phase splitting: If the task prompt is too long or covers multiple distinct stages, split it into separate aiAct calls — one per phase. Each phase should be a self-contained logical step, and all phases combined must match the user's original intent.
// Incorrect — prompt spans multiple pages and too many steps, AI may lose context mid-way
await ctx.agent.aiAct('click the settings button in the top nav, go to settings page, find personal info and click into it, change email to "[email protected]", change phone to "13800000000", click save, wait for success');
// Correct — split by page/stage boundary, each phase stays within one logical context
await ctx.agent.aiAct('click the settings button in the top nav, go to settings page, find personal info and click into it');
await ctx.agent.aiAct('change email to "[email protected]", change phone to "13800000000", click save');
await ctx.agent.aiAct('verify the save success message appears');
aiActionis deprecated. UseaiActoraiinstead.
'button' is ambiguous; use 'the blue "Submit" button at the top of the page'aiAction — use aiAct instead'the delete button in the first product row'aiActionContextaiActionContext is a system prompt string appended to all AI actions performed by the agent. Use it to define the AI's role and expertise.
// Set via agentOptions in setup()
const ctx = WebTest.setup('https://example.com', {
agentOptions: {
aiActionContext: 'You are a Web UI testing expert.',
},
});
Good examples:
'You are a Web UI testing expert.''You are an Android app testing expert who is familiar with Chinese UI.'Bad examples:
'Click the login button.' — specific actions belong in aiAct(), not aiActionContext'The page is in Chinese.' — this is page description, not a system promptnode_modules/@midscene/web, node_modules/@midscene/android, and node_modules/@midscene/ios, find the type definitions for the agent classes.d.ts files to read the implementation code in node_modulesgrep to search for the API or concept you need (the file is large, do not read it in full)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
6 skills in this plugin
/android-device-automationVision-driven Android 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 Android devices with natural language commands via ADB. Perform taps, swipes, text input, app launches, screenshots, and more.
Trigger keywords: android, phone, mobile app, tap, swipe, install app, open app on phone, android device, mobile automation, adb, launch app, mobile screen, test android app, verify mobile app, QA on phone, check the app on android, test on device, see if the app works on phone, end-to-end test on android, visual verification on mobile
Powered by Midscene.js (https://midscenejs.com)
/browser-automationVision-driven browser automation using Midscene. Operates from screenshots — no DOM or accessibility labels needed.
Runs in headless Puppeteer — does NOT take over the user's mouse or keyboard.
Also supports CDP mode and Bridge mode to connect to an existing Chrome.
Use this skill when the user wants to:
- Browse, navigate, or open web pages
- Scrape, extract, or collect data from websites
- Fill out forms, upload local files, click buttons, or interact with web elements
- Verify, validate, test, or QA frontend UI behavior
- Take screenshots of web pages
- Automate multi-step web workflows
- Test what was just built, see if it works in browser
- Connect to Chrome via CDP, DevTools Protocol, or remote debugging
- Connect to user's Chrome browser, control my browser, operate my Chrome
Powered by Midscene.js (https://midscenejs.com)
/computer-automationVision-driven desktop automation using Midscene. Control your local desktop (macOS, Windows, Linux) or a remote Windows desktop over RDP with natural language commands.
Operates entirely from screenshots — no DOM or accessibility labels required. Can interact with all visible elements on screen regardless of technology stack.
⚠️ In local mode this takes over the user's real mouse and keyboard. For web apps, prefer "Browser Automation" instead.
Only use this for desktop-native apps (Electron, Qt, native macOS/Windows/Linux) that cannot run in a browser, or for driving a remote Windows host via RDP.
Triggers: open app, press key, desktop, computer, click on screen, type text, screenshot desktop,
launch application, switch window, desktop automation, control computer, mouse click, keyboard shortcut,
screen capture, find on screen, read screen, verify window, close app, test Electron app,
rdp, remote desktop, windows server, connect via rdp
Powered by Midscene.js (https://midscenejs.com)
/harmonyos-device-automationVision-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 app, verify on harmonyos, QA on 鸿蒙, check the app on harmony, test on huawei device, see if the app works on harmony, end-to-end test on harmonyos, visual verification on 鸿蒙
Powered by Midscene.js (https://midscenejs.com)
/ios-device-automationVision-driven iOS device automation using Midscene CLI. Operates entirely from screenshots — no DOM or accessibility labels required. Can interact with all visible elements on screen regardless of technology stack.
Control iOS devices with natural language commands via WebDriverAgent.
Triggers: ios, iphone, ipad, ios app, tap on iphone, swipe, mobile app ios,
ios device, ios testing, iphone automation, ipad automation, ios screen, ios navigate,
test ios app, verify on iphone, QA on ipad, check the app on ios, test on ios device,
see if the app works on iphone, end-to-end test on ios, visual verification on ios
Powered by Midscene.js (https://midscenejs.com)
/web-infra-dev-midscene-skills-1:vitest-midscene-e2e [create|update|run|init] <feature-name>from web-infra-dev-midscene-skills-1
web-infra-dev-midscene-skills-1@cascade-ai-ml-agents-misc-2 is listed by joshuarweaver/cascade-ai-ml-agents-misc-2 — review the source before installing
npx claudepluginhub joshuarweaver/cascade-ai-ml-agents-misc-2 --plugin web-infra-dev-midscene-skills-1Other plugins' skills for the same job