playwright-stability

A guide for making Playwright browser tests reliable and closer to real user behaviour. Playwright is a tool for testing websites in a browser, and storageState lets tests reuse a saved signed-in session.

In plain words
What is it for?
Use it to improve locators and assertions, replace sleeps with state checks, reuse authentication, isolate tests, and inspect traces or screenshots when tests fail.
Why use it?
It addresses flaky tests, fixed waits, repeated logins, shared test data, stale development servers, and misleading retries.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/lftpadilla/agent-dev-kit/playwright-stability
Any agent
npx skills add LFTPadilla/agent-dev-kit --skill playwright-stability
Clone the repo
git clone --depth 1 https://github.com/LFTPadilla/agent-dev-kit

Made for: Claude Code, Codex.

Per session 70 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 684 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00070 $0.00684
Opus 5 $0.00035 $0.00342
Sonnet 5 $0.00014 $0.00137
Haiku 4.5 $0.00007 $0.00068

Measured 2d ago against content hash 5f57f0e712b6, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

playwright-stability scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

plugins/dev-skills/skills/playwright-stability/SKILL.md · 51 lines

How it starts

The opening of the file, as written. The whole thing — 51 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Playwright stability & real-user auth

Two jobs: (1) stop flakes, (2) authenticate like a real user without paying the login cost per test. Both raise realism and reliability at once.

Anti-flaky checklist

  1. Locators by role first. getByRole(name)getByLabelgetByTextgetByTestId. CSS/XPath last. Role locators double as an accessibility check.
  2. Web-first assertions only. await expect(locator).toBeVisible() auto-waits. Never waitForTimeout, never assert on a snapshot you grabbed manually.
  3. No manual sleeps. Replace every fixed wait with an assertion on the state you actually need (toHaveURL, toBeEnabled, toHaveText).
  4. Trace on first retry + screenshot on failure. Open the Trace Viewer before editing flaky code — DOM/network/console at each step finds the cause in minutes.
  5. retries: 2 in CI, 0 locally (a local flake is a bug to fix, not retry).
  6. Isolate. Each test sets up its own data; no shared mutable state, no order dependency.
  7. One clean server. Kill stray dev servers and confirm the port is free before a full run — a stale server serves old assets and fakes failures.

Real-user auth via storageState (stop mocking the session)

Mocking auth is the least realistic part of a suite. Instead log in once, save the browser state, and every test starts already authenticated — real tokens, real session, near-zero per-test cost.

See templates/playwright/auth.setup.ts and the config snippet beside it.

  • Run the provider's real login (WorkOS / Cognito / Auth0 / your own form) in a setup project, then context.storageState({ path }).
  • Other projects depend on that setup and load storageState.
  • Keep the state file out of git (it holds live tokens) and regenerate it at the start of each CI run — never commit and reuse across days.
  • MFA / bot-protected SSO: do the login interactively once, persist the state, refresh when it expires. Credentials come from env vars, never hardcoded.

Read the full file on GitHub · 51 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 51 lines · 70 tokens per session scan A 5f57f0e712b6

Subscribe to this mod's changes

playwright-stability is a skill published in the GitHub repository LFTPadilla/agent-dev-kit (2 stars, last pushed 5d ago), licensed MIT. It adds 70 tokens to every session and 684 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.