You shipped a small app in a weekend, mostly built by your coding agent, and it looks fine on your phone. Try tabbing through it and half the buttons never get focus, and a screen reader reads your icon row as "button, button, button." Those are people your app quietly shuts out, and every week the issues stay, the fix gets bigger.
The fix isn't a prompt that says "make it accessible." That ask is a vibe, and the agent answers it with scattered edits you can't verify. What works is a loop the agent can actually close: run an automated checker on the real page, hand it the findings one rule at a time, make it apply the smallest fix for each element, then add a test that fails if the issues ever come back. The parts no checker can see take you five minutes with a keyboard, and that's it.
What usually breaks in AI-built UIs
The same shortlist shows up in almost every agent-built app, because the model optimizes for what it can see: pixels. Icon buttons with no accessible name, so an SVG hamburger reads as just "button." Images with no alt text. A div with a click handler doing a button's job, which means Enter and Space do nothing. Inputs with placeholder text but no real label. Text that lands at 3:1 contrast on a gray background. And the classic: outline: none on :focus with nothing put back in its place, so keyboard users navigate blind.
The WCAG 2.2 quick reference lists each of these as a named rule with the exact criteria. That matters more than it sounds: when you and your agent share the same definition of done, "fix it" becomes a checkable sentence instead of a mood.
Get a findings list, not a request
Don't describe the problem to the agent. Show it the problem. Two tools do this in minutes.
The first is axe-core, an open-source accessibility engine you can run in tests or with its browser extension on any page. Be honest about what it covers: the axe-core README states you can find on average 57% of WCAG issues automatically, and it marks items "incomplete" where it can't be certain and a human needs to look. So the checker gives your agent a real to-do list, not a guarantee.
The second is Lighthouse, built into Chrome DevTools: open the Lighthouse panel, run it with the Accessibility category checked, and you get a scored report with the failing rules named. The Lighthouse accessibility docs explain how the score works and what each failure means.
Either way, the output should be a list where every row names a rule, a file, and an element. That's the format an agent can act on.
Fix one rule at a time, the boring way
Dumping 40 findings into one prompt gets you a big speculative diff. Instead, paste the findings grouped by rule and fix them one category at a time. Tell the agent two things explicitly: make the smallest fix per element, and prefer native HTML elements over ARIA.
Native first isn't a style preference, it's the actual written rule. The W3C's first rule of ARIA says don't use ARIA if a native HTML element already provides the semantics and behavior you need. A real <button> gets keyboard handling, focus, and its role for free. A div with role="button" and a keyboard handler bolted on is three lines of ARIA replacing one tag.
So the instructions read like: "For every violation of the button-name rule, add an aria-label or visible text, change nothing else. For every unlabeled input, add a <label> tied to the input with for/id. Replace clickable divs with <button> where one exists." Small diffs per rule are easy to review and easy to roll back.
Add one test so it stays fixed
Here's the part most people skip, and it's why accessibility regressions keep coming back. The agent fixes everything today, then next week you ask for a new feature and the model reintroduces an icon button with no name, because nothing was watching.
Stop that with one automated test in the suite. Playwright has a documented accessibility-testing integration built on axe, and it takes about ten lines:
import { test, expect } from '@playwright/test';
import AxeBuilder from '@axe-core/playwright';
test('no obvious accessibility issues', async ({ page }) => {
await page.goto('http://localhost:3000');
const results = await new AxeBuilder({ page }).analyze();
expect(results.violations).toEqual([]);
});
Now "make it accessible" is enforced by your CI, not by memory. The agent literally cannot reintroduce a violation without the test going red and telling it why.
The five-minute manual pass
Automated checks only find part of the problems (remember the axe-core figure above), so cover what they can't. Five minutes, once, per page:
- Tab through the page. Can you reach every control, and can you always see where focus is? If the focus ring was removed, that's your first fix.
- Press Enter and Space on every control. Anything that ignores them is a
divpretending to be a button. - Zoom to 200%. If content is cut off or overlapping, contrast and layout have real problems.
- Read the alt text out of context. "image1" and "hero" tell a screen reader user nothing.
Contrast deserves its own pass, and we wrote a 2-minute color contrast test you can run before you ship anything.
The prompt to paste
Here's the whole workflow as one prompt. Paste it with your page running locally:
You are fixing accessibility issues on this app. Run axe-core
against every page and route (use @axe-core/playwright in the
existing test setup). Then fix the findings one RULE AT A TIME,
in this order: button-name, image-alt, label, link-name,
color-contrast. Then fix clickable <div>s and removed focus
outlines, which the scanner may not flag.
Rules for every fix:
- Smallest change that fixes that one element. No refactoring.
- Prefer native HTML elements over ARIA: a real <button>,
a real <label>. ARIA only when no native element exists.
- Do not touch layout, styles, or anything not named in the
current rule's findings.
After each rule: run the accessibility test suite, show me the
remaining violations, then move to the next rule.
Checklist before you claim done:
[ ] Every icon button has an accessible name
[ ] Every image has alt text (empty alt "" is valid for
decorative images)
[ ] Every interactive element is a <button>, <a>, <input>,
<select> or <textarea>
[ ] Every input has a <label> connected by for/id
[ ] No focus outline removed without a visible replacement
[ ] `npx playwright test` passes with the a11y test included
If you don't have an agent setup yet, you can try the zcode agent harness free and run this loop end to end. And if your agent sessions start stacking up daily, there's 10% off GLM coding plans.
The pattern generalizes beyond accessibility, too. Anywhere your agent can't self-verify, it guesses. Give it a checker it can run, findings it can act on, and a test that holds the line, and suddenly the vague "make it better" becomes work it can actually finish.
There's more on our blog on getting agents to check their own work.
If this saved you an afternoon, a tip on this post is always appreciated.






Latest comments
0