AgentSkillsCN

a11y-audit

针对 WCAG 2.2 AA 标准开展重点无障碍审计。检查 ARIA 最佳实践、语义化 HTML、焦点管理、颜色对比度、键盘导航、跳过链接、替代文本、表单标签以及错误提示。

SKILL.md
--- frontmatter
name: a11y-audit
description: |
  Focused accessibility audit against WCAG 2.2 AA standards. Checks ARIA best
  practices, semantic HTML, focus management, color contrast, keyboard navigation,
  skip links, alt text, form labels, and error announcements.

Accessibility Audit Skill

Deep accessibility audit focused exclusively on WCAG 2.2 AA conformance. This skill provides more detailed a11y analysis than the broader ux-review skill.

Arguments

  • $ARGUMENTS -- File or directory to audit (default: current working directory).

Phase 1: File Discovery

Scan for auditable files:

text
*.html, *.htm, *.jsx, *.tsx, *.vue, *.svelte, *.css, *.scss

Skip node_modules/, dist/, build/, .next/, and vendor directories.


Phase 2: WCAG 2.2 AA Checks

Organize checks by WCAG principle.

Perceivable (WCAG 1.x)

CriterionCheckHow
1.1.1 Non-text ContentAll <img> have alt attributeGrep for <img without alt
1.1.1 Non-text ContentAll <svg> have accessible nameCheck for aria-label, aria-labelledby, or <title>
1.2.2 Captions<video> has <track kind="captions">Grep for <video without track
1.3.1 Info and RelationshipsHeading hierarchy is sequentialParse h1-h6 order per page
1.3.1 Info and RelationshipsTables have <th> and scopeGrep for <table without <th
1.3.5 Input PurposeInputs have autocomplete where applicableCheck login/address forms
1.4.3 Contrast (Minimum)Text has 4.5:1 contrast ratioFlag hardcoded color pairs to review
1.4.4 Resize TextNo font-size in px below 12pxGrep CSS for small px values
1.4.10 ReflowNo horizontal scroll at 320px viewportCheck for fixed widths > 320px
1.4.11 Non-text ContrastUI components have 3:1 contrastFlag border/outline colors for review
1.4.12 Text SpacingNo !important on line-height/letter-spacingGrep CSS
1.4.13 Content on HoverTooltips are dismissible and persistentCheck tooltip implementations

Operable (WCAG 2.x)

CriterionCheckHow
2.1.1 KeyboardAll interactive elements are keyboard-accessibleDetect onClick without onKeyDown or role="button"
2.1.2 No Keyboard TrapFocus is not trapped (except modals)Check for tabindex="-1" patterns
2.4.1 Bypass BlocksSkip-to-content link presentCheck first <a> or <button> in <body>
2.4.2 Page Titled<title> element is present and descriptiveGrep <title>
2.4.3 Focus Ordertabindex values are 0 or -1 (no positive values)Grep for tabindex="[1-9]"
2.4.4 Link PurposeLinks have descriptive text (no bare "click here")Grep for generic link text
2.4.7 Focus Visible:focus or :focus-visible styles definedGrep CSS for focus styles
2.5.3 Label in NameVisible label matches accessible nameFlag aria-label that differs from visible text
2.5.8 Target SizeInteractive elements >= 24x24px (AA)Flag elements with small explicit sizes

Understandable (WCAG 3.x)

CriterionCheckHow
3.1.1 Language<html> has lang attributeGrep for <html without lang
3.2.2 On InputNo unexpected context changes on inputFlag onChange navigation
3.3.1 Error IdentificationForm errors are announcedCheck for aria-live, role="alert", aria-invalid
3.3.2 LabelsAll form controls have labelsCheck <label>, aria-label, aria-labelledby

Robust (WCAG 4.x)

CriterionCheckHow
4.1.2 Name, Role, ValueCustom widgets have correct ARIA rolesCheck custom components for role, aria-*
4.1.3 Status MessagesStatus updates use aria-liveGrep for toast/notification patterns

Phase 3: ARIA Best Practices

Beyond WCAG, check for common ARIA misuse:

IssuePatternSeverity
Redundant roles<button role="button">Low
Invalid role valuesrole="custom-thing"High
Missing required attrsrole="checkbox" without aria-checkedHigh
aria-hidden on focusablearia-hidden="true" with tabindex="0"High
Orphan aria-describedbyaria-describedby pointing to nonexistent IDMedium

Output Format

markdown
## Accessibility Audit Report

**Target**: {path}
**Standard**: WCAG 2.2 AA
**Files scanned**: {count}
**Timestamp**: {ISO-8601}

### Conformance Summary

| Principle | Checks | Pass | Fail | N/A |
|-----------|--------|------|------|-----|
| 1. Perceivable | 12 | 9 | 2 | 1 |
| 2. Operable | 9 | 7 | 1 | 1 |
| 3. Understandable | 4 | 4 | 0 | 0 |
| 4. Robust | 3 | 2 | 1 | 0 |
| ARIA Best Practices | 5 | 4 | 1 | 0 |

### Violations

| WCAG | Severity | File | Line | Issue | Fix |
|------|----------|------|------|-------|-----|
| 1.1.1 | High | Card.tsx | 15 | Image missing alt text | Add descriptive `alt` attribute |
| 2.1.1 | High | Menu.tsx | 42 | `<div onClick>` not keyboard accessible | Use `<button>` or add `onKeyDown` + `role` |
| 2.4.3 | Medium | Nav.tsx | 8 | `tabindex="5"` creates unexpected focus order | Use `tabindex="0"` instead |

### Verdict

- **AA Conformant**: All checks pass
- **Partial**: Some violations found but core navigation works
- **Non-conformant**: Critical violations blocking keyboard/screen reader access

Safety Checks

  • Read-only analysis -- never modify source files
  • Skip minified and bundled files
  • Note checks that require manual verification (color contrast, cognitive load)
  • Cap findings at 100 per file