Communitygithub.com

GreenWich-art/agent-skills

A unified orchestration entry for desktop GUI operations. Use this skill when a user needs to operate a GUI-only application (change settings, click buttons, fill forms, operate software without a CLI/connector). It provides four levels of capability: routing decisions, authorization guidance, task dispatch and verification, and an AX fallback layer.

What is agent-skills?

This skill, named 'Desktop Takeover', serves as the central orchestration layer for AI agents to perform GUI operations on desktop applications, primarily on macOS. It is designed for scenarios where a task cannot be completed via connectors, browser automation, Office tools, or command-line scripts. The skill implements a four-tier capability system: first, a routing decision tree that determines the optimal path (connector, browser, CLI, or computer use); second, guidance for granting necessary macOS permissions (accessibility and screen recording); third, a structured task dispatch system that uses a three-part description (goal, boundaries, failure handling) to ensure robust execution; and fourth, an AX fallback tool (`axctl`) that uses Accessibility APIs for element-level operations without mouse interaction or focus stealing. It is extensively tested on macOS 15 and macOS 27.0.1, particularly around the quirks of Stage Manager, which can cause windows to become invisible to standard enumeration and screenshots. The skill provides detailed pre-flight checks, a troubleshooting quick reference, and explicit validation via final screenshots to confirm task success, avoiding reliance on text-based reports from the agent.

Works with~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/GreenWich-art/agent-skills/tree/HEAD/skills/desktop-takeover

Ask in your favorite AI

Open a new chat with this agent skill pre-loaded.

Documentation

Desktop Takeover

Overview

Unified orchestration for "having an agent take over the desktop to complete GUI operations": first route to determine the best path, then ensure computer use permissions are ready, and finally dispatch the task and verify. Computer use is a fallback path, not the preferred one—only used when the task must be completed via GUI.

Workflow Decision Tree

When a desktop operation request is received, determine the path in the following order, stop on the first match:

1. Connector/MCP directly accessible?
   Target app has an already-connected connector (GitHub, WPS knowledge base, WeCom, etc.)
   → Use the connector, don't touch GUI
   Example: Check a GitHub PR → gh connector; Read a WPS knowledge base doc → wps-knowledgebase

2. Pure browser operation?
   Task takes place on a webpage (fill forms, web clicks, screenshot comparison)
   → Use browser-use skill, don't touch system GUI
   Example: Log in to a website to change settings → browser-use

3. Office/WPS file read/write?
   Target is doc/docx/xls/xlsx/ppt/pptx file content
   → Use the office skill family (workbuddy-docx / sheetagent / local-office-edit)
   Example: Modify a table in Word → local-office-edit

4. Command line/script accessible?
   Task is fundamentally file operations, data processing, system configuration, and has a CLI or script path
   → Use Bash/scripts directly
   Example: Batch rename → script; Check system info → command

5. None of the above → computer use desktop takeover
   Task must operate on a GUI application's interface elements (buttons, menus, non-web forms)
   Example: Change a setting in some domestic software that only has a GUI entry

Decision principle: With each level down, reliability and speed decrease, uncertainty increases. GUI operations involve multiple uncertainties such as element positioning, window focus, and interface language, making it the last resort.

Note: The visibility dependency of level 5 (window enumeration + screenshots) is a structural weakness when Stage Manager is enabled (see Pre-flight item 2 and the "Invisible Window Trap"). AX tools (accessibility tree perception) read logical geometry and are not fooled by Stage Manager's thumbnail displacement; they are an alternative/supplementary path—re-checked on 27.0.1 has partially confirmed this (see Trap section Finding 5), with the caveat that newly launched windows that have never been on the Stage are also invisible to the AX tree. This skill's built-in AX fallback tool is: tools/axctl (usage in the "AX Fallback Layer" section).

When routing, if unsure whether a target app has a connector, first check list_installed_plugins, don't assert from memory.

Pre-flight: Dual Permission and Environment Check

Before going to computer use, two pre-flight checks must be completed, neither can be skipped:

1. Permission Check

Call gui_permission_status:

  • all_granted: true → Proceed to the second pre-flight check
  • Missing permissions → Guide the user to grant permissions following the flow in references/authorization-macos.md (macOS)
  • Windows → The current version only supports macOS; clearly inform the user

2. Stage Manager Pre-flight Check (Mandatory; users often have Stage Manager on)

