xiaohongshu
xiaohongshu
Real-time browser debugging and interaction via WebSocket bridge server on localhost:3141
Full skill instructions
BrowserBridge enables Claude Code to interact with web browsers in real-time through a C# bridge server and Chrome/Edge extension for debugging, DOM inspection, and JavaScript execution.
Prerequisites Check:
curl http://localhost:3141/api/browser/health
If successful, you can execute browser commands. If connection refused, bridge server is not running.
Common Commands:
# Execute JavaScript
curl -X POST http://localhost:3141/api/browser/execute -H "Content-Type: application/json" -d '{"script": "document.title"}'
# Inspect element
curl -X POST http://localhost:3141/api/browser/inspect -H "Content-Type: application/json" -d '{"selector": "#myElement"}'
# List connections
curl http://localhost:3141/api/browser/connections
Bridge Server Running: User must have started the bridge server
cd bridge-server/ClaudeBrowserBridge
dotnet run
Extension Connected: User must have:
chrome://extensions/)Active Webpage: User must be viewing a webpage in the browser
curl http://localhost:3141/api/browser/health
Response:
{
"status": "healthy",
"timestamp": "2025-11-21T10:30:00Z",
"connections": 1
}
Use this to verify bridge server is running and count connected browsers.
curl http://localhost:3141/api/browser/connections
Response shows all connected browser tabs with connection IDs and last activity.
curl -X POST http://localhost:3141/api/browser/execute \
-H "Content-Type: application/json" \
-d '{"script": "YOUR_JAVASCRIPT_HERE"}'
Common Scripts:
Get page title:
curl -X POST http://localhost:3141/api/browser/execute -H "Content-Type: application/json" -d '{"script": "document.title"}'
Check if element exists:
curl -X POST http://localhost:3141/api/browser/execute -H "Content-Type: application/json" -d '{"script": "document.querySelector(\"#myId\") !== null"}'
Get element innerHTML:
curl -X POST http://localhost:3141/api/browser/execute -H "Content-Type: application/json" -d '{"script": "document.querySelector(\"#myId\")?.innerHTML"}'
Get element count:
curl -X POST http://localhost:3141/api/browser/execute -H "Content-Type: application/json" -d '{"script": "document.querySelectorAll(\".className\").length"}'
Check if function exists:
curl -X POST http://localhost:3141/api/browser/execute -H "Content-Type: application/json" -d '{"script": "typeof window.myFunction"}'
Get computed style:
curl -X POST http://localhost:3141/api/browser/execute -H "Content-Type: application/json" -d '{"script": "window.getComputedStyle(document.querySelector(\"#myId\")).display"}'
Test DOM change live:
curl -X POST http://localhost:3141/api/browser/execute -H "Content-Type: application/json" -d '{"script": "document.querySelector(\"#test\").style.border = \"2px solid red\""}'
Note: Results are sent via WebSocket. The bridge server writes script results to a file for easy access:
# Read the last script result
cat "C:/RI Services/BrowserBridge/claude_browser_last_result.json"
Example result:
{"type":"script_result","success":true,"result":"2408","timestamp":1764632896201}
For debugging, all messages are logged to:
powershell -Command "Get-Content 'C:\RI Services\BrowserBridge\all_messages.log' -Tail 20"
curl -X POST http://localhost:3141/api/browser/inspect \
-H "Content-Type: application/json" \
-d '{"selector": "#myElement"}'
Inspection results appear in bridge server console with:
outerHTML and innerHTML)Common Selectors:
#pagination.button-class[data-id="123"]#parent .child:first-of-typecurl -X POST http://localhost:3141/api/browser/screenshot \
-H "Content-Type: application/json" \
-d '{"fullPage": false}'
Screenshot sent as base64 PNG via WebSocket to bridge server logs.
curl http://localhost:3141/api/browser/connections/{connectionId}
Get detailed info about a specific connection.
curl "http://localhost:3141/api/browser/connections/{connectionId}/history?limit=50"
Get recent messages from a connection (console logs, errors, etc).
The extension automatically captures and sends to bridge server:
console.log, console.warn, console.error, console.infoCheck the bridge server console to see these events in real-time.
curl -X POST http://localhost:3141/api/browser/execute -H "Content-Type: application/json" -d '{"script": "document.querySelector(\"#myElement\") !== null"}'
curl -X POST http://localhost:3141/api/browser/inspect -H "Content-Type: application/json" -d '{"selector": "#myElement"}'
display: none or visibility: hidden)Check if function exists:
curl -X POST http://localhost:3141/api/browser/execute -H "Content-Type: application/json" -d '{"script": "typeof window.updatePaginationControls"}'
If returns "function", get its source:
curl -X POST http://localhost:3141/api/browser/execute -H "Content-Type: application/json" -d '{"script": "window.updatePaginationControls.toString()"}'
ES6 modules encapsulate their variables, making them inaccessible from the global scope. Instead of repeatedly exposing individual variables, add a generic getValue helper:
Add this pattern to the module:
// Debug helper - access module values by dot-notation path
window.getValue = (path) => {
const moduleVars = { state, filterOptions, myFunction, loadData }; // Add all you need
const parts = path.split('.');
let val = moduleVars[parts[0]];
for (let i = 1; i < parts.length && val !== undefined; i++) {
val = val[parts[i]];
}
return val;
};
Usage from Browser Bridge:
# Get nested state value
curl -X POST http://localhost:3141/api/browser/execute -H "Content-Type: application/json" -d '{"script": "getValue(\"state.filters.lang\")"}'
# Get array length
curl -X POST http://localhost:3141/api/browser/execute -H "Content-Type: application/json" -d '{"script": "getValue(\"filterOptions.refs\")?.length"}'
# Get complex state as JSON
curl -X POST http://localhost:3141/api/browser/execute -H "Content-Type: application/json" -d '{"script": "JSON.stringify({filters: getValue(\"state.filters\"), count: getValue(\"state.data.totalCount\")})"}'
Alternative: Expose state to window directly:
// At module start
const state = window.__state = { /* ... */ };
Then access via window.__state.filters.lang without needing getValue.
Before suggesting code changes, test them:
curl -X POST http://localhost:3141/api/browser/execute -H "Content-Type: application/json" -d '{"script": "document.querySelectorAll(\"button\").forEach(b => b.style.border = \"2px solid red\")"}'
User sees changes immediately. If it works, provide the permanent CSS/JS fix.
Always use optional chaining to avoid errors:
# Good
curl -X POST http://localhost:3141/api/browser/execute -H "Content-Type: application/json" -d '{"script": "document.querySelector(\"#myId\")?.innerHTML || \"Element not found\""}'
# Bad (will throw if element doesn't exist)
curl -X POST http://localhost:3141/api/browser/execute -H "Content-Type: application/json" -d '{"script": "document.querySelector(\"#myId\").innerHTML"}'
When calling functions programmatically that normally run from UI events, event may be undefined:
// BAD - throws "Cannot read properties of undefined (reading 'add')"
event?.target?.classList.add('active'); // classList is undefined when event is undefined
// GOOD - chain all the way through
event?.target?.classList?.add('active');
This applies to any pattern where you use ?. but then call a method on the result.
curl: (7) Failed to connect to localhost port 3141
Cause: Bridge server not running
Tell User:
The bridge server isn't running. Please start it:
cd bridge-server/ClaudeBrowserBridge
dotnet run
{"connections": 0}
Cause: Extension not connected
Tell User:
The extension isn't connected. Please:
1. Click the extension icon in your browser
2. Click "Connect to Claude"
3. Verify status shows "Connected" (green dot)
Results appear in bridge server console. Check logs for:
?.) or null checks\" for quotes inside JSON stringsWhen constructing curl commands with nested quotes:
# Escape double quotes inside JSON
curl -X POST http://localhost:3141/api/browser/execute -H "Content-Type: application/json" -d '{"script": "document.querySelector(\"#myId\")"}'
# Or use single quotes in JavaScript
curl -X POST http://localhost:3141/api/browser/execute -H "Content-Type: application/json" -d "{\"script\": \"document.querySelector('#myId')\"}"
Tell user to:
window.__claudeBridge exists in consoleResults are sent via WebSocket to bridge server console. User must check the terminal running dotnet run to see:
User says: "The pagination controls aren't showing up"
Claude:
curl http://localhost:3141/api/browser/health
curl -X POST http://localhost:3141/api/browser/execute -H "Content-Type: application/json" -d '{"script": "document.querySelector(\"#pagination\") !== null"}'
curl -X POST http://localhost:3141/api/browser/inspect -H "Content-Type: application/json" -d '{"selector": "#pagination"}'
Check bridge server logs → See it has display: none or empty innerHTML
Find why:
curl -X POST http://localhost:3141/api/browser/execute -H "Content-Type: application/json" -d '{"script": "typeof updatePaginationControls"}'
| Action | Endpoint | Method |
|---|---|---|
| Health check | /api/browser/health | GET |
| List connections | /api/browser/connections | GET |
| Execute JavaScript | /api/browser/execute | POST |
| Inspect element | /api/browser/inspect | POST |
| Screenshot | /api/browser/screenshot | POST |
| Connection details | /api/browser/connections/{id} | GET |
| Message history | /api/browser/connections/{id}/history | GET |
bridge-server/ClaudeBrowserBridge/extension/SETUP.mdxiaohongshu
technical spec
product ux expert
database patterns
Conduct multi-agent task orchestration and workflow coordination.
Initialize project with Conductor artifacts (product definition,
Expert in web animations, transitions, and motion design using Framer Motion and CSS
Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...
PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.
Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...
Display project status, active tracks, and next actions
Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.
Generate, edit, and beat-sync AI video with leading models in one workspace.
The world's fastest calendar for remote work
Transform Your Design with AI Designer by ImgCreator.ai
Revolutionizing Video Production with AI-Powered Creativity
Extend an image past the frame and let AI fill the new aspect ratio.
Discover your celebrity doppelgänger with StarByFace!
ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.
Opus.ai: Revolutionize Your Web Experience