Skip to content

Instantly share code, notes, and snippets.

@levchenkod
Created June 8, 2026 20:33
Show Gist options
  • Select an option

  • Save levchenkod/a92f58b58c32c531528a709913b2506b to your computer and use it in GitHub Desktop.

Select an option

Save levchenkod/a92f58b58c32c531528a709913b2506b to your computer and use it in GitHub Desktop.
name codex-playwright-sandbox
description Run long autonomous coding tasks through the persistent codex-playwright Docker Sandbox, with Playwright/Chromium and web tooling already available. Use when the user asks to delegate substantial implementation, debugging, refactoring, e2e/browser work, AFK coding, background coding, or long-running autonomous work via sbx, especially with `sbx run codex-playwright -- exec "..."`.

Codex Playwright Sandbox

Use the codex-playwright sandbox for substantial coding work that can run independently, especially frontend, browser, Playwright, or repo-wide tasks. The sandbox is expected to contain Node, pnpm, Playwright, Chromium, Python, and Codex.

Quick Start

Run an autonomous task:

sbx run codex-playwright -- exec "Implement <task>. Read AGENTS.md first, preserve unrelated changes, run relevant tests, and report changed files plus verification."

When To Use

Use this sandbox when the task is:

  • Long-running or AFK-friendly.
  • Likely to need browser automation, Playwright, Chromium, screenshots, or video smoke tests.
  • Large enough that isolating work in a sandbox is safer than doing everything in the current thread.

Do not use it for tiny edits, sensitive credential handling, destructive git operations, or tasks that require continuous user judgment.

Before Launch

  1. Check whether the sandbox exists:
sbx ls
  1. If missing, ask the user before creating it. Prefer the prebuilt Playwright template:
sbx create --name codex-playwright --template docker.io/lapps/codex-pp:0.1.13 codex .
  1. If creation fails with EROFS, extraction, or No space left on device, stop and report host disk pressure. The template intentionally includes Chromium and is large.

Prompt Contract

Every exec prompt should include:

  • The concrete objective.
  • Instructions to read AGENTS.md first.
  • Preserve unrelated user changes.
  • Expected verification commands and final report format.

Good default:

sbx run codex-playwright -- exec "In /Users/dima/work/fastapi-02, read AGENTS.md first. Implement <objective>. Preserve unrelated changes. Use rg/git ls-files, not find. Run the narrowest relevant tests, then report changed files, tests run, and any blockers."

Long Task Loop

For autonomous tasks, ask the sandboxed agent to work in phases:

sbx run codex-playwright -- exec "Read AGENTS.md, inspect the code, make a short plan, implement the smallest complete slice, run verification, then continue until the objective is complete or genuinely blocked. Preserve unrelated changes. At the end, summarize changed files and test results."

For multi-iteration tasks, include a progress artifact:

sbx run codex-playwright -- exec "Maintain .scratch/codex-playwright-progress.md with decisions, commands, failures, and next steps while completing <objective>."

Playwright Checks

Verify preinstalled browser support:

sbx run codex-playwright -- exec "Run bash scripts/web-sandbox-smoke.sh and summarize whether pnpm used offline cache, Chromium launched, and a video artifact was produced."

Monitoring And Recovery

Use sbx run codex-playwright to reconnect if the agent is interactive or still running.

If a command appears stuck, ask for a status check rather than starting duplicate work:

sbx run codex-playwright -- exec "Report current git status, running processes relevant to the task, and the last completed step. Do not make changes."

Inspect sandbox changes from the host before trusting them:

git status --short
git diff --stat

Safety Rules

  • Never ask the sandboxed agent to run git reset --hard, delete broad directories, or rewrite history unless the user explicitly requested it.
  • Do not put secrets in the exec prompt.
  • Do not run multiple autonomous agents against the same worktree unless their file scopes are clearly disjoint.
  • Prefer explicit test commands over "run everything" when the repo has expensive suites.
  • If the sandbox reports missing auth, use codex login inside the sandbox or configure sbx secret; do not paste credentials into prompts.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment