Skip to content

Instantly share code, notes, and snippets.

@benzittlau
Created March 30, 2026 16:21
Show Gist options
  • Select an option

  • Save benzittlau/1041e18073d1aa73253c6a3f6c591706 to your computer and use it in GitHub Desktop.

Select an option

Save benzittlau/1041e18073d1aa73253c6a3f6c591706 to your computer and use it in GitHub Desktop.
Skill for agent browser clean sessions
name agent-browser-clean-sessions
description Use headed `agent-browser` sessions with explicit `--session` names, reuse each named session for the current conversation task, and close it only after the user is done. Use when work in this repo needs visible browser automation, manual login, auth recovery during a flow, or multiple clean sessions in parallel without persistent profiles, saved state, or CDP attach.

Agent Browser Clean Sessions

Use this skill with the global agent-browser skill when available.

  • Use the global skill for normal page automation patterns.
  • Use this skill for launch policy, headed-session rules, login handling, and cleanup.

Launch

Start a visible one-off session with an explicit name:

agent-browser --session SESSION_NAME --headed --args '--disable-blink-features=AutomationControlled' open https://example.com

Rules:

  • Always use --headed.
  • Always use an explicit semantic --session name.
  • Default to --args '--disable-blink-features=AutomationControlled' for launches in this repo. This keeps the session clean while reducing the chance that sites block the default Playwright automation fingerprint.
  • Reuse that same session name for the current task only.
  • Keep the session temporary to the current conversation task, but do not close it immediately after the first completed request.
  • Do not use --profile, --session-name, state save/load, auth-vault flows, --cdp, or --auto-connect.
  • Do not switch to the real Chrome executable just to work around site blocking unless the user explicitly asks for that fallback.

Reuse The Session

Keep every follow-up command explicit:

agent-browser --session SESSION_NAME snapshot -i
agent-browser --session SESSION_NAME get url
agent-browser --session SESSION_NAME click @e1

For parallel clean sessions, start distinct names and keep each command pinned to the right session.

Handle Login Interruptions

Treat login as a repeatable interruption, not a startup-only step.

Assume manual user login is required if you see a login page, account chooser, password or MFA UI, auth failure, session-expired message, or any sign-in / reauthenticate gate.

When that happens:

  1. Stop issuing page mutations.
  2. Tell the user manual login is required in the visible browser window for that session.
  3. Include the session name and current URL or page state.
  4. Wait for the user to confirm login is complete.
  5. Re-check with:
agent-browser --session SESSION_NAME get url
agent-browser --session SESSION_NAME snapshot -i
  1. Resume on the same session.

Do not relaunch the session just because login is needed again unless the session is no longer active.

Complete The Request

When the requested browser task is complete:

  1. Report the result to the user.
  2. Include the active session name when it helps the user continue the same flow.
  3. Ask whether the user has another request for that same session or wants it closed.
  4. If the user has a follow-up, keep reusing the same session.

Skip the extra confirmation only when the user already made closure intent explicit, such as saying they are done or asking to close the browser once the request completes.

Clean Up

Close the named session when the user is done with that session:

agent-browser --session SESSION_NAME close
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment