pair-agent
The facts
Its description
Pair a remote AI agent with your browser. (gstack) Triggers: pair with agent; connect remote agent; share my browser
The description the agent reads to decide when to use it. Phrases the author says should start it.
When it starts
Someone who wants a second AI agent (Codex, Cursor, OpenClaw, another Claude session) to browse the web through their own gstack browser, or who asks to share or connect their browser with another agent.
Things a person might say (the model's guesses)
- “I want my Codex agent to use my browser”
- “connect my other agent to my browser”
- “share my browser with another AI agent”
A model's summary of when it is used.
Tools it may use, or may not
allowed-tools: Bash, Read, AskUserQuestion
Tools it may use while it runs without asking you first.
Runs scripts
bin/gstack-skill-start, scripts/question-registry.ts, bin/gstack-question-preference, bin/gstack-question-log, bin/gstack-skill-end (first 5 of 8 lines)
Scripts the text names. Found by matching words, so treat them as pointers.
Stops for a person
10 lines stop to ask a person (first 5 linked)
Lines that stop and wait for a person before going on. Found by matching words, so treat them as pointers.
What it leads to
Other skills this one hands off to, calls, requires or offers instead, as a model read them.
What leads to it
- gstack hands off to this PROACTIVE all, or user names it gstack, line 232
Other skills that hand off to this one, call it, require it or offer it instead, as a model read them.
Licence
MIT, from LICENSE
The terms its author shares it under, which let it be shown here.
Other files in this skill (1) Close
The text
Most marks come from matching words in the file, so treat them as pointers.
<!-- AUTO-GENERATED from SKILL.md.tmpl — do not edit directly --> <!-- Regenerate: bun run gen:skill-docs -->
Raw lines 1 to 18Boilerplate, lines 19 to 75. The same text appears in 45 other files here. Close
Telemetry (run last)
After workflow completion, log telemetry with ONE command. OUTCOME is success/error/abort/unknown; SESSION_ID and TEL_START are the values the preamble's skill-start output echoed. It also drains the artifacts-sync queue (the former skill-end sync step — do not run gstack-brain-sync separately).
PLAN MODE EXCEPTION — ALWAYS RUN: This writes telemetry to $GSTACK_STATE_ROOT/analytics/, matching preamble analytics writes.
~/.claude/skills/gstack/bin/gstack-skill-end --skill "pair-agent" --outcome OUTCOME \
--session-id "SESSION_ID" --tel-start "TEL_START" --used-browse USED_BROWSE \
--error-message "ERROR_MESSAGE" --failed-step "FAILED_STEP" 2>/dev/null || trueReplace OUTCOME and USED_BROWSE (yes/no) before running; substitute SESSION_ID/TEL_START from the skill-start echoes. ERROR_MESSAGE/FAILED_STEP are "" unless outcome is error. If the command is missing (stale install), skip telemetry — it never blocks the workflow.
/pair-agent — Share Your Browser With Another AI Agent
You're sitting in Claude Code with a browser running. You also have another AI agent open (OpenClaw, Hermes, Codex, Cursor, whatever). You want that other agent to be able to browse the web using YOUR browser. This skill makes that happen.
Raw lines 76 to 102How it works
Your gstack browser runs a local HTTP server. This skill creates a one-time setup key, prints a block of instructions, and you paste those instructions into the other agent. The other agent exchanges the key for a session token, creates its own tab, and starts browsing. Each agent gets its own tab. They can't mess with each other's tabs.
The setup key expires in 5 minutes and can only be used once. If it leaks, it's dead before anyone can abuse it. The session token lasts 24 hours.
Same machine: If the other agent is on the same machine (like OpenClaw running locally), you can skip the copy-paste ceremony and write the credentials directly to the agent's config directory.
Remote: If the other agent is on a different machine, you need an ngrok tunnel. The skill will tell you if one is needed and how to set it up.
Raw lines 103 to 119SETUP (run this check BEFORE any browse command)
_ROOT=$(git rev-parse --show-toplevel 2>/dev/null)
B=""
[ -n "$_ROOT" ] && [ -x "$_ROOT/.claude/skills/gstack/browse/dist/browse" ] && B="$_ROOT/.claude/skills/gstack/browse/dist/browse"
[ -z "$B" ] && B="$HOME/.claude/skills/gstack/browse/dist/browse"
if [ -x "$B" ] && "${B%/browse/*}/bin/gstack-browser-ensure"; then
echo "READY: $B"
else
echo "NEEDS_SETUP"
figstack-browser-ensure installs Chromium on first use when the install skipped it (lazy browser); it prints BROWSER_OK or BROWSER_UNAVAILABLE <reason> first.
If NEEDS_SETUP:
- Tell the user: "gstack browse needs a one-time build (~10 seconds). OK to proceed?" Then STOP and wait.
- Run:
cd <SKILL_DIR> && ./setup - If
bunis not installed: ``bash if ! command -v bun >/dev/null 2>&1; then BUN_VERSION="1.4.2" BUN_INSTALL_SHA="bab8acfb046aac8c72407bdcce903957665d655d7acaa3e11c7c4616beae68dd" tmpfile=$(mktemp "${TMPDIR:-/tmp}/bun-install.XXXXXX") curl -fsSL "https://bun.sh/install" -o "$tmpfile" # shasum is macOS/perl; coreutils-only Linux ships sha256sum instead — # resolve whichever exists so the verify never fails on a missing tool. if command -v sha256sum >/dev/null 2>&1; then actual_sha=$(sha256sum < "$tmpfile" | awk '{print $(1)}') else actual_sha=$(shasum -a 256 < "$tmpfile" | awk '{print $(1)}') fi if [ "$actual_sha" != "$BUN_INSTALL_SHA" ]; then echo "ERROR: bun install script checksum mismatch" >&2 echo " expected: $BUN_INSTALL_SHA" >&2 echo " got: $actual_sha" >&2 rm "$tmpfile"; exit 1 fi bash "$tmpfile" "bun-v$BUN_VERSION" rm "$tmpfile" fi
Step 1: Check prerequisites
$B status 2>/dev/nullIf the browse server is not running, start it:
$B goto about:blankThis ensures the server is up and healthy before pairing.
Raw lines 164 to 177Step 2: Ask what they want
Use AskUserQuestion:
Which agent do you want to pair with your browser? This determines the instructions format and where credentials get written.
Options:
- A) OpenClaw (local or remote)
- B) Codex / OpenAI Agents (local)
- C) Cursor (local)
- D) Another Claude Code session (local or remote)
- E) Something else (generic HTTP instructions — use this for Hermes)
Based on the answer, set TARGET_HOST:
- A →
openclaw - B →
codex - C →
cursor - D →
claude - E → generic (no host-specific config)
Step 3: Local or remote?
Use AskUserQuestion:
Is the other agent running on this same machine, or on a different machine/server? Same machine skips the copy-paste ceremony. Credentials are written directly to the agent's config directory. No tunnel needed. Different machine generates a setup key and instruction block. If ngrok is installed, the tunnel starts automatically. If not, I'll walk you through setup. RECOMMENDATION: Choose A if the agent is local. It's instant, no copy-paste needed.
Options:
- A) Same machine (write credentials directly)
- B) Different machine (generate instruction block for copy-paste)
Step 4: Execute pairing
Live-daemon consent (one-way door). Pairing can relaunch the browser daemon; a relaunch KILLS the running headless daemon — open tabs, cookies, and logged-in sessions die with it. The CLI honors the iron rule (only an explicit --force-restart may kill a live daemon), so check first:
$B status 2>/dev/null | head -5If a daemon is running, ask via AskUserQuestion (one-way door — lost tabs/cookies/logins cannot be recovered):
"A headless browser daemon is live (tabs and logins may be active). Pairing headed requires relaunching it — everything in the current daemon is lost. RECOMMENDATION: Choose B unless the remote agent specifically needs a visible browser window; pairing works against the existing daemon."
Options:
- A) Relaunch (pass
--force-restart; current tabs/cookies/logins are lost) - B) Keep the live daemon (recommended — pair against it as-is)
Only pass --force-restart to the commands below after an explicit A. Never default to A on a vague reply — this is a destructive confirmation.
If same machine (option A):
Run pair-agent with --local flag:
$B pair-agent --local TARGET_HOSTReplace TARGET_HOST with the value from Step 2 (openclaw, codex, cursor, etc.).
If it succeeds, tell the user: "Done. TARGET_HOST can now use your browser. It will read credentials from the config file that was written. Try asking it to navigate to a URL."
If it fails (host not found, write permission error), show the error and suggest using the generic remote flow instead.
Raw lines 244 to 260If different machine (option B):
Consent gate (once per machine). The tunnel exposes this browser beyond the machine, so it is OFF until the user opts in — the daemon refuses /tunnel/start and BROWSE_TUNNEL=1 otherwise. Check the standing consent:
~/.claude/skills/gstack/bin/gstack-config get pair_agent 2>/dev/null || echo "unset"If the value is not on, ask via AskUserQuestion (one-way-door posture — this opens a path from the internet to the local browser):
"Remote pairing runs an ngrok tunnel from the internet to this machine's browser (locked to a 26-command allowlist + scoped token, but still an exposure). Enable pair-agent on this machine?"
Options: A) Enable — run ~/.claude/skills/gstack/bin/gstack-config set pair_agent on, confirm it reads back on, and continue. B) No — stop here; local pairing (option A above) still works.
If the value is already on, say nothing and continue — consent stands until gstack-config set pair_agent off.
Then detect ngrok status:
which ngrok 2>/dev/null && echo "NGROK_INSTALLED" || echo "NGROK_NOT_INSTALLED"
ngrok config check 2>/dev/null && echo "NGROK_AUTHED" || echo "NGROK_NOT_AUTHED"If ngrok is installed and authed: Just run the command. The CLI will auto-detect ngrok, start the tunnel, and print the instruction block with the tunnel URL:
$B pair-agent --client TARGET_HOSTDefault access already includes JS execution. To also grant browser-wide control (stop, restart, disconnect):
$B pair-agent --control --client TARGET_HOSTFor a less-trusted agent, narrow the scopes instead:
$B pair-agent --restrict read --client TARGET_HOST # read-only
$B pair-agent --restrict "read,write" --client TARGET_HOST # no JS, no cookiesCRITICAL: You MUST output the full instruction block to the user. The command prints everything between its ===== divider lines. Copy the ENTIRE block verbatim into your response so the user can copy-paste it into their other agent. Do NOT summarize it, do NOT skip it, do NOT just say "here's the output." The user needs to SEE the block to copy it. Output it inside a markdown code block so it's easy to select and copy.
Then tell the user: "Copy the block above and paste it into your other agent's chat. The setup key expires in 5 minutes."
If ngrok is installed but NOT authed: Walk the user through authentication.
SECURITY: the ngrok authtoken must NEVER pass through this chat, a Bash tool call, or shell history — a token pasted here lands in the transcript (and anything the transcript syncs to). The user runs the auth command in their OWN terminal; you only verify the result.
Tell the user: "ngrok is installed but not logged in. Let's fix that — in your own terminal (not here; the token should never enter this chat):
- Go to https://dashboard.ngrok.com/get-started/your-authtoken
- Copy your auth token
- In YOUR terminal, run: ngrok config add-authtoken <paste your token>
- Tell me 'done' when finished."
STOP here and wait for the user to say they've run it. Do NOT accept a pasted token; if the user pastes one anyway, tell them to rotate it at https://dashboard.ngrok.com (it's now in the transcript) and re-auth in their terminal with the new one.
When they say done, verify without touching the token:
ngrok config check 2>/dev/null && echo "NGROK_AUTHED" || echo "NGROK_NOT_AUTHED"If NGROK_AUTHED: retry $B pair-agent --client TARGET_HOST. If still NGROK_NOT_AUTHED: ask them to re-run the command in their terminal.
If ngrok is NOT installed: Walk the user through installation:
Tell the user: "To connect a remote agent, we need ngrok (a tunnel that exposes your local browser to the internet securely).
- Go to https://ngrok.com and sign up (free tier works)
- Install ngrok:
- macOS:
brew install ngrok - Linux:
snap install ngrokor download from ngrok.com/download - Auth it:
ngrok config add-authtoken YOUR_TOKEN(get your token from https://dashboard.ngrok.com/get-started/your-authtoken) - Come back here and run
/pair-agentagain."
STOP here. Wait for the user to install ngrok and re-invoke.
Raw lines 261 to 365Step 5: Verify connection
After the user pastes the instructions into the other agent, wait a moment then check:
$B statusLook for the connected agent in the status output. If it appears, tell the user: "The remote agent is connected and has its own tab. You'll see its activity in the side panel if you have GStack Browser open."
Raw lines 366 to 377What the remote agent can do
Default access is read+write+admin+meta. The trust boundary is the pairing ceremony, not the scope:
- Navigate to URLs, click elements, fill forms, take screenshots
- Read page content (text, HTML, snapshot)
- Create new tabs (each agent gets its own)
- Execute JavaScript via
eval - Cannot stop or restart the browser, or disconnect headed mode (needs --control)
Remote agents go through the tunnel command allowlist: eval works, but the js, cookies, and storage commands are not dispatchable over the tunnel even with admin scope. Agents paired with --local get all four.
With --restrict (--restrict read, --restrict "read,write"):
- Sandboxed sessions: read-only, or read+write with no JS, cookie, or storage access. Pair this way when the remote agent will read untrusted web content: a trusted agent can be prompt-injected by pages it reads, and scope caps the blast radius (eval works over the tunnel).
--restrictnever grantscontrol; that scope stays behind --control.- To tighten an agent that is ALREADY paired, re-pair it with the **same
--clientname** and the narrower--restrict/--domain. A reducing re-pair revokes the previous session immediately and releases its tabs — the agent must reconnect with the new key, so the old wide access does not linger. Re-pairing without--clientmints a brand-new agent and leaves the old one untouched. Broadening or refreshing keeps the working session (no outage). rootis a reserved--clientname (it would bypass all scope enforcement).
With --control (--admin is the legacy alias):
- Everything, plus browser-wide destructive ops (stop, restart, disconnect)
- Only for agents you fully trust.
Troubleshooting
"Tab not owned by your agent" — The remote agent tried to interact with a tab it didn't create. Tell it to run newtab first to get its own tab.
"Domain not allowed" — The token has domain restrictions. Re-pair with the same --client name and broader (or no) --domain. A broadening re-pair keeps the working session; a narrowing one revokes it immediately.
"Rate limit exceeded" — The agent is sending > 10 requests/second. It should wait for the Retry-After header and slow down.
"Token expired" — The 24-hour session expired. Run /pair-agent again to generate a new setup key.
Agent can't reach the server — If remote, check the ngrok tunnel is running ($B status). If local, check the browse server is running.
Platform-specific notes
Raw lines 428 to 429OpenClaw / AlphaClaw
OpenClaw agents use the exec tool instead of Bash. The instruction block uses exec curl syntax which OpenClaw understands natively. When using --local openclaw, credentials are written to ~/.openclaw/skills/gstack/browse-remote.json.
Codex
Codex agents can execute shell commands via codex exec. The instruction block's curl commands work directly. When using --local codex, credentials are written to ~/.codex/skills/gstack/browse-remote.json.
Cursor
Cursor's AI can run terminal commands. The instruction block works as-is. When using --local cursor, credentials are written to ~/.cursor/skills/gstack/browse-remote.json.
Revoking access
To disconnect a specific agent:
$B tunnel revoke AGENT_NAMEThe command deletes every token for that agent (the session and any pending setup keys) and re-reads the agent list to prove it's gone.
See who's paired:
$B tunnel agentsUnexchanged setup keys show as "(pending)"; tunnel revoke removes them too.
To disconnect ALL agents at once, stop the daemon. Scoped tokens live in daemon memory and never survive a restart; the next command boots a fresh daemon with a new root token:
$B stopRaw lines 449 to 474From garrytan/gstack at 3f79d81, 2026-11-01. Skills read by DeepSeek V4.1 Flash on 2026-11-04. Summary and techniques by Claude Opus 5.5 on 2026-11-06.