/training:api-playwright-testingfrom training
Guides creation of Playwright API tests from exploration through implementation, covering API discovery, test plan creation, helper/data factory development, and test writing with human checkpoints.
Ships in training. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Before starting, read the project config file
.claude/testing/api-config.mdfor project-specific patterns, auth strategy, data factory rules, and assertion conventions. If it does not exist, create it in Step 0 from theREFERENCE.mdtemplate in this skill's folder.
Do these before starting any test work:
package.json lists @playwright/test.playwright.config.ts, or the path in the config file if Step 0 is
done).If either is missing, stop and ask the user to set up Playwright. Do not install packages yourself.
Never put passwords, tokens, API keys, or session cookies into the conversation.
Do not ask the user for credentials. If the user pastes one, do not use or repeat it, and tell them to rotate it.
Code reads credentials from environment variables. Refer to them by name only.
Authenticate requests only through Playwright config or helpers that
read those variables (for example, extraHTTPHeaders in
playwright.config.ts). Do not call sign-in or token endpoints
yourself.
Never read, print, or log env files, saved auth state, tokens, auth
headers, helper output, or auth responses. Do not run commands that
print env values (printenv, echo $VAR), and do not open traces,
reports, or test-results/ files.
Before you open any project file (config, spec, helper, fixture, or
setup file), check it for hardcoded secrets with this match-only
search. Files that only read process.env do not match.
grep -lEi -e "(password|passwd|secret|token|api[_-]?key|cookie|credential)[a-z_]*[\"']?[[:space:]]*[:=][[:space:]]*[\"'\`][^\"'\`\$]" -e "(bearer|basic)[[:space:]]+[A-Za-z0-9._~+/=-]{8,}" <file>
If the file matches, do not open it. Tell the user that it has a hardcoded secret and ask them to move it to an env var.
When you run tests, you may quote test names, pass or fail, and assertion error messages. Before you quote output, remove any value that looks like a secret. If output shows a credential or token, do not repeat it, and tell the user to rotate it.
Tests on auth responses assert only presence or type (for example,
expect(typeof body.token).toBe("string")), never the value, so a
failed assertion cannot print a token.
Look for .claude/testing/api-config.md in the project.
[UPPER_SNAKE_CASE], skip this step.REFERENCE.md from this skill's folder to that path. Then enter Q&A mode before doing anything else.Before Q&A: offer to explore existing tests first.
Ask the user a single yes/no question:
"I can explore the existing test directory and
playwright.config.tsfirst to pre-fill answers from what already exists, then only ask you about anything I can't determine. Want me to do that, or would you rather answer every question manually?"
playwright.config.ts, api/, tests/api/, playwright/, tests/). Read the config, a sampling of existing specs, auth helpers, data factories, fixtures, and package.json scripts. Do not open .env files or saved auth state. When a helper or fixture holds credentials, record only the env var names; never copy credential values. If an OpenAPI / Swagger spec or Postman collection is referenced in the repo, scan it to draft endpoint and auth answers. Build a draft answer for each placeholder below. Then run Q&A in review mode: present each pre-filled answer and ask the user to confirm, correct, or fill in TBD. Skip questions that are fully answered and confirmed.Q&A mode rules:
TBD for that placeholder and move on..claude/testing/api-config.md, replacing every matching [PLACEHOLDER] token. Suggest that the user commits the file with the tests.Questions to ask (each maps to placeholders in the config file):
[APP_NAME], [APP_DESCRIPTION][BASE_URL], [BASE_URL_ENV_VAR]playwright.config.ts and the test files glob? -> [PLAYWRIGHT_CONFIG_PATH], [TESTS_GLOB][API_STYLE], [API_SPEC_SOURCE][BACKEND_FRAMEWORK_AND_VERSION], [DATABASE], [DEFAULT_CONTENT_TYPE], [RESPONSE_ENVELOPE_OR_NONE][AUTH_MECHANISM_DESCRIPTION], [AUTH_TYPE][SIGN_IN_METHOD_AND_ENDPOINT], [SIGN_OUT_METHOD_AND_ENDPOINT][AUTH_HEADER_SHAPE], [TEST_CREDENTIALS_LOCATION][TOKEN_LIFETIME_AND_REFRESH], [INVALID_AUTH_STRATEGY], [AUTH_RATE_LIMITS_OR_NONE][AUTH_SETUP_STRATEGY][METHOD_AUTH], [ROUTE_AUTH], [METHOD_HEALTH], [ROUTE_HEALTH], [METHOD_RESOURCE], [ROUTE_RESOURCE], [PURPOSE][BACKEND_QUIRKS_THAT_AFFECT_TESTS], [VALIDATION_ERROR_SHAPE_AND_STATUS], [WHICH_ENDPOINTS_RETURN_EMPTY_BODIES], [STATUS_CODE_QUIRKS], [PAGINATION_STYLE], [ID_FORMAT][CMD_RUN_TESTS], [CMD_RUN_FILE], [CMD_RUN_GREP], [CMD_RUN_DEBUG], [CMD_OPEN_REPORT]api, tests/api, playwright) -> [API_TEST_ROOT]@faker-js/faker) -> [RANDOMIZATION_LIBRARY][ANYTHING_ELSE_FUTURE_TESTS_SHOULD_KNOW], [PROJECT_SPECIFIC_ANTI_PATTERNS], [PROJECT_SPECIFIC_GOTCHAS]After saving, continue with the workflow below.
Create Playwright API tests for an endpoint or resource, from exploration through passing tests. Follow this workflow step by step. Stop after each step and check in with the user before proceeding.
In the steps below, a placeholder such as [API_TEST_ROOT] or
[API_SPEC_SOURCE] means the value saved in .claude/testing/api-config.md.
API Test Progress:
- [ ] Step 0: Project Configuration Q&A (skip if the config file has no placeholders)
- [ ] Step 1: Explore the API
- [ ] Step 2: Create the test plan
- [ ] Step 3: Create/update helpers & data factories
- [ ] Step 4: Write the tests
Understand the API before writing any tests. Gather information through one or more of these methods:
[API_SPEC_SOURCE]
points to one, fetch and analyze it to extract endpoints,
request/response schemas, required fields, auth mechanisms, and
status codes.request context. Skip sign-in and
token endpoints. For endpoints that need auth, use the config or
helpers that read env vars. Print
only status codes and field names, never header or body values.
Document endpoints, methods, auth requirements, request shapes,
and response shapes by observing actual behavior.[API_TEST_ROOT] to understand what's already
covered and what patterns are established.For each endpoint discovered, document:
# API Exploration: [Resource]
[Overview of the resource and its purpose]
## Endpoints Discovered
- [METHOD] [path] - [description]
- Auth: [required | optional | none]
- Request body: [shape or "none"]
- Response: [status code] [shape]
## Authentication Mechanism
- [cookie | token | bearer | API key | none]
- [How credentials are obtained — env var names only, never values]
## Data Models
- [Model name]: [key fields, types, required vs optional]
## Dependencies Between Resources
- [e.g., "Booking requires a Room to exist first"]
-> STOP. Present the exploration findings. Confirm endpoints, auth mechanism, and data models with the user before proceeding.
Based on the exploration, plan which endpoints to test and what scenarios to cover. If the user provides specific test scenarios, use ONLY those. Do not invent additional scenarios.
Present the plan in chat using this structure:
# Test Plan for [Resource]
[Overview]
## Setup Required
- [Dependencies]: [What must exist before tests run]
- [Auth]: [How auth headers/cookies will be created]
## Data Factories Needed
- [Factory name]: [What it creates, with what randomization]
## Helper Modifications
- [Helper]: [New methods or changes needed]
## Test Files to Create
- [resource].[method].spec.ts
- **[Test Case]**: [Description]
- Arrange: [Setup steps]
- Act: [Request details]
- Assert: [Expected status, body, headers]
For each endpoint, consider these test categories:
Include exact data requirements. Use the project's randomization
library (see [RANDOMIZATION_LIBRARY] in the config file) for realistic
values. Do NOT write the plan to a file.
-> STOP. Present the plan. Confirm scope, test cases, and data requirements with the user before proceeding.
[API_TEST_ROOT]
to identify what can be reused or extended.overrides argument for pinning specific fieldsFollow the Data Factory Pattern in the config file for the exact factory template and rules.
Rules:
-> STOP. Present the helpers and data factories. Review signatures, data shapes, and auth flow with the user.
[API_TEST_ROOT]/tests/[resource]/[resource].[method].spec.tsTest file structure to follow:
import { test, expect } from "@playwright/test";
test.describe("resource/ GET requests", async () => {
let headers;
test.beforeAll(async () => {
headers = await createHeaders();
});
test("GET all resources", async ({ request }) => {
const response = await request.get("resource/", {
headers: headers,
});
expect(response.status()).toBe(200);
const body = await response.json();
expect(body.length).toBeGreaterThan(0);
});
test("GET resource without auth", async ({ request }) => {
const response = await request.get("resource/");
expect(response.status()).toBe(403);
});
});
Rules:
test.describe groups tests by endpoint and methodtest.beforeAll / test.beforeEach for shared setuptest.step() for multi-step integration testsrequest.newContext() when tests need isolated cookie state-> STOP. Share test results. Confirm tests pass and cover the intended scenarios.
[PLACEHOLDER] tokensbeforeEach resetWhat SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
Other plugins' skills for the same job
npx claudepluginhub devclarityai/devclarity-marketplace --plugin training9 skills in this plugin
/context-coverageAudit how agent context (CLAUDE.md, AGENTS.md, GitHub Copilot instructions, Cursor/Windsurf rules, rules directories, skills) lines up with the code across a set of repositories and generate a self-contained HTML report. The report leads with a short list of specific "things to check" (context behind the code, thin coverage for the codebase, oversized files, no per-area context), then per-repo raw metrics and a folder tree comparing folder LOC to context coverage, and can show what changed since an earlier run. Use when the user wants to audit context coverage across repos, "which repos are missing CLAUDE.md", "which repos have no Copilot instructions", "where is our agent context thin or stale", "context coverage across my org / projects folder", "track context coverage week over week", or "/context-coverage". Works on a local folder of clones, a whole GitHub org via the gh CLI, or a single monorepo scoped to just the areas one team owns./context-managementSorts the lines in your agent context (CLAUDE.md, .claude/rules/, docs/, skill files) with five questions and moves each one to where it belongs: lint or CI, a ticket, CLAUDE.md, a path-scoped rule, a doc, or nowhere. Use when auditing or trimming a CLAUDE.md, when context files have grown long and noisy, when deciding where a new convention should live, or when promoting recurring review feedback into standing context. Trigger terms: context cleanup, audit CLAUDE.md, prune context, where does this line go, what belongs in CLAUDE.md, context is too long, /context-management./designing-ai-workflowsInterviews the user through the design of a new AI-enabled workflow. Frames it, drafts a skeleton early, then refines context, freedom, alignment, verification, and feedback phase by phase, including where the context window resets (same thread, a script, an in-skill subagent, or a separate skill) and where to fan out parallel agents. Scaffolds the result as one or more skills plus a living design-summary HTML with a visual flow map. Use when the user wants to design or build a new workflow or skill for a task type (integrations, modernization, maintenance, testing, incident triage, etc.), asks when to use subagents versus separate skills, or asks to be interviewed about a workflow./e2e-testingGuides the creation of Playwright E2E tests from planning through implementation. Covers test plan creation, data seeding, Page Object Model development, and test writing with human checkpoints at each stage./finding-skill-opportunitiesUse when asked to find skill opportunities in a codebase, audit a repo for automatable workflows, decide what skills to write, or mine git history, existing automation, and recent Claude Code session transcripts for recurring multi-step procedures worth turning into agent skills./managing-locatorsExplores features to discover stable locators and fixes broken locators in Playwright tests. Two modes — explore (proactive discovery) and fix (reactive repair) — both using Playwright MCP for live browser interaction.