accessibility-audit
Defines automated WCAG 2.1 Level AA accessibility evaluation rules, DOM audit patterns, and remediation guidance using axe-core for UI components, templates, and web applications.
- License 许可
- AGPL-3.0
- 最近更新
- 2026-11-14
- Stars
- ★ 25
- Forks
- 9
01 前言 Front Matter
- name
- accessibility-audit
- owner
- pm
- scope
- common
- status
- active
- version
- 1.1.0
- metadata
- { "type": "accessibility-testing", "triggers": [ "accessibility-audit", "/accessibility-audit", "axe-core audit", "wcag accessibility check", "wcag 2.1 aa" ] }
- description
- Defines automated WCAG 2.1 Level AA accessibility evaluation rules, DOM audit patterns, and remediation guidance using axe-core for UI components, templates, and web applications.
- l2_propagate
- true
- last_reviewed
- 1794096000000
- prerequisites
- axe-core (^4.9 || ^5.0), JSDOM / Playwright / Puppeteer test runner
03 SKILL.md 正文
♿ Skill: accessibility-audit
Context
In UI/UX design workflows and web development, accessible digital products ensure equal access for users with disabilities while satisfying international compliance mandates (WCAG 2.1 Level AA, Section 508, European Accessibility Act).
accessibility-audit provides automated rules, evaluation engines, test execution patterns, and remediation guidelines using axe-core to continuously audit web applications, DOM structures, and design components against WCAG 2.1 AA standards.
When to Use
Component & UI Audits:
- Trigger: "Run accessibility audit" or "Check WCAG compliance"
- Use Case: Auditing React/HTML UI components for WCAG 2.1 AA violations during component development.
Design System Token & Color Contrast Testing:
- Trigger: "Verify color contrast" or "Audit design tokens"
- Use Case: Ensuring token color pairings meet 4.5:1 text contrast ratios.
CI/CD Pipeline Gates:
- Trigger: "Run accessibility test suite" or "axe-core audit"
- Use Case: Blocking regressions in pull requests using automated Playwright or JSDOM test suites.
Execution Steps
Step 1: Engine & Rule Configuration
Automated audits execute using axe-core configured with WCAG 2.1 AA tags (wcag2a, wcag2aa, wcag21a, wcag21aa).
import axe from "axe-core";
export const AXE_WCAG21AA_CONFIG: axe.RunOptions = {
runOnly: {
type: "tag",
values: ["wcag2a", "wcag2aa", "wcag21a", "wcag21aa"],
},
resultTypes: ["violations", "incomplete"],
};
Step 2: Component Level Testing (JSDOM Environment)
import { JSDOM } from "jsdom";
import axe from "axe-core";
export async function auditHtmlSnippet(html: string): Promise<axe.AxeResults> {
const dom = new JSDOM(`<!DOCTYPE html><html lang="en"><head><title>Audit</title></head><body><main>${html}</main></body></html>`, {
runScripts: "dangerously",
});
const { window } = dom;
const axeScript = require.resolve("axe-core/axe.min.js");
const axeCode = require("fs").readFileSync(axeScript, "utf8");
window.eval(axeCode);
const results = await (window as unknown as { axe: typeof axe }).axe.run(window.document, {
runOnly: {
type: "tag",
values: ["wcag2a", "wcag2aa", "wcag21a", "wcag21aa"],
},
});
return results;
}
Step 3: End-to-End Page Audit (Playwright Integration)
import { test, expect } from "@playwright/test";
import AxeBuilder from "@axe-core/playwright";
test.describe("WCAG 2.1 AA Accessibility Audit", () => {
test("Page should have zero WCAG 2.1 AA violations", async ({ page }) => {
await page.goto("http://localhost:3000");
const accessibilityScanResults = await new AxeBuilder({ page })
.withTags(["wcag2a", "wcag2aa", "wcag21a", "wcag21aa"])
.analyze();
expect(accessibilityScanResults.violations).toEqual([]);
});
});
Step 4: Remediation Execution
Apply standard remediation patterns for detected violations:
- Form Labels: Bind
<label for="id">explicitly to input elements. - Icon Buttons: Add
aria-labelto icon-only interactive controls andaria-hidden="true"to decorative SVGs. - Contrast Ratios: Adjust foreground colors to satisfy >= 4.5:1 (normal text) or >= 3.0:1 (large text).
Output Format
When axe.run() finishes, violations are structured into JSON reports containing failure summaries, DOM selectors, and severity impact metrics:
{
"summary": {
"totalViolations": 1,
"critical": 1,
"serious": 0,
"moderate": 0,
"minor": 0
},
"violations": [
{
"id": "color-contrast",
"impact": "critical",
"tags": ["cat.color", "wcag2aa", "wcag143"],
"description": "Ensures contrast between foreground and background colors meets WCAG 2 AA thresholds",
"help": "Elements must have sufficient color contrast",
"helpUrl": "https://dequeuniversity.com/rules/axe/4.9/color-contrast",
"nodes": [
{
"html": "<button class=\"btn-subtle\" style=\"color: #999; background: #fff;\">Submit</button>",
"target": ["button.btn-subtle"],
"failureSummary": "Fix any of the following:\n Element has insufficient color contrast of 2.84 (expected 4.5:1)"
}
]
}
]
}
Related Skills
- ui-ux-design-intelligence: For design system token definitions and UI component design standards
- service-design: For customer experience touchpoints and inclusive service blueprints
- zod-contract-gate: For schema validation of audit configuration objects and diagnostic reporting DTOs
04 同仓库更多 Skills
discovery
暂无简介
x
暂无简介
root-skill
暂无简介
update-bun-packages
Scans, updates, and upgrades Bun dependencies and packages across the AI workspace (L0) or standalone project (L2/L3) while ensuring lockfile consistency, package.json version bumps, and security compliance. Use when: updating bun dependencies, upgrading packages to @latest, checking outdated packages in workspace or templates.
ui-ux-design-intelligence
Provides comprehensive UI/UX design capabilities including design system creation, component design, visual hierarchy, and user-centered design principles. Use when: building design systems, creating visual designs, designing UI components, or establishing design specifications.
translate
Translation helper for README and documentation files with diff preview and guidance