Execute defaults read com.apple.WindowManager GloballyEnabled:

  • Returns 1 (enabled) → Before dispatching, must open -a <AppName> to activate the target app and bring it back to the current Stage (this will briefly steal focus; inform the user first), then confirm the target window is visible with gui_list_windows, and only then create_task. If the window is still not in the list after activation, go directly to the "Invisible Window Trap" troubleshooting sequence below—do not retry create_task, do not conclude the app is faulty
  • Returns 0 (disabled) → Proceed directly with the normal dispatch flow

This pre-flight check upgrades the Stage Manager trap from "post-diagnosis" to "pre-emptive avoidance". Stage Manager is not uncommon among macOS 15+ users; for those who have it enabled, this path is the default for every dispatch, not a special case. The activate-manifest mechanism was re-verified on macOS 27.0.1 on the same day and holds true, but with two new details: "first activation doesn't stick" and "manifestation then retraction", see the "Invisible Window Trap" section's 27 re-check subsection.

Task Dispatch

Once permissions are ready, follow the standard workflow of the built-in computer use skill:

  1. gui_list_windows to locate the target application's window; if not found, open_app to launch it
  2. Verify visibility after launch: After open_app, must run gui_list_windows again to confirm the window is actually in the list. If it doesn't appear, don't jump to "the app is broken"—first see the "Invisible Window Trap" below
  3. When Stage Manager is enabled (pre-flight confirmed): First open -a to activate the target app, then dispatch—see Pre-flight item 2; no need to re-evaluate here
  4. create_task(window_id, task) to dispatch the task

Invisible Window Trap (Stage Manager Scenario)

Scope of Conclusion: Established by controlled experiments on macOS 15; re-checked and re-verified on macOS 27.0.1 (Swift dual-channel probe + native AX API binary test; mechanism confirmed with new details, see below). AX layer conclusions have been confirmed by 27.0.1 post-authorization testing (AXError=0 path), no longer dependent on inference.

Trigger Condition: Stage Manager is active, unrelated to background launch itself. When enabled, windows of applications not currently on the Stage do exist but cannot be properly captured by window enumeration and screenshots—the process is alive, windows are created (e.g., Cmd+N works), but gui_list_windows doesn't see normal windows. Once the app is activated (window brought back to the current Stage), the window immediately becomes visible.

macOS 27.0.1 Re-check New Findings:

  1. Thumbnail bar mechanism visualized: Windows from staged-out apps are reduced to side thumbnail windows (tested: Calculator main window shrunk to 39×100pt, flush left, plus 4 full-width 34pt Stage placeholder windows). If gui_list_windows filters by "normal-sized windows," these thumbnail windows may be missed or misidentified
  2. Activate-manifest still holds, but with a "first activation doesn't stick" phenomenon: Tested: first open -a left the main window in thumbnail state (when another app occupied the foreground); second open -a expanded it to full size (405, 517, 230×408). Action: After activation, immediately verify with gui_list_windows; if not manifested, open -a again (max 2 times); only if still not manifested should you proceed to the troubleshooting sequence
  3. Manifested window may retract: If foreground is taken by another app, within ~5 seconds the window can shrink back to thumbnail state (reproduced in testing). Corollary: Screenshot verification has a time window—if foreground is taken during create_task execution, the task itself is unaffected, but if gui_screenshot is taken after retraction, the target window will be out of frame. Action: If a foreground switch just occurred before taking a screenshot, open -a first, then capture
  4. CGWindowList channel unaffected: optionOnScreenOnly and full list can enumerate the window (though titles require screen recording permission)—but note that the onScreenOnly list contains thumbnail windows, not the main window. Tools relying on window coordinates for click targeting will click the wrong position (clicking the thumbnail instead of the real button)
  5. AX tree reads logical geometry, immune to thumbnail displacement, but has blind spots (27.0.1 post-authorization testing): The AX return window frame is the full-size logical coordinate (e.g., (405,517,230×408)), while at the same time the CGWindowList rendering state is a 39×100 thumbnail—Stage Manager's geometric displacement does not fool AX. But blind spot: For a newly launched window that has never been on the Stage, the AX tree reports windows=0; after it has been on the Stage once and then moved to background, AX continues to see it. Corollary: AX perception is not unconditionally immune; apps launched for the first time still need to be activated onto the Stage first. Also: Sending synthetic mouse events to AX logical coordinates on screen will click the wrong app (logical position ≠ current rendering position)—AX tools must use accessibility action APIs like AXPress (e.g., axctl), not coordinate-based clicks

