Description
Programmatically connect to and control a user-visible Chrome session through CDP, including tab discovery, DOM inspection, navigation, interaction, screenshots, and selective cookie cleanup.
Last updated
Updated on September 20byUse this skill in Bionic
Install manually with this CLI command in your terminal.
$lms get yagil/chrome-cdp-controlChrome CDP Control
Connect to and operate a user-visible Chrome session through CDP for browser inspection, navigation, and interaction.
SKILL.md
Use Chrome DevTools Protocol (CDP) when the user asks you to inspect or operate their Chrome browser. Take initiative: inspect the live page, perform requested browser actions, verify the result, and report concise outcomes.
wait-for and return only the needed proof; a full page dump after every action is unnecessary.element.click() or assigning input.value; framework-controlled pages often ignore synthetic DOM changes.Test the standard endpoint:
curl -fsS http://127.0.0.1:9222/json/version
If unavailable, inspect running browser processes and listening ports. A Chrome process without a remote-debugging endpoint cannot be attached in place.
If the user wants you to launch a controllable instance, call get_scratchpad_folder, create a profile folder there, and launch:
open -na "Google Chrome" --args \ --remote-debugging-address=127.0.0.1 \ --remote-debugging-port=9222 \ --user-data-dir="<scratchpad>/chrome-cdp-profile" \ "<requested-url>"
Explain that a scratchpad profile persists across immediate restarts only while that scratchpad exists. For durable use, offer a dedicated persistent profile and obtain permission before writing outside the workspace.
Never expose the CDP port beyond loopback.
Resolve scripts/cdp.mjs relative to this SKILL.md. It requires Node 22 or newer with built-in WebSocket and has no third-party dependencies.
node <skill-folder>/scripts/cdp.mjs list node <skill-folder>/scripts/cdp.mjs read --target-id '<id-from-list>' --selector '#status' --limit 1000 node <skill-folder>/scripts/cdp.mjs run --target-id '<id-from-list>' --file '<scratchpad>/workflow.json' node <skill-folder>/scripts/cdp.mjs body --target-url 'example.com/path' --limit 4000 node <skill-folder>/scripts/cdp.mjs navigate --target-url 'example.com' --url 'https://example.com/new' node <skill-folder>/scripts/cdp.mjs new --url 'https://example.com/' node <skill-folder>/scripts/cdp.mjs click-text --target-url 'example.com' --text 'Continue' node <skill-folder>/scripts/cdp.mjs type --target-url 'example.com' --selector 'input[name=email]' --text 'person@example.com' node <skill-folder>/scripts/cdp.mjs eval --target-url 'example.com' --expression 'document.title' node <skill-folder>/scripts/cdp.mjs screenshot --target-url 'example.com' --output '/absolute/scratchpad/page.png' node <skill-folder>/scripts/cdp.mjs clear-cookies --domains 'example.com,login.example.com'
--target-id selects an exact page ID from list. All per-page commands also accept --target-url, a case-sensitive URL substring that must match exactly one page. Supply one selector, not both. Endpoint discovery has a 10-second timeout; commands have a 30-second connection deadline (run --timeout-ms overrides it). Individual page evaluations are capped at 5 seconds.
list and identify the exact page target. Reuse its ID while working on that tab.read --selector CSS. If the page structure is unknown, use a bounded body once, then focused eval for labels, roles, and selectors without reading secret-field values.run with a JSON sequence of fill, click, wait-for, read, and checkpoint steps. It uses one connection and emits one compact receipt. Verify application state with waits and a small final read. Checkpoints only label progress; they do not verify success.completedSteps, failedStep, and live state. Earlier writes may have succeeded. Never automatically replay the whole file; reconcile and construct only the remaining work. outcomeUnknown flags an interrupted input dispatch, not a guarantee that other failures had no effects.new when testing a path should not disrupt the user's current page.view_images if needed.clear-cookies --domains deletes only matching-domain cookies and never prints cookie names or values.Storage.clearDataForOrigin only after explaining that it can reset an unfinished flow. Keep unrelated origins untouched.Input.insertText; follow with appropriate key events or blur./json/list shows a changed target ID after authentication, rediscover the target instead of reusing an old WebSocket URL.Included resources
4 files · 25.19 KB