chrome-cli
A CLI tool for browser automation via the Chrome DevTools Protocol.
A fast, standalone command-line tool for automating Chrome and Chromium browsers. No Node.js, no Python — just a single native binary that speaks the Chrome DevTools Protocol (CDP) directly over WebSocket.
Features
- Tab management — list, create, close, and activate browser tabs
- URL navigation — navigate to URLs, go back/forward, reload, and manage history
- Page inspection — capture accessibility trees, extract text, find elements
- Screenshots — full-page and viewport screenshots to file or stdout
- JavaScript execution — run scripts in the page context, return results as JSON
- Form filling — fill inputs, select options, and submit forms by accessibility UID
- Network monitoring — follow requests in real time, intercept and block URLs
- Console capture — read and follow console messages with type filtering
- Performance tracing — start/stop Chrome trace recordings, collect metrics
- Device emulation — emulate mobile devices, throttle network/CPU, set geolocation
- Dialog handling — accept, dismiss, or respond to alert/confirm/prompt dialogs
- Shell integration — completion scripts for Bash, Zsh, Fish, PowerShell, and Elvish
- Man pages — built-in man page viewer via
chrome-cli man
How does chrome-cli compare?
| chrome-cli | Puppeteer / Playwright | Chrome DevTools MCP | |
|---|---|---|---|
| Runtime | No Node.js — native Rust binary | Node.js | Node.js |
| Install | Single binary, cargo install |
npm install |
npx |
| Interface | CLI / shell scripts | JavaScript API | MCP protocol |
| Startup time | < 50ms | ~500ms+ | Varies |
| Binary size | < 10 MB | ~100 MB+ (with deps) | Varies |
| Shell pipelines | First-class (` | jq, |
grep`) |
Installation
Pre-built binaries
Download the latest release for your platform from GitHub Releases.
# macOS (Apple Silicon)
| &&
# macOS (Intel)
| &&
# Linux (x86_64)
| &&
# Linux (ARM64)
| &&
Cargo install
Build from source
# Binary is at target/release/chrome-cli
Supported platforms
| Platform | Target | Archive |
|---|---|---|
| macOS (Apple Silicon) | aarch64-apple-darwin |
.tar.gz |
| macOS (Intel) | x86_64-apple-darwin |
.tar.gz |
| Linux (x86_64) | x86_64-unknown-linux-gnu |
.tar.gz |
| Linux (ARM64) | aarch64-unknown-linux-gnu |
.tar.gz |
| Windows (x86_64) | x86_64-pc-windows-msvc |
.zip |
Quick Start
1. Install chrome-cli (see Installation above)
2. Start Chrome with remote debugging enabled:
# macOS
# Linux
# Or launch headless Chrome directly via chrome-cli:
3. Connect to Chrome:
4. Navigate to a URL:
5. Inspect the page:
Usage Examples
# Viewport screenshot
# Full-page screenshot
# Get the visible text content of the page
# Run a JavaScript expression and get the result
# Run JavaScript from a file
# First, capture the accessibility tree to find UIDs
# Fill a single field by accessibility UID
# Fill multiple fields at once
# Submit a form
# Follow network requests in real time
# Block specific URLs
# Record a trace for 5 seconds
# Record until Ctrl+C, with page reload
# Save to a specific file
# Get Core Web Vitals
Command Reference
| Command | Description |
|---|---|
connect |
Connect to or launch a Chrome instance |
tabs |
Tab management (list, create, close, activate) |
navigate |
URL navigation and history |
page |
Page inspection (screenshot, text, accessibility tree, find) |
dom |
DOM inspection and manipulation |
js |
JavaScript execution in page context |
console |
Console message reading and monitoring |
network |
Network request monitoring and interception |
interact |
Mouse, keyboard, and scroll interactions |
form |
Form input and submission |
emulate |
Device and network emulation |
perf |
Performance tracing and metrics |
dialog |
Browser dialog handling (alert, confirm, prompt, beforeunload) |
config |
Configuration file management (show, init, path) |
completions |
Generate shell completion scripts |
man |
Display man pages for chrome-cli commands |
Run chrome-cli <command> --help for detailed usage of any command, or chrome-cli man <command> to view its man page.
Architecture
┌──────────────────────────────────────────────────────┐
│ chrome-cli │
│ │
│ ┌────────────┐ ┌─────────────┐ ┌────────────┐ │
│ │ CLI Layer │──▶│ Command │──▶│ CDP Client │ │
│ │ (clap) │ │ Dispatch │ │ (WebSocket)│ │
│ └────────────┘ └─────────────┘ └─────┬──────┘ │
│ │ │
└────────────────────────────────────────────┼─────────┘
│ JSON-RPC
▼
┌─────────────────┐
│ Chrome Browser │
│ (DevTools │
│ Protocol) │
└─────────────────┘
How it works: chrome-cli communicates with Chrome using the Chrome DevTools Protocol (CDP) over a WebSocket connection. Commands are sent as JSON-RPC messages; responses and events flow back on the same connection.
Session management: When you run chrome-cli connect, a session file is created with the WebSocket URL. Subsequent commands reuse this connection automatically. The session persists until you run chrome-cli connect disconnect or Chrome exits.
Performance: chrome-cli is a native Rust binary with sub-50ms startup time. There is no interpreter, no runtime, and no JIT warmup — it goes straight from your shell to Chrome.
Claude Code Integration
chrome-cli is designed for AI agent consumption. See the full Claude Code Integration Guide for discovery mechanisms, common workflows, best practices, and error handling patterns.
Drop the CLAUDE.md template into your project to give Claude Code browser automation capabilities out of the box.
Related Projects
- Chrome DevTools MCP — The official Chrome DevTools MCP server by Google, providing browser automation for AI coding agents via the Model Context Protocol. If you're looking for MCP-based browser control rather than a CLI tool, check it out.
Contributing
All contributions must follow the NMG-SDLC workflow without deviation. NMG-SDLC is a BDD spec-driven development toolkit that enforces a structured delivery lifecycle: issue creation, specification writing, implementation, verification, and PR creation. Contributions that bypass the SDLC process will not be accepted.
Prerequisites
- Rust 1.85.0 or later (pinned via
rust-toolchain.toml) - Chrome or Chromium (for integration testing)
- Claude Code with the NMG-SDLC plugin installed
Build and test
# Build
# Run tests
# Lint
# Generate man pages
Code style
This project uses strict Clippy configuration (all = "deny", pedantic = "warn") and rustfmt with the 2024 edition. All warnings must be resolved before merging.
License
Licensed under either of MIT License or Apache License, Version 2.0 at your option.