Install
1
Install the plugin
$
npx claudepluginhub montinou/triqual --plugin triqual-plugin

Want just this skill?

Add to a custom plugin, then install with one command.

Description

Comprehensive Playwright best practices and rules. Use when writing, reviewing, or debugging Playwright tests. 31 rules across 8 categories.

Tool Access

This skill uses the workspace's default tool permissions.

Skill Content

/rules - Playwright Best Practices Guide

Comprehensive rules and best practices for writing reliable, maintainable Playwright tests. 31 documented rules across 8 categories.

When to Use

  • Writing new Playwright test files
  • Reviewing test code for anti-patterns
  • Debugging flaky tests
  • Learning Playwright best practices
  • Code review - referencing specific rule violations

Quick Reference

Critical Rules (ERROR Severity)

RuleCategoryIssue
wait-no-timeoutWaitsNever use waitForTimeout() - causes flaky tests
assert-web-firstAssertionsUse web-first assertions with auto-retry
test-isolationOrganizationTests must be independent for parallel execution
parallel-worker-isolationParallelWorkers cannot share state
parallel-shared-stateParallelNo shared mutable state between tests
selector-no-xpathLocatorsXPath is fragile and breaks easily
locator-firstLocatorsUse .first() explicitly when multiple match
network-route-handlersNetworkAlways resolve routes (continue/fulfill/abort)
debug-slow-moDebuggingNever leave slowMo in CI

Quick Patterns

