How Glue Works
Glue connects your UI to coding agents through a three-phase pipeline: compile-time instrumentation, runtime annotation, and agent handoff.Phase 1: Compile-Time Instrumentation
When you runglue run npm run dev, Glue instruments your JSX at compile time. Every host element (native HTML tags like <button>, <div>, <input>) gets data-agent-* attributes injected automatically:
data-agent-id— A deterministic, stable identifier derived from the element’s source location (file, line, column, tag)data-agent-source-file— Source file path relative to the project rootdata-agent-source-line— Line numberdata-agent-source-col— Column number
Only host elements (lowercase tags) are instrumented. React components like
<Button> or <CustomForm> are not — because only host elements render to the DOM.Phase 2: Runtime Annotation
With your app instrumented and running, use the Glue desktop app to visually annotate UI elements:- Browse your app in the embedded browser
- Click any element to select it
- Glue auto-discovers the nearest instrumented parent and extracts all
data-agent-*attributes - Add your comment describing what you want changed
Selector Priority
When you select an element, Glue generates multiple selectors ranked by stability:| Priority | Selector Type | Stability |
|---|---|---|
| 105 | data-agent-id | Highest |
| 100 | id attribute | High |
| 95 | data-testid | High |
| 85 | Unique CSS classes | Medium |
| 70 | Path selector | Low |
| 50 | nth-child | Lowest |
data-agent-id selector is always preferred because it’s deterministic and source-linked. Traditional selectors serve as fallbacks.
Phase 3: Agent Handoff
Runglue handoff to export annotations in formats coding agents understand:
latest.json— Structured JSON with element references, source locations, selectors, and commentslatest.md— Human-readable spec with file paths, line numbers, and acceptance criteria
data-agent-id, and implements the requested change.
Production Safety
Glue has zero production impact:- Conditional compilation — Instrumentation only runs in development mode
- Dev-only dependencies — All Glue packages are
devDependencies - No runtime code — Attributes are inert data; no JavaScript executes for Glue in the browser