pw-init — Claude Code skill: what it does, how to install
Initializes Playwright e2e testing in web projects. It inspects your framework, generates a tailored config, creates e2e folder structures, and wires CI workflows.
/plugin marketplace add alirezarezvani/claude-skills
/plugin install pw@claude-code-skillsWhat pw-init does
The skill inspects your project using the Explore subagent. It scans package.json for Next.js, React with Vite, Vue, Nuxt, or Angular, checks whether TypeScript is configured, and verifies existing test setups. Then it installs @playwright/test alongside browser binaries and builds playwright.config.ts using the appropriate port for your local dev server.
Next, it creates the e2e/ folder with fixture directories, page object placeholders, and an initial test file. It registers npm scripts inside package.json for default, UI, and debug execution. When .github/workflows/ or .gitlab-ci.yml is present, the skill adds a testing workflow with report artifact preservation.
Before finishing, it executes npx playwright test to diagnose any startup failures right away. This is worth installing when bootstrapping end-to-end tests in a clean repository without manual configuration work.
What it helps with
- install and configure Playwright based on the detected web framework
- generate playwright.config.ts with matching local dev server settings
- scaffold the e2e directory structure with a sample test and fixtures
- set up GitHub Actions or GitLab CI workflows for browser tests
Example prompts for the agent
- set up playwright
- add e2e tests
- configure playwright
How to install pw-init
1Plugin marketplace
/plugin marketplace add alirezarezvani/claude-skills/plugin install pw@claude-code-skillsThis installs the whole pw plugin with all its skills
2Skills CLI (Vercel)
npx skills add alirezarezvani/claude-skills --skill pw-init -a claude-code3Manually: put the files in place
~/.claude/skills/pw-init/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/pw-init/
Manually: put the files in place
.agents/skills/pw-init/SKILL.mdFor all projects use ~/.agents/skills/
Manually: put the files in place
.cursor/skills/pw-init/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install alirezarezvani/claude-skills pw-init2Manually: put the files in place
.github/skills/pw-init/SKILL.mdPlatform CLI
gemini skills install https://github.com/alirezarezvani/claude-skills --path engineering-team/playwright-pro/skills/pw-initManually: put the files in place
.devin/skills/pw-init/SKILL.mdThe legacy .windsurf/skills/ path still works
Claude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
From the same set349
The whole set →Similar
Questions about pw-init
How to install pw-init in Claude Code?
Run npx skills add alirezarezvani/claude-skills --skill pw-init -a claude-code or install it via /plugin marketplace add alirezarezvani/claude-skills.
What does pw-init do?
It installs Playwright, writes framework-specific test configurations, scaffolds the e2e/ folder with starter tests, and verifies the run using npx playwright test.
How does pw-init configure the webServer block?
It inspects package.json: Vite uses port 5173, Next.js or Nuxt use port 3000, and Angular defaults to port 4200. If no framework is detected, the block is omitted.
Source text
SKILL.md · MIT
---
name: "pw-init"
description: >-
Set up Playwright in a project. Use when user says "set up playwright",
"add e2e tests", "configure playwright", "testing setup", "init playwright",
or "add test infrastructure".
---
# Initialize Playwright Project
Set up a production-ready Playwright testing environment. Detect the framework, generate config, folder structure, example test, and CI workflow.
## Steps
### 1. Analyze the Project
Use the `Explore` subagent to scan the project:
- Check `package.json` for framework (React, Next.js, Vue, Angular, Svelte)
- Check for `tsconfig.json` → use TypeScript; otherwise JavaScript
- Check if Playwright is already installed (`@playwright/test` in dependencies)
- Check for existing test directories (`tests/`, `e2e/`, `__tests__/`)
- Check for existing CI config (`.github/workflows/`, `.gitlab-ci.yml`)
### 2. Install Playwright
If not already installed:
```bash
npm init playwright@latest -- --quiet
```
Or if the user prefers manual setup:
```bash
npm install -D @playwright/test
npx playwright install --with-deps chromium
```
### 3. Generate `playwright.config.ts`
Adapt to the detected framework:
**Next.js:**
```typescript
import { defineConfig, devices } from '@playwright/test';
export default defineConfig({
testDir: './e2e',
fullyParallel: true,
forbidOnly: !!process.env.CI,
retries: process.env.CI ? 2 : 0,
workers: process.env.CI ? 1 : undefined,
reporter: [
['html', { open: 'never' }],
['list'],
],
use: {
baseURL: 'http://localhost:3000',
trace: 'on-first-retry',
screenshot: 'only-on-failure',
},
projects: [
{ name: "chromium", use: { ...devices['Desktop Chrome'] } },
{ name: "firefox", use: { ...devices['Desktop Firefox'] } },
{ name: "webkit", use: { ...devices['Desktop Safari'] } },
],
webServer: {
command: 'npm run dev',
url: 'http://localhost:3000',
reuseExistingServer: !process.env.CI,
},
});
```
**React (Vite):**
- Change `baseURL` to `http://localhost:5173`
- Change `webServer.command` to `npm run dev`
**Vue/Nuxt:**
- Change `baseURL` to `http://localhost:3000`
- Change `webServer.command` to `npm run dev`
**Angular:**
- Change `baseURL` to `http://localhost:4200`
- Change `webServer.command` to `npm run start`
**No framework detected:**
- Omit `webServer` block
- Set `baseURL` from user input or leave as placeholder
### 4. Create Folder Structure
```
e2e/
├── fixtures/
│ └── index.ts # Custom fixtures
├── pages/
│ └── .gitkeep # Page object models
├── test-data/
│ └── .gitkeep # Test data files
└── example.spec.ts # First example test
```
### 5. Generate Example Test
```typescript
import { test, expect } from '@playwright/test';
test.describe('Homepage', () => {
test('should load successfully', async ({ page }) => {
await page.goto('/');
await expect(page).toHaveTitle(/.+/);
});
test('should have visible navigation', async ({ page }) => {
await page.goto('/');
await expect(page.getByRole('navigation')).toBeVisible();
});
});
```
### 6. Generate CI Workflow
If `.github/workflows/` exists, create `playwright.yml`:
```yaml
name: "playwright-tests"
on:
push:
branches: [main, dev]
pull_request:
branches: [main, dev]
jobs:
test:
timeout-minutes: 60
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: lts/*
- name: "install-dependencies"
run: npm ci
- name: "install-playwright-browsers"
run: npx playwright install --with-deps
- name: "run-playwright-tests"
run: npx playwright test
- uses: actions/upload-artifact@v4
if: ${{ !cancelled() }}
with:
name: "playwright-report"
path: playwright-report/
retention-days: 30
```
If `.gitlab-ci.yml` exists, add a Playwright stage instead.
### 7. Update `.gitignore`
Append if not already present:
```
/test-results/
/playwright-report/
/blob-report/
/playwright/.cache/
```
### 8. Add npm Scripts
Add to `package.json` scripts:
```json
{
"test:e2e": "playwright test",
"test:e2e:ui": "playwright test --ui",
"test:e2e:debug": "playwright test --debug"
}
```
### 9. Verify Setup
Run the example test:
```bash
npx playwright test
```
Report the result. If it fails, diagnose and fix before completing.
## Output
Confirm what was created:
- Config file path and key settings
- Test directory and example test
- CI workflow (if applicable)
- npm scripts added
- How to run: `npx playwright test` or `npm run test:e2e`
© Alireza Rezvani · MIT · alirezarezvani/claude-skills