AGENT SKILL

设备应用交互验证

device-interaction

通过截图、UI 层次结构和触摸交互,验证应用在系统(设备)或模拟器上的行为。

适用职业测试工程师
License 许可
MIT
所属仓库
mikker/dotfiles
最近更新
2026-11-10
Stars
★ 116
Forks
4

01 前言 Front Matter

name
device-interaction
description
Verify app behavior on device or simulator via screenshots, UI hierarchy, and touch interactions.

02 资源文件 3

03 SKILL.md 正文

Device Interaction

TRIGGER when: user asks to verify/test/check if the app works on device, after implementing a UI-affecting feature that needs device verification, user says "does it work", "test this", "check on device", user reports UI doesn't work as expected, need to debug touch/interaction issues. DO NOT TRIGGER when: user asks about unit tests only, build-only requests without device testing, code review without device testing, simulator configuration questions, changes that don't affect UI (e.g. comments, refactors, non-UI logic).


For the Main Agent

This is a SUBAGENT skill. Invoke it via the Agent tool when device verification is needed. If there is an open session for that work, provide that session identifier to a subagent for exclusive use by that subagent.

Agent tool:
- subagent_type: "general-purpose"
- description: "Verify login feature works"
- prompt: "Using the device-interaction skill, verify that the login feature works correctly on session <session-identifier>. Launch the app, capture screenshot and UI hierarchy, check that the login button is visible and tappable, and report if the implementation is working correctly."

After implementing a UI-affecting feature, invoke this skill to verify the implementation works on a device.

Session Lifecycle

DeviceInteractionStartWorkspaceSession (workspace-backed; do this early, runs in the background)
  → DeviceInteractionInstallAndRun (after each code change; includes building)
    → DeviceEventSynthesize (interact + observe, repeatable)
  → DeviceInteractionEndSession (when done — keeping sessions open is resource-heavy)

There are two ways to start a session:

  • DeviceInteractionStartWorkspaceSession — bound to a workspace. Required for DeviceInteractionInstallAndRun. Use this when verifying the app you are building.
  • DeviceInteractionStartSession — not bound to any workspace. Use this only when interacting with an already-installed app.

DeviceInteraction(Workspace)StartSession tools

Device Discovery

When opening a new device interaction session, pass a device identifier to select a device, or omit it to use the current destination. Pass an empty string to get a list of available targets.

DeviceInteractionInstallAndRun tool

Optional Parameters

  • commandLineArguments — arguments passed to the app at launch. Use $(inherited) as a token to preserve the scheme's existing arguments (e.g. ["$(inherited)", "--reset-state"] to add an extra argument at the end).
  • environmentVariables — key/value pairs set in the app's environment at launch. Use "$(inherited)" as a key to preserve the scheme's existing environment variables (e.g. {"$(inherited)": "", "DEBUG_MODE": "1"}).

Omit both parameters to leave the scheme's arguments and environment unchanged.

Prefer these parameters over editing the scheme directly. They are applied only for that one run and have no lasting effect on the user's configuration.


For the Subagent

ALWAYS report UI issues that might be caused by code: overlapping or unreadable text, unexpectedly cropped image/text, wrong colors etc.

DeviceEventSynthesize tool

This tool allows performing an interaction and observing the state of a device.

Reading Hierarchy Files

The hierarchy files include calculated hitPoint positions for each element:

UIView {{100, 200}, {60, 30}}, hitPoint: {130.0, 215.0}
  UIButton "Login" {{110, 205}, {30, 20}}, hitPoint: {125.0, 215.0}
  UIButton "Login2" {{140, 205}, {20, 20}}, hitPoint: {150.0, 215.0}, activationBundleId: com.your.app
  • {100, 200} - origin position
  • {50, 30} - width and height
  • hitPoint: {125.0, 215.0} - calculated hitPoint point (best for tapping)

Always prefer the hitPoint coordinates for touch events. Only after tapping a hitPoint and confirming (via recapture) it had no effect may you fall back to a raw screenshot-estimated position.

Warning: Elements marked isRemoteLeafPlaceholder do not report child elements — interacting with them requires falling back to screenshot-estimated coordinates.

Multiple Applications (activationBundleId annotations)

When windows from more than one application overlap on screen, each element line is annotated with a activationBundleId: <bundle-identifier> suffix.

If an element line carries a activationBundleId, any interaction with it requires activating that application first by passing activationBundleId parameter to the DeviceEventSynthesize tool.

Tip: you can pass activationBundleId with no interactionCommand. Application activation is expensive so use that only if necessary.

Example:

Device orientation: Landscape Right
------------------------
Application bundle identifier: com.some.app
Application UI orientation: Landscape Left
Application, pid: 123, label: ' '
 Window, {{0.0, 0.0}, {1133.0, 744.0}}, hitPoint: {566.5, 372.0}
  Other, {{0.0, 0.0}, {744.0, 1133.0}}, hitPoint: {372.0, 372.0}
