Skip to content
Claude edited this page Jun 30, 2026 · 1 revision

Macros — Save Repeated Sequences as Skills

When an agent performs a multi-step UI sequence the user is likely to repeat (e.g. "open app X, click here, type this, save"), it should capture it as a reusable macro Skill instead of leaving ad-hoc tool calls. The MCP server's built-in instructions tell agents to do exactly this.

A macro is just a Skill that records the ordered tool calls and parameterizes the parts that vary.

Rules for a good macro

  • Resolve handles at run time, never hard-code them. Window/control handles change every launch — each replay must call list_windowslist_child_windows to find the current handle by title/class.
  • Prefer background tools (win_set_control_text, mouse_click with hwnd, screenshot(hwnd=...)) so replays don't steal focus.
  • Parameterize the variable parts (text to type, file path, target app).
  • Verify with a screenshot(hwnd=...) after key steps and check the result.
  • For interactive login steps, call show_window/show_headless_desktop, wait for the user, then hide_window/hide_headless_desktop.

SKILL.md skeleton

---
name: <macro-name>
description: <when to use this macro — the trigger phrases / situation>
---

# <Macro Title>

Goal: <one line>.

Parameters:
- `text` — <what the user provides>
- `app_title` — default "<Window Title Substring>"

Steps (replay in order with this MCP server):

1. Ensure the app is running:
   - list_windows { "title_filter": "{app_title}" }
   - if absent, run_command { "command": "<launch command>" } and re-list.
2. Find the target control:
   - list_child_windows { "window_title": "{app_title}" } → note the Edit `handle`.
3. Drive it in the background:
   - win_set_control_text { "hwnd": <edit handle>, "text": "{text}" }
4. Verify:
   - screenshot { "window_title": "{app_title}" }

Worked example

---
name: notepad-append
description: Append a line of text to the open Notepad without focusing it
---

1. list_child_windows { "window_title": "Notepad" } → find the "Edit"/"RichEdit"
   control; capture its `handle`.
2. win_set_control_text { "hwnd": <handle>, "text": "{text}" }
3. screenshot { "window_title": "Notepad" } to confirm.

The repo ships this template at macros/MACRO_SKILL_TEMPLATE.md, and a full feature skill at skills/lowlevel-computer-use/.

Clone this wiki locally