Browse all tutorials →
Claude Code November 20, 2026 14 min read

25 Claude Code Prompts for Testers and QA Engineers

Copy-paste prompts for the testing jobs you actually do: turning requirements into test cases, generating Playwright tests from a live page, fixing broken locators, hunting flaky tests, building API tests and test data, and reviewing what the AI wrote. Each one is written to produce tests you can merge, not tests you have to rewrite.

Quick answer: A good Claude Code prompt for testing has five parts: the task, the context (files, URL, requirement), your conventions, a definition of done ("run it and show me the result"), and limits ("don't change assertions"). The 25 prompts below follow that pattern. Put the rules you repeat in CLAUDE.md, and save the prompts you use often as slash commands.

Most "AI prompts for testers" lists are written for chatbots: "Write test cases for a login page." That is fine for brainstorming, but Claude Code can do much more. It can open your app, read your repo, run your suite and fix what breaks. The prompts below are written for that: agent prompts that end with something running, not something you have to copy and paste.

Before you start: connect the Playwright MCP server (claude mcp add playwright npx @playwright/mcp@latest) and add a CLAUDE.md with your testing rules. Both make every prompt here shorter and more reliable.


Anatomy of a Good Testing Prompt

Part Weak Strong
Task Test the login Write tests/e2e/login.spec.ts covering valid, invalid and locked-out login
Context (none) Open http://localhost:3000/login with the Playwright MCP browser first
Conventions (none) Use the LoginPage object and the users fixture
Done when (none) Run it on chromium and show me the result
Limits (none) Don't modify the app code or other specs

Test Design Prompts (1–4)

1. Requirement → test scenarios
Read docs/stories/coupon-codes.md. List test scenarios as a table:
ID, scenario, type (positive / negative / boundary / security),
priority (P1-P3), and expected result. Include edge cases a tester
might miss. Flag anything in the requirement that is ambiguous as
a question for the product owner. Don't write code yet.
2. Boundary values and equivalence classes
The "quantity" field accepts 1-99 and the "promo code" field is
6-12 uppercase alphanumeric characters. List the equivalence classes
and boundary values for both fields, with the expected result for
each. Output as a table I can paste into a test case document.
3. Explore a page and find risks
Use the Playwright MCP browser to explore http://localhost:3000/checkout
like an exploratory tester for 10-15 actions. Try empty fields, long
input, back-button navigation and double clicks. Report anything that
looks like a bug or a usability problem, with steps to reproduce.
Don't write any test files.
4. Find coverage gaps
Compare the scenarios in docs/test-plan/checkout.md with the specs
in tests/e2e/checkout/. Which scenarios have no automated test?
Which tests don't map to any scenario? Output two lists, sorted by
risk.

More on this in Claude AI test case generation.

Writing Playwright Tests (5–10)

5. Generate a test from the live page
Open http://localhost:3000/login with the Playwright MCP browser and
read the accessibility snapshot. Then write tests/e2e/login.spec.ts
covering: valid login, wrong password, empty fields, locked account.
Follow CLAUDE.md conventions. Run the file on chromium and fix
failures until it passes. Show me the final code.
6. Manual test case → automated test
Convert this manual test case into a Playwright test in
tests/e2e/profile.spec.ts. Reuse existing page objects in tests/pages/
or create one if missing. Verify every "expected result" step with a
web-first assertion.

<paste test case steps and expected results>
7. Create a page object
Create a page object for the checkout page in
tests/pages/CheckoutPage.ts, following the style of
tests/pages/LoginPage.ts. Inspect the page with the Playwright MCP
browser first. Expose user actions (fillShipping, applyCoupon,
placeOrder), not raw locators. Don't change any spec files.
8. Data-driven test
Turn tests/e2e/search.spec.ts "finds a product" into a data-driven
test that loops over tests/data/search-terms.json (term + expected
first result). Each data row should appear as a separate test in the
report. Run it.
9. Mobile and cross-browser check
Run tests/e2e/checkout.spec.ts on all projects in
playwright.config.ts. For any test that fails only on webkit or the
mobile project, explain why and propose a fix that keeps one shared
test (no browser-specific copies).
10. Accessibility smoke test
Add an accessibility check to our @smoke tests for the home, login
and checkout pages using @axe-core/playwright. Fail only on
"serious" and "critical" violations. Run it and list any violations
found, with the element and the WCAG rule.

Debugging and Flaky Tests (11–15)

11. Classify before fixing
Run tests/e2e/cart.spec.ts and show me the failures. For each one,
classify it as: locator changed / timing / test data / environment /
real application bug, with evidence. Do not change any code yet.
12. Fix a broken locator properly
The "Place order" button locator broke after the redesign. Open the
checkout page with the Playwright MCP browser, find the new
accessible name or test id, update it in tests/pages/CheckoutPage.ts
only, then rerun every spec that imports CheckoutPage.
13. Reproduce a flaky test
"applies coupon" in tests/e2e/cart.spec.ts fails roughly 1 run in 10.
Run it with --repeat-each=20 --workers=1, then with --workers=4.
Tell me whether this looks like timing, shared data or test-order
dependency, and point to the exact lines responsible.
14. Remove hard waits
Find every page.waitForTimeout() in tests/. Replace each one with the
correct web-first assertion or wait (response, URL, element state)
based on what the test is actually waiting for. Rerun each changed
file 10 times with --repeat-each=10 to prove it is stable.
15. Explain a CI-only failure
This test passes locally but fails in CI. Here is the CI log:
<paste log>
Compare the CI environment (see .github/workflows/e2e.yml and
playwright.config.ts) with local. List the most likely causes in
order and how to confirm each one. Don't change code yet.

Full workflow: how to fix failing and flaky tests with Claude Code.

Want the full workflow behind these prompts?

Learn Playwright from scratch, Claude Code, the Playwright MCP Server and AI agents in one hands-on Udemy course.

See the course plan →

Refactoring and Maintenance (16–18)

16. Migrate specs to page objects
tests/e2e/legacy/ has specs with locators written inline. Move them
to page objects in tests/pages/, one page at a time. After each page,
run the affected specs. Don't change test behaviour or assertions.
Stop and show me the plan before you start.
17. Add tags to a suite
Tag every test in tests/e2e/: @smoke for the 10 most critical user
journeys (show me your list first), @regression for everything else,
and @slow for tests that take over 30 seconds in the last report.
Use the tag option, not the title.
18. Replace UI login with storageState
Most specs log in through the UI in beforeEach. Create an auth setup
project that logs in once and saves storageState, and update the
config and specs to use it. Keep tests/e2e/login.spec.ts logging in
through the UI. Compare total suite time before and after.

API Tests and Test Data (19–21)

19. API tests from an OpenAPI spec
Read docs/openapi.yaml. Write Playwright API tests in
tests/api/orders.spec.ts using the request fixture for the /orders
endpoints: happy path, validation errors (400), unauthorised (401)
and not found (404). Check status codes and response body fields.
Run them against BASE_URL.
20. Test data factory
Create a test data helper in tests/fixtures/factories.ts that creates
a user, a product and an order through the API, with unique values
each time, and returns their IDs. Expose it as a Playwright fixture
that cleans up after the test.
21. Mock a flaky third-party API
The checkout tests depend on a third-party shipping-rate API that is
slow and sometimes down. Use page.route() to mock it with the fixture
in tests/data/shipping-rates.json for all tests except one @contract
test that hits the real service.

CI and Reviewing AI Output (22–25)

22. GitHub Actions workflow
Create .github/workflows/e2e.yml that runs @smoke tests on every
pull request (chromium only) and the full suite nightly on all
projects, with sharding across 4 machines, the HTML report uploaded
as an artifact, and traces kept on failure.
23. Review a spec like a senior QA
Review tests/e2e/checkout.spec.ts as a senior QA automation engineer.
Flag: weak or missing assertions, brittle locators, hard waits, shared
state between tests, unclear test names, and missing negative cases.
Output a table: line, problem, why it matters, suggested fix.
Don't edit the file.
24. Check the AI's own changes
Show me git diff for the test changes you made in this session.
For each change, tell me whether any assertion became weaker, any
expected value changed, any timeout increased, or any test was
skipped. If yes, explain why it was justified.
25. Write the bug report
The test "applies coupon" fails because the discount is 5% instead of
10%. Write a bug report: title, environment, preconditions, steps to
reproduce, expected vs actual result, severity, and attach the
relevant error output. Keep it under 200 words.

