WCAG 2.2 AA Checker — Agent Prompt Reference

Reusable prompt definitions, output schema, and fix patterns for wiring WCAG 2.2 AA checks into any AI agent.


This page provides ready-to-use prompt definitions for integrating WCAG 2.2 AA accessibility checking into any AI agent, CI/CD pipeline, or development workflow.


System Prompt

Copy this directly into any LLM's system message:

You are an expert WCAG 2.2 accessibility auditor. When given HTML source or a URL,
perform a thorough structural analysis covering WCAG 2.2 Level A and AA success
criteria that can be evaluated without JavaScript execution.

For each detected violation, provide:
- WCAG criterion ID (e.g. 1.1.1, 2.5.8), level (A / AA), and principle
- Impact severity: critical | serious | moderate | minor
- Affected HTML element snippets
- Specific code fix with before/after example
- Link to the WCAG 2.2 Understanding document

Calculate an accessibility score (0–100):
- Start at 100
- Critical issues: −15 each (cap −45)
- Serious issues: −8 each (cap −32)
- Moderate issues: −4 each (cap −16)
- Minor issues: −2 each (cap −8)

After listing issues, write a 150–300 word expert commentary covering:
1. Executive summary (2 sentences)
2. Top 3 highest-priority issues and their user impact
3. One inline code fix for the most critical issue
4. Estimated effort to reach AA compliance

Always disclose that static analysis covers ~30–40% of WCAG 2.2 AA criteria and
that manual testing is required for keyboard behavior, color contrast (CSS-based),
focus order, and dynamic content.

Return ONLY valid JSON matching the WcagReport schema (no prose outside JSON).

WCAG 2.2 — What's New in 2.2

Six new Success Criteria were added in WCAG 2.2 (October 2023). All six are required for Level AA conformance:

CriterionTitleImpact
2.4.11Focus Not Obscured (Minimum)Sticky headers must not fully cover focused elements
2.4.12Focus Not Obscured (Enhanced)Focused component not obscured at all
2.4.13Focus AppearanceFocus indicator ≥2px, sufficient contrast
2.5.7Dragging MovementsDrag actions need single-pointer alternative
2.5.8Target Size (Minimum)Interactive targets ≥24×24 CSS pixels
3.3.7Accessible AuthenticationNo CAPTCHA without an accessible alternative

Output Schema

{
  "url": "string",
  "timestamp": "ISO-8601",
  "score": 0-100,
  "complianceLevel": "fail | A | AA",
  "issues": [
    {
      "id": "1.1.1",
      "principle": "perceivable | operable | understandable | robust",
      "level": "A | AA",
      "impact": "critical | serious | moderate | minor",
      "title": "Non-text Content",
      "description": "string",
      "elements": ["<img src=\"...\">"],
      "howToFix": "string",
      "wcagUrl": "https://www.w3.org/WAI/WCAG22/Understanding/...",
      "count": 1,
      "isNew22": false
    }
  ],
  "passed": ["string"],
  "criticalCount": 0,
  "seriousCount": 0,
  "moderateCount": 0,
  "minorCount": 0,
  "pageTitle": "string | null",
  "htmlLang": "en | null",
  "metadata": {
    "totalLinks": 0,
    "totalImages": 0,
    "totalForms": 0,
    "totalButtons": 0,
    "hasH1": true,
    "headingLevels": "h1,h2,h3"
  },
  "aiCommentary": "string",
  "disclaimer": "string"
}

Tool Definition (Vercel AI SDK)

import { tool } from "ai";
import { z } from "zod";

const analyzeWcag = tool({
  description:
    "Fetch a web page and run WCAG 2.2 Level AA accessibility checks. " +
    "Returns a structured JSON report with issue list, severity counts, and score.",
  inputSchema: z.object({
    url: z.string().url().describe("The URL to analyze"),
    maxElementsPerIssue: z
      .number().int().min(1).max(10).optional().default(5)
      .describe("Max HTML snippets to include per issue"),
  }),
  execute: async ({ url }) => {
    const res = await fetch(url, {
      headers: { "User-Agent": "WCAG-Checker/1.0" },
    });
    const html = await res.text();
    // Run checks — see /app/api/agent/wcag/route.ts for full implementation
    return { url, timestamp: new Date().toISOString() };
  },
});

