|
| 1 | +--- |
| 2 | +name: annotate-ui |
| 3 | +description: Annotate a web page with hover labels so you can identify UI elements by name. Use when doing frontend development and you need to reference specific elements. |
| 4 | +argument-hint: "<localhost-url> | (no args = auto-detect)" |
| 5 | +--- |
| 6 | + |
| 7 | +# Annotate UI |
| 8 | + |
| 9 | +When doing frontend development, use the UI Annotator to label page elements so you and the user can reference them by name. |
| 10 | + |
| 11 | +## When to use |
| 12 | + |
| 13 | +- User is working on frontend code and asks about specific UI elements |
| 14 | +- User says "change this", "move that", "what's this element called?" |
| 15 | +- User starts a dev server (e.g. `npm run dev`, `vite`, `next dev`) and you see a localhost URL |
| 16 | +- User asks for design feedback or wants to discuss layout changes |
| 17 | + |
| 18 | +## How to use |
| 19 | + |
| 20 | +### Step 1: Annotate the page |
| 21 | + |
| 22 | +When you detect a localhost URL (from `npm run dev` output, user message, etc.): |
| 23 | + |
| 24 | +``` |
| 25 | +Use the annotate tool with the localhost URL. |
| 26 | +``` |
| 27 | + |
| 28 | +This returns a proxy URL (http://localhost:7077/...). Tell the user to open this URL instead of the original localhost URL. |
| 29 | + |
| 30 | +### Step 2: Get elements |
| 31 | + |
| 32 | +Once the user has the page open in the proxy URL: |
| 33 | + |
| 34 | +``` |
| 35 | +Use get_elements to see all labeled UI elements on the page. |
| 36 | +``` |
| 37 | + |
| 38 | +This returns element names, CSS selectors, positions, and sizes. |
| 39 | + |
| 40 | +### Step 3: Reference by name |
| 41 | + |
| 42 | +Now you and the user can reference elements by name: |
| 43 | +- User: "make the hero-card bigger" |
| 44 | +- You know exactly which element `hero-card` is, its selector, and its position |
| 45 | +- You can make the code change with confidence |
| 46 | + |
| 47 | +### Step 4: Highlight to confirm |
| 48 | + |
| 49 | +If unsure which element the user means: |
| 50 | + |
| 51 | +``` |
| 52 | +Use highlight_element with the element name to flash it on the page. |
| 53 | +``` |
| 54 | + |
| 55 | +The user sees a red flash around the element and can confirm yes/no. |
| 56 | + |
| 57 | +## Tips |
| 58 | + |
| 59 | +- After code changes that affect the DOM, use `rescan_elements` to refresh the element list |
| 60 | +- Use `inspect_mode` to let the user click elements and copy their names |
| 61 | +- The proxy strips CSP headers, so it works even on strict sites |
0 commit comments