...
------------------------
Application bundle identifier: com.some.other.app
Application UI orientation: Landscape Left
Application, pid: 333, label: ' '
 Window, {{0.0, 0.0}, {1133.0, 744.0}}, hitPoint: {566.5, 372.0}
...

Interaction Command Syntax

The interactionCommand parameter accepts a command syntax:

Command Description
t <x> <y> [duration] Tap at coordinates with optional hold duration
d <x> <y> Double tap
t <x1> <y1> f <x2> <y2> [duration] Swipe from (x1,y1) to (x2,y2)
drag <x1> <y1> <x2> <y2> [holdDuration] [moveDuration] Drag-and-drop: press-and-hold at (x1,y1) then slowly move to (x2,y2). Use for reordering lists or drag-and-drop targets
mt [x1 y1, ...] dur [x1 y1, ...] dur ... Multi-touch sequence. Each [...] keyframe lists touch positions (x y). The duration after each block is the travel time to the next keyframe; for the last block it is the hold time before lifting. A finger ends when its slot is an empty comma entry (e.g. [, x y]) or when the frame has fewer entries than the finger's index — both are equivalent. A finger that reappears in a later keyframe after lifting starts a new tap.
b h/p/u/d [duration] Hardware button: h=Home, p=Power, u=VolUp, d=VolDown
b c/s/a [duration] watchOS only. c=Digital Crown press, s=side button, a=Action button (some devices only)
sender keyboard kbd <text> Type text; must be the last command in the chain — all content after kbd is taken verbatim (multiple spaces preserved). For special characters use \u{XXXX} Unicode escapes: \u{000A} (return/newline), \u{0009} (tab)
w duration Wait for a duration without any work
orientation faceDown/faceUp/landscapeLeft/landscapeRight/portrait/portraitUpsideDown Set device orientation (iOS only)
c <rotations> watchOS only. Rotate the Digital Crown; sign sets direction, 1.0 = one full revolution

Examples:

  • "t 100 200" - Tap at (100, 200)
  • "d 200 300" - Double tap at (200, 300)
  • "t 200 600 f 200 200 0.3" - Swipe up (scroll to the content below)
  • "t 200 200 f 200 600 0.3" - Swipe down (scroll to the content above)
  • "drag 100 300 100 100" - Drag-and-drop from (100,300) to (100,100) with default durations
  • "drag 100 300 100 100 0.5 1.5" - Drag-and-drop with 0.5s hold, 1.5s move
  • "mt [100 200] 0.5 [100 200] 1.0 [300 400] 0.2" - Drag: hold at (100,200) for 0.5s, move to (300,400) over 1.0s, hold 0.2s then lift
  • "mt [100 300, 300 300] 0.5 [175 300, 225 300] 0.5" - Two-finger pinch: both fingers start 200px apart and move toward each other
  • "b h" - Press home button
  • "b h b h" - Press home button twice to go to the app switcher
  • "b h w 0 b h" - Wake and unlock a device (non-passcode devices only)
  • "b c" - watchOS: press the Digital Crown
  • "b s" - watchOS: press the side button
  • "b a" - watchOS: press the Action button (some devices only)
  • "sender keyboard kbd hello world" - Type text with spaces
  • "sender keyboard kbd hello world" - Type text preserving multiple spaces
  • "sender keyboard kbd submit\u{000A}" - Type text then press Return/submit
  • "w 0.3" - Wait for 0.3s
  • "orientation landscapeLeft" - Rotate device to landscape
  • "c 1.0" - watchOS: rotate the Digital Crown one full turn (e.g. scroll a list)
  • "c -0.5" - watchOS: rotate the crown half a turn the other way

Standard Subagent Workflow

Before any interaction, always capture and read the hierarchy (and screenshot). After any interaction, capture again and verify the result. For complex components (like toggles or switches), look at nested elements (like Switch or Slider) — nearby elements might correspond to the actual control. When done, report findings to the main agent.

  • To capture without interacting, use DeviceEventSynthesize with an empty interactionCommand.
  • Never guess positions from screenshots alone — use hierarchy hitPoint coordinates; screenshot estimation is only a fallback after a hitPoint is tried and fails.
  • If not confident or thumbnail resolution is insufficient, analyze the full-size screenshot.

Timing and Retries

  • App launch: After starting a session, the app may take a few seconds to load. Capture the hierarchy and check it has meaningful UI elements before interacting. If the hierarchy is mostly empty or shows a launch screen, capture again before proceeding.
  • After interaction: If a tap or swipe doesn't produce the expected change, recapture the hierarchy and retry the interaction once (the element may have shifted during an animation). If it still fails after one retry, report the failure rather than retrying indefinitely.
  • Loading states: If the hierarchy shows a spinner or loading indicator, capture again after a brief pause. Do not interact with elements that are still loading.
  • Performance: Avoid adding wait delays that might slow down the process. Tools are designed to complete once animations are done.

