Skip to content

Force OpenCode to use agent-browser and block Playwright entirely #6

Description

@itse4elhaam

Problem

OpenCode must never use Playwright in any form. This includes direct CLI usage, package-runner downloads, Node imports, Playwright MCP, generated Playwright tests/configuration, or indirect fallback from another browser workflow.

The only approved browser automation tool should be:

~/.agents/skills/agent-browser

A shell alias alone is insufficient because agents may use non-interactive shells, npx, bunx, package scripts, MCP tools, or direct imports.

Required changes

1. Remove Playwright integrations

  • Remove Playwright MCP from the OpenCode configuration.
  • Remove any Playwright-specific tool/skill configuration.
  • Remove installed Playwright dependencies where present:
    • playwright
    • playwright-core
    • @playwright/test
  • Remove obsolete Playwright configuration, scripts, and browser caches where appropriate.

2. Add an explicit agent policy

Add a global OpenCode instruction stating:

## Browser Automation Policy

Playwright is prohibited.

Never:
- install or import `playwright`, `playwright-core`, or `@playwright/test`
- use Playwright MCP
- run `playwright`, `npx playwright`, `bunx playwright`, or `pnpm dlx playwright`
- generate Playwright tests or configuration
- use Playwright indirectly through another tool

For all browser interaction, use:
`~/.agents/skills/agent-browser`

If agent-browser cannot complete the task, report the limitation. Do not fall back to Playwright.

Place this in the strongest global instruction file loaded by OpenCode, not only in documentation.

3. Add a blocking playwright executable

Create a PATH-prioritized shim named playwright that exits non-zero and prints:

Playwright is disabled in this environment.
Use agent-browser instead: ~/.agents/skills/agent-browser

The shim must work in non-interactive shells and return exit code 126 or another clearly intentional failure code.

4. Block package-runner bypasses

Prevent OpenCode from downloading or invoking Playwright through at least:

  • npx playwright
  • npx playwright@...
  • bunx playwright
  • bunx playwright@...
  • pnpm dlx playwright
  • @playwright/test

Prefer PATH-prioritized guarded wrappers used specifically in the OpenCode environment. All unrelated package-runner commands must continue to work normally.

5. Add a repository tripwire

Add a script that fails when prohibited Playwright dependencies, MCP configuration, commands, or imports are introduced into active configuration.

Avoid false positives from:

  • documentation explaining the prohibition
  • the guard script itself
  • archived/legacy files, where explicitly excluded
  • node_modules and .git

Wire the check into the most appropriate existing validation/setup workflow.

6. Update documentation

Document that:

  • agent-browser is the single supported browser automation path
  • Playwright is intentionally unavailable
  • failure of agent-browser must be surfaced rather than triggering a fallback
  • aliases are not considered enforcement

Acceptance criteria

  • Playwright MCP is absent from active OpenCode configuration.
  • playwright fails with the custom guidance message.
  • npx playwright, bunx playwright, and pnpm dlx playwright are blocked.
  • Version-qualified and scoped Playwright package invocations are blocked.
  • Normal npx, bunx, and pnpm dlx commands still work for unrelated packages.
  • OpenCode's active instructions explicitly prohibit all Playwright usage and direct the agent to ~/.agents/skills/agent-browser.
  • A validation check prevents Playwright from being reintroduced.
  • Existing active Playwright configuration and dependencies are removed.
  • Documentation reflects agent-browser as the only supported browser automation tool.

Verification

Run and record the output of:

command -v playwright
playwright --version
npx playwright --version
bunx playwright --version
pnpm dlx playwright --version

The Playwright commands must fail with intentional guidance, while a harmless unrelated package-runner command should still succeed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions