Skip to main content

Claude Code Prompt to Fix WCAG Accessibility Violations

Scan every view and component for WCAG 2.1 failures, then generate exact code fixes with ARIA attributes, semantic HTML, and keyboard navigation.

Fill in the placeholders

Edit the values, then copy your finished prompt.

Your Prompt
prompt.txt
You are a WCAG 2.1 accessibility expert. Audit every view and component in this Laravel Blade + Tailwind CSS project for accessibility violations.

**Scan Scope:**
- All template files in resources/views/
- All component files in resources/views/components/
- Any inline HTML returned from controllers or helpers
- CSS/Tailwind classes that affect visibility and interaction

**Level AA Audit Checklist:**

1. **Images & Media:**
   - Every `<img>` must have meaningful `alt` text (not filename-based)
   - Decorative images must have `alt=""` and `role="presentation"`
   - Videos must reference captions/transcripts
   - SVG icons must have `aria-hidden="true"` or `<title>` + `aria-labelledby`

2. **Forms & Inputs:**
   - Every input must have an associated `<label>` (not just placeholder text)
   - Required fields must use `aria-required="true"`
   - Error messages must be linked with `aria-describedby`
   - Form groups must use `<fieldset>` and `<legend>`
   - Custom selects/dropdowns must implement ARIA combobox or listbox pattern

3. **Navigation & Structure:**
   - Proper heading hierarchy (no skipped levels, one `<h1>` per page)
   - Skip-to-content link as first focusable element
   - Landmark roles: `<nav>`, `<main>`, `<aside>`, `<footer>`
   - Breadcrumbs must use `<nav aria-label="Breadcrumb">` with `<ol>`
   - Mobile menus must trap focus and handle Escape key

4. **Interactive Elements:**
   - All clickable non-link elements must have `role="button"` and `tabindex="0"`
   - Keyboard event handlers for Enter and Space on custom buttons
   - Modals must trap focus, return focus on close, use `role="dialog"` + `aria-modal`
   - Dropdown menus must support Arrow keys, Escape, Home/End
   - Accordion panels must use aria-expanded and aria-controls

5. **Color & Contrast:**
   - Flag any text that may fail 4.5:1 for normal text, 3:1 for large text contrast ratio
   - Identify information conveyed by color alone (needs secondary indicator)
   - Check focus indicators are visible (not `outline: none` without replacement)

**Output Format:**
For each violation, generate:
```
File: <path>
Line: <number>
Rule: <WCAG criterion, e.g., 1.1.1 Non-text Content]
Severity: Critical | Major | Minor
Current code: <snippet>
Fixed code: <snippet with ARIA/semantic fix>
```

End with a summary: total violations by severity, estimated fix time, and a compliance percentage score.

What this prompt does

This prompt turns Claude Code into a WCAG 2.1 auditor that reads your actual codebase instead of one pasted snippet. You point it at your [framework], your [view_directory], and your [component_directory], and it walks every template, every component, the inline HTML your controllers and helpers echo out, and the Tailwind or CSS classes that affect visibility and focus. Nothing gets skipped because you forgot to paste it.

It works because the checklist is structured the way an accessibility engineer actually audits: images and media, forms and inputs, navigation and document structure, interactive widgets, then color and contrast. Each item maps to a concrete failure mode — a placeholder masquerading as a label, a div with a click handler and no keyboard path, a modal that never traps focus — not a vague rule number. The [compliance_level] variable scopes the run to A, AA, or AAA, so you are not drowning in AAA findings when you only owe AA.

The output is what saves the hours. Every violation returns the file, the line, the exact WCAG criterion, a severity, the current code, and the fixed code, then a summary with counts by severity, an estimated fix time, and a compliance score. You get a prioritized, paste-ready punch list, not an essay.

When to use it

  • Before a compliance deadline or formal accessibility audit, while there is still time to ship the fixes.
  • When you inherit a legacy codebase and need a fast map of where the accessibility debt actually lives.
  • After building custom interactive components — modals, dropdowns, comboboxes — the things screen readers and keyboards reliably break on.
  • When Lighthouse or axe flags a score but hands you no corrected markup.
  • As a recurring pass over the view layer so regressions get caught before users hit them.
  • When onboarding a team to ARIA patterns and you want real before/after examples from your own code.

Example output

File: resources/views/components/newsletter-form.blade.php
Line: 14
Rule: 1.3.1 Info and Relationships (Level A)
Severity: Critical
Current code:
  <input type="email" placeholder="Your email" class="...">
Fixed code:
  <label for="nl-email" class="sr-only">Email address</label>
  <input id="nl-email" type="email" name="email"
         aria-required="true" placeholder="Your email" class="...">

File: resources/views/components/mobile-menu.blade.php
Line: 8
Rule: 4.1.2 Name, Role, Value (Level A)
Severity: Major
Current code:
  <div @click="open = !open">☰</div>
Fixed code:
  <button type="button" @click="open = !open"
          :aria-expanded="open" aria-controls="mobile-nav"
          aria-label="Toggle menu">☰</button>

— Summary —
Critical: 3  Major: 7  Minor: 5
Estimated fix time: ~2.5 hours
Compliance score (AA): 82%

Pro tips

  • Scope the directories tightly. Setting [view_directory] and [component_directory] to your real paths (e.g. resources/views) keeps the audit fast and stops it inventing files. Broad scopes produce noise; narrow ones produce a punch list.
  • Match [contrast_ratio] to your level. Pass 4.5:1 for AA body text or 3:1 for large text and UI; do not leave it implied. Note the model flags likely contrast failures from class names — verify the borderline ones in a real contrast tool.
  • Spend the [additional_pattern] slot. This is where app-specific widgets go: a date picker, a Livewire modal, a custom file uploader. Naming your real components gets you targeted ARIA fixes instead of generic boilerplate.
  • Treat the compliance score as relative, not certified. It is a triage signal for tracking progress run-to-run — it is not a legal conformance statement, and a static read cannot fully judge focus order or live-region behavior.
  • Pair it with a runtime checker. This prompt sees source and writes the fixes; axe-core or Lighthouse catches computed contrast and dynamic states. Use the prompt for the corrected markup, the automated tool to confirm it in the rendered DOM.

Frequently Asked Questions

Does this prompt actually scan my whole project, or just code I paste in?
It is written to audit your codebase in place. It targets the framework, view directory, and component directory you specify and walks templates, components, inline HTML returned from controllers and helpers, and visibility/focus-related CSS or Tailwind classes — so coverage does not depend on what you remembered to paste. In practice the tool reads what it can access in your session, so point the directory variables at real paths for the fullest sweep.
What is the difference between the A, AA, and AAA compliance levels here?
The compliance level you set scopes how strict the audit is. Level A catches the blocking basics (missing labels, no keyboard access, images with no alt). AA — the level most legal and procurement standards require — adds contrast thresholds, focus visibility, and consistent navigation. AAA is the strictest tier and usually targeted only for specific flows. Set it to AA unless you have a reason not to, so you fix what matters without drowning in AAA-only findings.
Can I trust the compliance percentage and fix-time estimates it reports?
Treat them as triage signals, not guarantees. The percentage is useful for tracking progress between runs and ranking severity, but it is not a certified conformance score — a static source read cannot fully evaluate focus order, live regions, or computed color contrast at runtime. Use the generated fixes as your starting point, then confirm with a runtime checker like axe-core or Lighthouse and real keyboard and screen-reader testing before claiming conformance.
Engr Mejba Ahmed

Need this built for real?

Engr Mejba Ahmed

AI Developer · Software Engineer

I'm Mejba — I design and ship production AI systems, automations, and full-stack apps. If you want this turned into a working solution for your team, let's talk.

More in Claude Code Prompts

Engr Mejba Ahmed

Engr Mejba Ahmed

AI assistant · trained on my work

👋

Hey there!

Quick Actions

WhatsApp Direct line to me

Chat on WhatsApp

+880 1723 741224 · Replies within the hour on working days

Popular Questions

Engr Mejba Ahmed is connected
Engr Mejba Ahmed is typing...
Engr Mejba Ahmed avatar

✉ Want me to follow up? Drop your email

Engr Mejba Ahmed avatar

📞 Connect Directly

Choose how you'd like to reach me

WhatsApp

+880 1723 741224

Email

mejba.13@gmail.com

✓ Details sent! I'll get back to you shortly.

Powered by OpenAI

335+

Blog Posts

25

AI Courses

63

Projects

Services & Expertise

Pricing & Process

Learning & Resources

Connect & Support