Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Accessibility testing skill using axe-core and Playwright for automated WCAG 2.1 compliance auditing, custom rules, and accessibility reporting.
.claude/skills/pramoddutta-axe-core-accessibility-testing/SKILL.md| Model | Eval pass | Runs |
|---|---|---|
| gemini-3.6-flash | 100% | 3 |
| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-02 | ✗→✓ | ▲ Improved | 141% | 0% |
| case-06 | ✗→✓ | ▲ Improved | 167% | 0% |
| case-04 | ✓→✗ | ▼ Worse | 231% | 0% |
| case-21 | ✓→✗ | ▼ Worse | 184% | 0% |
| case-22 | ✓→✗ | ▼ Worse | 97% | 0% |
You are an expert accessibility engineer specializing in automated accessibility testing with axe-core and Playwright. When the user asks you to write, review, or debug accessibility tests, follow these detailed instructions.
tests/
accessibility/
pages/
homepage.a11y.spec.ts
login.a11y.spec.ts
dashboard.a11y.spec.ts
components/
navigation.a11y.spec.ts
forms.a11y.spec.ts
modals.a11y.spec.ts
utils/
axe-helper.ts
a11y-reporter.ts
config/
axe-config.ts
playwright.config.tsbashnpm install --save-dev @axe-core/playwright axe-core playwright @playwright/test
typescript// config/axe-config.ts import { AxeBuilder } from '@axe-core/playwright'; import { Page } from '@playwright/test'; export const DEFAULT_AXE_OPTIONS = { runOnly: { type: 'tag' as const, values: ['wcag2a', 'wcag2aa', 'wcag21a', 'wcag21aa', 'best-practice'], }, }; export const STRICT_AXE_OPTIONS = { runOnly: { type: 'tag' as const, values: ['wcag2a', 'wcag2aa', 'wcag21a', 'wcag21aa', 'wcag22aa'], }, }; export async function runAxeScan(page: Page, options = DEFAULT_AXE_OPTIONS) { const results = await new AxeBuilder({ page }) .options(options) .analyze(); return results; } export async function runAxeOnComponent(page: Page, selector: string) { const results = await new AxeBuilder({ page }) .include(selector) .options(DEFAULT_AXE_OPTIONS) .analyze(); return results; }
typescriptimport { test, expect } from '@playwright/test'; import AxeBuilder from '@axe-core/playwright'; test.describe('Homepage Accessibility', () => { test('should have no accessibility violations', async ({ page }) => { await page.goto('/'); const accessibilityScanResults = await new AxeBuilder({ page }) .withTags(['wcag2a', 'wcag2aa', 'wcag21a', 'wcag21aa']) .analyze(); expect(accessibilityScanResults.violations).toEqual([]); }); test('should have no critical or serious violations', async ({ page }) => { await page.goto('/'); const accessibilityScanResults = await new AxeBuilder({ page }).analyze(); const criticalViolations = accessibilityScanResults.violations.filter( (v) => v.impact === 'critical' || v.impact === 'serious' ); expect(criticalViolations).toEqual([]); }); test('should pass accessibility after dynamic content loads', async ({ page }) => { await page.goto('/'); // Wait for dynamic content await page.getByRole('heading', { name: 'Featured Products' }).waitFor(); await page.waitForLoadState('networkidle'); const results = await new AxeBuilder({ page }) .withTags(['wcag2a', 'wcag2aa']) .analyze(); expect(results.violations).toEqual([]); }); });
typescripttest.describe('Navigation Component Accessibility', () => { test('navigation menu should be accessible', async ({ page }) => { await page.goto('/'); const results = await new AxeBuilder({ page }) .include('nav[aria-label="Main navigation"]') .withTags(['wcag2a', 'wcag2aa']) .analyze(); expect(results.violations).toEqual([]); }); test('navigation should have proper ARIA landmarks', async ({ page }) => { await page.goto('/'); // Check for main navigation landmark const nav = page.getByRole('navigation', { name: 'Main navigation' }); await expect(nav).toBeVisible(); // Check for skip navigation link const skipLink = page.getByRole('link', { name: /skip to/i }); await expect(skipLink).toBeAttached(); }); test('mobile menu should be accessible when opened', async ({ page }) => { await page.setViewportSize({ width: 375, height: 667 }); await page.goto('/'); // Open mobile menu const menuButton = page.getByRole('button', { name: /menu/i }); await menuButton.click(); // Scan the opened menu const results = await new AxeBuilder({ page }) .include('[role="dialog"], [aria-expanded="true"]') .withTags(['wcag2a', 'wcag2aa']) .analyze(); expect(results.violations).toEqual([]); // Verify focus management const firstMenuItem = page.getByRole('menuitem').first(); await expect(firstMenuItem).toBeFocused(); }); });
typescripttest.describe('Form Accessibility', () => { test('login form should be fully accessible', async ({ page }) => { await page.goto('/login'); const results = await new AxeBuilder({ page }) .include('form') .withTags(['wcag2a', 'wcag2aa']) .analyze(); expect(results.violations).toEqual([]); }); test('form inputs should have associated labels', async ({ page }) => { await page.goto('/login'); // Every input should be findable by its label await expect(page.getByLabel('Email')).toBeVisible(); await expect(page.getByLabel('Password')).toBeVisible(); }); test('form errors should be announced to screen readers', async ({ page }) => { await page.goto('/login'); // Submit empty form await page.getByRole('button', { name: 'Sign in' }).click(); // Error messages should have appropriate ARIA attributes const errorMessages = page.locator('[role="alert"]'); await expect(errorMessages.first()).toBeVisible(); // Check aria-describedby links errors to inputs const emailInput = page.getByLabel('Email'); const describedBy = await emailInput.getAttribute('aria-describedby'); expect(describedBy).toBeTruthy(); const errorElement = page.locator(`#${describedBy}`); await expect(errorElement).toBeVisible(); }); test('required fields should be marked with aria-required', async ({ page }) => { await page.goto('/login'); const emailInput = page.getByLabel('Email'); const passwordInput = page.getByLabel('Password'); await expect(emailInput).toHaveAttribute('aria-required', 'true'); await expect(passwordInput).toHaveAttribute('aria-required', 'true'); }); });
typescripttest.describe('Keyboard Navigation', () => { test('all interactive elements should be keyboard accessible', async ({ page }) => { await page.goto('/'); // Tab through the page and collect focused elements const focusedElements: string[] = []; for (let i = 0; i < 20; i++) { await page.keyboard.press('Tab'); const focused = await page.evaluate(() => { const el = document.activeElement; return el ? `${el.tagName}:${el.textContent?.trim().substring(0, 30)}` : 'none'; }); focusedElements.push(focused); } // Verify that interactive elements are in the tab order expect(focusedElements.some((el) => el.includes('Skip'))).toBe(true); expect(focusedElements.some((el) => el.includes('A:'))).toBe(true); // Links }); test('modal dialog should trap focus', async ({ page }) => { await page.goto('/'); // Open a modal await page.getByRole('button', { name: 'Open dialog' }).click(); const dialog = page.getByRole('dialog'); await expect(dialog).toBeVisible(); // Tab through modal elements await page.keyboard.press('Tab'); const firstFocused = await page.evaluate(() => document.activeElement?.closest('[role="dialog"]') !== null); expect(firstFocused).toBe(true); // Tab many times -- focus should stay within dialog for (let i = 0; i < 20; i++) { await page.keyboard.press('Tab'); } const stillInDialog = await page.evaluate(() => document.activeElement?.closest('[role="dialog"]') !== null); expect(stillInDialog).toBe(true); // Escape should close dialog await page.keyboard.press('Escape'); await expect(dialog).toBeHidden(); // Focus should return to trigger element const triggerFocused = await page.evaluate(() => document.activeElement?.textContent?.includes('Open dialog') ); expect(triggerFocused).toBe(true); }); test('dropdown menu should support arrow key navigation', async ({ page }) => { await page.goto('/'); const menuButton = page.getByRole('button', { name: 'Account menu' }); await menuButton.focus(); await page.keyboard.press('Enter'); // Arrow down should move to first item await page.keyboard.press('ArrowDown'); const firstItem = page.getByRole('menuitem').first(); await expect(firstItem).toBeFocused(); // Arrow down again await page.keyboard.press('ArrowDown'); const secondItem = page.getByRole('menuitem').nth(1); await expect(secondItem).toBeFocused(); }); });
typescripttest.describe('Color Contrast', () => { test('text elements should meet contrast requirements', async ({ page }) => { await page.goto('/'); const results = await new AxeBuilder({ page }) .withRules(['color-contrast']) .analyze(); expect(results.violations).toEqual([]); }); test('focus indicators should be visible', async ({ page }) => { await page.goto('/'); // Tab to first link await page.keyboard.press('Tab'); await page.keyboard.press('Tab'); // Check that the focused element has a visible focus indicator const focusOutline = await page.evaluate(() => { const el = document.activeElement; if (!el) return null; const styles = window.getComputedStyle(el); return { outline: styles.outline, outlineWidth: styles.outlineWidth, boxShadow: styles.boxShadow, }; }); // Should have either outline or box-shadow for focus const hasFocusIndicator = (focusOutline?.outlineWidth && focusOutline.outlineWidth !== '0px') || (focusOutline?.boxShadow && focusOutline.boxShadow !== 'none'); expect(hasFocusIndicator).toBe(true); }); });
typescripttest('should pass with known exceptions excluded', async ({ page }) => { await page.goto('/'); const results = await new AxeBuilder({ page }) .withTags(['wcag2a', 'wcag2aa']) .exclude('#third-party-widget') // Exclude third-party content .exclude('.legacy-component') // Exclude legacy code being refactored .disableRules(['color-contrast']) // Disable specific rules if justified .analyze(); expect(results.violations).toEqual([]); });
typescript// utils/a11y-reporter.ts import { AxeResults, Result } from 'axe-core'; export function formatViolations(violations: Result[]): string { if (violations.length === 0) return 'No accessibility violations found.'; return violations .map((violation) => { const nodes = violation.nodes.map((node) => { return ` - Element: ${node.html}\n Target: ${node.target.join(', ')}\n Fix: ${node.failureSummary}`; }).join('\n'); return ` Rule: ${violation.id} Impact: ${violation.impact} Description: ${violation.description} Help: ${violation.helpUrl} Affected elements: ${nodes}`; }) .join('\n---\n'); } export function assertNoViolations(results: AxeResults, allowedImpacts: string[] = []) { const filteredViolations = results.violations.filter( (v) => !allowedImpacts.includes(v.impact || '') ); if (filteredViolations.length > 0) { throw new Error( `Found ${filteredViolations.length} accessibility violations:\n${formatViolations(filteredViolations)}` ); } }
| Level | Guideline | Test Approach | |-------|-----------|---------------| | A | 1.1.1 Non-text Content | Check all images have alt text | | A | 1.3.1 Info and Relationships | Verify headings, lists, tables are semantic | | A | 2.1.1 Keyboard | Tab through all functionality | | A | 2.4.1 Bypass Blocks | Verify skip navigation link exists | | A | 4.1.2 Name, Role, Value | Check ARIA attributes on custom widgets | | AA | 1.4.3 Contrast (Minimum) | 4.5:1 for normal text, 3:1 for large text | | AA | 1.4.4 Resize Text | Page usable at 200% zoom | | AA | 2.4.6 Headings and Labels | Descriptive heading hierarchy | | AA | 2.4.7 Focus Visible | Visible focus indicator on all elements | | AA | 1.4.11 Non-text Contrast | 3:1 contrast for UI components |
prefers-reduced-motion is respected.display: none -- Screen readers cannot access hidden content.tabindex greater than 0 -- It disrupts natural tab order.outline: none without a replacement removes focus indicators.aria-live or role="alert".| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-01 | fail→fail | 35,503 | 23,979 | -32% | 1 | 1 | 0% | 5,569 | 7,153 | +28% | 0 | 0 | — |
case-02 | fail→pass | 23,259 | 24,017 | +3% | 1 | 1 | 0% | 3,097 | 7,455 | +141% | 0 | 0 | — |
case-03 | pass→pass | 17,385 | 14,080 | -19% | 1 | 1 | 0% | 2,112 | 6,490 | +207% | 0 | 0 | — |
case-04 | pass→fail | 17,756 | 16,214 | -9% | 1 | 1 | 0% | 2,032 | 6,718 | +231% | 0 | 0 | — |
case-05 | pass→pass | 14,836 | 12,600 | -15% | 1 | 1 | 0% | 2,469 | 6,192 | +151% | 0 | 0 | — |
case-06 | fail→pass | 16,013 | 21,557 | +35% | 1 | 1 | 0% | 2,607 | 6,962 | +167% | 0 | 0 | — |
case-07 | fail→fail | 18,682 | 22,458 | +20% | 1 | 1 | 0% | 2,514 | 7,140 | +184% | 0 | 0 | — |
case-08 | fail→fail | 14,057 | 18,998 | +35% | 1 | 1 | 0% | 2,244 | 6,364 | +184% | 0 | 0 | — |
case-09 | pass→pass | 12,730 | 17,777 | +40% | 1 | 1 | 0% | 2,146 | 6,774 | +216% | 0 | 0 | — |
case-10 | pass→pass | 16,991 | 11,915 | -30% | 1 | 1 | 0% | 2,125 | 6,062 | +185% | 0 | 0 | — |
case-11 | pass→pass | 18,089 | 11,894 | -34% | 1 | 1 | 0% | 1,909 | 5,829 | +205% | 0 | 0 | — |
case-12 | pass→pass | 19,104 | 18,733 | -2% | 1 | 1 | 0% | 2,601 | 7,234 | +178% | 0 | 0 | — |
case-13 | pass→pass | 18,760 | 12,364 | -34% | 1 | 1 | 0% | 1,952 | 5,783 | +196% | 0 | 0 | — |
case-14 | pass→pass | 21,249 | 20,828 | -2% | 1 | 1 | 0% | 2,505 | 6,625 | +164% | 0 | 0 | — |
case-15 | pass→pass | 14,449 | 14,481 | +0% | 1 | 1 | 0% | 2,286 | 6,633 | +190% | 0 | 0 | — |
case-16 | pass→pass | 7,150 | 15,017 | +110% | 1 | 1 | 0% | 1,289 | 5,621 | +336% | 0 | 0 | — |
case-17 | pass→pass | 21,842 | 23,007 | +5% | 1 | 1 | 0% | 2,386 | 6,685 | +180% | 0 | 0 | — |
case-18 | pass→pass | 15,229 | 15,997 | +5% | 1 | 1 | 0% | 1,787 | 5,770 | +223% | 0 | 0 | — |
case-19 | pass→pass | 13,888 | 11,984 | -14% | 1 | 1 | 0% | 2,238 | 5,334 | +138% | 0 | 0 | — |
case-20 | pass→pass | 36,696 | 32,182 | -12% | 1 | 1 | 0% | 4,956 | 8,737 | +76% | 0 | 0 | — |
case-21 | pass→fail | 20,954 | 16,912 | -19% | 1 | 1 | 0% | 2,514 | 7,150 | +184% | 0 | 0 | — |
case-22 | pass→fail | 27,651 | 25,269 | -9% | 1 | 1 | 0% | 4,499 | 8,883 | +97% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 22 cases were attempted. The headline lift of -14 percentage points is the difference between those two pass rates over the 22 comparable cases. 4 cases got worse with the skill loaded, and they are included in that figure.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.