Skip to content

Repository files navigation

webcli

Headless browser CLI for AI coding agents. Control a real Chromium browser from the command line.

Built for Claude Code and similar AI-powered development tools that need to interact with web pages programmatically.

npmlicensenode

Links

npmnpmjs.com/package/@erdinccurebal/webcli
Websitewebcli.erdinc.curebal.dev
GitHubgithub.com/erdinccurebal/webcli
ClawHubclawhub.ai/skills/webcli
Skills.shnpx skills add erdinccurebal/webcli

Features

  • 55+ commands — navigate, read, interact, snapshot, screenshot, PDF, console, storage, state management
  • Accessibility snapshot — get the page's accessibility tree with deterministic refs (@e1, @e2...) for reliable element targeting
  • Persistent daemon — browser stays open between commands, no startup overhead
  • Multi-tab — manage multiple named browser tabs simultaneously
  • Anti-detection — realistic user-agent, webdriver flag removal, configurable viewport
  • Session persistence — save/load full browser state (cookies, localStorage, sessionStorage)
  • Device emulation — emulate mobile devices (iPhone, iPad, Pixel, etc.)
  • JSON output — structured output for programmatic consumption
  • Headed/headless — toggle via config for sites with bot detection
  • Agent skill — works as a skill for Claude Code, Cursor, Copilot, Codex, Windsurf and 30+ other agents

Installation

As npm package

npm install -g @erdinccurebal/webcli
npx playwright install chromium

As agent skill

Skills.sh (Claude Code, Cursor, Copilot, Codex, Windsurf + 30 more):

npx skills add erdinccurebal/webcli

ClawHub (OpenClaw):

clawhub install webcli

Quick Start

webcli go https://example.com # Navigate (auto-starts daemon)
webcli source# Read page text
webcli links # List all links
webcli click "More information..."# Click by visible text
webcli snapshot # Get accessibility tree with refs
webcli click @e1 # Click using snapshot ref
webcli screenshot -o page.png # Take screenshot
webcli stop # Stop daemon

Commands

Navigation

CommandDescription
webcli go <url>Navigate to URL
webcli backGo back in history
webcli forwardGo forward in history
webcli reloadReload current page

Options for go: -w, --wait <strategy>domcontentloaded (default), networkidle, load

Reading

CommandDescription
webcli sourceGet visible text content of the page
webcli html <selector>Get innerHTML of a specific element
webcli attr <selector> <attribute>Get an element's attribute value
webcli linksList all links (text + href)
webcli formsList all forms with their inputs
webcli eval <js>Execute JavaScript and return result
webcli titleGet the page title
webcli urlGet the current URL
webcli value <selector>Get the value of an input/textarea
webcli count <selector>Count elements matching a selector
webcli box <selector>Get element bounding box (x, y, width, height)
webcli styles <selector> [props...]Get computed CSS styles
webcli visible <selector>Check if element is visible (bool)
webcli enabled <selector>Check if element is enabled (bool)
webcli checked <selector>Check if checkbox is checked (bool)

Interaction

CommandDescription
webcli click <text>Click element by visible text
webcli clicksel <selector>Click element by CSS selector
webcli dblclick <text>Double-click element by visible text
webcli hover <selector>Hover over an element
webcli focus <selector>Focus element by CSS selector
webcli type <text>Type text with keyboard
webcli fill <selector> <value>Fill an input field
webcli select <selector> <value>Select a dropdown option
webcli press <key>Press a keyboard key (Enter, Tab, Escape...)
webcli check <selector>Check a checkbox
webcli uncheck <selector>Uncheck a checkbox
webcli drag <from> <to>Drag and drop between two selectors
webcli upload <selector> <file>Upload a file to an input element
webcli scroll <direction> [amount]Scroll the page (up/down/left/right)

All interaction commands support snapshot refs: webcli click @e1, webcli fill @e3 "value"

Accessibility Snapshot

CommandDescription
webcli snapshotGet accessibility tree with interactive element refs
webcli snapshot --allInclude non-interactive elements
webcli snapshot --max-depth <n>Limit tree depth

The snapshot assigns deterministic refs (@e1, @e2, ...) to interactive elements. Use these refs in other commands for reliable element targeting:

webcli snapshot # Get tree with refs
webcli click @e1 # Click using ref
webcli fill @e3 "hello"# Fill input using ref
webcli hover @e5 # Hover using ref

Waiting

CommandDescription
webcli wait <selector>Wait for CSS selector to become visible
webcli waitfor <text>Wait for text to appear on page
webcli sleep <ms>Sleep for specified milliseconds

Screenshots & PDF

CommandDescription
webcli screenshotTake a full-page screenshot
webcli screenshot --no-fullViewport-only screenshot
webcli screenshot --annotateScreenshot with numbered interactive elements
webcli pdfSave page as PDF

Options: -o, --output <file> for custom output path.

Console & Errors

CommandDescription
webcli console onStart capturing console messages
webcli console offStop capturing
webcli consoleShow captured console messages
webcli errorsShow page errors

Dialog Handling

CommandDescription
webcli dialog accept [text]Accept a browser dialog (alert/confirm/prompt)
webcli dialog dismissDismiss a browser dialog

Frame (iframe) Switching

CommandDescription
webcli frame <selector>Switch to an iframe
webcli frame mainSwitch back to main frame

Storage (localStorage)

CommandDescription
webcli storage get [key]Get localStorage value(s)
webcli storage set <key> <value>Set a localStorage value
webcli storage clearClear all localStorage

State Management

CommandDescription
webcli state save [file]Save full browser state (cookies + storage) to JSON
webcli state load <file>Load browser state from JSON

Cookies & Browser

CommandDescription
webcli cookie exportExport cookies as JSON
webcli cookie import <file>Import cookies from JSON file
webcli viewport <width> <height>Change viewport size
webcli useragent <string>Change user agent
webcli device <name>Emulate a device (e.g. "iPhone 14", "iPad Pro 11")
webcli network [on|off]Toggle request/response logging

Tab & Daemon Management

CommandDescription
webcli tabsList all open tabs
webcli quitClose a tab
webcli statusShow daemon status (PID, uptime, tabs)
webcli stopStop the daemon and close browser

Global Options

OptionDescription
-t, --tab <name>Target tab (default: "default")
--jsonOutput as JSON
--timeout <ms>Command timeout (default: 30000)
--verboseEnable debug logging

Configuration

Create ~/.webcli/config.json:

{
"headless": true,
"browser": "chromium",
"userDataDir": "~/.webcli/browser-data",
"viewport": { "width": 1280, "height": 800 },
"locale": "en-US",
"timezoneId": "America/New_York",
"geolocation": { "latitude": 40.7128, "longitude": -74.0060 },
"colorScheme": "dark",
"offline": false,
"extraHeaders": { "X-Custom": "value" },
"waitAfterClick": 500,
"waitAfterPress": 300,
"idleTimeout": 300000,
"defaultTimeout": 30000
}

Set "headless": false to use headed mode (required for sites with aggressive bot detection like X/Twitter).

Architecture

CLI Client (webcli)
|
|-- Unix Socket (~/.webcli/daemon.sock)
|
v
Daemon (background process)
|
|-- Playwright Browser (Chromium/Firefox/WebKit)
| |-- Tab: "default" -> Page
| |-- Tab: "search" -> Page
| +-- Tab: "login" -> Page
|
|-- Tab Manager (named page instances)
|-- Handler Registry (action dispatch)
|-- Ref Store (snapshot @e1 refs -> ElementHandle)
+-- Auto-shutdown after 5min idle

The daemon starts automatically on the first command and persists in the background. All commands communicate via a Unix domain socket using newline-delimited JSON.

Contributing

See CONTRIBUTING.md for development setup and guidelines.

License

MIT

About

Headless browser CLI - navigate, scrape, and interact from the terminal. Built on Playwright.

Topics

Resources

Contributing

Security policy

Stars

2 stars

Watchers

0 watching

Forks

Used by

Contributors

Languages