| name | agent-browser-cli-control |
| description | Control and interact with Chrome browser via agent-browser-cli for tab management, page automation, CDP operations, and content extraction. |
| triggers | ["interact with the browser","control chrome tabs","execute javascript in browser","get page content from browser","take browser screenshot","manage browser cookies","automate browser actions","extract content from web pages"] |
agent-browser-cli Control
Skill by ara.so — Devtools Skills collection.
agent-browser-cli is a browser control CLI built in Rust that connects to a real Chrome session via a Chrome extension. It enables AI agents to scan tabs, execute JavaScript, manage cookies, capture screenshots, and perform CDP operations while preserving the user's login state and session.
Key difference from Selenium/Playwright: This tool works with an existing Chrome session (not headless), preserving all user login states and cookies. Perfect for AI agents that need to work with authenticated web sessions.
Installation
Via npm (recommended)
npm install -g @sleepinsummer/agent-browser-cli
Via source
git clone https://github.com/sleepinginsummer/agent-browser-cli.git
cd agent-browser-cli
cargo build --release
Chrome Extension Setup
Critical: The Chrome extension must be loaded for the CLI to work.
- Download
chrome-extensions.zip from the latest release
- Extract the zip file
- Open Chrome and navigate to
chrome://extensions
- Enable "Developer mode"
- Click "Load unpacked extension"
- Select the extracted
tmwd_cdp_bridge directory
- Ensure at least one normal web page tab is open (not
about:blank or chrome://)
The extension will show a small indicator on the right side of the page when connected.
Architecture
agent-browser-cli runs as a daemon service that:
- Listens on port
18765 for Chrome extension WebSocket connections
- Listens on port
18767 for CLI HTTP API calls
- Maintains persistent browser connection to avoid re-initialization overhead
Performance reference (with daemon running):
- Simple page read / JS execution: 40-120ms
- DOM query operations: 270-360ms
- Page monitoring with change summary: 720-880ms
Core Commands
Daemon Management
agent-browser-cli start
agent-browser-cli stop
agent-browser-cli restart
agent-browser-cli status
Tab Management
agent-browser-cli tabs
agent-browser-cli switch 0
agent-browser-cli open https://example.com
agent-browser-cli close
agent-browser-cli active
Page Content Extraction
agent-browser-cli scan
agent-browser-cli scan --text-only
agent-browser-cli scan --full
agent-browser-cli scan --tab 0
agent-browser-cli scan --screenshot
JavaScript Execution
agent-browser-cli exec 'return document.title'
agent-browser-cli exec --monitor 'document.querySelector("#search").value = "test"'
agent-browser-cli exec 'const btn = document.querySelector("button");
btn.click();
return "clicked";'
agent-browser-cli exec --tab 0 'return window.location.href'
Screenshots
agent-browser-cli screenshot
agent-browser-cli screenshot --tab 0
agent-browser-cli screenshot --output /path/to/screenshot.png
Cookie Management
agent-browser-cli cookies
agent-browser-cli cookies --domain example.com
agent-browser-cli cookies --set 'name=value; domain=.example.com; path=/'
Configuration
agent-browser-cli set-extension-port 18766
cat ~/.agent-browser-cli/config.json
Real-World Examples
Example 1: Search Automation
agent-browser-cli open "https://www.google.com"
sleep 1
agent-browser-cli exec 'document.querySelector("textarea[name=q]").value = "rust programming"'
agent-browser-cli exec --monitor 'document.querySelector("textarea[name=q]").form.submit()'
agent-browser-cli scan --text-only
Example 2: Form Filling
agent-browser-cli open "https://example.com/contact"
agent-browser-cli exec '
const form = {
name: document.querySelector("#name"),
email: document.querySelector("#email"),
message: document.querySelector("#message")
};
form.name.value = "AI Agent";
form.email.value = "agent@example.com";
form.message.value = "Hello from agent-browser-cli";
return "Form filled";
'
agent-browser-cli exec --monitor 'document.querySelector("form").submit()'
Example 3: Multi-Tab Workflow
TABS=$(agent-browser-cli tabs)
echo "$TABS"
agent-browser-cli switch 0
agent-browser-cli exec 'return document.title'
agent-browser-cli open "https://example.com"
agent-browser-cli scan --text-only
Example 4: Data Extraction with Cookies
agent-browser-cli open "https://example.com/dashboard"
COOKIES=$(agent-browser-cli cookies --domain example.com)
echo "$COOKIES"
agent-browser-cli scan --text-only
agent-browser-cli screenshot --output dashboard.png
Example 5: Page Monitoring
RESULT=$(agent-browser-cli exec --monitor '
document.querySelector("#load-more").click();
return "Clicked load more";
')
echo "$RESULT"
agent-browser-cli scan --text-only
Response Format
All commands return JSON:
{
"ok": true,
"result": {
"status": "success",
"data": "...",
"metadata": {}
}
}
Error format:
{
"ok": false,
"error": "Error message"
}
Common Patterns
Wait for Element
agent-browser-cli exec '
return new Promise((resolve) => {
const check = () => {
const el = document.querySelector("#target");
if (el) resolve("Found");
else setTimeout(check, 100);
};
check();
});
'
Extract Structured Data
agent-browser-cli exec '
return Array.from(document.querySelectorAll(".item")).map(item => ({
title: item.querySelector(".title")?.textContent,
link: item.querySelector("a")?.href,
price: item.querySelector(".price")?.textContent
}));
'
File Upload
agent-browser-cli exec '
const input = document.querySelector("input[type=file]");
const dt = new DataTransfer();
dt.items.add(new File(["content"], "test.txt"));
input.files = dt.files;
input.dispatchEvent(new Event("change", { bubbles: true }));
return "File set";
'
Dropdown Selection
agent-browser-cli exec '
const select = document.querySelector("select#country");
select.value = "US";
select.dispatchEvent(new Event("change", { bubbles: true }));
return select.value;
'
Troubleshooting
Extension not connecting
- Verify extension is loaded in
chrome://extensions
- Check extension port matches config:
cat ~/.agent-browser-cli/config.json
- Ensure at least one normal web page is open (not
chrome:// or about:)
- Restart daemon:
agent-browser-cli restart
Command timeout
- Check daemon status:
agent-browser-cli status
- Verify Chrome is running and extension is active
- Try simpler command first:
agent-browser-cli tabs
- Check logs:
tail -f ~/.agent-browser-cli.log
Port conflicts
agent-browser-cli set-extension-port 18766
agent-browser-cli restart
WSL 2 connectivity issues
For WSL 2 users on Windows 11 22H2+:
- Enable
networkingMode=mirrored in .wslconfig
- Restart WSL
- Ensure Chrome extension can connect to
localhost:18765
Slow performance
- Use
--text-only flag for faster content extraction
- Avoid
--screenshot unless needed
- Use
--monitor only when detecting page changes is necessary
- Consider increasing system resources if Chrome is sluggish
Advanced: CDP Operations
The underlying Chrome extension uses Chrome DevTools Protocol (CDP). While most operations are abstracted by the CLI, you can execute raw CDP commands via JavaScript:
agent-browser-cli exec '
return await chrome.debugger.sendCommand({tabId: chrome.tabs.getCurrent().id}, "Network.getCookies", {});
'
Environment Variables
The CLI uses a config file instead of environment variables:
Config location: ~/.agent-browser-cli/config.json
{
"extension_port": 18765
}
Logs
Daemon logs are written to:
~/.agent-browser-cli.log
Monitor in real-time:
tail -f ~/.agent-browser-cli.log
Integration with AI Agents
When called by AI coding agents, typical workflows:
- Check tab state:
agent-browser-cli tabs
- Navigate or switch:
agent-browser-cli open <url> or agent-browser-cli switch <index>
- Extract content:
agent-browser-cli scan --text-only
- Perform action:
agent-browser-cli exec --monitor '<js code>'
- Verify result:
agent-browser-cli scan or agent-browser-cli screenshot
The tool is designed for high-frequency calls with minimal overhead (~40-120ms for simple operations).