Agent skill

Playwright Login Flows

by andrewyng in andrewyng/context-hub

Collects reusable Playwright patterns for logging in during end-to-end tests: password forms, OAuth redirects, saved browser state and TOTP two-factor codes.

MITAuto-check passedTesting & QA

Install Playwright Login Flows

skills CLI
$ npx skills add andrewyng/context-hub --skill login-flows -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install andrewyng/context-hub login-flows --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/andrewyng/context-hub.git skills-src && mkdir -p .claude/skills && cp -r skills-src/content/playwright-community/skills/login-flows .claude/skills/login-flows && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
login-flows
GitHub stars
14k
Token cost
~715 tokens
SKILL.md length
99 words
Files
1
Skills in repo
8
Repo updated
First seen
Licence
MIT

At a glance

Collects reusable Playwright patterns for logging in during end-to-end tests: password forms, OAuth redirects, saved browser state and TOTP two-factor codes.

  • Writing end-to-end tests for pages behind a login
  • SKILL.md covers Basic Username/Password Login, OAuth / SSO Login, Persisting Auth State… and MFA / 2FA Handling, plus 1 more section
  • Needs TEST_PASSWORD
  • Speeding up a Playwright suite that logs in before every test

What it does

The skill gives ready-made TypeScript snippets for the login step of browser tests. It covers a plain username and password helper, an OAuth or SSO flow that clicks through to an outside provider such as Google, and a TOTP two-factor helper built on the otplib package.

To avoid logging in before every test, it shows how to save the browser's storageState in a global setup file that runs once and how to point playwright.config.ts at that file. A few tips close it out: keep credentials in environment variables, use a dedicated test user in CI, and wait for the post-login URL with waitForURL instead of fixed timeouts.

When your agent uses it

  • Writing end-to-end tests for pages behind a login
  • Speeding up a Playwright suite that logs in before every test
  • Testing OAuth or SSO sign-in against a test environment
  • Handling TOTP two-factor prompts in automated tests

Example prompts

  • “Set up a Playwright global setup that logs in once and saves storageState for all tests.”
  • “Write a login helper for our staging site that reads the username and password from environment variables.”
  • “Add a TOTP step to the existing login test using otplib.”

Requirements

  • Playwright Test with TypeScript
  • otplib, for TOTP-based two-factor logins
  • A test user or test environment to sign in to

What it can do on your machine

Read from SKILL.md and the folder at commit 67dcbeb. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md (its code samples are typescript).

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names these keys or tokens, usually read from environment variables:

    • TEST_PASSWORD

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Playwright Login Flows loads about 715 tokens when it runs. Until then it costs about 19 tokens; SKILL.md has 99 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~19
When it runs · the whole SKILL.md, loaded when a task matches
~715

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from andrewyng/context-hub at commit 67dcbeb, republished under its MIT licence (© andrewyng). 99 words, ~715 tokens.

Download SKILL.mdSave it as .claude/skills/login-flows/SKILL.md (or your agent's skills folder).
name
login-flows
description
Common login automation patterns for web apps using Playwright
metadata.updated-on
2026-02-01
metadata.source
community
metadata.tags
browser,automation,playwright,login,testing

Login Flow Patterns for Playwright

Reusable patterns for automating login flows in end-to-end tests.

Basic Username/Password Login

typescript
import { Page } from '@playwright/test';

async function login(page: Page, username: string, password: string) {
  await page.goto('/login');
  await page.fill('[name="username"]', username);
  await page.fill('[name="password"]', password);
  await page.click('button[type="submit"]');
  await page.waitForURL('/dashboard');
}

OAuth / SSO Login

For OAuth flows that redirect to an external provider:

typescript
async function loginWithOAuth(page: Page) {
  await page.goto('/login');
  await page.click('text=Sign in with Google');

  // Handle the OAuth popup or redirect
  await page.fill('input[type="email"]', process.env.TEST_EMAIL!);
  await page.click('text=Next');
  await page.fill('input[type="password"]', process.env.TEST_PASSWORD!);
  await page.click('text=Next');

  // Wait for redirect back to app
  await page.waitForURL('**/dashboard');
}

Persisting Auth State (storageState)

Avoid logging in before every test by saving and reusing browser state:

typescript
// global-setup.ts — runs once before all tests
import { chromium } from '@playwright/test';

async function globalSetup() {
  const browser = await chromium.launch();
  const page = await browser.newPage();

  await page.goto('/login');
  await page.fill('[name="username"]', 'testuser');
  await page.fill('[name="password"]', 'testpass');
  await page.click('button[type="submit"]');
  await page.waitForURL('/dashboard');

  // Save signed-in state
  await page.context().storageState({ path: './auth.json' });
  await browser.close();
}

export default globalSetup;

Then in playwright.config.ts:

typescript
export default defineConfig({
  globalSetup: './global-setup.ts',
  use: {
    storageState: './auth.json',
  },
});

MFA / 2FA Handling

For test environments with TOTP-based 2FA:

typescript
import { authenticator } from 'otplib';

async function loginWithMFA(page: Page, secret: string) {
  await login(page, 'user', 'pass');

  // Generate TOTP code
  const code = authenticator.generate(secret);
  await page.fill('[name="totp"]', code);
  await page.click('button[type="submit"]');
  await page.waitForURL('/dashboard');
}

Tips

  • Always use storageState to avoid repeated logins — it's the single biggest speedup for E2E suites
  • Use environment variables for credentials, never hardcode them
  • For CI, consider a dedicated test user with stable credentials
  • Use page.waitForURL() instead of arbitrary waitForTimeout() after login

© andrewyng, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in content/playwright-community/skills/login-flows of andrewyng/context-hub.

Open the folder on GitHubat commit 67dcbeb

Compare with similar skills

Playwright Login Flows next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Playwright Login Flows compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Playwright Login Flows this skillandrewyng/context-hub14k—~715Automated safety check: PassMIT
Playwright E2E Testingfugazi/test-automation-skills-agents247—~3.2kAutomated safety check: PassMIT
Playwrightsecondsky/claude-skills227—~3.7kAutomated safety check: NotesMIT
RStudio Selenium to Playwright Migrationrstudio/rstudio5.1k—~3.6kAutomated safety check: PassCustom licence
Playwright Coretestdino-hq/playwright-skill3901 repos~1.4kAutomated safety check: PassMIT
Svelte Testingspences10/sveltest113—~579Automated safety check: PassMIT

Similar skills

  • Playwright E2E Testing

    fugazi/test-automation-skills-agents

    Author and maintain versioned Playwright (@playwright/test) TypeScript UI specs for browser user flows.

    247 GitHub stars~3.2k tokensUpdated 6 days ago
    Testing & QAAuto-check passed
  • Playwright

    secondsky/claude-skills

    Browser automation and E2E testing with Playwright. An agent skill from secondsky/claude-skills.

    227 GitHub stars~3.7k tokensUpdated 11 days ago
    Testing & QAAuto-check: notes
  • Converts RStudio Python Selenium electron tests into TypeScript Playwright tests, checking each against a live RStudio before counting it as migrated.

    5.1k GitHub stars~3.6k tokensUpdated yesterday
    Testing & QAAuto-check passed
  • Playwright Core

    testdino-hq/playwright-skill

    Battle-tested Playwright patterns for writing and debugging reliable E2E, API, component, visual, accessibility, and security tests.

    390 GitHub starsUsed in 1 repo~1.4k tokens
    Testing & QAAuto-check passed
  • Svelte Testing

    spences10/sveltest

    Fix and create Svelte 5 tests with vitest-browser-svelte and Playwright.

    113 GitHub stars~579 tokensUpdated yesterday
    Testing & QAAuto-check passed
  • Open Browser

    JasonHonKL/Openbrowser

    A skill your agent uses whenever the task involves browsing web pages, extracting page content, clicking forms, or completing web workflows.

    114 GitHub stars~1.6k tokensUpdated 5 mo ago
    Testing & QAAuto-check passed

More from andrewyng/context-hub

All 8 skills in this repo
  • Get API Docs with chub

    andrewyng/context-hub

    Fetches current documentation for third-party APIs and SDKs with the chub CLI before the agent writes code against them, instead of relying on remembered API shapes.

    14k GitHub starsUsed in 1 repo~775 tokens
    Auto-check passed
  • Tavily Search API Integration

    andrewyng/context-hub

    Guides building Tavily integrations for web search, URL extraction, site crawling and AI-assisted research in Python or JavaScript agent and RAG projects.

    14k GitHub stars~1.1k tokensUpdated 4 mo ago
    Auto-check passed
  • Flutter Bloc and Cubit

    andrewyng/context-hub

    Helps choose between Bloc and Cubit in Flutter and sets defaults for packages, lifecycle, widget binding and tests.

    14k GitHub stars~998 tokensUpdated 4 mo ago
    Auto-check passed
  • Sequences parts-mcp tool calls for finding, pricing and checking availability of electronic components, including BOM processing and datasheet navigation.

    14k GitHub stars~1.8k tokensUpdated 4 mo ago
    Auto-check passed
  • Olakai Monitoring Integration

    andrewyng/context-hub

    Adds Olakai monitoring to an existing LLM application with minimal code changes, then configures custom KPIs so the dashboard tracks business outcomes instead of just token counts.

    14k GitHub stars~4.5k tokensUpdated 4 mo ago
    Auto-check passed
  • Olakai Agent Project Setup

    andrewyng/context-hub

    Builds a new AI agent with Olakai monitoring from the start: CLI login, SDK integration, per-agent KPI configuration and an end-to-end check that data flows.

    14k GitHub stars~5k tokensUpdated 4 mo ago
    Auto-check passed

Categories

Questions about Playwright Login Flows

What does Playwright Login Flows do?

Collects reusable Playwright patterns for logging in during end-to-end tests: password forms, OAuth redirects, saved browser state and TOTP two-factor codes. The skill gives ready-made TypeScript snippets for the login step of browser tests. It covers a plain username and password helper, an OAuth or SSO flow that clicks through to an outside provider such as Google, and a TOTP two-factor helper built on the otplib package.

When should I use Playwright Login Flows?

Playwright Login Flows fits situations like: writing end-to-end tests for pages behind a login; speeding up a Playwright suite that logs in before every test; testing OAuth or SSO sign-in against a test environment; handling TOTP two-factor prompts in automated tests.

How do I install Playwright Login Flows in Claude Code?

Run `npx skills add andrewyng/context-hub --skill login-flows -a claude-code`. Or copy the skill folder (content/playwright-community/skills/login-flows in andrewyng/context-hub) into .claude/skills/login-flows in your project. Claude Code loads it when a task matches its description.

How do I install Playwright Login Flows in Codex?

Run `npx skills add andrewyng/context-hub --skill login-flows -a codex`. Or copy the skill folder (content/playwright-community/skills/login-flows in andrewyng/context-hub) into .agents/skills/login-flows in your project. Codex loads it when a task matches its description.

Can I use Playwright Login Flows in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add andrewyng/context-hub --skill login-flows -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/login-flows, .gemini/skills/login-flows, .github/skills/login-flows and .opencode/skills/login-flows in your project.

What does Playwright Login Flows need to run?

Going by SKILL.md and its folder, Playwright Login Flows needs credentials named TEST_PASSWORD. Our summary lists: Playwright Test with TypeScript; otplib, for TOTP-based two-factor logins; A test user or test environment to sign in to.

Does Playwright Login Flows access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Playwright Login Flows safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Playwright Login Flows use?

Playwright Login Flows is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Playwright Login Flows use?

About 715 tokens (SKILL.md is roughly 2.9k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Playwright Login Flows?

Skills that share tags, products or a category with Playwright Login Flows: Playwright E2E Testing (fugazi/test-automation-skills-agents, 247 stars), Playwright (secondsky/claude-skills, 227 stars), RStudio Selenium to Playwright Migration (rstudio/rstudio, 5.1k stars) and Playwright Core (testdino-hq/playwright-skill, 390 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Playwright Login Flows?

andrewyng (a GitHub user) maintains it in andrewyng/context-hub, which has 13,975 GitHub stars. The repository holds 8 skills in this directory. The repository was last updated on May 31, 2026.

Source: andrewyng/context-hub on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.