When working as a QA Automation Engineer, I face QA challenges every day. I solve most of them with the same tools: Playwright with TypeScript and AI agents. Many teams choose the same tools: Gartner predicts that by 2028, 90% of enterprise software engineers will use AI code assistants. You can get a lot from these assistants in test automation, and you also need rules for them. This article shares the rules we formed from real problems and a free skill you can adapt to your project.
What Is a QA Skill for Playwright?
A QA skill for Playwright is a Markdown file, SKILL.md, with the testing rules of your team for an AI agent. It explains how the agent needs to write Playwright tests in your project: how to create test data, how to wait for results, what to assert and where you can use mocks. The file starts with a short YAML header with the skill name and description. Below the header, you write the rules and code examples.
The agent reads the description first. When your request matches it, the agent loads the full instructions and follows them. You write the rules once, and the agent applies them to every new test.
Skills work in many AI coding agents, such as Claude Code, Cursor, Codex and GitHub Copilot. You can keep the skill in the folder of your project, so the whole team works with the same rules.

Why AI Agents Repeat the Same Mistakes in Playwright Tests
- Rules instead of fixes. You can save a lot of time here. The same mistake returns in the next test when you fix each case separately, so you need to turn repeated mistakes into rules and the rules into a skill.
- What the agent does. AI agents such as Claude Code and Cursor can simplify your work as a QA Automation Engineer a lot. In the same session the agent can:
- Read your repository
- Find the right component
- Learn the API
- Write a new test
- Run the test
- Step-by-step mode. AI can also work with a test step by step. For example, the agent in CodeceptJS with the MCP integration can run a test directly in the browser:
- It performs an action.
- It checks the result.
- It adds the step to the test only after the check succeeds.
Claude Code can do the same with the Chrome or Firefox extension, and you can read how Playwright MCP works with Claude Code on the blog. This is close to how you create a test by hand: you first click through the scenario and check the result of each step, then you save the working version in code.
- Explorbot on CI. Explorbot works in a similar way on CI: it explores your web app for hours and writes the flows that worked as Playwright or CodeceptJS specs.
- Learning takes time. You need a lot of time to learn correct work with AI tools. Gartner expects that 80% of the engineering workforce will need new skills because of generative AI through 2027, and QA engineers are part of this group.

- Our first mistakes. Our first AI-generated tests showed this. They had the same problems again and again:
- The same test data in every test
- waitForTimeout() instead of a real wait
- Very large E2E scenarios
- A URL check instead of the real result of the operation
All of this led to broken code.
The lesson. I learned a lot from my mistakes. Each wrong result from an approach started the same cycle: I fixed it and then repeated the whole process with the next approach until the tests became stable.
I understood later that this is a waste of time. The same problem returns in every new test when you fix it by hand. So you can explain a rule to AI once and put it into a skill for your AI agent.
Read also: Multi-Agent AI Testing with Claude Code and Playwright Test Agents
7 Rules for AI-Generated Playwright Tests in Your QA Skill

These rules are specific to our team. Every company has its processes and priorities. I am sure that at least part of our rules can be useful for your project too. Below you can see the automation antipatterns that helped us make the work with AI simpler and the tests better.
Rule 1: Every Test Has Its Data
Many tests run in parallel in your CI. They can use the same data: the first test creates Demo Project while the second test deletes the same project at the same moment. You get unstable failures. The cause is hard to find in CI logs. So you need to describe in the skill exactly how to create test data:
### Rules for Test Data Generation
- NEVER hardcode static IDs, emails, or user credentials in test cases.
- ALWAYS use dynamic data generators (e.g., `@faker-js/faker` or test data factories).
- Ensure test data cleanup or isolation via setup/teardown hooks (`beforeEach`, `afterEach`).
The test creates its project name instead of using a static Demo Project:
const user = await userFactory.create();
const projectName = `Project ${faker.string.nanoid(6)}`;
You can also prepare test data through API fixtures, and the advanced Playwright E2E framework tutorial shows how to build this layer.
Rule 2: Waiting Patterns for the Framework
AI sometimes fails to find the result at once and adds a five-second pause:
await page.waitForTimeout(5000);
Your system can be ready in a second. It can also need seven seconds. A fixed pause gives you slow test runs in the first case and flaky tests in the second, because network delays change from run to run. So you need to describe in the skill what to avoid and what to use instead:
### Anti-Patterns to Avoid: Flakiness
- DO NOT use explicit sleep delays (`page.waitForTimeout()`, `Thread.sleep()`).
- ALWAYS wait for specific UI state transitions or explicit network responses:
- Example: `await page.waitForResponse('/api/v1/users')`
- Example: `await expect(locator).toBeVisible()`
A good test waits for the exact result it needs:
const responsePromise = page.waitForResponse(r => r.url().includes('/api/v1/users') && r.ok());
await page.getByRole('button', { name: 'Save' }).click();
await responsePromise;
The test continues as soon as the needed state appears. It stays green when the operation takes a bit longer, and the Playwright assertions guide explains how expect retries until the element reaches the needed state.
Rule 3: The Iceberg Test
AI often creates long user journeys. A typical example:
- Register a user
- Create a project
- Import tests
- Configure an environment
- Run the tests
- Open the report
- Export the report to PDF
It looks like a good E2E test. It is hard to debug, because a failure at the registration step hides the results of all later steps, from import to export. You can ask the model to split scenarios into smaller tests. API preconditions then prepare the state for each of them.
### Test Architecture Requirements
- Keep individual E2E tests focused on a SINGLE critical assertions path (max 5-7 logical steps).
- Avoid long dependency chains in UI.
- Use API calls or storage state to set up prerequisites (e.g., seed data via API before opening UI).
- Separate Independent Feature Tests into isolated spec files.
Read also: Grouping Playwright Tests: Best Practices and Organization
Rule 4: Explicit and Multi-Layer Validation
The next problem is weak assertions. AI can check only the URL:
await expect(page).toHaveURL(/\/runs\//);
The test is green. The URL check alone tells you very little about the real run and its state, so you need to describe in the skill the requirement for explicit and multi-layer validation of business logic:
### Validation & Assertion Rules
- EVERY test must contain explicit, meaningful assertions verifying business outcomes.
- Avoid checking only URL changes or generic container visibility.
- Assert specific UI elements, state values, or expected API responses.
- Example: Instead of checking if modal exists, check specific success message text and action button states.
For example:
await page.getByRole('button', { name: 'Launch' }).click();
await expect(page.getByTestId('run-summary'))
.toContainText('4 tests');
await expect(page.getByTestId('run-status'))
.toHaveText('In progress');
await expect(page.getByRole('row'))
.toHaveCount(5);
The article on Playwright assertions and where AI fits in an E2E test covers this topic in detail.
Rule 5: Use of Mocks
AI started to use mocks to stabilize our E2E tests, and this became the next obstacle. Everything works at first sight: the API always returns the expected response and the test becomes stable. But the mock removes exactly this part of the system from the test when you check how the UI works with your backend. So you need to set limits for mock usage. For your core services, Playwright API testing gives you real checks instead of mocks.
### Mocking Strategy Guidelines
- DO NOT mock primary system components under test.
- Use mocks ONLY for:
1. Third-party integrations (Payment Gateways, External Auth providers).
2. Unstable/expensive external APIs.
3. Inducing rare edge-case error states (e.g., HTTP 500/503).
- Prefer Contract/API testing or real test environments for core backend services.
Read also: API Testing Strategy: Best Practices and Framework for CI/CD
Rule 6: Priorities for Automation Coverage
You give AI user stories with a request to cover the functionality. It starts to automate everything through the UI, from buttons to small changes in the interface. Every check becomes an E2E test.
So AI needs to know what exactly to check and at which level to check it before it writes code. The testing pyramid and a written test automation strategy give you these levels. You can describe it in the skill like this:
### Test Automation Strategy Prioritization
When analyzing user stories or acceptance criteria:
1. Recommend Unit/Integration coverage first for complex calculations or data transformations.
2. Limit UI Automation to:
- Smoke scenarios & Critical User Journeys (P0/P1).
- Stable core workflows (e.g., Auth, Checkout, Search).
3. FLAG items that SHOULD NOT be UI-automated (e.g., third-party captcha, visual layout tweaks, unstable canvas/third-party widgets).
Rule 7: Independence Strategy
AI can split scenarios into several tests and write them so that Test B works only after Test A has created an object in the database. This works on a single worker. Such tests always fail in a parallel run (workers > 1), and you can see how the Playwright config file controls workers and other run options. You need to record the requirement for full independence of every test in the skill.
### Test Independence Principles
- Each test MUST be fully isolated and runnable in any order or in parallel.
- NEVER rely on state or side-effects left by previous test cases.
- Use unique entities (e.g., isolated workspaces, unique user prefixes) for concurrent executions.
How to Adapt the QA Skill to Your Project
Our team started with the idea to create a skill for our automation needs. The result looked interesting. So I decided to share it with others, and you can find the ready version in the free open-source library QA skills.
You can use the skill in these ways:
- Use it as it is.
- Take it as a base for your skill.
I recommend the second option. A perfect skill on the first day is the wrong goal. Start with these steps:
- Take the latest tests that your AI agent wrote.
- Find repeated problems in them.
- Write a concrete rule for each problem.
AI then writes tests by the Playwright documentation and by the rules of your team. This is a different level of automation.
How to Write a QA Skill for Playwright Tests
You need a separate instruction layer. It lives in the structure of your project or AI agent, for example as .cursorrules, as a skill file for Claude Code or as a prompt for the agent.

The SKILL file explains when to use the skill and gives context about your project. It also holds the critical rules:
---
name: automate-manual-test-cases
description: This skill converts manual test cases into production-ready automated test scripts.
It analyzes the existing automation framework, interprets manual test steps, and generates maintainable tests following automation best practices.
Use this skill whenever the user wants to automate manual test cases, expand test coverage, or create end-to-end automated flows from existing test documentation.
license: MIT
metadata:
version: 1.0.0
---
Structure of a section in an AI skill or prompt:
# Role: Senior QA Automation Engineer
## Code Style & Best Practices
[Core patterns]
## CRITICAL: Anti-Patterns to Avoid (Strict Rules)
1. NO explicit sleeps or hardcoded timeouts.
2. NO hardcoded test data or static credentials.
3. NO chained test dependencies.
4. NO weak assertions (always validate final state explicitly).
## Code Generation Checklist
Before outputting code, verify that:
- [ ] No hardcoded delays were inserted.
- [ ] Test data is isolated/generated dynamically.
- [ ] Assertions verify actual business requirements.
A skill is a practical solution. Your AI agent knows what to do in your project, and you can add or remove rules for your team whenever the project changes.
How to Review AI-Generated Tests With a Second Skill
A skill helps AI write better tests. The logical next step is a second skill that checks the result of the first.
A separate skill can review the generated code and check:
- Hardcoded data
- Test independence
- Extra pauses
- Assertions that verify the business result
- The correct test level
You get a simple cycle: an AI tool creates the test and another tool checks it by the rules of your team.
I think this is among the most practical ways to use AI in automation: you teach AI to work the way your team needs.
Read also: Agentic AI Testing: The Complete Guide for QA Teams
Does your team use skills for AI agents? If your AI agent repeats the same mistakes in new tests, a skill with your team’s rules helps you fix them for all future tests.
👉 Install the automate-manual-test-cases skill from the free QA skills library and adapt its rules to your project.
Then connect your Playwright tests to Testomat.io. It marks flaky tests based on the results of recent runs, so you can see which rules your skill misses and add them. If you want to see how it works for your team, book a free demo.