Tool Definition (OpenAI / Claude)

{
  "type": "function",
  "function": {
    "name": "analyzeWcag",
    "description": "Run WCAG 2.2 Level AA accessibility checks on a web page.",
    "parameters": {
      "type": "object",
      "properties": {
        "url": { "type": "string", "description": "The URL to analyze" }
      },
      "required": ["url"]
    }
  }
}

Common Fix Patterns

1.1.1 — Missing alt Text

<!-- ❌ -->
<img src="hero.jpg">

<!-- ✅ Informative image -->
<img src="hero.jpg" alt="Team collaborating in a bright office">

<!-- ✅ Decorative image -->
<img src="divider.png" alt="" role="presentation">

1.3.1 — Missing Form Labels

<!-- ❌ -->
<input type="email" placeholder="Email">

<!-- ✅ -->
<label for="email">Email address</label>
<input type="email" id="email" autocomplete="email">

<!-- ✅ aria-label alternative -->
<input type="search" aria-label="Search products" placeholder="Search...">
<!-- Add as the very first focusable element -->
<a href="#main"
   class="sr-only focus:not-sr-only focus:absolute focus:top-4 focus:left-4
          focus:z-50 focus:px-4 focus:py-2 focus:bg-white focus:text-black">
  Skip to main content
</a>
<main id="main">...</main>

2.4.11 — Focus Obscured by Sticky Header (WCAG 2.2)

html {
  scroll-padding-top: 64px; /* match sticky header height */
}

2.5.8 — Small Click Target (WCAG 2.2)

/* Expand hit area without changing visual size */
.icon-btn {
  position: relative;
  padding: 10px;         /* min total area 24×24px */
  min-width: 24px;
  min-height: 24px;
}

3.3.7 — CAPTCHA Without Alternative (WCAG 2.2)

<!-- Provide multiple authentication paths -->
<fieldset>
  <legend>Verify your identity</legend>
  <label><input type="radio" name="verify" value="email"> Email OTP</label>
  <label><input type="radio" name="verify" value="sms"> SMS OTP</label>
  <label><input type="radio" name="verify" value="captcha"> Visual CAPTCHA</label>
</fieldset>

4.1.2 — Button Without Accessible Name

<!-- ❌ -->
<button><svg>...</svg></button>

<!-- ✅ -->
<button aria-label="Close dialog">
  <svg aria-hidden="true" focusable="false">...</svg>
</button>

CI/CD Integration

# .github/workflows/wcag.yml
- name: WCAG Accessibility Check
  run: |
    TASK=$(curl -s -X POST https://dev.solokit.run/api/sandbox/dispatch \
      -H "Content-Type: application/json" \
      -d "{\"type\":\"wcag\",\"url\":\"${{ env.PREVIEW_URL }}\"}" \
      | jq -r '.taskId')

    for i in $(seq 1 40); do
      R=$(curl -s "https://dev.solokit.run/api/sandbox/tasks/$TASK")
      S=$(echo "$R" | jq -r '.status')
      case "$S" in done|failed|timeout) break;; esac
      sleep 3
    done

    CRITICAL=$(echo "$R" | jq -r '.result.report.issues[]? | select(.impact=="critical") | .title' | wc -l)
    if [ "$CRITICAL" -gt 0 ]; then
      echo "❌ $CRITICAL critical WCAG issues found"
      echo "$R" | jq -r '.result.report.issues[]? | select(.impact=="critical") | " - \(.title)"'
      exit 1
    fi
    echo "✅ WCAG check passed"

Field definitions are in the API Reference.


Resources