setup-accessibility
Setup Accessibility
What This Sets Up
PostToolUse hook on Edit/Write catching accessibility anti-patterns in TSX/JSX:
- Ban
<img>withoutalt— images must havealttext (usealt=""for decorative images) - Ban mouse-only event handlers —
onClickon non-interactive elements (<div>,<span>) requiresrole,tabIndex, andonKeyDown/onKeyUp - Ban missing ARIA attributes on widget roles —
role="combobox"needsaria-expanded+aria-controls,role="dialog"needsaria-label/aria-labelledby,role="tablist"needs childrole="tab"elements
Also includes:
- Playwright AXE test setup for automated WCAG 2.1 AA scanning
- ARIA Patterns Reference — correct markup for combobox, tabs, dialog, accordion, and more
Steps
1. Install Playwright AXE
bun add -D @axe-core/playwright --yarn
2. Create hook script
Copy scripts/accessibility-check.sh and scripts/_hook-lib.sh into .claude/hooks/. Make executable.
3. Configure hook in .claude/settings.json
Add to hooks config: PostToolUse (matcher: Edit|Write): .claude/hooks/accessibility-check.sh
4. Create accessibility test helper
Write the test fixture from REFERENCE.md into your test utilities.
5. Verify
- Hook blocks
<div onClick>withoutrole+tabIndex+ keyboard handler - Hook blocks
<img>withoutalt - Hook blocks
role="combobox"withoutaria-expanded - Hook skips non-TSX/JSX files
-
@axe-core/playwrightis installed - Accessibility test helper runs against a sample page
6. Commit
Stage all files and commit: Add accessibility enforcement hook + Playwright AXE setup
More from malinskibeniamin/skills
setup-react-rules
Enforce React/TS/security rules via PostToolUse hooks — bans raw HTML, TS escape hatches, XSS vectors, barrel imports, missing passive listeners. Use when enforcing React patterns or component library standards.
9setup-react-compiler
Install React Compiler with rsbuild and enforce compiler-friendly patterns via PostToolUse hooks. Flags manual memoization, derived state, useRef cache. Use when setting up React Compiler or post-compiler patterns.
9setup-biome
Install Biome linter with Ultracite preset, create biome.jsonc config, and configure Claude Code Stop hook for auto-fix before finishing. Use when setting up linting, formatting, Biome, Ultracite, or code quality enforcement.
9setup-quality-gate
Add quality:gate package.json script for fast local/CI quality checks (biome + tsgo + related tests), GitHub Actions workflow, and Stop hook for type checking. Use when setting up quality gates, CI pipelines, or pre-push validation.
9setup-connect-query
Enforce ConnectRPC + Connect Query + Protobuf v2 patterns via PostToolUse hooks. Bans raw useQuery, empty invalidateQueries, $typeName literals. Use when setting up ConnectRPC, protobuf type safety, or data fetching enforcement.
8work-automation-kit
Install planning and project management skills — PRD creation, implementation planning, issue breakdown, bug triage, code review. Use when setting up project planning workflows or creating PRDs.
8