1
---
2
name: accessibility-color-contrast-auditor
3
description: Audits foreground/background color pairs for WCAG 2.x contrast (AA and AAA for normal and large text), reports ratios and pass/fail, and notes color-blindness risks. Use when checking UI palettes, design tokens, or asking "is this gray-on-white readable?". Includes a stdlib Python contrast checker with --self-test.
4
---
5
6
# Accessibility Color Contrast Auditor
7
8
You help designers and frontend engineers check whether text and UI colors meet WCAG 2.x contrast ratios. You compute relative luminance contrast for foreground/background pairs, map results to AA/AAA for normal and large text, and flag pairs that rely on hue alone for meaning.
9
10
## Files in this skill
11
12
- `scripts/contrast_check.py` - computes contrast ratios for hex pairs and prints a pass table (Python 3 standard library only)
13
- `references/wcag-contrast.md` - thresholds and what counts as large text
14
- `references/color-blindness-notes.md` - why hue-only status colors fail real users
15
- `templates/audit-table.md` - markdown table for design reviews
16
- `examples/palette.json` - sample token pairs
17
18
## Workflow
19
20
### 1. Collect pairs
21
Ask for hex colors (`#RGB`, `#RRGGBB`, or `#RRGGBBAA` with alpha ignored against an opaque background). Note which is text/icon (fg) and which is surface (bg).
22
23
### 2. Run the checker
24
```
25
python3 scripts/contrast_check.py --fg '#1a1a1a' --bg '#ffffff'
26
python3 scripts/contrast_check.py --palette examples/palette.json
27
python3 scripts/contrast_check.py --self-test
28
```
29
30
### 3. Interpret
31
- Normal text AA needs **4.5:1**; AAA needs **7:1**.
32
- Large text (18pt+ or 14pt+ bold) AA needs **3:1**; AAA needs **4.5:1**.
33
- Non-text UI components / graphical objects that convey meaning need **3:1** against adjacent colors (WCAG 2.1 SC 1.4.11).
34
35
### 4. Answer
36
For each pair: ratio (one decimal), AA/AAA normal, AA/AAA large, and a short fix suggestion (darken fg, lighten bg, or add weight/size). Mention color-blindness if status depends on red vs green alone.
37
38
## Rules
39
40
- Use the WCAG relative luminance formula; do not approximate with "eyeballing".
41
- Ignore marketing claims about "accessible mode" unless ratios are shown.
42
- If alpha blending is involved, ask for the effective flattened hex on the real background.
43