Snu browser debug

From arnoudkooi/sn-scriptsync · View interactive version

Snu browser debug is an AI agent skill from the GitHub repository arnoudkooi/sn-scriptsync. Drive the connected ServiceNow tab through the Chrome DevTools Protocol (Pro): capture network requests + response bodies, capture console output and uncaught exceptions, take full-page/element screenshots beyond the viewport, and auto-handle (and record) native confirm/alert/prompt/beforeunload dia

How to use this skill

Skill file

<!-- SN-SCRIPTSYNC:SKILL instructionsSchemaVersion=39 -->

SN ScriptSync โ€” Browser Debugger (CDP)

Escalation layer that uses the Chrome debugger for what content scripts cannot do: network/console capture, full-page screenshots, and native dialog handling.

๐Ÿž Browser Debugger (CDP) โ€” network, console, full-page capture & dialogs

These commands drive the connected ServiceNow tab through the **Chrome DevTools

Protocol** (chrome.debugger) for things the normal content-script bridge

can't do. They are an escalation, not the default โ€” reach for the g_form /

REST commands first; use these only when you specifically need network bodies,

console errors, a beyond-viewport screenshot, or captured dialog text.

Requirements & caveats (read before using)

enables sn-scriptsync.browserDebugger.enabled. Don't ask repeatedly โ€” if it's

disabled, fall back (e.g. take_screenshot, the suppressDialogs flag) and

mention the setting once.

SN Utils Debug edition browser build

(https://chromewebstore.google.com/detail/sn-utils-debug/imjkemgdgfakdbobaoagilnoanibajeb) โ€”

the regular build returns E_CDP_UNAVAILABLE. Using it is a Pro capability, so

an active SN Utils Pro, Trial, or Enterprise license is also required

(E_PRO_REQUIRED when the adapter is present but the license doesn't

qualify). Tell the user which of the two is missing rather than just surfacing

the code.

and parsing the error, call get_capabilities once: if cdp.available is

true the debugger is usable; if false, cdp.reason tells you why

(E_DISABLED / E_CDP_UNAVAILABLE / E_PRO_REQUIRED) so you can fall back

gracefully.

shows a persistent "SN Utils started debugging this browser" bar. Streaming

captures keep it up until you stop; one-shot capture_full_page flashes it

briefly. Always close what you open.

these are developers), attach fails with E_DEBUGGER_BUSY. Ask them to close

DevTools, or target another tab.

Always pair start/stop

The capture commands hold the debugger session open. Pair them so the banner

drops and you actually read results:

Picking the right tool

debugger, no banner) but needs a per-tab capture grant โ€” the first call on

a tab returns E_SCREENSHOT_PERMISSION. capture_full_page goes through the

Chrome debugger (Page.captureScreenshot), which needs no per-tab grant

(only the debugger attach + brief yellow banner) and also does whole-page /

element-selector capture.

navigate_and_screenshot) โ€” the browser uses activeTab when the tab is

granted, silently switches to the debugger when the grant is missing and

the build + Pro + browserDebugger.enabled allow it (result carries

capturedVia: "debugger"), and only asks the user to click the SN Utils

icon as a last resort. Call capture_full_page explicitly only for

whole-page or element-selector captures. check_connection's

helper.debuggerAvailable tells you up front whether the debugger features

(full-page capture, network/console, dialogs) exist on this session โ€” the

Debug edition is the exception, not the rule. Don't use the debugger path at

all if the user has asked you not to attach the debugger.

click_element is lighter and needs no debugger โ€” use it for a single action.

Use set_dialog_handler only when you need a persistent handler across

navigations or want the dialog's message text.

reason the capability exists.

Typical "why did that request fail?" loop

start_network_capture  (urlFilter: "/api/now")
start_console_capture
โ†’ run_ui_action / click_element / navigate   (reproduce the action)
stop_network_capture   (inspect status, response body)
stop_console_capture   (inspect client-side errors)

Verify a change end to end (Pro / Trial)

Run this after any write that changes behaviour in the browser: a client script, UI policy,

UI action, widget, or a server script that a form or list triggers. Do not report the behaviour

as verified until it has been exercised against the synced code. If verification is blocked,

report the implementation and the remaining verification gap explicitly.

Console and network evidence need the Debug edition plus a Pro, Trial or Enterprise license.

Check get_capabilities and respect per-instance gates: for E_PRO_REQUIRED, offer

https://snutils.com/trial once; for E_CDP_UNAVAILABLE, explain that the Debug edition is

missing; for E_DISABLED, respect the opt-out without proposing a trial as the remedy.

Use the free screenshot, form-state (where supported), and get_last_error steps when CDP is

unavailable. State that console errors and request bodies were not checked. A failed or

unsupported check is not a pass.

Before starting captures, identify a test tab on the instance you changed. Pass its tabId

to both captures, navigation, form actions, stop commands, and screenshots. Navigate in that

same tab with newTab: false and discardUnsaved: false; do not silently discard a user's

unsaved work. If a clean test tab is needed, create it before starting captures and use its