Troubleshooting Order (when the target app is not in the window list):

  1. First check if the process is alive (pgrep): alive → likely a visibility issue, not an app fault
  2. Confirm if the user has Stage Manager enabled (macOS 15+, defaults read com.apple.WindowManager GloballyEnabled, 1=enabled): enabled → go to step 3; not enabled → possibly window doesn't exist anymore or other reason
  3. Activate the app to make it visible: open -a <AppName> (will briefly steal focus; inform the user first); On 27, the first activation may not stick; verify immediately after activation; if not manifested, activate again (max 2 times)
  4. Run gui_list_windows again; usually the window_id will be available

Additional Signal: When Stage Manager is enabled, open_app usually does not get a window_id (returns a hint to do a second enumeration); when disabled, returns window_id normally.

Important Corollaries:

  • Reporting no visible windows ≠ window doesn't exist, and ≠ previous operation failed—the previously "failed" task may have actually succeeded (window created, just not visible)
  • Dialog-type windows (e.g., "Open" file dialog) become invalid once closed by the task; subsequent screenshots will error—this is normal; re-enumerate to get a new ID
  • Some apps (e.g., TextEdit) have no window when launched without a document; this is normal behavior; need to open with a file

Three-Part Task Description (Critical for Success)

The task parameter must include three parts:

Goal: Describe step by step what needs to be completed
Boundaries: Clearly state what must not be touched, e.g., "Do not click any entry in the history list"
Failure handling: If an action has no response, accurately record what happened and proceed to the next step; do not retry or change the method

The failure handling rule is not optional—without it, a single failure will trigger repeated retries, exhausting the entire step quota.

In the description, do not include pixel coordinates or numeric positions; use visible text and control names on the interface to refer to targets.

Example

User request: "Help me open the XX app and change the export format to CSV"

Goal: 1. Find and click the "Settings" or "Preferences" entry in the menu bar or toolbar
2. In the settings panel, find the "Export Format" or "Export Format" option
3. Change its value to CSV
4. Save settings and close the panel
Boundaries: Do not modify any other settings; do not click the "Reset" button
Failure handling: If the above controls are not found, record the actual control names seen and end the task; do not guess-click

AX Fallback Layer (axctl)

When the built-in computer use is unavailable (not enabled, gui_* tools missing, task too small to warrant dispatching) or semantic-level element operations are needed, use this skill's built-in AX fallback tool tools/axctl. Purely Accessibility API implementation, no mouse touching, no focus stealing, not limited by AppleEvents sandbox (WorkBuddy sandbox prohibits sending control events to System Events; the osascript path is deprecated; do not attempt it further).

Location and Installation: Binary tools/axctl, source tools/axctl.swift (Swift single file), both distributed with the skill. Before first use, run sh tools/install.sh: if swiftc is detected, it will compile on-site (recommended; source is auditable, tailored to the local architecture); otherwise, it uses the pre-compiled binary in the package (Apple Silicon only). After modifying the source code, recompile by running swiftc -O -o axctl axctl.swift in the tools directory.

Prerequisites: The host must have the "Accessibility" TCC permission (check in System Settings → Privacy & Security → Accessibility for the host app, then restart the host for it to take effect; confirmed ready when AX API call returns AXError=0).

Subcommands

axctl list <bundle-id|pid>        List windows: title + logical geometry frame
axctl tree <target> [depth]       Read UI tree: role/title/description/value/frame (default depth=2)
axctl actions <target> <title>    List available actions for a matching element
axctl press <target> <title>      Perform AXPress (semantic click, element-level, no coordinates needed)
axctl activate <target>           Activate app (NSRunningApplication.activate)