Judging Success vs Failure

When verifying, distinguish between these categories:

  • Functional bug (always report): element doesn't respond to tap, navigation goes to wrong screen, crash, data not displayed, missing expected UI element.
  • Visual/layout bug (always report): overlapping text, truncated labels, elements rendered off-screen, wrong colors, broken alignment.
  • Transient state (do NOT report as bug): loading spinners, brief animations, keyboard appearing/dismissing. Capture again after the transition completes.
  • Unexpected exits (always report): crashes, application exits. To identify, track process id and capture process's standard output.
  • Expected behavior (do NOT report as bug): empty states with placeholder text, disabled buttons when form is incomplete, permission dialogs.

Error Handling

  • If application is not visible, retry once, as this might be caused by a slow device.
  • If tap target unclear, re-read hierarchy data for correct hitPoint coordinates.
  • You can inspect runtime logs to troubleshoot. If you suspect timing bugs, suggest to the main agent that temporarily adding print statements in the relevant code may help diagnose the issue.
  • Report issues back to the main agent with details and suggestions.

04 同仓库更多 Skills

mikker
mikker/dotfiles

unslop

Cut AI tells from any writing.

★ 116
mikker
mikker/dotfiles

stageshow

Build faux product UI that looks like a real product, as a still illustration or an animated demo with a cursor. Browser and app windows, dashboards, phones, notifications, terminals, bento grids and cursor walkthroughs, framed, masked and cropped the way a marketing page, feature card or docs hero needs them. Use whenever someone wants a fake or mocked UI, a product demo or walkthrough animation, a hero or feature-card illustration of an app, a product shot in the style of a polished marketing site, or an animated cursor doing things in an interface, even if they never say "faux UI". React and plain CSS.

★ 116
mikker
mikker/dotfiles

clean-copy

Cut interface copy that shouldn't exist — captions that restate a label, hints that pre-empt a worry the user never had, warnings that are scar tissue from a fixed bug. Use when writing or reviewing any user-facing string (labels, hints, empty states, toasts, confirmations, button text), or when asked to clean up / tighten copy.

★ 116
mikker
mikker/dotfiles

Elyx 设计文件处理

elyx

Elyx 是一款设计工具,使用本地的、对 AI 友好的 `.elyx` 文件来管理屏幕、组件、布局、流程和设计系统。此技能仅对在外部 harness 中运行并使用 Elyx CLI 的智能体可用。在 Elyx 应用内部的 ACP harness 中运行时不可用,且不得使用。在外部 harness 中,凡涉及 Elyx 或 `.elyx` 文件的问题——包括创作、编辑、验证、检查、审查、重构、比较或推荐修改,以及不产生任何编辑的只读分析——在读取、推理或回答之前都应先使用此技能。不要仅凭源文本推断 `.elyx`;导入、实例、覆盖和布局只能通过工具来解析。

界面设计师视觉设计
★ 116
mikker
mikker/dotfiles

UIKit 应用多窗口现代化改造

uikit-app-modernization

通过将旧的共享状态 API 替换为符合上下文的现代替代方案,使 UIKit 应用现代化以适配多窗口环境。这包括对 mainScreen、interfaceOrientation、application 与 scene 生命周期,以及安全区域 inset 更新的引用。

软件开发工程师Apple 平台应用开发
★ 116
mikker
mikker/dotfiles

SwiftUI 27 新特性与变更

swiftui-whats-new-27

2027 年操作系统版本(iOS 27 及同步的 macOS/watchOS/tvOS/visionOS)中新增的 SwiftUI API、行为变更和弃用项。当被问及 SwiftUI 27 有哪些新特性,或处理以下工作时请查阅: - SDK 更新后的 @State 编译错误("used before being initialized"、"invalid redeclaration of synthesized property"),或 @State 变成宏 - @ViewBuilder/@ContentBuilder 的歧义重载或类型检查回归;通过 reorderable()/reorderContainer 及其拖放功能在任意容器(List、stacks、grids、自定义布局)中实现拖拽重排 - AsyncImage 缓存、滚动时重新加载或使用自定义 URLSession - 通过 swipeActions()/swipeActionsContainer() 在 List 之外(ScrollView、LazyVStack、LazyVGrid)使用滑动操作 - Toolbar 溢出、可见性(visibilityPriority、ToolbarOverflowMenu、toolbarMinimizeBehavior)与固定(pinning) - 从可选 item 绑定呈现 confirmationDialog 或 alert

软件开发工程师Apple 平台应用开发
★ 116