Locators (Do → Don't)

// ✅ getByRole('button', { name: 'Submit' })  →  ❌ locator('.btn-submit')
// ✅ getByTestId('user-avatar')               →  ❌ locator('#avatar-12345')
// ✅ getByLabel('Email')                      →  ❌ locator('input[type="email"]')
// ✅ locator('.item').first()                 →  ❌ locator('.item') when multiple

Waits (Do → Don't)

// ✅ await expect(el).toBeVisible()           →  ❌ await page.waitForTimeout(1000)
// ✅ await page.waitForURL('/dashboard')      →  ❌ await page.waitForLoadState('networkidle')
// ✅ await response.finished()                →  ❌ await page.waitForTimeout(500)

Assertions (Do → Don't)

// ✅ await expect(locator).toHaveText('Hi')   →  ❌ expect(await locator.textContent()).toBe('Hi')
// ✅ await expect(locator).toBeVisible()      →  ❌ expect(await locator.isVisible()).toBe(true)
// ✅ await expect(page).toHaveURL('/home')    →  ❌ expect(page.url()).toBe('/home')

Rule Categories

Read the full documentation at ${CLAUDE_PLUGIN_ROOT}/docs/playwright-rules/rules/:

1. Locators (6 rules)

Finding elements reliably and maintainably.

# Read all locator rules
cat ${CLAUDE_PLUGIN_ROOT}/docs/playwright-rules/rules/locator-*.md
cat ${CLAUDE_PLUGIN_ROOT}/docs/playwright-rules/rules/selector-*.md
RuleDescription
locator-visibilityVerify element visibility before interactions
locator-firstUse .first() explicitly or refine locators
locator-chainingChain locators to narrow scope
selector-testidPrefer getByTestId over CSS selectors
selector-no-xpathAvoid fragile XPath expressions
selector-role-basedPrefer role-based locators (getByRole)

2. Waits & Timing (4 rules)

Handling asynchronous operations without flakiness.

cat ${CLAUDE_PLUGIN_ROOT}/docs/playwright-rules/rules/wait-*.md
RuleDescription
wait-no-timeoutCRITICAL - No hardcoded waitForTimeout
wait-for-statePrefer waitFor over networkidle
wait-auto-waitingLeverage Playwright's auto-waiting
wait-explicit-conditionsUse explicit wait conditions

3. Assertions (4 rules)

Verifying outcomes with auto-retry.

cat ${CLAUDE_PLUGIN_ROOT}/docs/playwright-rules/rules/assert-*.md
RuleDescription
assert-web-firstCRITICAL - Use web-first assertions
assert-specificUse specific assertion methods
assert-softUse soft assertions appropriately
assert-timeoutConfigure assertion timeouts properly

4. Page Objects (4 rules)

Organizing locators and actions.

cat ${CLAUDE_PLUGIN_ROOT}/docs/playwright-rules/rules/page-object-*.md
RuleDescription
page-object-locatorsMove inline locators to Page Objects
page-object-actionsEncapsulate actions in methods
page-object-compositionCompose Page Objects for complex pages
page-object-no-assertionsKeep assertions in tests, not POs

5. Test Organization (5 rules)

Structuring tests for maintainability and parallel execution.

cat ${CLAUDE_PLUGIN_ROOT}/docs/playwright-rules/rules/test-*.md
RuleDescription
test-isolationCRITICAL - Tests must be independent
test-hooksUse beforeEach/afterEach properly
test-fixturesLeverage Playwright fixtures
test-describe-groupingGroup related tests with describe
test-namingUse descriptive test names

6. Network (4 rules)

Mocking and intercepting network requests.

cat ${CLAUDE_PLUGIN_ROOT}/docs/playwright-rules/rules/network-*.md
RuleDescription
network-mock-apiMock external API calls
network-route-handlersCRITICAL - Always resolve routes
network-wait-responseWait for specific responses
network-abort-unnecessaryAbort unnecessary requests

7. Debugging (4 rules)

Troubleshooting and diagnosing test failures.

cat ${CLAUDE_PLUGIN_ROOT}/docs/playwright-rules/rules/debug-*.md
RuleDescription
debug-trace-on-failureEnable traces for failed tests
debug-screenshotsCapture screenshots strategically
debug-video-recordingConfigure video recording
debug-slow-moCRITICAL - Never in CI

8. Parallelization (4 rules)

Running tests safely in parallel.

cat ${CLAUDE_PLUGIN_ROOT}/docs/playwright-rules/rules/parallel-*.md
RuleDescription
parallel-worker-isolationCRITICAL - Ensure worker isolation
parallel-shared-stateCRITICAL - No shared mutable state
parallel-test-dataUse unique test data per worker
parallel-serial-when-neededMark serial tests explicitly

Usage

Review Code Against Rules

When reviewing test code, read the relevant rule files:

// If you see this in a test:
await page.waitForTimeout(2000);

// Reference: wait-no-timeout.md (ERROR severity)
// This is the #1 cause of flaky tests!

Fix Violations

Each rule file includes:

  • Summary - One-line description
  • Rationale - Why the rule exists
  • Best Practice - Correct code examples
  • Anti-Pattern - What to avoid
  • Auto-fix - How to transform bad code to good code

Code Review Comments

Reference rules in code reviews:

This violates `wait-no-timeout` (ERROR) - use explicit conditions instead:
- Before: `await page.waitForTimeout(2000)`
- After: `await expect(element).toBeVisible()`
See: docs/playwright-rules/rules/wait-no-timeout.md

Read Specific Rules

To read a specific rule:

# Read a specific rule
cat ${CLAUDE_PLUGIN_ROOT}/docs/playwright-rules/rules/wait-no-timeout.md

# Read all rules in a category
cat ${CLAUDE_PLUGIN_ROOT}/docs/playwright-rules/rules/assert-*.md

# Search for patterns
grep -r "auto-fix" ${CLAUDE_PLUGIN_ROOT}/docs/playwright-rules/rules/

Integration with Other Skills

  • /test --explore - Apply rules when writing ad-hoc tests
  • /test - Use patterns when creating production tests
  • /test --ticket - Reference rules when generating from tickets

Severity Levels

  • ERROR - Must fix; will cause flaky or broken tests
  • WARNING - Should fix; may cause issues
  • INFO - Recommended best practice

What This Skill Does

  • Provides comprehensive Playwright best practices reference
  • Documents patterns and anti-patterns with code examples
  • Helps diagnose why tests are flaky
  • Serves as a code review checklist

What This Skill Does NOT Do

  • Auto-fix code (use /check --fix for auto-fixes)
  • Run tests (use /test or /test --explore)
  • Create Page Objects (use /test)
Stats
Stars0
Forks0
Last CommitJan 27, 2026
Actions

Similar Skills