Claude Skills Guide

Claude Code for WCAG 2.2 Compliance Workflow Guide

Web accessibility is no longer optional—it’s a legal requirement in many jurisdictions and a fundamental aspect of inclusive design. WCAG 2.2 (Web Content Accessibility Guidelines) introduces several new success criteria that address user experience gaps for people with disabilities. This guide shows you how to use Claude Code to build, audit, and maintain WCAG 2.2 compliant applications throughout your development workflow.

Understanding WCAG 2.2 Key Changes

WCAG 2.2 builds on previous versions with three new success criteria that directly impact code implementation:

Claude Code can help you implement these criteria systematically, catching accessibility issues before they reach production.

Setting Up Your Accessibility-First Workflow

Before writing code, configure Claude Code with accessibility-aware prompts. Create a skill that defines your accessibility requirements:

---
name: accessibility-audit
description: Audit code for WCAG 2.2 compliance
---

When reviewing code for accessibility, check for:
1. Semantic HTML structure (proper heading hierarchy, landmark regions)
2. ARIA attributes used correctly (not as a弥补 for missing semantics)
3. Keyboard navigation support (focusable elements, tab order)
4. Color contrast compliance (4.5:1 for text, 3:1 for UI)
5. Form labels and error handling
6. Focus management for modals and dynamic content

This skill becomes your accessibility reviewer, automatically checking every component you create.

Implementing Accessible Components with Claude Code

Focus Management for Modals

One of the most common accessibility failures involves modal dialogs. Claude Code can generate properly accessible modal components:

// Accessible Modal Component
function Modal({ isOpen, onClose, title, children }) {
  const modalRef = useRef(null);
  const previousFocusRef = useRef(null);

  useEffect(() => {
    if (isOpen) {
      previousFocusRef.current = document.activeElement;
      modalRef.current?.focus();
      document.body.style.overflow = 'hidden';
    } else {
      previousFocusRef.current?.focus();
      document.body.style.overflow = '';
    }
  }, [isOpen]);

  // Trap focus within modal
  useEffect(() => {
    const handleKeyDown = (e) => {
      if (e.key === 'Escape') {
        onClose();
        return;
      }
      if (e.key === 'Tab') {
        const focusable = modalRef.current.querySelectorAll(
          'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'
        );
        const first = focusable[0];
        const last = focusable[focusable.length - 1];
        
        if (e.shiftKey && document.activeElement === first) {
          e.preventDefault();
          last.focus();
        } else if (!e.shiftKey && document.activeElement === last) {
          e.preventDefault();
          first.focus();
        }
      }
    };

    if (isOpen) {
      document.addEventListener('keydown', handleKeyDown);
    }
    return () => document.removeEventListener('keydown', handleKeyDown);
  }, [isOpen, onClose]);

  if (!isOpen) return null;

  return (
    <div 
      role="dialog" 
      aria-modal="true" 
      aria-labelledby="modal-title"
      ref={modalRef}
      tabIndex="-1"
    >
      <h2 id="modal-title">{title}</h2>
      <button onClick={onClose} aria-label="Close modal">
        <span aria-hidden="true">×</span>
      </button>
      {children}
    </div>
  );
}

Ask Claude Code to explain each accessibility feature in this component—it will walk you through the focus trap, aria attributes, and keyboard handling.

Automated Testing for Accessibility

Integrate accessibility testing into your CI/CD pipeline using established tools. Claude Code can help write these tests:

// accessibility.test.js
import { axe, toHaveNoViolations } from 'jest-axe';

expect.extend(toHaveNoViolations);

describe('Accessibility Tests', () => {
  test('Homepage should have no accessibility violations', async () => {
    const { container } = render(<App />);
    const results = await axe(container);
    expect(results).toHaveNoViolations();
  });

  test('Modal should be keyboard accessible', async () => {
    render(<Modal isOpen={true} title="Test Modal" />);
    
    // Verify modal traps focus
    const modal = screen.getByRole('dialog');
    const closeButton = screen.getByLabelText('Close modal');
    
    expect(closeButton).toHaveFocus();
    
    // Test Tab cycles within modal
    await userEvent.keyboard('{Tab}');
    // Focus should cycle back to close button
    expect(closeButton).toHaveFocus();
  });

  test('Form inputs must have associated labels', async () => {
    render(<LoginForm />);
    const inputs = screen.getAllByRole('textbox');
    
    inputs.forEach(input => {
      const label = screen.getByLabelText(input.getAttribute('aria-label') || '');
      expect(label).toBeInTheDocument();
    });
  });
});

Run these tests locally with Claude Code monitoring the output for specific accessibility failures.

Color Contrast Checking Workflow

Claude Code can analyze your color palette for WCAG compliance. Create a simple contrast checker:

// contrast-checker.js
function getContrastRatio(color1, color2) {
  const lum1 = getLuminance(color1);
  const lum2 = getLuminance(color2);
  const lighter = Math.max(lum1, lum2);
  const darker = Math.min(lum1, lum2);
  return (lighter + 0.05) / (darker + 0.05);
}

function getLuminance(hex) {
  const rgb = hexToRgb(hex);
  const [r, g, b] = rgb.map(c => {
    c = c / 255;
    return c <= 0.03928 ? c / 12.92 : Math.pow((c + 0.055) / 1.055, 2.4);
  });
  return 0.2126 * r + 0.7152 * g + 0.0722 * b;
}

// WCAG 2.2 thresholds
const requirements = {
  AA_normal: 4.5,
  AA_large: 3.0,
  AAA_normal: 7.0,
  AAA_large: 4.5,
  UI_components: 3.0
};

function checkCompliance(ratio) {
  return {
    AA_normal: ratio >= requirements.AA_normal,
    AA_large: ratio >= requirements.AA_large,
    AAA_normal: ratio >= requirements.AAA_normal,
    AAA_large: ratio >= requirements.AAA_large,
    UI_components: ratio >= requirements.UI_components
  };
}

Ask Claude Code to generate a comprehensive color audit of your design system—it will check each color combination against these thresholds.

Real-Time Accessibility Review Process

Establish a workflow where Claude Code reviews accessibility before any merge:

  1. Pre-commit hook: Run axe-core on staged files
  2. Pull request review: Claude Code analyzes changed components
  3. CI pipeline: Full accessibility audit with lighthouse
  4. Post-deployment: Automated monitoring for regressions
# .github/workflows/accessibility.yml
name: Accessibility Audit
on: [pull_request]

jobs:
  accessibility:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-node@v3
      - run: npm install
      - run: npm run test:a11y
      - name: Runaxe audit
        run: npx axe https://staging.example.com --exit

Actionable Tips for WCAG 2.2 Compliance

Conclusion

Building WCAG 2.2 compliant applications doesn’t have to be a manual, time-consuming process. By integrating Claude Code into your workflow—with accessibility-focused skills, automated testing, and systematic component patterns—you create a sustainable system that catches issues early and maintains compliance over time.

Start by adding an accessibility skill to your Claude Code configuration, then progressively add automated tests for each component you build. The initial investment pays dividends in reduced remediation costs, broader user reach, and legal compliance.


This guide is part of the Claude Skills Guide series, providing practical workflows for modern web development.

Built by theluckystrike — More at zovo.one