---
description: Generate a Playwright Page Object Model for a single live URL using playwright-cli
argument-hint: "<URL> [output-dir] [auth-env-file]"
---

Use the `playwright-pom` skill and `playwright-cli` commands to generate a Page Object Model for the single page at $1.

Scope and rules:
- Only generate a POM for the exact page at $1 — do not navigate to or explore any other pages.
- Use `playwright-cli open <url>` to launch the browser. If `playwright-cli` is not on PATH, use `npx -p @playwright/cli playwright-cli open <url>` instead.
- Use `playwright-cli snapshot` to capture the accessibility tree and element refs for the page. Do not use `goto` or `click` to navigate to additional pages.
- Generate one page object for this page (plus small reusable component objects only if the page clearly contains distinct, reusable UI components).
- Use resilient locators: `getByRole`, `getByLabel`, `getByTestId`, `getByPlaceholder`, `getByText` (in that order). Use CSS/XPath only as a last resort.
- Each page object should expose high-level business methods (e.g., `loginAs(user)`, `searchFor(term)`) built from the low-level locators.
- Keep selectors and URLs inside the page object; tests should read like user workflows.
- Save generated files under `${2:-tests/pom/}` with clear, kebab-case names (e.g., `login-page.ts`).
- Only target applications you own or have explicit authorization to test.
- Do not interact with destructive actions (delete, remove, sign out) unless explicitly requested.
- Report what was covered once the page object is complete.

## Authentication

If the site requires login, handle credentials securely:

1. **Preferred: provide an auth env file** as the third argument (`$3`).
   - The env file should contain variables such as:
     ```bash
     POM_AUTH_URL=https://example.com/login
     POM_USERNAME=user@example.com
     POM_PASSWORD=secret
     ```
   - Load the file in a single bash command, use the variables immediately to fill the login form via `playwright-cli fill`/`click`, and **do not echo, log, or persist the values anywhere**.
   - Do not include the env file in generated POMs, snapshots, or test code.
   - Mark the env file in `.gitignore` and delete it when the session is complete.
   - After logging in, you may use `playwright-cli state-save <file>` to persist the authenticated session if you need to revisit pages.

2. **Fallback: manual login**.
   - If no env file is provided, `playwright-cli open` the login page and ask the user to complete authentication manually in the browser session.
   - Then continue generating POMs from the authenticated state.

3. **Never** ask the user to paste credentials into the chat, and **never** hardcode credentials into generated files.

After generating, summarize:
- The page (and any components) covered
- The output file path(s)
- Any parts of the page that could not be inspected and why
- How authentication was handled (env file or manual)
