Loading...
Loading...
Launch and automate VS Code (Code OSS) using agent-browser via Chrome DevTools Protocol. Use when you need to interact with the VS Code UI, automate the chat panel, test UI features, or take screenshots of VS Code. Triggers include 'automate VS Code', 'interact with chat', 'test the UI', 'take a screenshot', 'launch Code OSS with debugging'.
npx skill4agent add microsoft/vscode launchagent-browsernpm installnpx agent-browsernpm install -g agent-browser./scripts/code.shVSCODE_SKIP_PRELAUNCH=1.interactive-input-part.interactive-input-editor.part.auxiliarybarevalagent-browser snapshot -i# Launch Code OSS with remote debugging
./scripts/code.sh --remote-debugging-port=9224
# Wait for Code OSS to start, retry until connected
for i in 1 2 3 4 5; do agent-browser connect 9224 2>/dev/null && break || sleep 3; done
# Discover UI elements
agent-browser snapshot -i
# Focus the chat input (macOS)
agent-browser press Control+Meta+i# Connect to a specific port
agent-browser connect 9222
# Or use --cdp on each command
agent-browser --cdp 9222 snapshot -i
# Auto-discover a running Chromium-based app
agent-browser --auto-connect snapshot -iconnect--cdp# List all available targets (windows, webviews, etc.)
agent-browser tab
# Switch to a specific tab by index
agent-browser tab 2
# Switch by URL pattern
agent-browser tab --url "*settings*"scripts/code.sh--remote-debugging-portcd <repo-root> # the root of your VS Code checkout
./scripts/code.sh --remote-debugging-port=9224# Wait for Code OSS to start, retry until connected
for i in 1 2 3 4 5; do agent-browser connect 9224 2>/dev/null && break || sleep 3; done
agent-browser snapshot -iVSCODE_SKIP_PRELAUNCH=1VSCODE_SKIP_PRELAUNCH=1 ./scripts/code.sh --remote-debugging-port=9224--user-data-dir--user-data-dir=/tmp/code-oss-debug--extensionDevelopmentPath--remote-debugging-port--user-data-dir# Build the extension first
cd <extension-repo-root> # e.g., the root of your extension checkout
npm run compile
# Launch VS Code Insiders with the extension and CDP
code-insiders \
--extensionDevelopmentPath="<extension-repo-root>" \
--remote-debugging-port=9223 \
--user-data-dir=/tmp/vscode-ext-debug
# Wait for VS Code to start, retry until connected
for i in 1 2 3 4 5; do agent-browser connect 9223 2>/dev/null && break || sleep 3; done
agent-browser snapshot -i--extensionDevelopmentPath=<path>--remote-debugging-port=9223--user-data-dir=<path>--user-data-dirclickfillkeyboard typepress# 1. Open and focus the chat input with the keyboard shortcut
# macOS:
agent-browser press Control+Meta+i
# Linux / Windows:
agent-browser press Control+Alt+i
# 2. Type using individual press commands
agent-browser press H
agent-browser press e
agent-browser press l
agent-browser press l
agent-browser press o
agent-browser press Space # Use "Space" for spaces
agent-browser press w
agent-browser press o
agent-browser press r
agent-browser press l
agent-browser press d
# Verify text appeared (optional)
agent-browser eval '
(() => {
const sidebar = document.querySelector(".part.auxiliarybar");
const viewLines = sidebar.querySelectorAll(".interactive-input-editor .view-line");
return Array.from(viewLines).map(vl => vl.textContent).join("|");
})()'
# 3. Send the message (same on all platforms)
agent-browser press EnterCtrl+Cmd+Iagent-browser press Control+Meta+iCtrl+Alt+Iagent-browser press Control+Alt+iCtrl+Alt+Iagent-browser press Control+Alt+idocument.activeElementDIVnative-edit-contextagent-browser presstype @reftype @refagent-browser snapshot -i
# Look for: textbox "The editor is not accessible..." [ref=e62]
agent-browser type @e62 "Hello from George!"type @refkeyboard typekeyboard inserttextpresspress| Method | VS Code Insiders | Code OSS |
|---|---|---|
| ✅ Works | ✅ Works |
| ✅ Works | ❌ Silent fail |
| ✅ Works | ❌ Silent fail |
| ✅ Works | ❌ Silent fail |
| ❌ Blocked by overlay | ❌ Blocked by overlay |
| ❌ Element not visible | ❌ Element not visible |
agent-browser eval '
(() => {
const inputPart = document.querySelector(".interactive-input-part");
const editor = inputPart.querySelector(".monaco-editor");
const rect = editor.getBoundingClientRect();
const x = rect.x + rect.width / 2;
const y = rect.y + rect.height / 2;
editor.dispatchEvent(new MouseEvent("mousedown", { bubbles: true, clientX: x, clientY: y }));
editor.dispatchEvent(new MouseEvent("mouseup", { bubbles: true, clientX: x, clientY: y }));
editor.dispatchEvent(new MouseEvent("click", { bubbles: true, clientX: x, clientY: y }));
return "activeElement: " + document.activeElement?.className;
})()'
# Then use press for each character
agent-browser press H
agent-browser press e
# ...# Verify text in the chat input
agent-browser eval '
(() => {
const sidebar = document.querySelector(".part.auxiliarybar");
const viewLines = sidebar.querySelectorAll(".interactive-input-editor .view-line");
return Array.from(viewLines).map(vl => vl.textContent).join("|");
})()'
# Clear the input (Select All + Backspace)
# macOS:
agent-browser press Meta+a
# Linux / Windows:
agent-browser press Control+a
# Then delete:
agent-browser press Backspaceagent-browser screenshot --fullagent-browser screenshot ".part.auxiliarybar" sidebar.pngagent-browser screenshot --annotatemacOS: Ifreturns "Permission denied", your terminal needs Screen Recording permission. Grant it in System Settings → Privacy & Security → Screen Recording. As a fallback, use theagent-browser screenshotverification snippet to confirm text was entered — this doesn't require screen permissions.eval
--remote-debugging-port=NNNNlsof -i :9224netstat -ano | findstr 9224agent-browser tabagent-browser snapshot -i -Cagent-browser pressCtrl+Cmd+ICtrl+Alt+Itype @refkeyboard typekeyboard inserttextpress⚠️ IMPORTANT: Always quit Code OSS when you're done. Code OSS is a full Electron app that consumes significant memory (often 1–4 GB+). Leaving it running in the background will slow your machine considerably. Don't just disconnect agent-browser — kill the Code OSS process too.
# 1. Disconnect agent-browser
agent-browser close
# 2. QUIT Code OSS — do not leave it running!
# macOS: Cmd+Q in the app window, or:
# Find the process
lsof -i :9224 | grep LISTEN
# Kill it (replace <PID> with the actual PID)
kill <PID>
# Linux:
# kill $(lsof -t -i :9224)
# Windows:
# taskkill /F /PID <PID>
# Or use Task Manager to end "Code - OSS"./scripts/code.shElectronCode - OSS# Confirm no process is listening on the debug port
lsof -i :9224 # should return nothing