/remote-gateway:gateway-profilingfrom remote-gateway
Find where a ByteDesk remote gateway spends CPU, memory, goroutines or lock time with the gateway `profiling` plugin: list and switch per-plugin profiling, capture a CPU profile or a heap, allocs, goroutine, mutex or block snapshot, summarize hot functions and trace them to the owning plugin, read the flame graph, compare before and after a fix, and switch profiling off afterwards. Use this whenever the gateway or one of its plugins is slow, pegs a CPU, grows in memory, leaks goroutines, hangs, stalls on a lock, or process-evaluator or host-monitor flags the gateway process — "profile the gateway", "why is bytedesk-emote-gateway at 100% CPU", "is the terminal plugin leaking", "did my fix help" — even when the user does not say "profile". Covers the MCP tools `profiling_list`, `profiling_set`, `profiling_capture_cpu`, `profiling_capture_snapshot`, `profiling_captures`, `profiling_get_meta`, `profiling_summarize`, `profiling_compare`, and the HTTP API `/profiling/api/*`. Read gateway-logs first when the symptom is an error rather than resource use.
Trending skills
7-day visitors to each skill page
Ships in remote-gateway. 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.
The gateway can profile itself per plugin. In-process plugins are separated by
pprof labels; a spawned plugin (external: true) profiles its own process.
Captures are stored on the host, so you can summarize and compare them later.
Never print, log or paste a token, cookie value or password.
A. MCP tools. If profiling_list is in your tool list (often as
mcp__bytedesk-gateway__profiling_list), call the tools directly. They are
served properly only by the running gateway at http://127.0.0.1:8757/mcp,
which accepts only an operator API token as a Bearer. A stand-alone stdio
mcp-gateway (the per-session generated config, also named
bytedesk-gateway) may list the same tools but has no profile store and
profiles only itself. Check before trusting route A: if profiling_list
returns an empty plugins list, or profiling_captures fails with "profile
store unavailable", use route B.
B. HTTP API. Otherwise log in with the remote-gateway-login skill and
reuse the cookie jar (it prints url and cookieJar, never the password):
LOGIN="${CLAUDE_PLUGIN_ROOT:-<remote-gateway plugin dir>}/skills/remote-gateway-login/scripts/login.sh"
OUT=$(bash "$LOGIN") || { echo "$OUT"; exit 1; } # stop on exit 2-5; see remote-gateway-login
U=$(jq -r .url <<<"$OUT"); J=$(jq -r .cookieJar <<<"$OUT")
gw() { curl -sS --fail-with-body -m 90 -b "$J" "$U$@"; }
Shell state does not survive between Bash calls, so run this block at the start
of every call that uses gw. Rerunning is cheap: the login script reuses a
valid cookie and sends no password.
For another host, give the login script that gateway's flags, or use
infra run <service> -- from the infrastructure repo. Do not use
gateway_api for this: it refuses profiling paths.
| MCP tool | HTTP equivalent |
|---|---|
profiling_list | GET /profiling/api/plugins |
profiling_set {id, enabled, levels?, all?, callers?} | POST /profiling/api/switch (same JSON) |
profiling_capture_cpu {plugin?, seconds?} | POST /profiling/api/capture {"kind":"cpu","plugin":"x","seconds":20} |
profiling_capture_snapshot {kind, seconds?} | POST /profiling/api/capture {"kind":"heap"} |
profiling_captures {kind?, plugin?, limit?} | GET /profiling/api/captures?kind=&plugin=&limit= |
profiling_get_meta {id} | GET /profiling/api/captures/{id} |
profiling_summarize {id, top?} | GET /profiling/api/captures/{id}/summary?top=15 |
| (flame graph) | GET /profiling/api/captures/{id}/flame |
| (raw pprof) | GET /profiling/api/captures/{id}/download |
profiling_compare {a, b, top?} | none; fetch both summaries and diff the flat shares |
| Symptom | Capture |
|---|---|
| High CPU, slow responses | CPU, 10–30 s, while the problem is happening |
| Memory growing (RSS, process-evaluator leak finding) | heap now and again later; allocs for churn |
| Goroutine count climbing, hangs, leaked sessions | goroutine |
| Requests stall but CPU is low | mutex and block (these sample over seconds) |
profiling_list. Note each plugin's enabled, external
and eligible (with reason, such as "spawned plugin is not running").
Write down which plugins were already on, so you can compare at the end.profiling_set {"id":"x","enabled":true}. Add
levels: N or all: true to include what it depends on, or
callers: true to include what depends on it. The response's applied
list (applied[].id) includes every plugin in the chain, even ones that
were already on. The switches you own are the applied[].id values that
were not enabled in your starting inventory. Profiling adds overhead, so
on a production host say what you are switching on and for how long.
Snapshots (heap, goroutine, …) cover the whole gateway process and do
not need a switch.plugin profiles the
whole gateway process.profiling_summarize {"id":N,"top":20} gives the top
functions by flat and cumulative share. MCP adds a hint naming the
dominant non-runtime function (20% flat or more); HTTP /summary has no
hint. Infer the owning plugin from the function's package path or the
capture's plugin. Open /flame when you need the call
path. Use /download with go tool pprof only for deeper work.If you were given a "before" capture id, read it with profiling_get_meta
(or GET /profiling/api/captures/{id}) and match its kind, plugin and
seconds. Otherwise take a "before" capture of the same kind, plugin and duration. Apply the fix
(through the normal release and cutover path, never a hand-copied binary).
Take an "after" capture under the same load, then
profiling_compare {"a":before,"b":after}. A fix counts only if the hot
function's flat share fell and the symptom is gone. Report both ids and the
deltas.
applied[].id not enabled at the
start), one at a time, with no levels, all or callers:
profiling_set {"id":"x","enabled":false}. Off is always allowed. A
propagated off would also switch off plugins that were on before you
started.profiling_list, compare with the starting inventory, and
report the final state.DELETE /profiling/api/captures/{id}) destroys evidence; do it only when
asked.Save the summaries you relied on into the task's evidence folder, the incident runbook entry or the playbook the caller named:
: "${EVIDENCE_DIR:?set EVIDENCE_DIR first}"; mkdir -p "$EVIDENCE_DIR"
gw "/profiling/api/captures/$ID/summary?top=20" > "$EVIDENCE_DIR/profile-$ID-summary.json"
Record the capture ids, kind, plugin, duration and what load was running.
What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub bytedeskai/bytedesk-marketplace --plugin remote-gateway17 skills in this plugin
/commitCommit and push repo changes with human-only authorship, Keep a Changelog update, and embedded changelog sync. After a successful commit in a linked git worktree, offer to merge into the main checkout and remove the tree (Grok/Claude/Codex isolation). Never attributes coding agents or external co-authors. Use when the user runs /commit, says "commit", "commit and push", "land the changes", "update changelog and push", or wants a clean push of the current worktree.
/cutoverSafe production cutover for bytedesk-remote-gateway via this skill's bundled scripts/deploy-safe.sh, only from the develop branch. DEFAULT always restarts: preflight → stage → restart-cutover → postflight (do not stage-only or ask for restart). Use FORCE_RESTART=1 when stage is UNCHANGED but bounce is still required. Also after every completed implementation task that changes gateway/SPA runtime. After feature cutover PASS, ask the operator to /commit (do not auto-commit). Triggers: /cutover, "safe cutover", "deploy-safe", "stage binary" (stage-only only if user says stage only / no restart), "restart cutover", FORCE_RESTART, postflight healthz.
/desktop-depsCheck desktop/agents profile dependencies for the gateway on Linux, macOS, and Windows. Use when desktop profile, VNC, Xvfb, or ttyd is missing.
/gateway-doctorDiagnose a ByteDesk gateway install without printing secrets. Use for doctor, health check, missing control.env, or post-install verification.
/gateway-installInstall ByteDesk remote gateway (commercial free core) on Linux, macOS, or Windows. Profiles core|agents|desktop. Use when the user says install gateway, setup gateway, or wants a private-first bytedesk-gateway home.
/gateway-lifecycleStart, stop, status, healthz, and print /setup URL for an installed ByteDesk gateway on Linux (systemd), macOS (launchd), or Windows (run.ps1/pid).
Other plugins' skills for the same job