mirror of
https://github.com/wesammustafa/opencode-primer.git
synced 2026-11-18 18:04:22 +00:00
Each walkthrough follows the same template: when to reach for it, setup (verbatim opencode.json snippet), example prompts, capabilities and limitations, gotchas, resources. - playwright.md: browser automation — visual iteration loop, e2e scaffolding, bug repro from a URL - context7.md: live, version-pinned library docs piped into the prompt, with the "resolve first, query second" pattern - sentry.md: errors / traces / releases via OAuth (DCR), with the error-to-root-cause pattern - grep.md: code search across public GitHub via the Vercel-hosted MCP README.md ranks "when to add a server" against the cost of the extra tokens it puts in the model's context every turn, with a tools-map example for disabling chatty MCP tools per agent. All endpoint URLs and package names link-checked at commit time.
2.8 KiB
2.8 KiB
Playwright MCP
Drive a real browser from OpenCode — open pages, click elements, fill forms, take screenshots, capture network requests, inspect accessibility trees.
When to reach for it
- Visual iteration: implement a UI, take a screenshot, refine
- E2E test scaffolding
- Reading documentation from sites that aren't well-indexed
- Reproducing a bug a user reported with a URL
Setup
Add to opencode.json:
{
"$schema": "https://opencode.ai/config.json",
"mcp": {
"playwright": {
"type": "local",
"command": ["npx", "-y", "@playwright/mcp@latest"],
"enabled": true,
"environment": {
"BROWSER_TYPE": "chromium"
}
}
}
}
Restart OpenCode. Verify:
opencode mcp list
You should see playwright in the list.
Example prompts
use playwright to open https://example.com and screenshot the navbar
use playwright to visit our staging site at https://staging.example.com,
log in with the credentials in @.dev/staging-creds.json, and
verify the dashboard renders without console errors
the user reports a bug at https://app.example.com/billing — use playwright to
reproduce: log in, navigate to billing, click "upgrade plan", and report what
happens
Visual-iteration loop
[plan] > here's a mock: [drag mock.png in]
> sketch the HTML/CSS structure that matches
[build] > <Tab>
[build] > implement it under src/components/Dashboard/
[build] > use playwright to render the new component at http://localhost:5173/dashboard
> and screenshot it; compare to the mock
[build] > refine until the screenshot matches
Two-three iteration rounds usually closes the gap.
What it can do
- Open URLs, navigate, fill forms, click, hover, drag
- Take screenshots (full page, viewport, or element-scoped)
- Read DOM (CSS selectors, XPath, ARIA roles)
- Capture network requests/responses
- Inspect console messages
- Run JavaScript in the page context
- Read the accessibility tree
What it won't do
- Persist browser state across sessions by default (use
--user-data-dirif you need this) - Bypass strong bot detection (Cloudflare, etc.)
- Replace a real E2E test suite (use the screenshots and traces to write the tests)
Gotchas
- First run is slow — Playwright downloads a browser the first time you invoke it.
- Headless by default — you don't see the browser. Pass
BROWSER_HEADED=1inenvironmentto watch it run (useful for debugging). - Cross-origin / authenticated flows — use Playwright's auth-state file pattern; see the upstream docs.