Files
mygo/.agents/skills/playwright-cli/SKILL.md
T
ld 52dd56ff06 build(web): replace Playwright MCP with project-scoped Playwright CLI
- feat: add `.agents/skills/playwright-cli/` with complete Skill
  markdown, agent interface, and 9 reference files covering session
  management, spec-driven testing, video recording, tracing, storage,
  request mocking, element attributes, test debugging, and running
  custom code
- feat: add `.playwright/cli.config.json` to configure the Playwright
  CLI
- feat: add `web/package.json` `playwright:cli` script that resolves
  `playwright cli` from the repo root
- build: remove `@playwright/mcp` dependency from `web/package.json`
- build: set `XDG_CACHE_HOME` in `mise.toml`
- build: delete `.codex/config.toml` (MCP server config)
- docs: update `README.md`, `docs/web/roadmap.md`,
  `docs/web/decisions.md`, and `web/README.md` to reflect the new
  Playwright CLI approach
2026-07-15 23:10:43 +08:00

5.3 KiB

name, description
name description
playwright-cli Debug and automate the MyGO Web interface with the repository-pinned Playwright CLI. Use for headless browser inspection, login and file-flow debugging, screenshots, DOM snapshots, console or network diagnosis, Playwright test debugging, and browser-driven verification in this repository.

Debug MyGO with Playwright CLI

Use the Playwright CLI bundled with the locked @playwright/test dependency. Keep every browser action behind the repository npm script so a future CLI entry-point change is isolated to web/package.json.

Use the repository command contract

Run browser commands from web/:

mise exec -- npm run playwright:cli -- <command> [arguments]

The npm script changes to the repository root before starting Playwright. This makes the CLI discover .playwright/cli.config.json and keeps generated output under .artifacts/playwright-cli/.

Never invoke playwright-cli, npx playwright-cli, npx playwright, a global Playwright installation, or @latest. Do not install @playwright/cli; the locked stable @playwright/test package supplies the CLI.

Prepare the local environment

Install locked JavaScript dependencies and the matching Chromium revision:

cd web
mise exec -- npm ci
mise exec -- npm run playwright:install:deps
mise exec -- npm run playwright:install

Treat the Debian system-library command as an environment setup step. Do not rerun it during ordinary debugging when the dependencies are already present.

For authenticated file workflows, start both services in separate long-running terminals:

# Repository root: backend API on 127.0.0.1:10086.
mise exec -- go run . serve

# web/: Vite on 127.0.0.1:5173, proxying /api to the backend.
mise exec -- npm run dev -- --host 127.0.0.1

Use existing local test credentials or credentials supplied for the task. Never write credentials into the Skill, source files, screenshots, or reports. Keep upload fixtures below 20 MB for the current milestone.

Follow the debugging loop

  1. Reproduce the problem with the narrowest existing test first. Confirm the test expresses the intended behavior before changing implementation code.
  2. Confirm the required server is reachable. The login page itself only needs Vite; login, list, upload, and download also need the Go backend and suitable local data.
  3. Open the page and read its accessibility snapshot:
mise exec -- npm run playwright:cli -- open http://127.0.0.1:5173/login
mise exec -- npm run playwright:cli -- snapshot
  1. Use refs from the latest snapshot for interactions. Take another snapshot after navigation, modal changes, or substantial rerenders because refs can become stale.
  2. Inspect browser and API evidence before guessing:
mise exec -- npm run playwright:cli -- console
mise exec -- npm run playwright:cli -- requests
mise exec -- npm run playwright:cli -- request <number>
  1. Prefer snapshots for structure and screenshots for visual evidence:
mise exec -- npm run playwright:cli -- screenshot --filename=.artifacts/playwright-cli/mygo-debug.png
  1. Close every session when finished, including error paths:
mise exec -- npm run playwright:cli -- close
mise exec -- npm run playwright:cli -- close-all

Use a named session with -s=<name> when parallel or persistent investigations would otherwise collide. Keep sessions isolated unless the task explicitly requires saved state.

Debug Playwright tests

Run the repository suite from web/:

mise exec -- npm run test:e2e

For interactive debugging, start the test with --debug=cli, wait for its tw-* session name, then attach through the same npm wrapper. Read playwright-tests.md before using this workflow.

Load detailed references only when needed

Preserve repository boundaries

Write screenshots, traces, videos, downloaded responses, and temporary upload fixtures only under ignored .artifacts/ paths. Do not change application data, create accounts, or call destructive UI actions unless the task authorizes those effects. Report browser launch or sandbox failures instead of silently disabling the configured Chromium sandbox.