Save Your Best Prompts as Slash Commands

Any prompt you use more than twice should become a custom slash command. Save it as a Markdown file in .claude/commands/ and commit it so the whole team can use it. $ARGUMENTS is replaced with whatever you type after the command:

.claude/commands/fix-test.md
Run the test $ARGUMENTS and show me the failure.
Classify it as: locator changed / timing / test data / environment /
real application bug, with evidence.
If it is a real bug or an environment issue, STOP and explain.
Otherwise make the smallest fix (page object over spec), then rerun
every spec that uses the changed file.
Never weaken assertions, change expected values or add waitForTimeout.

Now /fix-test tests/e2e/cart.spec.ts runs the whole workflow. Newer Claude Code versions also support skills for larger reusable workflows. Check the current docs for the format.

One rule for every prompt: you are responsible for every test you merge, so read the diff. AI makes a good tester much faster; it does not make an unreviewed test trustworthy.

Frequently Asked Questions

What are the best Claude Code prompts for testers?

The most useful prompts give Claude Code a specific task, the context (files, URL, requirement), your conventions, a definition of done and clear limits. Examples include generating a Playwright test from a live page via the Playwright MCP server, classifying a failing test before fixing it, and reviewing a spec for weak assertions.

Do I need to know coding to use these prompts?

You can use the test design prompts without coding. For the prompts that generate Playwright code, you need enough Playwright knowledge to review the output, run it and judge whether the assertions are meaningful.

Can I save prompts as reusable commands in Claude Code?

Yes. Save a prompt as a Markdown file in .claude/commands/ in your project, for example .claude/commands/fix-test.md, and run it as a slash command such as /fix-test. Use $ARGUMENTS in the file to pass in a test name or file path.

Do these prompts work in Claude.ai chat or Cursor?

The test design and review prompts work in any AI assistant. The prompts that run tests or open a browser need a tool that can run commands and use the Playwright MCP server, such as Claude Code, Cursor Agent or Copilot agent mode.

How do I stop Claude Code from writing flaky tests?

Tell it to use role-based locators and web-first assertions, forbid waitForTimeout, make each test create its own data, and require it to run new tests several times with --repeat-each. Put these rules in CLAUDE.md so you do not have to repeat them in every prompt.

Should I use the Playwright MCP server with these prompts?

Yes, for any prompt that writes or fixes UI tests. The MCP server lets Claude Code open the real page and read its accessibility tree, so locators are based on what is actually there instead of guesses.

Are AI-generated test cases good enough to use directly?

They are a strong first draft. AI is good at listing scenarios, edge cases and negative paths quickly, but a tester must remove irrelevant cases, add business-specific ones, and confirm the expected results against the requirement.

What should I never ask Claude Code to do in testing?

Do not ask it to simply make a failing test pass, run tests against production, or work with real customer data or secrets in the prompt. Always ask it to explain failures before changing tests.


Asim Noaman, Playwright and Claude AI course instructor

Asim Noaman

Sr. SQA Manager & AI Automation Engineer

18+ years in QA. Asim currently runs an 80+ engineer QA function at Tkxel and built a Testing Center of Excellence for a major Saudi bank. He builds AI testing agents with Playwright, Claude AI and the MCP Server at work, and teaches the same workflow in his courses.

18+ Years in QA 80+ engineer QA function
Udemy Instructor 4.5★ · 140+ ratings · 570+ students
Anthropic Certificates Claude API · MCP
Connect on LinkedIn

Full profile →

Playwright + Claude AI Course on Udemy

Learn Playwright and Claude Code in One Course

The course teaches Playwright in JavaScript from scratch (locators, assertions, hooks and the Page Object Model), then Claude Code, the Playwright MCP Server, your own QA AI agent and Playwright Test Agents. Rated 4.5★ from 130+ ratings, 510+ students.

  • Playwright from scratch, no prior coding needed
  • Claude Code project setup, test generation and custom QA subagents
  • Playwright MCP Server test generation and your own QA AI agent
  • Playwright Test Agents and prompt engineering for testers
See the Course Plan →

New to testing? Start with Manual Testing & QA with AI or AI Software Testing for Beginners · Which course is right for me?