Home › Accessibility › Web accessibility (WCAG 2.2) rules

Web accessibility (WCAG 2.2) rules

Windsurf rules for building accessible web UIs to WCAG 2.2 AA: semantics, keyboard, focus, contrast, and testing.

WindsurfAccessibility

How to use

Save this as .windsurf/rules/accessibility.md in your repository root, commit it, and your agent will pick it up automatically. Edit the commands to match your project.

Note: Review and test before use. Provided as is, without warranty. See Terms.

.windsurf/rules/accessibility.mdDownload  
# Accessibility (WCAG 2.2 AA)

## Semantics first
- Use native elements: `<button>` for actions, `<a href>` for navigation, `<label for>` for inputs, headings in order (one `<h1>` per page), landmarks (`<header>`, `<nav>`, `<main>`, `<footer>`).
- ARIA only when no native element fits; then follow the APG pattern exactly. No `role="button"` on a `<div>` when a `<button>` works.
- Every image has `alt` (empty `alt=""` for decorative). Icon-only buttons get an `aria-label`.

## Keyboard and focus
- Everything works with keyboard only: Tab order follows visual order, no `tabindex` > 0.
- Visible focus indicator on all interactive elements; never `outline: none` without a replacement.
- Dialogs trap focus, close on Esc, and return focus to the trigger (use `<dialog>` or the UI library's accessible dialog).
- Targets are at least 24x24 CSS px.

## Forms
- Errors are announced (`aria-describedby` to the message, `aria-invalid="true"`), not shown by color alone.
- Use `autocomplete` attributes for personal data fields.

## Visual
- Text contrast >= 4.5:1 (3:1 for large text and UI components). Support 200% zoom and reflow at 320px width.
- Respect `prefers-reduced-motion`.

## Dynamic content
Announce async updates with a polite live region (`aria-live="polite"`).

## Check
Run axe (`@axe-core/playwright` or the browser extension) on changed pages with zero violations, and tab through the flow once.

More: all Accessibility rules · all Windsurf rules

Related rules

Agent safety guardrails Windsurf rules

Always-on Windsurf rules that stop agents from running destructive, costly, or externally visible actions without approval.

WindsurfAny stack

Documentation writing rules

Windsurf rules for writing and updating READMEs, docstrings, ADRs, and changelogs alongside code changes.

WindsurfAgent workflows

API route security .claude/rules file

A path-scoped Claude Code rules file for API routes and handlers: auth, ownership checks, validation, and safe errors.

Claude Code (CLAUDE.md)Security

Code review Copilot instructions

Copilot instructions focused on pull request review: what to flag, severity labels, and how to word comments.

GitHub CopilotAgent workflows

Code review prompt file (Copilot)

A Copilot prompt file (/review-changes) that reviews the current changes and reports issues by severity without editing.

GitHub CopilotAgent workflows

Code reviewer subagent (Claude Code)

A Claude Code subagent definition that reviews the current diff for bugs, security, and tests, reporting by severity.

Claude Code (CLAUDE.md)Agent workflows

Get new rules weekly

One email a week: fresh rule files, agent tips, and what's changing in Cursor, Claude Code and Copilot. Free, unsubscribe anytime.

Opens the Rulestack Newsletter on beehiiv in a new tab. Or subscribe directly on beehiiv.