Skip to content

CLI Reference

tauri-pilot is a command-line client that communicates with the tauri-plugin-pilot server running inside your Tauri application over a Unix socket.

These options can be used with any command.

OptionDescription
--socket <path>Explicit path to the Unix socket. Auto-detected if omitted. Env: TAURI_PILOT_SOCKET
--window <label>Target a specific window by label. Env: TAURI_PILOT_WINDOW. Default: main, falls back to first available
--jsonOutput JSON instead of human-readable text

When --socket is not specified, the CLI resolves the socket in this priority order:

  1. --socket <path> — explicit flag (highest priority)
  2. $TAURI_PILOT_SOCKET — environment variable
  3. Glob /tmp/tauri-pilot-*.sock → most recently modified file (by mtime)

The --window <label> option (or TAURI_PILOT_WINDOW env var) selects which window all commands operate on:

Terminal window
tauri-pilot --window settings snapshot # snapshot the settings window
tauri-pilot click @e3 --window main # click in the main window
TAURI_PILOT_WINDOW=settings tauri-pilot snapshot

If --window is not specified, the CLI targets the main window and falls back to the first available window. If the specified window label does not exist, the command exits with an error.

Many commands accept a <target> argument that identifies a DOM element. Three formats are supported:

FormatExampleDescription
Element ref@e1Reference from the last snapshot call
CSS selector#submit-btn or .classStandard CSS selector
Coordinates100,200Raw x,y screen coordinates

Note: Element refs (@e1, @e2, …) are reset on every snapshot call. Always take a fresh snapshot before using refs.


Health check. Verifies the plugin server is reachable and responding.

Terminal window
tauri-pilot ping

Example:

Terminal window
$ tauri-pilot ping
ok

List all open windows with their label, URL, and title.

Terminal window
tauri-pilot windows

Example:

Terminal window
$ tauri-pilot windows
main http://localhost:1420/dashboard PR Dashboard
settings http://localhost:1420/settings Settings
about http://localhost:1420/about About

JSON-RPC example:

// Request
{"jsonrpc":"2.0","id":1,"method":"windows.list","params":{}}
// Response
{"jsonrpc":"2.0","id":1,"result":{"windows":[
{"label":"main","url":"http://localhost:1420/dashboard","title":"PR Dashboard"},
{"label":"settings","url":"http://localhost:1420/settings","title":"Settings"},
{"label":"about","url":"http://localhost:1420/about","title":"About"}
]}}

Capture the current accessibility tree of the WebView and assign stable element refs (e1, e2, …).

Terminal window
tauri-pilot snapshot [OPTIONS]

Options:

OptionDescription
-i, --interactiveOnly include interactive elements (buttons, inputs, links, etc.)
-s, --selector <sel>Scope the snapshot to the subtree matching this CSS selector
-d, --depth <n>Maximum tree depth to traverse
--save <file>Save the snapshot to a JSON file for later comparison with diff --ref

Example:

Terminal window
$ tauri-pilot snapshot --interactive
e1 heading "PR Dashboard"
e2 textbox "Search PRs" value=""
e3 button "Refresh"

JSON-RPC example:

// Request
{"jsonrpc":"2.0","id":1,"method":"snapshot","params":{"interactive":true}}
// Response
{"jsonrpc":"2.0","id":1,"result":{"elements":[
{"ref":"e1","role":"heading","name":"PR Dashboard","depth":0},
{"ref":"e2","role":"textbox","name":"Search PRs","depth":1,"value":""},
{"ref":"e3","role":"button","name":"Refresh","depth":1}
]}}

Compare the current page state with a previous snapshot and show only the differences. Massive token savings for AI agents that currently re-read the entire tree after each interaction.

Terminal window
tauri-pilot diff [OPTIONS]

Options:

OptionDescription
--ref <file>Diff against a saved snapshot file instead of the last in-memory snapshot
-i, --interactiveOnly include interactive elements in the new snapshot
-s, --selector <sel>Scope the new snapshot to a CSS selector
-d, --depth <n>Maximum tree depth to traverse

Output format:

Terminal window
+ button "Submit" [ref=e8] # added
- button "Loading..." [ref=e3] # removed
~ textbox "Search PRs" [ref=e2] value: """workspace" # changed

Example:

Terminal window
# Take a snapshot, interact, then diff
$ tauri-pilot snapshot -i
$ tauri-pilot fill @e2 "workspace"
$ tauri-pilot click @e3
$ tauri-pilot diff -i
~ textbox "Search PRs" [ref=e2] value: """workspace"
# Save and diff against a file
$ tauri-pilot snapshot -i --save before.snap
$ tauri-pilot fill @e2 "workspace"
$ tauri-pilot diff -i --ref before.snap
# No changes
$ tauri-pilot diff -i
No changes detected.

How matching works:

Elements are matched between snapshots by (role, name, depth) — not by ref ID, since refs reset on every snapshot. For duplicate elements sharing the same identity, position order is used as a tiebreaker.

JSON-RPC example:

// Request (diff vs last snapshot)
{"jsonrpc":"2.0","id":1,"method":"diff","params":{"interactive":true}}
// Request (diff vs saved reference)
{"jsonrpc":"2.0","id":1,"method":"diff","params":{"interactive":true,"reference":{"elements":[...]}}}
// Response
{"jsonrpc":"2.0","id":1,"result":{
"added": [{"ref":"e8","role":"button","name":"Submit","depth":1}],
"removed": [{"ref":"e3","role":"button","name":"Loading...","depth":1}],
"changed": [{"old":{"ref":"e2","role":"textbox","name":"Search PRs","value":"","depth":1},
"new":{"ref":"e2","role":"textbox","name":"Search PRs","value":"workspace","depth":1},
"changes":["value"]}]
}}

One-step verification of element state, text, or URL. Returns exit code 0 with ok on success, exit code 1 with a clear error message on failure. Designed to reduce AI agent round-trips and token usage.

Terminal window
tauri-pilot assert <subcommand> [args...]

Subcommands:

SubcommandArgumentsDescription
text<target> <expected>Assert exact text content match
visible<target>Assert element is visible
hidden<target>Assert element is hidden
value<target> <expected>Assert input/textarea/select value
count<selector> <expected>Assert number of elements matching CSS selector
checked<target>Assert checkbox/radio is checked
contains<target> <expected>Assert text contains substring
url<expected>Assert current URL contains substring

Examples:

Terminal window
# Take a snapshot first (refs reset each time)
$ tauri-pilot snapshot -i
# Exact text match
$ tauri-pilot assert text @e1 "Dashboard"
ok
# Element visibility
$ tauri-pilot assert visible @e3
ok
# Check input value
$ tauri-pilot assert value @e2 "workspace"
FAIL: expected value "workspace", got ""
# Count elements by CSS selector
$ tauri-pilot assert count ".list-item" 5
ok
# Checkbox state
$ tauri-pilot assert checked @e4
FAIL: element is not checked
# Partial text match
$ tauri-pilot assert contains @e1 "Dash"
ok
# URL check
$ tauri-pilot assert url "/dashboard"
ok

Note: Element refs (@e1, @e2, …) require a prior snapshot call. Always take a fresh snapshot before using refs in assertions.

Exit codes:

CodeMeaning
0Assertion passed
1Assertion failed — error message on stderr

Simulate a realistic click on an element (dispatches focus → mousedown → mouseup → click events).

Terminal window
tauri-pilot click <target>

Example:

Terminal window
tauri-pilot click @e3
tauri-pilot click "#submit-btn"
tauri-pilot click 100,200

Clear an input field and type a new value. Uses the native setter to trigger synthetic React events.

Terminal window
tauri-pilot fill <target> <value>

Example:

Terminal window
tauri-pilot fill @e2 "my-feature-branch"
tauri-pilot fill "#search" "open issues"

Type text into a focused element without clearing existing content first.

Terminal window
tauri-pilot type <target> <text>

Example:

Terminal window
tauri-pilot type @e2 " additional text"

Send a keyboard event to the focused element.

Terminal window
tauri-pilot press <key>

Common keys: Enter, Tab, Escape, ArrowDown, ArrowUp, Backspace, Space.

Example:

Terminal window
tauri-pilot press Enter
tauri-pilot press Tab
tauri-pilot press Escape

Select an option in a <select> dropdown by value.

Terminal window
tauri-pilot select <target> <value>

Example:

Terminal window
tauri-pilot select "#status-filter" "open"
tauri-pilot select @e5 "closed"

Toggle a checkbox (check if unchecked, uncheck if checked).

Terminal window
tauri-pilot check <target>

Example:

Terminal window
tauri-pilot check "#remember-me"
tauri-pilot check @e7

Scroll the page or a specific element.

Terminal window
tauri-pilot scroll <direction> [amount] [OPTIONS]

Arguments:

ArgumentDescription
<direction>up, down, left, or right
[amount]Scroll distance in pixels (default: 300)

Options:

OptionDescription
--ref <ref>Element to scroll (defaults to the page)

Example:

Terminal window
tauri-pilot scroll down 500
tauri-pilot scroll up --ref @e4

Drag an element to another element or by a pixel offset. Dispatches the full HTML5 drag event sequence: mousedowndragstartdragleavedragenterdragoverdropdragend.

Terminal window
tauri-pilot drag <source> [target] [OPTIONS]

Arguments:

ArgumentDescription
<source>Element to drag (ref, selector, or coordinates)
[target]Element to drop onto (mutually exclusive with --offset)

Options:

OptionDescription
--offset <X,Y>Drag by pixel offset instead of to an element (mutually exclusive with [target])

Examples:

Terminal window
# Drag a card to a column (kanban board)
tauri-pilot drag "#card-1" "#col-done"
# Drag by ref (after snapshot)
tauri-pilot drag @e5 @e8
# Drag a slider thumb by pixel offset
tauri-pilot drag "#slider-thumb" --offset "150,0"
# Drag to coordinates
tauri-pilot drag @e5 "400,200"

JSON-RPC example:

// Element-to-element drag
{"jsonrpc":"2.0","id":1,"method":"drag","params":{"source":{"ref":"e5"},"target":{"ref":"e8"}}}
// Offset drag
{"jsonrpc":"2.0","id":1,"method":"drag","params":{"source":{"selector":"#thumb"},"offset":{"x":150,"y":0}}}

Simulate a file drop on an element. Reads files from disk, base64-encodes them, and creates DataTransfer + File objects in the WebView. Useful for testing file upload zones, import features, and drag-from-OS scenarios.

Terminal window
tauri-pilot drop <target> --file <path> [--file <path>...]

Arguments:

ArgumentDescription
<target>Element to drop files onto (ref, selector, or coordinates)

Options:

OptionDescription
--file <path>File to drop (required, can be repeated for multiple files)

Limits: 50 MB per file, 100 MB total payload.

Examples:

Terminal window
# Drop a single file
tauri-pilot drop "#file-zone" --file ./photo.png
# Drop multiple files
tauri-pilot drop @e3 --file ./doc.pdf --file ./data.csv

JSON-RPC example:

{"jsonrpc":"2.0","id":1,"method":"drop","params":{
"selector":"#file-zone",
"files":[{"name":"photo.png","type":"image/png","data":"iVBORw0KGgo..."}]
}}

Watch for DOM mutations using MutationObserver. Blocks until changes are detected (or timeout), then returns a summary of what changed. Useful for waiting on async UI updates without polling snapshots.

Terminal window
tauri-pilot watch [OPTIONS]

Options:

OptionDescription
--selector <sel>Scope observation to a subtree matching this CSS selector
--timeout <ms>Maximum wait time in milliseconds (default: 10000)
--stable <ms>Wait until DOM is stable (no new mutations) for N ms (default: 300)

Examples:

Terminal window
# Wait for any DOM change
tauri-pilot watch
# Watch a specific subtree
tauri-pilot watch --selector "#results-list"
# Short timeout
tauri-pilot watch --timeout 3000
# Wait for DOM to settle after animations
tauri-pilot watch --stable 500

JSON-RPC example:

{"jsonrpc":"2.0","id":1,"method":"watch","params":{"selector":"#results","timeout":5000,"stable":300}}

Get the text content of an element.

Terminal window
tauri-pilot text <target>

Example:

Terminal window
$ tauri-pilot text @e1
PR Dashboard

Get the innerHTML of an element, or the full document HTML if no target is given.

Terminal window
tauri-pilot html [target]

Example:

Terminal window
tauri-pilot html @e1
tauri-pilot html "#main-content"
tauri-pilot html

Get the current value of an input, textarea, or select element.

Terminal window
tauri-pilot value <target>

Example:

Terminal window
$ tauri-pilot value "#search"
my-feature-branch

Get all HTML attributes of an element as key-value pairs.

Terminal window
tauri-pilot attrs <target>

Example:

Terminal window
$ tauri-pilot attrs @e3
id = submit-btn
class = btn btn-primary
disabled = false
type = button

Execute arbitrary JavaScript in the WebView context and return the result.

Terminal window
tauri-pilot eval <script>

Example:

Terminal window
$ tauri-pilot eval "document.title"
PR Dashboard
$ tauri-pilot eval "window.location.pathname"
/dashboard

Call a Tauri IPC command (registered with tauri::Builder) and return the response.

Terminal window
tauri-pilot ipc <command> [OPTIONS]

Options:

OptionDescription
--args <json>JSON object of arguments to pass to the command

Example:

Terminal window
tauri-pilot ipc get_prs
tauri-pilot ipc create_pr --args '{"title":"Fix bug","branch":"fix/issue-42"}'

Capture the current WebView as a PNG using the injected html-to-image bridge.

Terminal window
tauri-pilot screenshot [path] [OPTIONS]

Arguments:

ArgumentDescription
[path]Output file path. Prints base64 to stdout if omitted

Options:

OptionDescription
--selector <sel>Capture only the element matching this CSS selector

Example:

Terminal window
tauri-pilot screenshot ./dashboard.png
tauri-pilot screenshot --selector "#main-panel" ./panel.png
tauri-pilot screenshot # prints base64 PNG to stdout

Change the WebView URL.

Terminal window
tauri-pilot navigate <url>

Example:

Terminal window
tauri-pilot navigate "http://localhost:1420/settings"
tauri-pilot navigate "/"

Get the current page URL.

Terminal window
tauri-pilot url

Example:

Terminal window
$ tauri-pilot url
http://localhost:1420/dashboard

Get the current page title.

Terminal window
tauri-pilot title

Example:

Terminal window
$ tauri-pilot title
PR Dashboard

Get the current page state: URL, title, viewport dimensions, and scroll position.

Terminal window
tauri-pilot state

Example:

Terminal window
$ tauri-pilot state
url http://localhost:1420/dashboard
title PR Dashboard
viewport 1280x800
scroll 0,0

Wait for an element to appear (or disappear) in the DOM.

Terminal window
tauri-pilot wait [target] [OPTIONS]

Options:

OptionDescription
--selector <sel>CSS selector to wait for (alternative to positional [target])
--goneWait for the element to disappear instead of appear
--timeout <ms>Maximum wait time in milliseconds (default: 10000)

Example:

Terminal window
tauri-pilot wait "@e3"
tauri-pilot wait --selector "#loading-spinner" --gone
tauri-pilot wait --selector ".toast-success" --timeout 5000

Display or stream captured console logs (console.log, console.warn, console.error, console.info).

The JS bridge monkey-patches the browser console methods and stores entries in a 500-entry ring buffer with timestamp, level, serialized arguments, and source location.

Terminal window
tauri-pilot logs [OPTIONS]

Options:

OptionDescription
--level <level>Filter by log level: log, info, warn, error
--last <n>Show only the last N entries
-f, --followContinuously poll for new logs (500ms interval)
--clearFlush the ring buffer

Examples:

Terminal window
# Show all captured logs
$ tauri-pilot logs
[14:32:01.123] log App initialized
[14:32:01.456] warn Deprecated API call
[14:32:02.789] ✗ error Failed to fetch: NetworkError
# Filter by level
$ tauri-pilot logs --level error
[14:32:02.789] ✗ error Failed to fetch: NetworkError
# Last 5 entries
$ tauri-pilot logs --last 5
# Stream logs in real-time
$ tauri-pilot logs --follow
# Stream errors as NDJSON (one JSON object per line, compatible with jq)
$ tauri-pilot logs --follow --level error --json
# Clear the buffer
$ tauri-pilot logs --clear
cleared

JSON output format:

[
{
"id": 1,
"timestamp": 1712073600000,
"level": "error",
"args": ["Failed to fetch:", "NetworkError: 500"],
"source": "app.js:42"
}
]

JSON-RPC examples:

// Get logs filtered by level
{"jsonrpc":"2.0","id":1,"method":"console.getLogs","params":{"level":"error","last":10}}
// Clear buffer
{"jsonrpc":"2.0","id":2,"method":"console.clear"}

Display or stream captured network requests (fetch and XMLHttpRequest).

The JS bridge monkey-patches fetch and XMLHttpRequest and stores entries in a 200-entry ring buffer with timestamp, method, URL, status code, duration, and error details.

Terminal window
tauri-pilot network [OPTIONS]

Options:

OptionDescription
--filter <pattern>Filter by URL substring match
--failedShow only failed requests (4xx/5xx and network errors)
--last <n>Show only the last N entries
-f, --followContinuously poll for new requests (500ms interval)
--clearFlush the ring buffer

Examples:

Terminal window
# Show all captured requests
$ tauri-pilot network
[14:32:01.123] GET https://api.github.com/repos 200 125ms
[14:32:02.456] POST https://api.github.com/graphql 200 340ms
[14:32:03.789] GET https://api.github.com/rate_limit 403 12ms
# Filter by URL
$ tauri-pilot network --filter graphql
# Show only failures
$ tauri-pilot network --failed
# Stream requests in real-time
$ tauri-pilot network --follow
# Stream as NDJSON (compatible with jq)
$ tauri-pilot network --follow --json
# Clear the buffer
$ tauri-pilot network --clear
cleared

JSON-RPC examples:

// Get requests filtered by URL
{"jsonrpc":"2.0","id":1,"method":"network.getRequests","params":{"filter":"graphql","last":10}}
// Clear buffer
{"jsonrpc":"2.0","id":2,"method":"network.clear"}

Read and write browser storage (localStorage or sessionStorage) from the CLI. Useful for AI agents inspecting persisted state, auth tokens, or modifying app configuration during testing.

Terminal window
tauri-pilot storage <subcommand> [OPTIONS]

Subcommands:

SubcommandArgumentsDescription
get<key>Read a single key
set<key> <value>Write a key-value pair
listDump all key-value pairs
clearClear all storage

Options:

OptionDescription
--sessionUse sessionStorage instead of localStorage

Examples:

Terminal window
# Read a key from localStorage
$ tauri-pilot storage get "auth_token"
eyJhbGciOiJIUzI1NiJ9...
# Write a key
$ tauri-pilot storage set "theme" "dark"
ok
# List all localStorage entries
$ tauri-pilot storage list
auth_token = eyJhbGciOiJIUzI1NiJ9...
theme = dark
locale = en
# Clear localStorage
$ tauri-pilot storage clear
cleared
# Use sessionStorage instead
$ tauri-pilot storage --session list
$ tauri-pilot storage --session get "csrf_token"
# JSON output
$ tauri-pilot storage list --json
[{"key":"auth_token","value":"eyJ..."},{"key":"theme","value":"dark"}]

JSON-RPC examples:

// Get a key
{"jsonrpc":"2.0","id":1,"method":"storage.get","params":{"key":"auth_token","session":false}}
// Set a key
{"jsonrpc":"2.0","id":2,"method":"storage.set","params":{"key":"theme","value":"dark","session":false}}
// List all
{"jsonrpc":"2.0","id":3,"method":"storage.list","params":{"session":false}}
// Clear
{"jsonrpc":"2.0","id":4,"method":"storage.clear","params":{"session":false}}

Dump all form fields on the page in a single command. Useful for AI agents inspecting form state, pre-filled values, or verifying form structure without calling value on each input individually.

Terminal window
tauri-pilot forms [OPTIONS]

Options:

OptionDescription
--selector <css>Target a specific form by CSS selector

Notes:

  • Password fields display [redacted] in human-readable output (raw values are available in --json mode)
  • Output is limited to 100 forms and 500 fields per form; a truncation warning appears if exceeded
  • The --selector must match a <form> element; other elements are rejected with an error

Examples:

Terminal window
# Dump all forms on the page
$ tauri-pilot forms
# Target a specific form
$ tauri-pilot forms --selector "#login-form"
# JSON output
$ tauri-pilot forms --json

JSON-RPC:

// Dump all forms
{"jsonrpc":"2.0","id":1,"method":"forms.dump"}
// Dump specific form
{"jsonrpc":"2.0","id":2,"method":"forms.dump","params":{"selector":"#login-form"}}

Record user interactions for later replay.

Start recording interactions. All subsequent actions (click, fill, type, etc.) will be captured.

Terminal window
tauri-pilot record start

Stop recording and save captured interactions to a JSON file.

Terminal window
tauri-pilot record stop --output test.json
OptionDescription
--output, -oOutput file path (JSON format, required)

Check if recording is currently active.

Terminal window
tauri-pilot record status

Replay a previously recorded session.

Terminal window
tauri-pilot replay test.json

Export as a shell script instead of replaying:

Terminal window
tauri-pilot replay test.json --export sh
OptionDescription
--exportExport format instead of replaying (supported: sh)

Recordings are stored as JSON arrays:

[
{"action": "click", "ref": "e3", "timestamp": 0},
{"action": "fill", "ref": "e2", "value": "test", "timestamp": 1200}
]
// Start recording
{"jsonrpc":"2.0","id":1,"method":"record.start","params":{}}
// Stop recording
{"jsonrpc":"2.0","id":2,"method":"record.stop","params":{}}
// Check recording status
{"jsonrpc":"2.0","id":3,"method":"record.status","params":{}}
// Add an explicit entry (e.g., assertion from CLI)
{"jsonrpc":"2.0","id":4,"method":"record.add","params":{"action":"click","ref":"e3","timestamp":0}}

The CLI communicates with the plugin over a Unix socket using a hand-rolled JSON-RPC 2.0 protocol with newline-delimited framing (\n).

You can interact directly with the socket using socat or nc for debugging:

Terminal window
echo '{"jsonrpc":"2.0","id":1,"method":"ping","params":{}}' | socat - UNIX-CONNECT:/tmp/tauri-pilot-com.myapp.sock

Request structure:

{"jsonrpc":"2.0","id":1,"method":"<method>","params":{...}}

Success response:

{"jsonrpc":"2.0","id":1,"result":{...}}

Error response:

{"jsonrpc":"2.0","id":1,"error":{"code":-32601,"message":"Method not found"}}