Pinchtab

From pinchtab/pinchtab · View interactive version

Pinchtab is an AI agent skill from the GitHub repository pinchtab/pinchtab. Use this skill when a task needs browser automation through PinchTab: open a website, inspect interactive elements, click through flows, fill out forms, scrape page text, reuse a dedicated automation profile with user approval, export screenshots or PDFs, manage multiple browser instances, or fall b

How to use this skill

Skill file

Browser Automation with PinchTab

CLI-first browser skill. Use pinchtab commands.

Core Workflow

  1. Create a session: export PINCHTAB_SESSION=$(pinchtab session create --agent-id myagent) — do this once before any browser command.
  2. Navigate: pinchtab nav <url> --snap — auto-starts the local server if needed, then returns tab ID + interactive snapshot in one call.
  3. Interact: pinchtab click <ref> --snap-diff — returns OK + only changed elements (most token-efficient).
  1. For read-only observation: pinchtab text when you won't act on refs.

Key optimization: Use --snap-diff on nav, click, fill, select, press, scroll, back, forward, reload to get only added/changed/removed elements — most token-efficient for multi-step flows. Use --snap when you need the full snapshot (e.g., first navigation, or after major page changes). --text is available on nav, click, fill, select, press, back, forward, reload (but NOT on scroll) when you need prose content for verification (skips snap, returns page text directly). dblclick does not support any observation flag — run a separate snap after.

--snap-diff returns the same compact format as snap, but with change markers and a header showing counts:

# Page Title | URL | 57 nodes | +2 ~1 -0
e0:link "Home"
e5:button "Submit" [+]
e12:textbox val="updated" [~]
# removed: e99

[+] = added, [~] = changed, removed refs listed at end. All valid refs are shown — no need to remember previous snapshot. Do not follow with redundant snap; only call text when you need prose content.

Fallback observation (when --snap wasn't used):

Rules: only nav <url> and session create auto-start the default local server; snap, text, html, find, and action commands operate on an already-running server/current tab. Explicit --server / PINCHTAB_SERVER targets are never auto-started. Never act on stale refs; screenshots only for visual/debug; choose the instance/profile up front for parallel or multi-site work.

Safety Defaults

For the handling rules for page code, files, cookies/state, network data, and artifacts, read safety.md.

Selectors

Unified selectors accepted by any element-targeting command:

Auto-detection: bare eN→ref, #/./[...]→CSS, //→XPath. Use explicit css:/xpath:/text:/find: prefixes when ambiguous. HTTP API uses the same syntax in the selector field (legacy ref still accepted).

Command Chaining

&& when you don't need intermediate output (pinchtab nav <url> --snap && pinchtab click e3 --snap-diff). Run separately when you must read refs before acting.

Restricted Challenge Handling

If a site requires a CAPTCHA, anti-bot challenge, or other human verification, stop and ask the user to complete it. Do not attempt to defeat, evade, or automate the protection.

Authentication and State

Patterns: (1) one-off pinchtab instance start; (2) reuse a profile with instance start --profile work; (3) HTTP POST /profiles then POST /profiles/<name>/start. The --profile pattern requires the profile to exist first. Human setup: pinchtab profiles create work, authenticate headed; agents reuse headless. Agent sessions: pinchtab session create --agent-id <id> or POST /sessions → set PINCHTAB_SESSION=ses_....

Session reuse safety: When reusing authenticated browser sessions established by a human, use a dedicated low-privilege profile — not the user's personal browsing profile. Confirm with the user before performing account-changing actions (password changes, payment, deletion, permissions) in a reused session. Restrict navigation to the sites needed for the task.

Configuration

Config file: ~/.pinchtab/config.json. Edit it directly to change settings — no need for PINCHTAB_CONFIG or temp files.

pinchtab config show          # view current config
pinchtab security             # review security posture

Key settings agents may need to change:

After changing config with the server running, restart to apply: pinchtab server restart.

Essential Commands

Server and targeting

pinchtab server | health
pinchtab server stop                                # stop any running server (foreground or background)
pinchtab server restart                             # stop + restart in background (applies config changes)
pinchtab instance list | profiles
pinchtab --server http://localhost:9868 snap -i -c  # target a specific instance

pinchtab server prints READY to stdout when the browser instance is up and ready to accept commands. Read its output — it includes hints on how to get started (session creation, first nav).

The optional background daemon is for local convenience, not normal agent workflow. Prefer the foreground server unless the user explicitly wants a persistent local service.

Navigation and tabs

pinchtab nav <url>                                  # auto-starts default local server; flags: --snap, --new-tab, --tab <id>, --timeout <seconds>, --block-images, --block-ads, --dismiss-banners, --print-tab-id
pinchtab back | forward | reload                    # all support --snap, --snap-diff, --text, --dismiss-banners
pinchtab tab                                        # list tabs
pinchtab tab <tab-id>                               # focus tab
pinchtab nav <url> --new-tab                        # force another tab
pinchtab tab close <tab-id>
pinchtab instance navigate <instance-id> <url>

Anonymous commands share a single current tab — if anything else navigates that tab, your next command hits the wrong page. Always create a session before your first nav:

export PINCHTAB_SESSION=$(pinchtab session create --agent-id myagent)

All subsequent commands use that session's dedicated tab automatically — no --new-tab or --tab <id> needed.

State commands are sensitive and only belong in a user-approved diagnostics workflow:

Observation

pinchtab snap [selector]                            # default: compact + interactive; flags: --full (JSON), -d (diff), --selector <css>, --max-tokens <n>
pinchtab text                                       # Readability-filtered page text
pinchtab text --full                                # raw document.body.innerText (alias: --raw)
pinchtab text <selector>                            # ref / -s CSS / xpath:... — text from one element
pinchtab text --json                                # full JSON (url/title/truncated)
pinchtab find <query>                               # semantic search; --ref-only for just the ref

Guidance:

Interaction

All interaction commands accept unified selectors (see Selectors above).

pinchtab click <selector>                           # flags: --snap, --snap-diff, --text, --wait-nav, --dismiss-banners (with --wait-nav), --x/--y (coords), --mode dom|dispatch, --humanize, --dialog-action accept|dismiss [--dialog-text "..."]
pinchtab dblclick <selector>
pinchtab mouse move <selector|x y>
pinchtab mouse down|up [selector] [--x <n> --y <n>]  # --button left|middle|right
pinchtab mouse wheel [dy|selector] --dx <n> --dy <n>
pinchtab drag <from> <to>                           # or: drag <selector> --drag-x <n> --drag-y <n>
pinchtab type <selector> <text>                     # keystroke events
pinchtab fill <selector> <text>                     # set value directly; flags: --snap, --snap-diff, --text
pinchtab press <key>                                # Enter, Tab, Escape, ...
pinchtab hover <selector>
pinchtab select <selector> <value|text>             # flags: --snap, --snap-diff, --text; matches value attr, falls back to visible text
pinchtab scroll <pixels|direction|selector>         # `scroll 1500`, `scroll down`, `scroll '#footer'`
pinchtab check <selector> | uncheck <selector>      # toggle checkboxes / radios
pinchtab focus <selector>                           # move keyboard focus
pinchtab scrollintoview <selector>                  # scroll element into view
pinchtab dialog accept [text] | dismiss             # standalone dialog handling (besides click --dialog-action)
pinchtab keyboard type <text> | inserttext <text>   # low-level keystroke text entry
pinchtab keydown <key> | keyup <key>                # individual key events

DOM inspection helpers (skip a snap when you only need one value):

pinchtab title | url | html                         # page metadata / serialized HTML
pinchtab value <selector>                           # form-field value
pinchtab attr <selector> <name>                     # arbitrary attribute
pinchtab count <selector>                           # querySelectorAll length
pinchtab box <selector>                             # getBoundingClientRect
pinchtab visible <selector> | enabled <selector> | checked <selector>

Rules:

Waiting

Use for async DOM settling (spinners, toasts, XHR).

pinchtab wait <selector>                            # default: visible; --state hidden to wait for disappear
pinchtab wait --text "..." | --not-text "..."       # text appear / disappear (polls document.body.innerText)
pinchtab wait --url "**/dashboard"                  # glob: **, *, ?
pinchtab wait --load ready-state|content-loaded|network-idle
pinchtab wait --fn "window.dataReady === true"      # requires security.allowEvaluate: true (else 403 evaluate_disabled)
pinchtab wait 500                                   # fixed ms delay (last resort, max 30000ms)

Timeout 10s default, 30s max via --timeout-ms <ms>. All non-ms wait modes poll internally every ~250ms. For dynamic SPA content (iframes, shadow DOM, virtualized lists) where document.body.innerText is unreliable, prefer wait <selector> --state hidden|visible over --text/--not-text.

Export, debug, verification

pinchtab screenshot [-o path.png] [-q <jpeg-quality>] [--beyond-viewport] [--scale 0.5]   # format by extension; --beyond-viewport captures the full scrollable page; --scale rescales the bitmap
pinchtab capture [-o path.jpg] [--beyond-viewport] [--require-pair] [--scale 0.5]         # paired image + snapshot from same DOM epoch; nodes carry boundingBox — use when the model reads pixels AND acts on refs
pinchtab pdf [-o path.pdf] [--landscape]
pinchtab record start out.gif [--fps 5] [--scale 1.0]  # .gif/.webm/.mp4; requires security.allowScreencast; .gif works without ffmpeg, .webm/.mp4 need ffmpeg
pinchtab record stop                                    # stop, encode, and save to path given at start
pinchtab record status                                  # check active recording
pinchtab console [--clear] [--json]                      # browser console logs for the tab
pinchtab errors [--clear] [--json]                       # uncaught JS exceptions the page threw

When a snapshot looks right but the page does not respond to actions, check pinchtab errors (and pinchtab console) before retrying. A script that threw on load leaves the DOM present and the handlers unwired, so clicks land on nothing; the error log is the only channel that says so. A buffer full of errors is the useful answer, not a failed command.

Site review

pinchtab audit <url> --output-dir ./audit
pinchtab compare <live-url> <staging-url> --output-dir ./comparison
pinchtab scrape <url> --preview

For options and report details, read site-review.md.

Advanced (explicit opt-in only)

These operations are high-impact and gated by security policy. Do not use unless the task specifically requires them and simpler commands are insufficient.

pinchtab eval "document.title"                      # --await-promise for async; requires security.allowEvaluate: true
pinchtab download <url> -o /tmp/out.bin             # requires security.allowDownload: true
pinchtab upload /absolute/path -s <css>             # requires security.allowUpload: true

The CLI reads the file on the machine where you run it and sends its content: pinchtab upload ./photo.jpg -s "#file-input".

HTTP API fallback

Use curl only when the CLI is unavailable. See api.md for full endpoint reference.

Common Patterns

Verification

An interaction reporting success only confirms that the browser event fired. Verify consequential actions with --snap-diff, a fresh snap, or text. Fetch fresh refs after page changes rather than retrying stale ones.

For text extraction, frames, visibility, selectors, and JavaScript edge cases, read verification.md.

References

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.