/kernel-dev:debug-session <session-id-or-name>from kernel-dev
Debug a failed, hung, blocked or timed-out Kernel browser session from its session id or name: read session state and telemetry events (they stay readable after the browser is deleted), check live page state, replays and logs, then diagnose and propose a fix. Use when a Kernel run fails or misbehaves, or the user gives a Kernel session id.
Ships in kernel-dev. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
You are diagnosing one Kernel browser session. Evidence order: session record, then telemetry events, then (only if the browser is still alive) live checks, then replays. Telemetry and the session record stay readable after the browser is deleted, so start there.
Inputs:
ARGUMENTS:). If there is none, use the latest Kernel session id or name visible in the conversation or the last run output. Ask only if there is none at all.Rules for the whole run:
kernel browsers curl uses the browser's own cookie jar, so a profile opened with save_changes could save what that request sets. Run step 4 only for a browser that is still live, and prefer the process exec form in item 3.cdp_ws_url, webdriver_ws_url, base_url, browser_live_view_url, replay_view_url, API keys, or full event payloads. Event data can hold Cookie/Authorization headers, bodies and URL tokens (https://kernel.sh/docs/browsers/telemetry/categories). Project fields with jq and cut URL query strings (sub("\\?.*";"?***")).--types, --categories, jq, and head/tail.head -1.-o json errors are plain text such as ERROR: Not_found: ... with exit 1, written to stderr, and stdout stays empty. So never pipe a kernel command straight into jq (an empty input makes jq exit 0 and the failure looks like success). Capture first: out=$(kernel ... -o json) && jq '...' <<<"$out" || echo "could not run: <what>", or redirect to a file with || { ...; }.rm -rf <D>.Run command -v kernel. If it prints nothing, print these install commands and stop (do not install anything):
brew install kernel/tap/kernel
npm i -g @onkernel/cli
Run out=$(kernel auth context -o json) && jq 'keys' <<<"$out" || echo "could not run: auth context". On could not run, tell the user to set KERNEL_API_KEY in their environment and stop. Do not print the key.
Shell state does not persist between Bash calls. Create the private directory once, print it, then use that literal path (called <D>) in every later command:
umask 077; D=$(mktemp -d); echo "$D"
Fetch the record and keep only safe fields before anything touches disk. First check the argument (id or name) against ^[A-Za-z0-9._-]{1,64}$; if it does not match, say so, run the cleanup and stop. Put it, single-quoted, in place of ARG:
out=$(kernel browsers get 'ARG' --include-deleted -o json) || { echo "could not read the session record"; rm -rf <D>; exit 1; }
jq '{session_id,name,created_at,deleted_at,timeout_seconds,headless,stealth,proxy,tags,usage_status,telemetry}' <<<"$out" > <D>/browser.json || { echo "could not parse the record"; rm -rf <D>; exit 1; }
jq '. + {running:(.deleted_at == null),
ran_s:((if .deleted_at then (.deleted_at|sub("\\.[0-9]+";"")|fromdate) else now|floor end)-(.created_at|sub("\\.[0-9]+";"")|fromdate)),
telemetry_on:([.telemetry.browser//{}|to_entries[]|select(.value.enabled)|.key])} | del(.telemetry)' <D>/browser.json
Read session_id from the record. From here on, use that literal id as <SESSION_ID> in every command (never the name).
Read the result:
deleted_at present: the browser is gone. Skip step 4 (live checks). The record has deleted_at, not a status key.Not_found even with --include-deleted: the id is wrong, belongs to another project (retry with --project <name>), or the name does not resolve (not verified whether --include-deleted accepts a name; prefer the id). Run the cleanup, then stop and ask.running: true (no deleted_at): ran_s is the elapsed time so far (now minus created_at), so the timeout checks below still apply: ran_s at or past timeout_seconds on a still-active record means it is about to be, or is being, reaped.ran_s close to timeout_seconds: the browser was most likely reaped by its timeout, not crashed. The timeout countdown starts after the browser enters standby, which happens after about 5 s with no activity, so also compare with the time of the last cdp_disconnect in step 3. Fix: raise timeout_seconds at create (../kernel/references/browsers.md).headless: true: no live view URL and no replays exist for this session.telemetry_on lacks console, network or page: capture was off for those categories; there is no evidence to recover, and enabling later cannot backfill. Defaults (connection, control, system, captcha) always layer on, so you will still see CDP connects and API calls.proxy and stealth: note them for the diagnosis (unblock cases).Events default to a 5 minute window. Always pass --since <created_at> and --all, or you will miss the failure. --until in the future is rejected.
Run now, with <CREATED> set to created_at from <D>/browser.json:
kernel browsers telemetry events <SESSION_ID> --since "<CREATED>" --all -o json > <D>/events.json || { echo "could not read telemetry"; rm -rf <D>; exit 1; }
jq -r '.events|map(.event.type)|group_by(.)|map("\(.[0]) \(length)")[]' <D>/events.json
The JSON is { "events": [ { "seq": N, "event": { "ts", "type", "category", "source", "data" } } ] }; seq is on the envelope and ts is microseconds. If the count is 0, report "no telemetry captured", then go to step 4 if deleted_at is null, else step 5.
Then pull only the failure signals, one line each, with URLs stripped of query strings. Failures sit at the end, so take the last 40:
jq -r -f "${CLAUDE_SKILL_DIR}/scripts/events.jq" <D>/events.json > <D>/rows.txt || echo "could not filter events"; tail -40 <D>/rows.txt
(${CLAUDE_SKILL_DIR} is this skill's folder; if it is empty the file is <plugin>/skills/debug-session/scripts/events.jq.) The filter keeps console_error, page-level network_loading_failed, HTTP 4xx/5xx network_response and the crash and disconnect types, and redacts bearer values, secret-looking key=value pairs, URL userinfo, query strings, fragments and long opaque path segments. That is best effort: console text can still hold something sensitive, so quote a row in your answer only after reading it, and never paste whole event objects.
Do not print .event.data whole. The CLI also filters server-side: --types console_error,network_loading_failed and --categories console both work; --limit/--offset page manually if --all is too much.
Traps in the data:
console_error. There is no page_error event.page.goto to an unresolvable host does not throw. The signal is page_navigation events plus a 502 network_response on /favicon.ico, not a network_loading_failed for the document.fetch that returned HTTP 500 shows as network_loading_failed with net::ERR_ABORTED (canceled), not as a network_response 500. Do not read it as a network outage.ERR_ABORTED can mean a failed navigation to an HTTP error page (a top-level goto to a 500 gave no page_navigation, only this), not only a canceled fetch. Check the failing URL and the caller's error before choosing.network_loading_failed rows can be target_type: service_worker calls to a Kernel-internal endpoint. The filter above keeps only page targets.monitor_disconnected means the collector dropped; treat events until monitor_reconnected as incomplete.Map signal to likely cause (state it as "likely", cite the event seq):
| Signal | Likely cause | Fix to propose |
|---|---|---|
system_oom_kill, service_crashed, page_crashed | VM out of memory or renderer crash | More memory at create (default headless VM is 1 GiB; headless accepts 1, 2 or 4 GiB) and fewer parallel executors: ../kernel/references/browsers.md, ../kernel/references/control.md |
network_response 403/429, or network_loading_failed on the document with a challenge page | Bot detection or rate limit | ../kernel/references/unblock.md (stealth, proxy, captcha) |
proxy_error | Proxy path failed (a classification of branded 502/403 responses, only with network telemetry on; not a complete record of proxy refusals) | proxy: { mode: 'direct' } to isolate, or fix the proxy: ../kernel/references/unblock.md |
network_response 403 with X-Kernel-Proxy-Error: network_policy_denied | Blocked by network.allowed_hosts (header seen on page.goto and browsers curl responses, not checked on telemetry events) | Add the host to the allow list |
ran_s near timeout_seconds, last cdp_disconnect then silence | Idle timeout reaped the browser | Raise timeout_seconds, keep the client connected or delete explicitly: ../kernel/references/browsers.md |
api_call for ExecutePlaywrightCode returned HTTP 200 but the run died in its own code (playwright.execute gave success:false) | Failure in the caller's code. The error text is only in the caller's result (result.error), not in telemetry (observed live: it was absent) | Ask for or read the run's output or logs; then fix or catch the error inside the Playwright code |
page_navigation events end, then an execute failure, after a top-level page.goto to a URL that answers HTTP 500 | Playwright goto to an HTTP error page can fail with net::ERR_HTTP_RESPONSE_CODE_FAILURE; the execute result then has success=false while the API call itself is HTTP 200 (observed live with https://httpbin.org/status/500, where telemetry showed no page_navigation, only a document network_loading_failed ERR_ABORTED; the throw text was seen in the caller's result, not in events). Other statuses were not tested | Catch the goto error inside the Playwright code and return { ok:false, navError }, or treat the status yourself (details: ../kernel/references/control.md) |
ran_s far below timeout_seconds, cdp_connect with no cdp_disconnect after it | The client deleted the browser explicitly (e.g. deleteByID in its finally). Telemetry showed no delete api_call, so it cannot name the deleter | Find the deleting code path in the user's code; check why it ran early (a thrown error reaching finally) |
console_error after a navigation | Page-side JS failure (the site, not Kernel) | Fix selectors or wait for page_navigation_settled before acting |
Only connection/control/system events | console/network/page were not enabled | Create with telemetry including them: ../kernel/references/observe.md |
monitor_disconnected before the failure window | Evidence gap | Say the diagnosis is partial |
deleted_at is null)Run these once each, in this order, and stop as soon as the cause is clear. Use the literal <SESSION_ID>.
kernel browsers computer screenshot <SESSION_ID> --to <D>/shot.png, then open the PNG with the Read tool. Tell the user what the page shows (blank, challenge, error page). Do not paste image bytes.kernel browsers playwright execute <SESSION_ID> 'return await page.title()' -o json.kernel browsers process exec <SESSION_ID> -- curl -sI https://<FAILING_HOST>/ | head -1
kernel browsers curl <SESSION_ID> https://<FAILING_HOST>/ -I | head -1 # uses the browser's cookie jar: only for a throwaway or read-only browser
An empty line means the command failed, not that the host answered: say "could not check" for it.
Chrome-only failure points at fingerprinting, cookies or the proxy route (../kernel/references/unblock.md). Failure on both points at network or DNS.
4. Service logs (often returns no lines): kernel browsers logs stream <SESSION_ID> --source supervisor --supervisor-process chromium --follow=false | head -50. If it prints logs source not available or failed to open log path, say logs were unavailable and move on. Do not retry in a loop.
5. Live view: only if the user wants to look. kernel browsers view <SESSION_ID> prints a URL that is a bearer token; do not show it. Tell the user to run the command themselves. Absent on headless.
Run out=$(kernel browsers replays list <SESSION_ID> -o json) && jq 'map({replay_id,started_at,finished_at})' <<<"$out" || echo "could not run: replays list" (works after delete). If empty, say no replay was recorded (a replay records only from the moment it is started, and a headless browser returns 400 on replays start).
If there is one and the symptom is visual, offer to download it; do not download unasked. Save outside <D> so cleanup does not delete it:
kernel browsers replays download <SESSION_ID> <REPLAY_ID> -f ./kernel-replay-<REPLAY_ID>.mp4
If the download is not ready (HTTP 202 while finalizing; the CLI's message for it was not captured), wait a few seconds and retry, at most 5 times. Any other failure: report it and stop. The replay is video only. Report the file path, not the replay URL.
seq and type, or a record field).@onkernel/sdk when code is needed, and name the reference file to read (../kernel/references/browsers.md, ../kernel/references/unblock.md, ../kernel/references/observe.md, ../kernel/references/control.md). Add the docs URL when one applies: telemetry events https://kernel.sh/docs/browsers/telemetry/categories, replays https://kernel.sh/docs/browsers/replays.console, network and page telemetry (and start a replay on a headful browser) before the run. See ../kernel/references/observe.md.rm -rf <D>.disable_default_proxy or other routing on a live session to A/B test; that field is deprecated and had no direct effect. Use proxy: { mode: 'direct' } on a new browser instead (../kernel/references/unblock.md).kernel browsers delete ... -y: delete has no -y flag.kernel logs or app logs cover browser failures; for Apps use kernel logs <app> -i <invocation_id>.Report to the user in exactly this shape:
Session: <id> (<name>) - <live | deleted at <deleted_at>> - <headless | headful> - ran <ran_s>s of <timeout_seconds>s (so far, if live)
Telemetry captured: <categories> | events read: <count> | window: <created_at> to now
Likely cause: <one sentence>
Evidence:
- seq <n> <event type> <short text, no URLs with tokens>
- <record field or live check result>
Ruled out / not checked: <list, each with the reason>
Fix:
- <concrete change, with code in TypeScript if needed>
- Read: ../kernel/references/<file>.md (<docs URL>)
Next step: <one thing you can run for the user, if any>
Never include Kernel-issued session URLs (CDP, live view, replay, hosted login), keys, cookies or raw event payloads in that report. Docs URLs are fine.
Verified live 2026-10-20 (Hobbyist plan); types re-checked on @onkernel/sdk 0.129.0. Evidence ledger: https://github.com/yigitkonur/plugin-kernel-sh/blob/main/verified-facts.md
What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub yigitkonur/plugin-kernel-sh --plugin kernel-dev7 skills in this plugin
/auditAudit this project's Kernel usage: environment, deprecated fields, cleanup on every path, secrets, retries, pools, profiles, telemetry. Read-only; reports file:line findings with fixes and sources./diff-profilesCompare two Kernel profiles (cookies, storage, preferences, extensions, login state) without printing values, and explain why a flow works on one and not the other./kernelSteering for Kernel (kernel.sh) cloud browsers in TypeScript projects: the @onkernel/sdk, the `kernel` CLI, the Kernel MCP server and KERNEL_API_KEY. Use when code or commands create, drive, debug or scale Kernel browsers or Kernel Apps: bot detection and proxies, logins and profiles, vaults, pools, live view, replays, telemetry, API keys and projects. Not for Linux or Jupyter kernels, Semantic Kernel, or other browser vendors.