Pw Init skill for Claude

Use when setting up Playwright in a project ('set up playwright', 'add e2e tests', 'configure playwright', 'init playwright').

Pw Init SKILL.md

The full skill file from alirezarezvani/claude-skills (MIT).

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:

npm init playwright@latest -- --quiet

Or if the user prefers manual setup:

npm install -D @playwright/test
npx playwright install --with-deps chromium

3. Generate playwright.config.ts

Adapt to the detected framework:

Next.js:

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

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:

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:

{
  "test:e2e": "playwright test",
  "test:e2e:ui": "playwright test --ui",
  "test:e2e:debug": "playwright test --debug"
}

9. Verify Setup

Run the example test:

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

How to install Pw Init

Claude Code

Copy the skill into your personal skills folder (or into .claude/skills/ inside a project):

npx degit alirezarezvani/claude-skills/engineering-team/playwright-pro/skills/pw-init#main ~/.claude/skills/pw-init

Codex

npx degit alirezarezvani/claude-skills/engineering-team/playwright-pro/skills/pw-init#main ~/.codex/skills/pw-init

Claude.ai and Claude Desktop

Download the skill folder from GitHub, zip it, and upload it under Settings → Capabilities → Skills.

Frequently asked questions

+What does the Pw Init skill do?

Use when setting up Playwright in a project ('set up playwright', 'add e2e tests', 'configure playwright', 'init playwright').

+How do I install Pw Init in Claude Code?

Copy the skill folder into ~/.claude/skills/pw-init, for example with "npx degit alirezarezvani/claude-skills/engineering-team/playwright-pro/skills/pw-init#main ~/.claude/skills/pw-init". Claude Code loads it automatically and uses it when a task matches.

+Does Pw Init work with ChatGPT or Codex?

Yes. Pw Init uses the open SKILL.md format. In Codex, put the folder in ~/.codex/skills/pw-init. In Claude.ai, zip the folder and upload it under Settings → Capabilities → Skills.

+Is Pw Init free?

Pw Init is published on GitHub by alirezarezvani under the MIT license, which allows free use.

Related testing & code review skills

  1. Agent Browser

    Official

    Browser automation CLI for AI agents. Use when the user needs to interact with websites, including navigating pages, filling forms,…

    vercel-labs/agent-browser★ 53k
  2. Playwright

    Official

    Use when the task requires automating a real browser from the terminal (navigation, form filling, snapshots, screenshots, data extraction,…

    openai/skills★ 29k
  3. Playwright Skill

    Complete browser automation with Playwright. Auto-detects dev servers, writes reusable test scripts, and supports screenshots, responsive…

    lackeyjb/playwright-skill★ 3.3k
  4. Pw Review

    Use when reviewing Playwright tests for quality ('review tests', 'audit tests', 'playwright best practices check').

    alirezarezvani/claude-skills★ 30k
  5. Quality Manager Qmr

    Use for QMR duties under ISO 13485 5.5.2: management review, quality policy and objectives, quality KPIs and cost of quality.

    alirezarezvani/claude-skills★ 30k
  6. Red Green Proof

    Turns a suspected bug into a proven one. Verify the cause against reality before claiming it, write a test that FAILS on the current code,…

    alirezarezvani/claude-skills★ 30k
  7. Sample Text Processor

    Reference BASIC-tier skill used as a fixture by skill-tester. Counts words and characters and applies basic text transformations.

    alirezarezvani/claude-skills★ 30k
  8. Self Eval

    Grade finished work honestly on two axes with a devil's-advocate pass against inflation.

    alirezarezvani/claude-skills★ 30k
  9. Senior Data Scientist

    Design experiments and analyze tabular data: A/B tests, causal inference, feature engineering, model evaluation.

    alirezarezvani/claude-skills★ 30k

See all testing & code review skills →

More skills from alirezarezvani

  1. Qms Audit Expert

    Use for ISO 13485 internal audits: planning the program, running an audit, classifying findings or preparing for an external audit.

    alirezarezvani/claude-skills★ 30k
  2. Quality Documentation Manager

    Use for QMS document control: numbering, versioning, change control or 21 CFR Part 11 e-signatures.

    alirezarezvani/claude-skills★ 30k

All skills by alirezarezvani →

Give your whole team an AI agent with skills

Cody runs managed AI agents your team can message in Slack, Teams, WhatsApp and the web, with 50+ business integrations, scheduled tasks and memory. No terminal required.