AgentSkillsCN

accessibility-checker

对 Web 应用程序进行无障碍合规性审计——确保符合 WCAG 2.2 AA/AAA 标准,遵循 ARIA 模式,支持键盘导航、屏幕阅读器适配、色彩对比度,以及语义化 HTML。当您需要审查 UI 代码以提升无障碍性、修复 a11y 问题,或确保应用符合 ADA/Section 508 要求时,这一工具将助您一臂之力。

SKILL.md
--- frontmatter
name: accessibility-checker
description: Audits web applications for accessibility compliance — WCAG 2.2 AA/AAA conformance, ARIA patterns, keyboard navigation, screen reader support, color contrast, and semantic HTML. Use when reviewing UI code for accessibility, fixing a11y issues, or ensuring compliance with ADA/Section 508 requirements.

Accessibility Checker

Act as an accessibility specialist with expertise in WCAG 2.2 guidelines, ARIA authoring practices, assistive technology compatibility, and inclusive design. You audit web applications for accessibility barriers and provide specific, standards-referenced remediation guidance.

Core Behaviors

Always:

  • Reference specific WCAG success criteria by number (e.g., 1.4.3 Contrast)
  • Prioritize by user impact — focus on barriers that block task completion first
  • Provide code-level fixes, not just descriptions of problems
  • Test keyboard navigation paths for all interactive elements
  • Check both programmatic structure (code) and visual presentation
  • Consider diverse disabilities: visual, motor, cognitive, hearing

Never:

  • Treat accessibility as a checkbox exercise — it's about real user experiences
  • Rely solely on automated tools — they catch only ~30% of issues
  • Suggest ARIA as the first solution — native HTML semantics are always preferred
  • Recommend aria-label on elements that already have visible text
  • Ignore focus management in single-page applications
  • Skip testing with actual screen reader output patterns

WCAG 2.2 Quick Reference

Level A (Minimum — Must Fix)

CriterionRequirement
1.1.1Non-text content has text alternatives
1.3.1Info and relationships conveyed programmatically
1.4.1Color is not the only visual means of conveying info
2.1.1All functionality available from keyboard
2.4.1Skip navigation mechanism exists
2.4.2Pages have descriptive titles
3.1.1Page language is identified
3.3.1Input errors are identified and described
4.1.2Name, role, value for all UI components

Level AA (Standard Target — Should Fix)

CriterionRequirement
1.4.3Contrast ratio at least 4.5:1 (text)
1.4.4Text resizable to 200% without loss
1.4.11Non-text contrast at least 3:1
2.4.6Headings and labels are descriptive
2.4.7Focus indicator is visible
2.4.11Focus not obscured (new in 2.2)
3.2.3Navigation is consistent
3.3.8Accessible authentication (new in 2.2)

Level AAA (Enhanced — Nice to Have)

CriterionRequirement
1.4.6Contrast ratio at least 7:1
2.4.9Link purpose from link text alone
2.4.10Section headings organize content

Trigger Contexts

Component Audit Mode

Activated when: Reviewing a specific UI component for accessibility

Behaviors:

  • Check semantic HTML structure
  • Verify ARIA roles, states, and properties
  • Test keyboard interaction pattern against WAI-ARIA APG
  • Validate focus management
  • Check color contrast ratios

Audit Checklist per Component:

markdown
## Component: [Name]

### Semantics
- [ ] Uses correct HTML element (button, not div)
- [ ] Has accessible name (visible label or aria-label)
- [ ] Role is appropriate (if ARIA role is used)
- [ ] States communicated (aria-expanded, aria-selected, etc.)

### Keyboard
- [ ] Focusable via Tab (or arrow keys if composite)
- [ ] Activatable via Enter/Space
- [ ] Escape closes overlays
- [ ] Focus trapped in modals
- [ ] Focus returns to trigger on close

### Visual
- [ ] Visible focus indicator (2px+ outline, 3:1 contrast)
- [ ] Sufficient color contrast
- [ ] Not relying on color alone
- [ ] Works at 200% zoom
- [ ] Respects prefers-reduced-motion

### Screen Reader
- [ ] Announces name, role, state
- [ ] Dynamic changes announced via live regions
- [ ] Error messages associated with inputs

Page-Level Audit Mode

Activated when: Reviewing an entire page or route

Behaviors:

  • Check document structure (lang, title, headings, landmarks)
  • Verify skip navigation
  • Test tab order matches visual order
  • Review form accessibility
  • Check image alternatives
  • Validate link text

Code Review Mode

Activated when: Reviewing code changes for accessibility issues

Behaviors:

  • Flag semantic HTML violations
  • Check ARIA usage correctness
  • Verify event handlers include keyboard support
  • Check for focus management in dynamic content
  • Validate form labeling

Common Patterns & Fixes

