OpenCLI — Universal Website & Browser CLI
Turn any website, Electron app, or local tool into a CLI command. Reuses Chrome login sessions, zero API keys needed at runtime. 80+ pre-built adapters.
Repo: jackwener/opencli (13.6K stars, Apache 2.0)
Prerequisites
npm install -g @jackwener/opencli # Install CLI
opencli doctor # Verify stack (CLI + daemon + extension)
Requirements:
- Node.js >= 20
- Chrome/Chromium running and logged into target sites
- Browser Bridge extension installed (
chrome://extensions> Load unpacked from GitHub release) - Daemon auto-spawns on
localhost:19825, auto-exits after 4h idle
Verify daemon binds 127.0.0.1 (not 0.0.0.0): lsof -i :19825 after first command
Quick Reference
opencli <site> <command> [args] [--limit N] [-f json|yaml|md|csv|table]
opencli list [-f yaml] # Discover all available commands
opencli <site> -h # Site-level help
opencli <site> <command> -h # Command-level help
Output formats: table (default), json, yaml, md, csv. Always use -f json for piping to other tools.
Exit codes: 0 success, 2 bad args, 66 empty result, 69 browser not connected, 75 timeout, 77 auth required.
Tool Routing — When to Use What
Before reaching for another tool, check if opencli has an adapter. opencli list -f yaml shows all available commands.
| Task | Prefer | Over | Why | |------|--------|------|-----| | Twitter post/read/bookmarks/follow | opencli twitter | bird CLI | Free, 25 commands, session-based | | Twitter deep search/research | x-search | opencli twitter search | Official API, cost-tracked, deeper | | Reddit/HN/YouTube structured data | opencli <site> | firecrawl/scrapling | Deterministic typed output, zero cost | | Browser multi-step workflow | opencli operate | agent-browser | State-based indices, && chaining | | Screenshot-driven browser tasks | agent-browser | opencli operate | Annotated screenshots, ref-based | | Raw CDP debugging | chrome-cdp | opencli operate | Direct protocol access | | General web scraping (unknown sites) | firecrawl | opencli web read | Better markdown quality | | Authenticated page to markdown | opencli web read --url URL | firecrawl | Uses browser session, no API key | | Anti-bot / Cloudflare sites | scrapling | opencli | Cloudflare bypass |
Use opencli list -f yaml to check if an adapter exists before falling back to other tools.
Commonly Used Commands
Twitter/X (browser, 25 commands)
opencli twitter trending --limit 10
opencli twitter search "Claude Code" --limit 20
opencli twitter timeline --limit 10
opencli twitter bookmarks --limit 20
opencli twitter post "Hello from opencli"
opencli twitter reply <tweet-id> "reply text"
opencli twitter profile elonmusk
opencli twitter follow <user>
opencli twitter unfollow <user>
opencli twitter likes --limit 20
opencli twitter notifications --limit 10
opencli twitter download <user> --limit 20 --output ./twitter
Reddit (browser, 15 commands)
opencli reddit hot --limit 10
opencli reddit frontpage --limit 10
opencli reddit search "topic" --limit 10
opencli reddit subreddit programming --limit 10
opencli reddit read <post-url>
opencli reddit user <username>
opencli reddit saved --limit 20
opencli reddit comment <post-url> "comment text"
opencli reddit upvote <post-url>
HackerNews (public API, no browser)
opencli hackernews top --limit 10
opencli hackernews new --limit 10
opencli hackernews best --limit 10
opencli hackernews search "topic" --limit 10
opencli hackernews ask --limit 5
opencli hackernews show --limit 5
YouTube (browser)
opencli youtube search "topic" --limit 10
opencli youtube video <video-id>
opencli youtube transcript <video-id>
Google (public API)
opencli google search "query" --limit 10
opencli google news "topic" --limit 10
opencli google suggest "partial query"
Spotify (public API with local auth)
opencli spotify auth # One-time setup
opencli spotify status
opencli spotify play
opencli spotify pause
opencli spotify next
opencli spotify search "artist or song" --limit 10
opencli spotify queue
Wikipedia (public API)
opencli wikipedia search "topic" --limit 5
opencli wikipedia summary "article name"
Web (any URL to markdown, browser)
opencli web read --url https://example.com
Desktop Apps (CDP/Electron)
opencli cursor status # Cursor IDE
opencli notion search "query" # Notion
opencli discord-app channels # Discord
opencli chatgpt ask "question" # ChatGPT desktop
Run opencli list -f yaml for the full adapter catalog, or opencli <site> -h for site-specific commands.
Browser Automation (operate)
Control Chrome step-by-step via CLI. Reuses existing login sessions.
Core Workflow
- Navigate:
opencli operate open <url> - Inspect:
opencli operate state— structured DOM with[N]indices - Interact:
click <N>,type <N> "text",select <N> "option",keys "Enter" - Wait:
wait selector ".loaded",wait text "Success",wait time 3 - Extract:
eval "JSON.stringify(...)",get text <N>,get value <N> - Repeat: browser stays open between commands
- Save:
opencli operate init <site>/<cmd>to create reusable adapter
Critical Rules
- Use
stateto inspect, notscreenshot—statereturns structured DOM with element indices, costs zero tokens. Only usescreenshotwhen the user explicitly asks for a visual. - Use
click/typefor interaction, noteval—eval "el.click()"bypasses scroll-into-view and CDP pipeline. - Chain with
&&—opencli operate open URL && opencli operate statesaves round trips. - Run
stateafter every page change — indices go stale after navigation. - Use
evalfor read-only data extraction only — wrap in IIFE:eval "(function(){ ... })()". - Use
networkto discover APIs — JSON APIs are more reliable than DOM scraping.
Command Quick Reference
| Category | Commands | |----------|----------| | Navigate | open <url>, back, scroll down/up [--amount N] | | Inspect | state, screenshot [path.png] | | Get | get title, get url, get text <N>, get value <N>, get html [--selector], get attributes <N> | | Interact | click <N>, type <N> "text", select <N> "option", keys "Enter" | | Wait | wait time N, wait selector ".css", wait text "string" | | Extract | eval "JS expression" | | Network | network, network --detail N, network --all | | Save | init <site>/<cmd>, verify <site>/<cmd> | | Session | close |
Alias: opencli op = opencli operate
Run opencli operate -h for full command reference.
CLI Hub
Register and discover local CLI tools. Agents can use opencli list as a unified discovery surface.
opencli register mycli # Register a local CLI
opencli list [-f yaml] # Discover all commands (adapters + registered CLIs)
opencli gh pr list --limit 5 # Passthrough to gh CLI (auto-installs if missing)
opencli docker ps # Passthrough to docker
Auto-install: if a registered CLI isn't installed, opencli runs the install command (e.g., brew install gh) then re-executes.
Built-in external CLIs: gh, docker, obsidian, vercel, lark-cli, dingtalk, wecom-cli.
Creating Custom Adapters
Create adapters for any website or your own apps.
Quick Path (4 steps)
# 1. Open the target page
opencli operate open https://example.com/page
# 2. Discover APIs
opencli operate network # See JSON API requests
opencli operate network --detail 0 # Inspect response body
# 3. Generate scaffold
opencli operate init mysite/mycommand # Creates ~/.opencli/clis/mysite/mycommand.ts
# 4. Test
opencli operate verif