Accessibility basics

From makifbaysal/tasktrooper · View interactive version

Accessibility basics is an AI agent skill from the GitHub repository makifbaysal/tasktrooper. Use on every UI change - semantic HTML, labels for controls, keyboard-navigable dialogs/menus, visible focus, and never color as the only signal

How to use this skill

Skill file

Accessibility Basics

Overview

Accessibility is not a pass at the end — it's built into each component. The recurring defects are div with onClick instead of a button, icon buttons with no label, and custom menus/dialogs that trap keyboard users.

Core principle: Semantic HTML and the accessible primitives do most of the work — reach for them first.

Rules

Worked Example

// ❌ not keyboard-accessible, no role, no label
<div className="icon-btn" onClick={onDelete}><TrashIcon /></div>

// ✅ real button, labeled, gets focus + Enter/Space for free
<button type="button" aria-label="Delete task" onClick={onDelete}>
  <TrashIcon aria-hidden />
</button>

The button is focusable and keyboard-activatable with no extra code; the aria-label gives screen readers the action; aria-hidden on the icon stops it being announced twice.

Proving keyboard behaviour

There is no keyboard-press browser tool at runtime (browser_click/browser_fill only) — prove tab order, Escape, and focus-return in a co-located RTL component test instead of a manual browser pass:

test("closes on Escape and returns focus to the trigger", async () => {
  const user = userEvent.setup();
  render(<MenuExample />);
  await user.click(screen.getByRole("button", { name: "Actions" }));
  await user.keyboard("{Escape}");
  expect(screen.getByRole("button", { name: "Actions" })).toHaveFocus();
});

user.tab() walks focus order, user.keyboard('{Escape}') fires the key, toHaveFocus() asserts the result — this is how keyboard behaviour is verified since the browser tools have no key-press action.

Common Mistakes

Red Flags

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.