Wcag 22 audit patterns

From findscripter/everything-skills · View interactive version

Wcag 22 audit patterns is an AI agent skill from the GitHub repository findscripter/everything-skills. 当需要对网页做 WCAG 2.2 无障碍审计或修复违规时使用;先跑自动化扫描再做键盘/读屏人工核验,逐条映射到 WCAG 准则+严重度并给可执行修复(产出 A/AA 审计报告与整改清单);不适用于出具法律合规认证、纯自动扫描无人工复核、或无法访问 UI/源码的场景;触发词:WCAG、无障碍、a11y、可访问性、ADA、Section 508、axe、对比度、读屏、键盘导航

How to use this skill

Skill file

WCAG 2.2 无障碍审计模式

按 WCAG 2.2(A/AA 为主)审计网页内容,并给出可落地的整改方案。围绕 POUR 四原则:可感知(Perceivable)、可操作(Operable)、可理解(Understandable)、健壮(Robust)。

何时使用

不该用的边界:

步骤 / 指令

  1. 自动化扫描:跑 axe / Lighthouse / pa11y / WAVE 收集初筛问题。
  2. 人工核验:键盘走查(仅 Tab/Shift+Tab/Enter/Space/方向键,无鼠标)、焦点顺序、读屏(NVDA/VoiceOver)流程;自动化测不到的项目(焦点可见性、阅读顺序、链接上下文、动态状态播报)靠人工。
  3. 逐条定级:把每个问题映射到 WCAG 准则号 + 等级(A/AA) + 严重度 + 整改建议。严重度参考:
  1. 复测留痕:修复后回归,记录残余风险与合规状态,保留测试步骤与结果作为审计证据链。

关键准则速查(A/AA)

示例

CLI 自动化扫描:

npx @axe-core/cli https://example.com
npx pa11y https://example.com
lighthouse https://example.com --only-categories=accessibility

Playwright 集成 axe-core(CI 门禁):

const results = await page.evaluate(async () =>
  axe.run(document, {
    runOnly: { type: 'tag',
      values: ['wcag2a', 'wcag2aa', 'wcag21aa', 'wcag22aa'] }
  })
);
expect(results.violations).toHaveLength(0);

常见整改:

<!-- 表单缺 label -->
<label for="email">邮箱</label>
<input id="email" type="email" />
<!-- 或 aria-label / aria-labelledby -->

<!-- 跳转链接 -->
<a href="#main" class="skip-link">跳到主内容</a><main id="main">...</main>

<!-- 链接文案在上下文外仍可理解 -->
<a href="report.pdf">下载 Q4 销售报告 (PDF)</a> <!-- 不要用「点这里」 -->
/* 对比度不足 #767676(2.5:1) → #595959(4.5:1) */
.text { color: #595959; }

/* 焦点可见 */
:focus { outline: 3px solid #005fcc; outline-offset: 2px; }

/* 尊重减动偏好 */
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

自定义控件键盘可达(Enter/Space 激活、方向键导航、Esc 关闭),并补 role/tabindex="0"/aria-* 状态。

注意事项

互见


采编自 sickn33/antigravity-awesome-skills(MIT)。

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.