Accessibility wcag audit

From findscripter/everything-skills · View interactive version

Accessibility wcag audit is an AI agent skill from the GitHub repository findscripter/everything-skills. 当需要对 Web/移动端做无障碍(a11y)WCAG 合规审计、定位障碍并给出修复方案时使用;做自动化扫描+键盘/读屏/对比度手动核查、映射到 WCAG 准则并产出违规清单与修复指引;不适用于不涉及无障碍的通用 UI 评审或无法访问页面/设计稿的场景。触发词:无障碍、WCAG、a11y、axe、读屏、对比度

How to use this skill

Skill file

何时使用

适用:

不该用(负边界):

步骤

  1. 确认范围:平台、目标 WCAG 级别(A/AA/AAA)、待测页面、关键用户旅程。
  2. 自动化扫描:用 axe-core 跑基线,收集违规与覆盖缺口。
  3. 人工核查:键盘可达性、屏幕阅读器、焦点顺序、色彩对比度(自动化只能覆盖约 30%-50%,人工不可省)。
  4. 映射归因:把每条发现对应到具体 WCAG 准则、严重级别(critical/serious/moderate/minor)与用户影响。
  5. 给出修复:逐项整改步骤;修复后回归复测。
  6. 产出:无障碍评分、违规报告、测试结果、整改指南、可访问组件示例。

指令

import { render } from "@testing-library/react";
import { axe, toHaveNoViolations } from "jest-axe";
expect.extend(toHaveNoViolations);

it("should have no violations", async () => {
  const { container } = render(<MyComponent />);
  expect(await axe(container)).toHaveNoViolations();
});

示例

CI 集成(GitHub Actions 关键步骤):

name: Accessibility Tests
on: [push, pull_request]
jobs:
  a11y-tests:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-node@v3
        with: { node-version: "18" }
      - run: npm ci && npm run build
      - run: npm start & npx wait-on http://localhost:3000
      - run: npm run test:a11y
      - run: npx pa11y http://localhost:3000 --standard WCAG2AA --threshold 0

常见整改片段:

// 补缺失 alt(装饰图置空)
document.querySelectorAll("img:not([alt])").forEach((img) => {
  const decorative = img.role === "presentation" || img.closest('[role="presentation"]');
  img.setAttribute("alt", decorative ? "" : img.title || "Image");
});
// 用 placeholder 兜底补 aria-label
document.querySelectorAll("input:not([aria-label]):not([id])").forEach((i) => {
  if (i.placeholder) i.setAttribute("aria-label", i.placeholder);
});

注意事项

互见


采编自 sickn33/antigravity-awesome-skills(MIT),原技能 accessibility-compliance-accessibility-audit,已适配重写。

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.