snapshot

Dump the accessibility tree of any application and get refs you can use with every other command.

Usage

agent-click snapshot [OPTIONS]

Options

OptionDescription
-a, --appTarget application
-i, --interactiveOnly show interactive elements (buttons, inputs, links)
-c, --compactSkip empty structural elements
-d, --depthLimit tree traversal depth

Examples

agent-click snapshot -a Calculator -i -c        # interactive + compact (best for AI)
agent-click snapshot -a Safari -i -c -d 8       # deeper tree
agent-click snapshot -a Music                   # full tree (verbose)

Output

application "Calculator" window "Calculator" id=main group splitgroup id=main, SidebarNavigationSplitView group group id=CalculatorKeypadView [@e1] button "Delete" id=Delete [@e2] button "All Clear" id=AllClear [@e3] button "7" id=Seven [@e4] button "8" id=Eight

Each [@eN] is a ref you can use in other commands:

agent-click click @e3          # clicks "7"
agent-click get-value @e1      # reads "Delete" button info

Refs

  • Refs are assigned sequentially: @e1, @e2, @e3...
  • With -i, only interactive elements get refs (reduces noise)
  • Refs are cached in ~/.agent-click/refs.json with a 5-minute staleness warning
  • Refs go stale after any UI change — always re-snapshot after acting

CDP (Electron apps)

For Electron apps, snapshot merges the native window shell (menus, title bar) with the CDP DOM tree:

agent-click snapshot -a Slack -i -c

CDP elements get id=__cdp:N identifiers and are clickable via JavaScript.

Tips

  • Always use -i -c for AI workflows — 10x less output
  • Add -d 8 if elements are missing (deeper tree)
  • Re-snapshot after every action — refs become stale