<target> supports bundle id (recommended, e.g., com.apple.calculator), numeric PID, or localized app name (lowercase matching—on Chinese systems, it's "计算器" not "Calculator"; name matching is error-prone; prefer bundle id).

Usage Rules

  1. Element Lookup: First tree or actions with a known button title to confirm AXPress exists, then press. press works only on elements with the AXPress action; menu items use AXPick; check per type
  2. Action Verification: After press returns PRESSED, use tree to read the target element or the new value of an associated display area as evidence (see Calculator test: after pressing "3", the StaticText value becomes 3)—same principle as computer use's screenshot verification; text self-report doesn't count
  3. Stage Manager Scenario: AX tree reads logical geometry; thumbnail-state windows are readable and operable (tested); but newly launched apps never on the Stage have an empty AX tree—first axctl activate or open -a to bring it to the Stage before operating
  4. Scope: axctl is suitable for element-level read/write (buttons/menus/text fields); for cross-app menu bar clicks, system-level keyboard/mouse simulation, or complex multi-step GUI flows, still use the built-in computer use dispatch
  5. Known Limitations: No UI change observer (axmcp's observe_changes capability; will be re-evaluated after upstream adapts to Swift 6.4); single-element operation per call, no batch transactions

Test Record (macOS 27.0.1, Stage Manager Enabled)

axctl press com.apple.calculator "3" → PRESSED path=w/0/0/0/1/0/15 → tree reads back AXStaticText value as 3—full chain of tree reading, positioning, semantic click, and effect verification works.

Result Verification

A GUI agent's text self-report is insufficient as evidence of completion—residual old UI state may be misjudged as success. You must:

  1. After the task returns done=true, call gui_screenshot(window_id) to get the final screenshot
  2. Use the screenshot content to determine if the goal was achieved
  3. When reporting to the user, note that the conclusion is based on the screenshot

Between rounds, do not take screenshots by default (the continue_task return value already contains execution history); only take an additional screenshot when the agent's reasoning/action_desc remains unchanged for several consecutive rounds to determine if it's stuck.

Troubleshooting Quick Reference

SymptomAction
permission_deniedSee references/authorization-macos.md
Stuck on the same step for multiple roundsCall continue_task with hint parameter providing the exact visible text of the control
Interface unchanged but reports successRely on gui_screenshot; confirm window_id is correct
conflictThat window already has a task; first delete_task
window_not_foundWindow closed or ID expired; re-run gui_list_windows
no visible windows (process alive)Stage Manager activated making the window uncapturable: open -a to activate → immediately re-enumerate; if not manifested, activate again (on 27, first activation may not stick; max 2 times); see "Invisible Window Trap" (experimentally confirmed on both 15 and 27.0.1)
Screenshot shows an abnormally small window / screen edgeTarget window is in Stage Manager thumbnail state (27 re-check finding): first open -a to activate and restore full size, then capture; see "Invisible Window Trap" 27 re-check subsection items 1 and 3
State is call_userHuman intervention needed; relay reasoning to the user; do not call continue_task

Platform Support

  • macOS: Full support. Authorization process in references/authorization-macos.md
  • Windows: Not yet tested; current version does not promise support. When encountering a Windows environment, honestly inform the user of this limitation; do not attempt to apply the macOS permission model

Resources

  • references/authorization-macos.md — Full macOS authorization process, including tested pitfalls (permission not effective after checkbox, Quit & Reopen dialog, etc.)
  • tools/axctl — AX fallback tool (source tools/axctl.swift in the same directory; run sh tools/install.sh before first use), usage in the "AX Fallback Layer" section

Individual skills in this repo

This repo contains 4 individual skills — each has its own dedicated page.

GreenWich-art/agent-skills

按学术论文规范(小三黑体一级标题/四号黑体二级/小四正文宋体1.5倍行距/三线表/中西文混排Times New Roman/统计量斜体) 批量重整 Markdown 或已有 docx 的格式。用户说"按学术格式排版""三线表""小三号黑体标题""1.5倍行距" "数字英文用Times New Roman""P值斜体"时使用。基于 python-docx 直接生成 docx,不走逐段插入。 不适用:高校课程论文/作业的字体字号约定(标准不同);党政机关公文国标 GB/T 9704 (又是另一套标准)。三套标准不可混用。

GreenWich-art/agent-skills

参考文献的 GB/T 7714-2015 著录规范化,以及 URL / DOI / PMID / PMC 链接的 可访问性批量核验与"假失效"识别。 触发场景: - 论文 / 综述 / 作业要交,需要核对参考文献格式 - "帮我按国标改一下参考文献" - 要交付一份文献清单,需要确认链接没死 - 已经有一堆 links,要批量验证哪些还能打开 含一个可复用脚本 `scripts/check_refs.py`,能自动判别 URL / DOI / PMID / PMC 并并发核验,且能区分「真死」与「被反爬」——后者不该判为失效。 不适用:从零生成一份带引文的正文(那是写作任务); Zotero 样式定制(见正文第六节,按需手工改 CSL)。

GreenWich-art/agent-skills

Local OCR using the macOS Vision framework. Triggers: OCR, 识别图片文字, 提取截图内容, 扫描件转文字, 图片转文字, 扫描版PDF转文字, read text from image/screenshot/photo/scanned PDF. Local-first and offline; prefer it over cloud OCR whenever data is sensitive or the machine is offline.

GreenWich-art/agent-skills

Download open-access biomedical article PDFs from PMC with offline Proof-of-Work solving. Triggers: 下载文献PDF, PMC PDF, 403/404 on PDF link, Preparing to download, reCAPTCHA page, OA full text, supplementary files, download paper PDF.

Related Skills