Skip to content

Open-source Python library for AI browser agents, plus Browser Use Cloud: stealth browsers and a hosted agent API.

remote browser fixes + readme

Gregor Žuničc7c5cae20ed7
diff --git a/README.md b/README.md
index 047cb0159..0c64a69be 100644
--- a/README.md
+++ b/README.md
@@ -143,6 +143,33 @@ uvx browser-use init --template default --output my_agent.py
<br/>
+# 💻 CLI
+
+Fast, persistent browser automation from the command line:
+
+```bash
+browser-use open https://example.com # Navigate to URL
+browser-use state # See clickable elements
+browser-use click 5 # Click element by index
+browser-use type "Hello" # Type text
+browser-use screenshot page.png # Take screenshot
+browser-use close # Close browser
+```
+
+The CLI keeps the browser running between commands for fast iteration. See [CLI docs](browser_use/skill_cli/README.md) for all commands.
+
+### Claude Code Skill
+
+For [Claude Code](https://claude.ai/code), install the skill to enable AI-assisted browser automation:
+
+```bash
+mkdir -p ~/.claude/skills/browser-use
+curl -o ~/.claude/skills/browser-use/SKILL.md \
+ https://raw.githubusercontent.com/browser-use/browser-use/main/skills/browser-use/SKILL.md
+```
+
+<br/>
+
# Demos
diff --git a/browser_use/skill_cli/README.md b/browser_use/skill_cli/README.md
index f8a0ff042..359521548 100644
--- a/browser_use/skill_cli/README.md
+++ b/browser_use/skill_cli/README.md
@@ -161,6 +161,16 @@ browser.screenshot('scrolled.png')
"
```
+## Claude Code Skill
+
+For [Claude Code](https://claude.ai/code), a skill provides richer context for browser automation:
+
+```bash
+mkdir -p ~/.claude/skills/browser-use
+curl -o ~/.claude/skills/browser-use/SKILL.md \
+ https://raw.githubusercontent.com/browser-use/browser-use/main/skills/browser-use/SKILL.md
+```
+
## How It Works
The CLI uses a session server architecture:
diff --git a/browser_use/skill_cli/api_key.py b/browser_use/skill_cli/api_key.py
index 4d5db73a7..b9bab5680 100644
--- a/browser_use/skill_cli/api_key.py
+++ b/browser_use/skill_cli/api_key.py
@@ -57,7 +57,7 @@ def require_api_key(feature: str = 'this feature') -> str:
│ │
│ {feature} requires an API key. │
│ │
-│ Get yours at: https://browser-use.com/dashboard │
+│ Get yours at: https://browser-use.com/new-api-key │
│ │
│ Then set it via: │
│ export BROWSER_USE_API_KEY=your_key_here │
@@ -77,7 +77,7 @@ def prompt_for_api_key(feature: str) -> str:
│ 🔑 Browser-Use API Key Required │
│ │
│ {feature} requires an API key. │
-│ Get yours at: https://browser-use.com/dashboard │
+│ Get yours at: https://browser-use.com/new-api-key │
╰─────────────────────────────────────────────────────────────╯
"""
)
diff --git a/browser_use/skill_cli/commands/browser.py b/browser_use/skill_cli/commands/browser.py
index 862442423..4e1f94dfc 100644
--- a/browser_use/skill_cli/commands/browser.py
+++ b/browser_use/skill_cli/commands/browser.py
@@ -55,7 +55,13 @@ async def handle(action: str, session: SessionInfo, params: dict[str, Any]) -> A
from browser_use.browser.events import NavigateToUrlEvent
await bs.event_bus.dispatch(NavigateToUrlEvent(url=url))
- return {'url': url, 'success': True}
+ result: dict[str, Any] = {'url': url}
+ # Add live preview URL for cloud browsers
+ if bs.browser_profile.use_cloud and bs.cdp_url:
+ from urllib.parse import quote
+
+ result['live_url'] = f'https://live.browser-use.com/?wss={quote(bs.cdp_url, safe="")}'
+ return result
elif action == 'click':
from browser_use.browser.events import ClickElementEvent
diff --git a/browser_use/skill_cli/commands/session.py b/browser_use/skill_cli/commands/session.py
index 5466a804e..ded333428 100644
--- a/browser_use/skill_cli/commands/session.py
+++ b/browser_use/skill_cli/commands/session.py
@@ -22,20 +22,18 @@ async def handle(action: str, registry: 'SessionRegistry', params: dict[str, Any
elif action == 'close':
if params.get('all'):
- # Close all sessions
+ # Close all sessions and signal shutdown
sessions = registry.list_sessions()
await registry.close_all()
return {
'closed': [s['name'] for s in sessions],
'count': len(sessions),
+ '_shutdown': True, # Signal to stop server
}
else:
- # Close current session
+ # Close current session and signal shutdown
name = params.get('session', 'default')
- success = await registry.close_session(name)
- if success:
- return {'closed': name}
- else:
- return {'error': f'Session not found: {name}'}
+ await registry.close_session(name)
+ return {'closed': name, '_shutdown': True}
raise ValueError(f'Unknown session action: {action}')
diff --git a/browser_use/skill_cli/main.py b/browser_use/skill_cli/main.py
index 18dbe2b91..db8b289e8 100755
--- a/browser_use/skill_cli/main.py
+++ b/browser_use/skill_cli/main.py
@@ -368,6 +368,18 @@ def main() -> int:
if args.api_key:
os.environ['BROWSER_USE_API_KEY'] = args.api_key
+ # Validate API key for remote browser mode upfront
+ if args.browser == 'remote':
+ from browser_use.skill_cli.api_key import APIKeyRequired, require_api_key
+
+ try:
+ api_key = require_api_key('Remote browser')
+ # Ensure it's in environment for the cloud client
+ os.environ['BROWSER_USE_API_KEY'] = api_key
+ except APIKeyRequired as e:
+ print(f'Error: {e}', file=sys.stderr)
+ return 1
+
# Ensure server is running
ensure_server(args.session, args.browser, args.headed, args.profile, args.api_key)
@@ -395,6 +407,9 @@ def main() -> int:
print(data['_raw_text'])
else:
for key, value in data.items():
+ # Skip internal fields
+ if key.startswith('_'):
+ continue
if key == 'screenshot' and len(str(value)) > 100:
print(f'{key}: <{len(value)} bytes>')
else:
diff --git a/browser_use/skill_cli/server.py b/browser_use/skill_cli/server.py
index a24741f97..b85d0a94a 100644
--- a/browser_use/skill_cli/server.py
+++ b/browser_use/skill_cli/server.py
@@ -108,7 +108,15 @@ class SessionServer:
if action == 'shutdown':
return {'id': req_id, 'success': True, 'data': {'shutdown': True}}
- # Get or create session
+ # Session commands don't need a browser session
+ if action in session.COMMANDS:
+ result = await session.handle(action, self.registry, params)
+ # Check if command wants to shutdown server
+ if result.get('_shutdown'):
+ asyncio.create_task(self.shutdown())
+ return {'id': req_id, 'success': True, 'data': result}
+
+ # Get or create session for browser commands
session_info = await self.registry.get_or_create(
self.session_name,
self.browser_mode,
@@ -123,8 +131,6 @@ class SessionServer:
result = await python_exec.handle(session_info, params)
elif action == 'run':
result = await agent.handle(session_info, params)
- elif action in session.COMMANDS:
- result = await session.handle(action, self.registry, params)
else:
return {'id': req_id, 'success': False, 'error': f'Unknown action: {action}'}