returned tabId. A new load alone does not prove that a widget or browser cache has refreshed;

verify an observable effect of the changed code before declaring success.

sync_now                      (only for the intended pending writes; never bypass review)
get_sync_status               (wait until the changed files are no longer pending or syncing)
get_record                    (only if the save is not already verified; skip after successful verified:true with matching persisted content)
                              (sync_now's synced:true only means sent, so file sync still needs a content check)
                              (for a NOW SDK app, use sdk_deploy and wait for its final install result instead)
get_capabilities              (cdp.available must be true for capture; otherwise use the free fallback)
start_console_capture         (tabId: the test tab; remember whether this succeeded)
start_network_capture         (same tabId; scoped urlFilter, e.g. "/api/now" or "xmlhttp.do"; includeBodies: true)
โ†’ navigate                    (same tabId, newTab: false, discardUnsaved: false; wait for load)
โ†’ set_field / run_ui_action / click_element   (same tabId; reproduce the affected behaviour)
get_form_state                (same tabId; values, mandatory flags, messages, where g_form exists)
stop_network_capture          (same tabId; inspect failed requests, status and available response bodies)
stop_console_capture          (same tabId; inspect exceptions and console errors)
capture_full_page             (same tabId; take_screenshot when CDP is unavailable)
run_background_script         (optional, if permitted: read-only assertion for server-side behaviour)

Rules for the loop:

Commands

`start_network_capture` โšก (Remote - Async ยท Pro)

Start recording network traffic on the connected ServiceNow tab through the Chrome debugger (CDP). Captures request method/URL/headers and, by default, response bodies โ€” things content scripts can't see. Pair every call with stop_network_capture, which returns the log and detaches the debugger.

Attaching the debugger shows Chrome's unavoidable yellow "SN Utils started debugging this browser" banner until you stop. Requires SN Utils Pro (and a build that ships the debugger adapter).

Request:

{
  "id": "snc_1",
  "command": "start_network_capture",
  "params": { "urlFilter": "/api/now", "includeBodies": true }
}

Parameters:

Response (success):

{ "status": "success", "result": { "capturing": true, "urlFilter": "/api/now", "includeBodies": true, "tabId": 42 } }

Error codes: E_PRO_REQUIRED, E_CDP_UNAVAILABLE (build without the debugger adapter), E_DEBUGGER_BUSY (DevTools/another debugger attached to that tab), E_NO_TAB, E_BROWSER_DISCONNECTED, E_TIMEOUT.

Tip: Start the capture, then drive the page (navigate / run_ui_action / click_element), then stop_network_capture to read what fired.

`stop_network_capture` โšก (Remote - Async ยท Pro)

Stop the capture started by start_network_capture and return the recorded requests. Detaches the Chrome debugger (dropping the banner) unless a console capture or dialog handler is still active on the tab.

Request:

{ "id": "snc_2", "command": "stop_network_capture", "params": {} }

Parameters:

Response (success):

{
  "status": "success",
  "result": {
    "count": 2,
    "tabId": 42,
    "requests": [
      {
        "url": "https://acme.service-now.com/api/now/table/incident",
        "method": "GET",
        "type": "XHR",
        "status": 200,
        "mimeType": "application/json",
        "responseHeaders": { "...": "..." },
        "body": "{\"result\":[...]}",
        "bodyTruncated": false
      }
    ]
  }
}

Each entry may also include requestHeaders, postData, encodedDataLength, remoteIP, fromCache, and โ€” on failures โ€” failed, errorText. body is omitted when unavailable; bodyBase64: true marks binary bodies.

Error codes: E_PRO_REQUIRED, E_CDP_UNAVAILABLE, E_NO_TAB, E_BROWSER_DISCONNECTED, E_TIMEOUT.

`start_console_capture` โšก (Remote - Async ยท Pro)

Start capturing console.* output, log entries, and uncaught exceptions on the connected ServiceNow tab through the Chrome debugger (CDP). Pair with stop_console_capture.

Shows Chrome's yellow debugger banner until stopped. Requires SN Utils Pro.

Request:

{ "id": "scc_1", "command": "start_console_capture", "params": {} }

Parameters:

Response (success):

{ "status": "success", "result": { "capturing": true, "tabId": 42 } }

Error codes: E_PRO_REQUIRED, E_CDP_UNAVAILABLE, E_DEBUGGER_BUSY, E_NO_TAB, E_BROWSER_DISCONNECTED, E_TIMEOUT.

Tip: Use this to catch client-script / UI-policy errors that only surface in the console while you reproduce a form interaction.

`stop_console_capture` โšก (Remote - Async ยท Pro)

Stop the capture started by start_console_capture and return the collected entries. Detaches the Chrome debugger unless another capture/handler is still active on the tab.

Request:

{ "id": "scc_2", "command": "stop_console_capture", "params": {} }

Parameters:

Response (success):

{
  "status": "success",
  "result": {
    "count": 2,
    "tabId": 42,
    "entries": [
      { "kind": "console", "level": "error", "text": "TypeError: g_form is not defined", "timestamp": 173... },
      { "kind": "exception", "level": "error", "text": "Uncaught ReferenceError: x is not defined", "url": "https://acme.service-now.com/...", "lineNumber": 12 }
    ]
  }
}

kind is console (a console.* call), log (a Log.entryAdded browser log), or exception (an uncaught error).

Error codes: E_PRO_REQUIRED, E_CDP_UNAVAILABLE, E_NO_TAB, E_BROWSER_DISCONNECTED, E_TIMEOUT.

`capture_full_page` โšก (Remote - Async ยท Pro)

Capture a full-page (entire scrollable page, beyond the viewport) or single-element screenshot through the Chrome debugger and save it under screenshots/. Unlike take_screenshot (viewport only, no debugger), this uses CDP to render the whole page or a specific element.

Briefly attaches the Chrome debugger (banner flashes, then detaches). Requires SN Utils Pro.

Request:

{ "id": "cfp_1", "command": "capture_full_page", "params": { "fullPage": true } }

Parameters:

Response (success):

{
  "status": "success",
  "result": {
    "saved": true,
    "filePath": "/abs/workspace/screenshots/fullpage_2026-06-16T19-30-00.png",
    "fileName": "fullpage_2026-06-16T19-30-00.png",
    "format": "png",
    "clip": { "x": 0, "y": 0, "width": 1280, "height": 4200, "scale": 1 },
    "tabId": 42,
    "url": "https://dev.service-now.com/incident.do?sys_id=abc123",
    "tabTitle": "Incident | ServiceNow"
  }
}

Verify url/tabTitle match the page you intended โ€” without an explicit tabId the capture targets the first matching ServiceNow tab, which may not be the one you navigated.

Error codes: E_PRO_REQUIRED, E_CDP_UNAVAILABLE, E_DEBUGGER_BUSY, E_NO_ELEMENT (selector matched nothing / not visible), E_NO_TAB, E_BROWSER_DISCONNECTED, E_TIMEOUT.

Tip: Reach for take_screenshot for a quick viewport check; use capture_full_page when you need the whole long form/list or a specific component in isolation.

`set_dialog_handler` โšก (Remote - Async ยท Pro)

Install a native-dialog handler on the connected tab through the Chrome debugger (CDP). While active, browser-native confirm() / alert() / prompt() and the dirty-form beforeunload ("Leave site?") prompt are answered automatically and recorded (message text included). Pair with clear_dialog_handler to remove it and read what was intercepted.

Keeps the Chrome debugger attached (banner stays) until cleared. Requires SN Utils Pro.

This is the heavyweight alternative to the per-action suppressDialogs flag on run_ui_action / click_element: it persists across navigations and, unlike the in-page suppression, captures the dialog message via CDP. Prefer suppressDialogs for a single action; use this when you need a persistent handler and/or the dialog text.

Request:

{ "id": "sdh_1", "command": "set_dialog_handler", "params": { "autoAccept": true } }

Parameters:

Response (success):

{ "status": "success", "result": { "handlerActive": true, "autoAccept": true, "tabId": 42 } }

Error codes: E_PRO_REQUIRED, E_CDP_UNAVAILABLE, E_DEBUGGER_BUSY, E_NO_TAB, E_BROWSER_DISCONNECTED, E_TIMEOUT.

Warning: With autoAccept: true, a destructive UI action that asks "Are you sure?" (e.g. sysverb_delete) will be confirmed โ€” the record gets deleted. Clear the handler when done.

`clear_dialog_handler` โšก (Remote - Async ยท Pro)

Remove the native-dialog handler installed by set_dialog_handler and return the dialogs intercepted while it was active. Detaches the Chrome debugger unless a network/console capture is still running on the tab.

Request:

{ "id": "cdh_1", "command": "clear_dialog_handler", "params": {} }

Parameters:

Response (success):

{
  "status": "success",
  "result": {
    "count": 1,
    "tabId": 42,
    "dialogs": [
      { "type": "confirm", "message": "Are you sure you want to delete this record?", "url": "https://acme.service-now.com/incident.do?sys_id=..." }
    ]
  }
}

type is confirm, alert, prompt, or beforeunload.

Error codes: E_PRO_REQUIRED, E_CDP_UNAVAILABLE, E_NO_TAB, E_BROWSER_DISCONNECTED, E_TIMEOUT.

`debugger_detach` โšก (Remote - Async ยท Pro)

Force-detach the Chrome debugger from the connected tab. Removes the yellow "SN Utils started debugging this browser" banner and ends any network/console capture or dialog handler still active. A safety net โ€” stop_* / clear_* already detach when nothing else is running.

Request:

{ "id": "dd_1", "command": "debugger_detach", "params": {} }

Parameters:

Response (success):

{ "status": "success", "result": { "detached": true, "tabId": 42 } }

Error codes: E_PRO_REQUIRED, E_CDP_UNAVAILABLE, E_NO_TAB, E_BROWSER_DISCONNECTED, E_TIMEOUT.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.