Overview
Every agent-native command supports the--json flag for structured output. This makes agent-native ideal for AI agents and programmatic use.
JSON output uses pretty-printed, sorted keys for readability and consistency.
Why JSON output?
For AI agents and programmatic use:- Structured data that’s easy to parse and query
- Consistent format across all commands
- Rich metadata including element attributes, actions, and state
- No text parsing required — direct access to all fields
- Type safety when used with typed languages
Global pattern
Add--json to any command:
Command output formats
apps
List running GUI applications.Output
name(string): Application namepid(number): Process IDbundleId(string | null): Bundle identifierisActive(boolean): Whether app is frontmostisHidden(boolean): Whether app is hidden
snapshot
Capture AX tree with refs.Output
ref(string): The ref identifier (e.g. “n1”, “n2”)role(string): AX role (e.g. “AXButton”, “AXTextField”)title(string | null): Element titlelabel(string | null): Accessibility labelvalue(string | null): Current value (for inputs, checkboxes, etc.)enabled(boolean): Whether element is enabledactions(string[]): Available AX actionsdepth(number): Depth in the tree (0 = root)
click
Click an element.Output
action(string): The action performedsuccess(boolean): Whether action succeededelement(object): Full element metadata
fill / type
Fill or type into a field.Output
action(string): “fill” or “type”success(boolean): Whether operation succeededtext(string): The text that was enteredelement(object): Full element metadata
check / uncheck
Toggle checkbox state.Output
action(string): “check” or “uncheck”success(boolean): Whether operation succeededelement(object): Full element metadata with updatedvalue
The
check and uncheck commands are idempotent — they check current state first and only toggle if needed.get text / value / attr
Read element data.Output
Output
Output
get title
Get frontmost window title.Output
is enabled / focused
Check element state.Output
Output
inspect
Get all attributes and actions.Output
element(object): Basic element infoattributes(object): All AX attributes as key-value pairsactions(string[]): Available actions
find
Find elements by filters.Output
AXNode objects matching the filters.
screenshot
Capture app window.Output
Output
path(string): Path to saved screenshotwidth(number): Image width in pixelsheight(number): Image height in pixels
action
Perform arbitrary AX action.Output
Parsing strategies
Python
JavaScript / TypeScript
Bash (with jq)
Error handling
When a command fails, agent-native:- Prints JSON error to stderr (if
--jsonwas used) - Exits with non-zero code
stderr
Type definitions
For TypeScript projects, you can define types for agent-native output:Next steps
Best practices
Learn patterns for reliable AI automation
AI integration
See example workflows and integration patterns