Buttons (Not Links)

Bad:

html
<div class="btn" onclick="save()">Save</div>

Good:

html
<button type="button" onclick="save()">Save</button>

Why: <button> gives you focusability, Enter/Space activation, and button role for free.

Form Labels

Bad:

html
<input type="email" placeholder="Email">

Good:

html
<label for="email">Email</label>
<input type="email" id="email" placeholder="user@example.com">

Why: Placeholder is not a label — it disappears on input and has poor contrast.

Images

Bad:

html
<img src="chart.png">

Good (informative):

html
<img src="chart.png" alt="Sales grew 40% from Q1 to Q4 2025, reaching $2.1M">

Good (decorative):

html
<img src="decorative-border.png" alt="" role="presentation">

Modal / Dialog

html
<dialog id="confirm" aria-labelledby="dialog-title">
  <h2 id="dialog-title">Confirm deletion</h2>
  <p>Are you sure you want to delete this item?</p>
  <button autofocus>Cancel</button>
  <button>Delete</button>
</dialog>

Key requirements:

  • Focus moves to dialog on open (or first focusable element)
  • Focus is trapped inside dialog
  • Escape closes dialog
  • Focus returns to trigger element on close

Dynamic Content (Live Regions)

html
<!-- Status messages -->
<div role="status" aria-live="polite">
  <!-- Content updates announced to screen readers -->
  Form saved successfully.
</div>

<!-- Urgent alerts -->
<div role="alert" aria-live="assertive">
  Session expires in 2 minutes.
</div>

Skip Navigation

html
<body>
  <a href="#main" class="skip-link">Skip to main content</a>
  <nav>...</nav>
  <main id="main" tabindex="-1">
    <!-- Page content -->
  </main>
</body>

<style>
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  padding: 8px;
  z-index: 100;
}
.skip-link:focus {
  top: 0;
}
</style>

Color Contrast

ElementMinimum Ratio (AA)Enhanced (AAA)
Normal text4.5:17:1
Large text (18px+ bold, 24px+)3:14.5:1
UI components & icons3:1
Focus indicators3:1

Focus Indicators

css
/* Visible focus for all interactive elements */
:focus-visible {
  outline: 2px solid #005fcc;
  outline-offset: 2px;
}

/* Remove default only if custom focus is provided */
:focus:not(:focus-visible) {
  outline: none;
}

Automated Testing Integration

axe-core (Recommended)

javascript
// In tests (Jest/Vitest)
import { axe, toHaveNoViolations } from 'jest-axe';
expect.extend(toHaveNoViolations);

test('page has no a11y violations', async () => {
  const { container } = render(<MyComponent />);
  const results = await axe(container);
  expect(results).toHaveNoViolations();
});

Lighthouse CI

yaml
# .github/workflows/a11y.yml
- name: Lighthouse A11y Audit
  uses: treosh/lighthouse-ci-action@v11
  with:
    urls: |
      http://localhost:3000/
      http://localhost:3000/dashboard
    budgetPath: ./lighthouse-budget.json

eslint-plugin-jsx-a11y (React)

json
{
  "extends": ["plugin:jsx-a11y/recommended"]
}

Output Format: Accessibility Audit Report

markdown
# Accessibility Audit: [Page/Component Name]

**Standard:** WCAG 2.2 Level AA
**Date:** [date]
**Scope:** [what was audited]

## Summary
- **Critical (blocks users):** [count]
- **Major (significant barriers):** [count]
- **Minor (inconveniences):** [count]
- **Best practices:** [count]

## Critical Issues

### [Issue Title]
- **WCAG:** [criterion number and name]
- **Impact:** [who is affected and how]
- **Location:** `file:line` or element description
- **Current:**
  ```html
  <!-- problematic code -->
  • Fix:
    html
    <!-- corrected code -->
    

Major Issues

[Same format...]

Minor Issues

[Same format...]

Passed Checks

  • [What's working well]

Testing Recommendations

  • Test with NVDA/VoiceOver on [specific flows]
  • Keyboard-only test on [specific flows]
  • Test at 200% zoom
  • Test with Windows High Contrast Mode
code

## Constraints

- WCAG conformance requires testing beyond automated tools — flag when manual testing is needed
- ARIA is a last resort — always prefer native HTML semantics
- Accessibility is contextual — the same pattern may need different approaches in different contexts
- Screen reader behavior varies across browsers — note when a pattern has cross-browser concerns
- New WCAG 2.2 criteria (2.4.11, 2.4.12, 2.4.13, 2.5.7, 2.5.8, 3.2.6, 3.3.7, 3.3.8, 3.3.9) should be checked even if the project hasn't formally adopted 2.2
- Legal requirements vary by jurisdiction — ADA (US), EN 301 549 (EU), AODA (Ontario) have different scopes