diff --git a/README.md b/README.md index 7a3d9c3..44807ea 100644 --- a/README.md +++ b/README.md @@ -111,6 +111,16 @@ have none) pointing the agent at the full guide: `AGENT.md`, the `ipal-reference (every option, env var, route and export) and the `ipal-setup` skill. Only the text between the markers is ever rewritten. `--no-pointer` skips that step. There is no `postinstall` script. +`pnpm exec ipal-skills --external` also adds a few well-known third-party skills as `ext-*` folders — Vercel's +React best practices and composition patterns, Addy Osmani's accessibility skill, Anthropic's frontend-design +skill and the official Payload 3 skill. They are vendored into the package at pinned commits (text only, each +with its licence and source), so nothing is downloaded, and each starts with a note that ipal-kit's rules win. +Pick some with `--external ext-accessibility,ext-payload`. + +*Updating the pins (plugin maintainers):* change the commit in `scripts/vendor-external-skills.mjs`, run +`node scripts/vendor-external-skills.mjs`, review `git diff docs/agent/external`, and run +`pnpm vitest run test/externalSkills.test.ts`. + From here, the guide takes over: **[docs/dev/PROGRAMISTA.md](./docs/dev/PROGRAMISTA.md)** — from an empty project to a working site. diff --git a/bin/ipal-skills.mjs b/bin/ipal-skills.mjs index 4abe5b8..8815b6a 100755 --- a/bin/ipal-skills.mjs +++ b/bin/ipal-skills.mjs @@ -4,22 +4,30 @@ // pnpm ipal-skills --dry-run → show what would change // pnpm ipal-skills --dest .claude/skills // pnpm ipal-skills --no-pointer → skills only, leave AGENTS.md / CLAUDE.md alone +// pnpm ipal-skills --external → also the vendored third-party skills (ext-*, pinned, text only) +// pnpm ipal-skills --external ext-accessibility,ext-payload → only those // Only folders named ipal-* are touched; the project's own skills stay as they are. // ipal-* folders that no longer exist in the package are removed (renamed/retired skills). +// ext-* folders are touched only with --external, and only those carrying ipal-kit's SOURCE.md. // AGENTS.md (and CLAUDE.md) get a marked ipal-kit block pointing at the guide — only the // text between the markers is ever rewritten; the project's own content stays as it is. +import { createHash } from 'node:crypto' import { cpSync, existsSync, mkdirSync, readFileSync, readdirSync, rmSync, statSync, writeFileSync } from 'node:fs' import { dirname, join, relative, resolve } from 'node:path' import { fileURLToPath } from 'node:url' const args = process.argv.slice(2) if (args.includes('--help') || args.includes('-h')) { - console.log('Usage: ipal-skills [--dest ] [--dry-run] [--no-pointer]\nDefault dest: .agents/skills') + console.log('Usage: ipal-skills [--dest ] [--dry-run] [--no-pointer] [--external [ext-a,ext-b]]\nDefault dest: .agents/skills') process.exit(0) } const dryRun = args.includes('--dry-run') const pointer = !args.includes('--no-pointer') +const externalArg = args.indexOf('--external') +const externalPick = externalArg >= 0 && args[externalArg + 1] && !args[externalArg + 1].startsWith('-') + ? args[externalArg + 1].split(',').map((n) => n.trim()).filter(Boolean) + : null const destArg = args.indexOf('--dest') const destValue = destArg >= 0 ? args[destArg + 1] : '.agents/skills' // A missing value would resolve to cwd and remove every ipal-* folder there. @@ -40,6 +48,16 @@ if (!existsSync(src)) { process.exit(1) } +// Validate --external before anything is copied. +const extSrc = join(pkgRoot, 'docs', 'agent', 'external') +const manifest = externalArg >= 0 ? JSON.parse(readFileSync(join(extSrc, 'manifest.json'), 'utf8')) : { skills: [] } +const known = manifest.skills.map((skill) => skill.name) +const unknown = (externalPick ?? []).filter((name) => !known.includes(name)) +if (unknown.length) { + console.error(`ipal-skills: unknown external skill(s): ${unknown.join(', ')} — available: ${known.join(', ')}`) + process.exit(1) +} + const isSkillDir = (base, name) => name.startsWith('ipal-') && statSync(join(base, name)).isDirectory() const shipped = readdirSync(src).filter((n) => isSkillDir(src, n)) const existing = existsSync(dest) ? readdirSync(dest).filter((n) => isSkillDir(dest, n)) : [] @@ -60,6 +78,41 @@ for (const name of retired) { } console.log(`${dryRun ? '[dry-run] ' : ''}${shipped.length} skill(s) → ${dest}`) +// Third-party skills, vendored into the package at pinned commits (docs/agent/external, +// scripts/vendor-external-skills.mjs). Nothing is downloaded here: every file is checked +// against manifest.json before it is copied. +if (externalArg >= 0) { + const MARK = 'Vendored by @intecion/ipal-kit' + const ours = (name) => existsSync(join(dest, name, 'SOURCE.md')) && readFileSync(join(dest, name, 'SOURCE.md'), 'utf8').includes(MARK) + const filesOf = (dir) => readdirSync(dir).flatMap((n) => (statSync(join(dir, n)).isDirectory() ? filesOf(join(dir, n)).map((f) => `${n}/${f}`) : [n])) + for (const skill of manifest.skills.filter((s) => !externalPick || externalPick.includes(s.name))) { + const from = join(extSrc, skill.name) + const files = filesOf(from).sort() + const tampered = files.filter((f) => skill.files[f] !== createHash('sha256').update(readFileSync(join(from, f))).digest('hex')) + if (tampered.length || files.length !== Object.keys(skill.files).length) { + console.error(`ipal-skills: ${skill.name} does not match manifest.json (${tampered.join(', ') || 'file list'}) — skipped`) + process.exitCode = 1 + continue + } + if (existsSync(join(dest, skill.name)) && !ours(skill.name)) { + console.warn(`skip ${skill.name} (a folder of that name exists and is not from ipal-kit)`) + continue + } + console.log(`${existsSync(join(dest, skill.name)) ? 'update' : 'add '} ${skill.name} (${skill.publisher}, ${skill.license}, ${skill.commit.slice(0, 12)})`) + if (!dryRun) { + rmSync(join(dest, skill.name), { recursive: true, force: true }) + cpSync(from, join(dest, skill.name), { recursive: true }) + } + } + const retiredExt = existsSync(dest) + ? readdirSync(dest).filter((n) => n.startsWith('ext-') && !known.includes(n) && ours(n)) + : [] + for (const name of retiredExt) { + console.log(`remove ${name} (no longer in ipal-kit)`) + if (!dryRun) rmSync(join(dest, name), { recursive: true, force: true }) + } +} + // Pointer block: an agent opening the project must find the guide without being told. // AGENTS.md is read by Codex/Cursor/Antigravity, CLAUDE.md by Claude Code (which also // follows `@AGENTS.md` imports, so a CLAUDE.md that imports AGENTS.md needs no copy). @@ -79,8 +132,9 @@ if (pointer) { `2. Everything the plugin provides (options, env vars, routes, layout, hooks, collections, globals, every export): the \`ipal-reference\` skill — \`${skillsDir}/ipal-reference/SKILL.md\`.`, `3. New project or missing foundation: the \`ipal-setup\` skill; a whole site: \`ipal-site\`. All skills: \`${skillsDir}/\`.`, '4. Module details: `node_modules/@intecion/ipal-kit/docs/.md`.', - '5. If the plugin has it, use it. If an option is missing, use the `ipal-plugin-gap` skill — never patch `node_modules`.', - '6. ipal-kit docs, this guide and the skills are in English; write rules, AGENTS.md entries and gap reports in English.', + '5. ipal-kit first: if the plugin has it, use it. Broken or not enough → report it with the `ipal-plugin-gap` skill and wait for the owner — no hand-built replacement, never patch `node_modules`.', + '6. Before you set up a site: ask the owner the architecture questions (AGENT.md "Ask before you build") and wait for the answers; record them under "Project decisions".', + '7. ipal-kit docs, this guide and the skills are in English; write rules, AGENTS.md entries and gap reports in English.', END, ].join('\n') const upsert = (file, { create }) => { diff --git a/docs/agent/AGENT.md b/docs/agent/AGENT.md index fe36a3c..7e2168a 100644 --- a/docs/agent/AGENT.md +++ b/docs/agent/AGENT.md @@ -30,8 +30,8 @@ or data shape where an option or an exported building block is enough. **In practice:** before you write something from scratch or start fighting the plugin — find the option or the exported builder (module docs §12, types in `dist/**/*.d.ts`). It is missing → -**plugin gap** (report + a marked workaround in the project code), never patching -`node_modules` or forking the package. +**plugin gap**: report it to the owner and wait for their decision (see "ipal-kit first" below), never +patch `node_modules` or fork the package. **Docs language:** all ipal-kit docs, this guide and the skills are written in English. Write new rules, AGENTS.md entries and plugin-gap reports in English. @@ -46,12 +46,66 @@ Write new rules, AGENTS.md entries and plugin-gap reports in English. records an editor changed are always skipped and reported (`skip (edited)`) — never use `SEED_FORCE=1` there. - Schema and one-off data fixes → Payload migrations; field renames with content → **ipal-migrate-fields**; content → seeds. +## Ask before you build — architecture questions + +Before you set up a site (or a new part of one), **ask the owner these questions and wait for the answers**. +They decide the architecture; a wrong guess means rework. Ask them as **one list**, once, at the start — +the ready-to-send list is in **ipal-setup** stage 0 (ipal-site phase 0 uses the same list). + +| Topic | What you need to know | +|---|---| +| Languages | which locales, the default locale, URL structure (`/pl/…` for every language, or the default without a prefix) | +| Styling | a design system / `DESIGN.md` or plain Tailwind tokens, brand colours, fonts, light/dark theme | +| Content | the pages, the collections (blog, case studies, products…), archive pages | +| Forms | which forms, who receives them, e-mail provider (SMTP from the panel or Microsoft Graph) | +| Analytics and consent | GA4 / GTM / pixels, Consent Mode basic or advanced, cookie banner mode, cookie scan | +| SEO / GEO | market and local business data, AI crawler policy (llms.txt, Markdown, MCP, AI bots) | +| Data and media | database (Postgres or MongoDB), media storage (R2 or local disk) | +| Admin | 2FA, white-label (client brand in the panel), agency credit | +| Hosting | Coolify, the production domain(s), who adds the DNS records (deployment.md §6) | + +- Write every answer into the project's `AGENTS.md` → **"Project decisions"** (one line per topic). +- **Do not guess a missing answer.** No answer to an architecture question → do not build that part; ask again. + (Only *content* gaps — company data, texts, IDs — may wait: use `[TO FILL: …]` in the panel, §0a.) +- An answer that conflicts with these rules → say so straight away and propose a compliant option. + +## ipal-kit first — hard rule + +- **Anything the plugin covers, you build with the plugin's feature.** Always. Look it up first: the + **ipal-reference** skill, the module docs (§12), the types in `dist/**/*.d.ts`. +- The only exceptions: the plugin's feature **does not work**, or it **is not enough** for this project. +- Even then: **report the gap to the owner first** with the **ipal-plugin-gap** skill and **do nothing on + your own** for that part until the owner decides (wait for a plugin fix / an approved option / an approved, + marked workaround). Work on unrelated parts may go on. +- **No hand-built replacements and no silent workarounds.** A workaround exists only after the owner approved + it, is marked `// WORKAROUND ipal-kit : docs/plugin-requests/` and is recorded in + "Project decisions". + +## Code rules + +Short version of §8 — every skill follows it. +- **Single responsibility:** one job per file, per component, per function. +- **Small files, clear names, no dead code** (no commented-out code, unused exports or props). +- **No duplicated logic** — extract it once; reuse the plugin's exports instead of rewriting them. +- **Typed, no `any`** (no `@ts-ignore`; unknown shape → `unknown` + a type guard). +- **Texts in i18n, never literals** — every visible text comes from the panel / localized fields (§2). +- **Tests or checks for new behaviour** — a unit test, an `ipal-audit` / `ipal-seo-check` result, or a + documented manual check (§8a). + +```tsx +// BAD — one component fetches, formats and renders; hardcoded text; any +export function Offer({ data }: { data: any }) { const p = fetch(…); return

Nasza oferta

} +// GOOD — data comes in typed props (enhanceProps / lib/content), text from the panel, one job +export function Offer({ header, items }: OfferBlockProps) { return
} +``` + --- ## 0. COMPASS (if you remember only this) +0. **Ask first.** Architecture questions before you build ("Ask before you build" above) — never guess. 1. **ipal-kit is mandatory.** A feature the plugin has goes through the plugin. - Something is missing → report (§1.3, plugin gap) + a marked workaround, not a silent patch. + Missing or broken → report it (plugin gap, §1.3) and wait for the owner's decision — no silent patch. 2. **Nothing hardcoded.** Text, image, link, file, company data → admin panel. Domains, keys → `.env`. Also in an `||` fallback and in `catch`. 3. **Next 16 = `proxy.ts`.** NEVER `middleware.ts`. @@ -222,6 +276,7 @@ yourself and check your own work yourself. For a full build use the - plugin defaults (media limits, ISR, robots) — unless the brief says otherwise. ### You ask only about this (collect the questions in **one list**, not one at a time) +- **the architecture questions** ("Ask before you build" at the top) — before you build; you wait for these answers; - **data that is missing** from the brief and the panel: languages, market, domain, company data, analytics IDs and integration keys, notification email addresses; - **irreversible decisions**: deleting content, migrating a database with content, changing slugs @@ -257,8 +312,8 @@ Diagnose (**ipal-debug**: symptom → cause → fix), fix it at the source, check again. Do not report problems you can solve. ### Report only when -- **ipal-kit has a bug or is missing a feature** → **plugin gap** (report + - a minimal, marked workaround — the work goes on, you do not wait), +- **ipal-kit has a bug or is missing a feature** → **plugin gap** (report to the owner and + wait for their decision on that part — no workaround on your own; unrelated work goes on), - you see an **ipal-kit improvement** useful in many projects → **plugin gap** (type: improvement), - **the task is finished** → the final report (format in **ipal-site**). @@ -289,8 +344,9 @@ Rule: **identical in every project → plugin. Depends on the client → project ### 1.3 When the plugin is missing something or something does not work **Do not patch silently** (a hook with a hardcoded value, your own helper, `as any`). It almost always means the plugin already has it (check the docs) or the plugin is missing it. -The **ipal-plugin-gap** skill: report + a minimal, marked workaround -(`// WORKAROUND ipal-kit : …`), the work goes on. The report contains: +The **ipal-plugin-gap** skill: report to the owner and **wait for their decision** on that part +("ipal-kit first" at the top). A workaround only after approval, marked +(`// WORKAROUND ipal-kit : …`) and recorded in "Project decisions". The report contains: - a description of the problem / missing feature, - the proposed API (function / option signature), - why it is universal (useful in other projects). @@ -1049,6 +1105,8 @@ Rules: ## 8. CODE STANDARDS +The short version is "Code rules" at the top; the details: + **Types** - No `any` / `@ts-ignore`. Unknown shape → `unknown` + a type guard. - Types from `@/payload-types` (`pnpm generate:types`), not hand-made copies. @@ -1223,14 +1281,19 @@ Before your first change, read all of: Module details: `node_modules/@intecion/ipal-kit/docs/.md`. Skills: `.agents/skills/ipal-*` (refresh: `pnpm exec ipal-skills`). Always run `ipal-audit` before "done". The rules in AGENT.md take precedence over your general knowledge of Next/Payload. -ipal-kit helps, never limits: first the plugin's option / exported builder; missing → plugin gap (ipal-plugin-gap), never a patch in `node_modules`. +ipal-kit first: anything the plugin covers is built with the plugin. Missing or broken → plugin gap (ipal-plugin-gap): report to the owner and wait; never a hand-built replacement or a patch in `node_modules`. +Code rules: AGENT.md "Code rules" (single responsibility, no duplicates, typed, texts from the panel, checks). Write everything in this file in English. ## Site map - ## Project decisions +- Architecture answers (AGENT.md "Ask before you build"), one line each: languages + default + URLs · + styling · pages/collections · forms + e-mail · analytics/consent/cookie scan · SEO/GEO · database + media · + 2FA/white-label/credit · hosting + domains + DNS - +- - - ipal-audit-skip: — ``` @@ -1265,7 +1328,7 @@ the task matches — manually: `/`. | `ipal-audit` | before every "done" — the §0b set + the §11 checks + panel (§6.5a) + hardcoding in JSX + tsc + build | | `ipal-seo-check` | the running site through the eyes of Googlebot and AI agents (head, canonical, hreflang, sitemap, 404, JSON-LD, llms, Markdown, MCP) | | `ipal-consent-check` | browser: no tracking pixels or cookies before consent; the Google tag may load before consent only in Consent Mode `advanced` (all signals `denied`) — a client who wants zero requests gets `consentMode: 'basic'` | -| `ipal-plugin-gap` | ipal-kit has a bug or is missing a feature — report + a marked workaround, the work goes on | +| `ipal-plugin-gap` | ipal-kit has a bug or is missing a feature — report to the owner, wait for the decision; a marked workaround only after approval | Run the scripts in the skills, do not read them (the output is enough): `ipal-audit/scripts/audit.sh`, `ipal-seo-check/scripts/seo-check.mjs`, `ipal-consent-check/scripts/consent-check.mjs`, @@ -1287,6 +1350,27 @@ It copies only the `ipal-*` folders: adds new ones, replaces existing ones entir retired ones. Name the project's own skills **without** the `ipal-` prefix — they stay untouched. `--dest` must be a subdirectory of the project. Commit the copied `ipal-*` to the project repo. +**External skills (opt-in)** — well-known third-party skills, vendored into the package at pinned commits +(text only, licence + `SOURCE.md` in each folder). `ipal-skills` downloads nothing; it checks every file +against `docs/agent/external/manifest.json` before copying: +```bash +pnpm exec ipal-skills --external # all ext-* next to the ipal-* skills +pnpm exec ipal-skills --external ext-accessibility,ext-payload # only these +``` +| Skill | Publisher · licence | What it is for | Our override | +|---|---|---|---| +| `ext-react-best-practices` | Vercel · MIT | React/Next performance rules (waterfalls, bundles, RSC, re-renders) | no `swr` / client-fetch libraries — Server Components + Payload / `@/lib/content` | +| `ext-composition-patterns` | Vercel · MIT | compound components instead of boolean props, React 19 APIs | block schema and `RenderBlocks` follow §6 | +| `ext-accessibility` | Addy Osmani · MIT | WCAG 2.2 audit and fixes | Lighthouse / axe only as pinned devDependencies; ipal-kit components fixed via props or a plugin gap | +| `ext-frontend-design` | Anthropic · Apache-2.0 | distinctive visual direction, design quality floor | `DESIGN.md` tokens win; use it to write/extend `DESIGN.md`, never hex/fonts/text in components | +| `ext-payload` | Payload CMS · MIT | Payload 3 reference (v3.92.1) | reference only, never Payload 4 guidance; ipal-kit features first | + +**Our rules win.** Every `ext-*` SKILL.md starts with an override note; when an external skill conflicts with +this file, the project's `AGENTS.md` or `DESIGN.md`, those win — ipal-kit first, Payload data fetching over `swr`, +`DESIGN.md` tokens, Payload 3 not 4. `ext-*` folders are touched only with `--external`, and only those with +ipal-kit's `SOURCE.md`; do not name the project's own skills `ext-…`. Use them only after the owner chose them +("Project decisions"). + **`tsconfig.json` must exclude the skills directory** (it contains `.ts`/`.tsx` templates that break `tsc` and `next build`): `"exclude": ["node_modules", ".agents"]` (with `--dest .claude/skills` — `".claude"`). Without it `ipal-skills` prints a warning and exits with diff --git a/docs/agent/external/ext-accessibility/LICENSE b/docs/agent/external/ext-accessibility/LICENSE new file mode 100644 index 0000000..90715bb --- /dev/null +++ b/docs/agent/external/ext-accessibility/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2026 Addy Osmani + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/docs/agent/external/ext-accessibility/SKILL.md b/docs/agent/external/ext-accessibility/SKILL.md new file mode 100644 index 0000000..46e6f83 --- /dev/null +++ b/docs/agent/external/ext-accessibility/SKILL.md @@ -0,0 +1,475 @@ +--- +name: ext-accessibility +description: Audit and improve web accessibility following WCAG 2.2 guidelines. Use when asked to "improve accessibility", "a11y audit", "WCAG compliance", "screen reader support", "keyboard navigation", or "make accessible". +license: MIT +metadata: + author: web-quality-skills + version: "2.0" +--- + +> **Project rules win.** Vendored by @intecion/ipal-kit as guidance. When this skill conflicts with +> `node_modules/@intecion/ipal-kit/docs/agent/AGENT.md`, the project's `AGENTS.md` or `DESIGN.md`, those win: +> ipal-kit features first (the `ipal-reference` skill), Payload 3 + Next 16 App Router, data from Server Components +> through Payload / `@/lib/content`, every visible text from the CMS, design values from `DESIGN.md` tokens. +> Never add a dependency this skill suggests without the owner's decision. +> +> **Tools:** never run `npx lighthouse` / `npx @axe-core/cli` unpinned — add them as devDependencies at fixed versions +> first. Use the ipal-kit components (CookieBanner, AccessibilityWidget, RenderForm…) and fix their markup through +> their props or a plugin gap report, not by copying them. + + +# Accessibility (a11y) + +Comprehensive accessibility guidelines based on WCAG 2.2 and Lighthouse accessibility audits. Goal: make content usable by everyone, including people with disabilities. + +## Evidence-led audit workflow + +When a rendered page is available: + +1. Run a live Lighthouse Accessibility audit when that capability is available; with Chrome DevTools MCP, use `lighthouse_audit`. Use mobile navigation mode for a general public page or snapshot mode when reloading would lose authenticated or user-created state. +2. Use failed audit nodes to localize the relevant component or template instead of searching the whole repository for generic patterns. +3. Inspect a rendered accessibility-tree snapshot for names, roles, states, landmarks, and heading structure; with Chrome DevTools MCP, use `take_snapshot`. Exercise the affected flow with the keyboard. +4. Fix the source, then re-run the same audit and manual interaction. + +If the live tools are unavailable, use Lighthouse CLI or axe for automated coverage and complete the same manual checks. Automated tools detect only a subset of accessibility barriers: a score of 100 is not WCAG conformance, and a low score does not replace issue-level evidence. + +## WCAG Principles: POUR + +| Principle | Description | +|-----------|-------------| +| **P**erceivable | Content can be perceived through different senses | +| **O**perable | Interface can be operated by all users | +| **U**nderstandable | Content and interface are understandable | +| **R**obust | Content works with assistive technologies | + +## Conformance levels + +| Level | Requirement | Target | +|-------|-------------|--------| +| **A** | Minimum accessibility | Must pass | +| **AA** | Standard compliance | Should pass (legal requirement in many jurisdictions) | +| **AAA** | Enhanced accessibility | Nice to have | + +--- + +## Perceivable + +### Text alternatives (1.1) + +**Images require alt text:** +```html + + + + +Bar chart showing 40% increase in Q3 sales + + + + + +
+ 2024 market trends infographic +
+ +
+
+``` + +**Icon buttons need accessible names:** +```html + + + + + + + + +``` + +**Visually hidden class:** +```css +.visually-hidden { + position: absolute; + width: 1px; + height: 1px; + padding: 0; + margin: -1px; + overflow: hidden; + clip: rect(0, 0, 0, 0); + white-space: nowrap; + border: 0; +} +``` + +### Color contrast (1.4.3, 1.4.6) + +| Text Size | AA minimum | AAA enhanced | +|-----------|------------|--------------| +| Normal text (< 18px / < 14px bold) | 4.5:1 | 7:1 | +| Large text (≥ 18px / ≥ 14px bold) | 3:1 | 4.5:1 | +| UI components & graphics | 3:1 | 3:1 | + +```css +/* ❌ Low contrast (2.5:1) */ +.low-contrast { + color: #999; + background: #fff; +} + +/* ✅ Sufficient contrast (7:1) */ +.high-contrast { + color: #333; + background: #fff; +} + +/* ✅ Focus states need contrast too (3:1 against background, WCAG 1.4.11) */ +:focus-visible { + outline: 2px solid currentColor; + outline-offset: 2px; +} +``` + +**Don't rely on color alone:** +```html + + + + + +
+ + + + Please enter a valid email address + +
+``` + +### Media alternatives (1.2) + +```html + + + + + +
+ Transcript +

Full transcript text...

+
+``` + +--- + +## Operable + +### Keyboard accessible (2.1) + +**All functionality must be keyboard accessible.** Prefer native interactive elements — ` +``` + +```javascript +// ✅ When you MUST use a non-interactive element (e.g. div with role="button"), +// make it focusable AND handle keyboard activation. Do NOT add this to a native +// + +``` + +--- + +## Robust + +### ARIA usage (4.1.2) + +**Prefer native elements:** +```html + +
Click me
+ + + + + +
Option
+ + + +``` + +**When ARIA is needed,** use the correct roles and states. See the [ARIA tabs pattern](references/A11Y-PATTERNS.md#aria-tabs) for a complete tablist example. + +### Live regions (4.1.3) + +Use `aria-live` regions to announce dynamic content changes without moving focus. See the [live regions pattern](references/A11Y-PATTERNS.md#live-regions-and-notifications) for markup and a `showNotification()` helper. + +--- + +## Testing checklist + +### Automated testing + +Prefer a live Lighthouse audit that returns failing rendered nodes directly to the agent. With Chrome DevTools MCP, this is `lighthouse_audit`. Otherwise: + +```bash +# Lighthouse accessibility audit +npx lighthouse https://example.com --only-categories=accessibility + +# axe-core +npm install @axe-core/cli -g +axe https://example.com +``` + +### Manual testing + +- [ ] **Keyboard navigation:** Tab through entire page, use Enter/Space to activate +- [ ] **Screen reader:** Test with VoiceOver (Mac), NVDA (Windows), or TalkBack (Android) +- [ ] **Zoom:** Content usable at 200% zoom +- [ ] **High contrast:** Test with Windows High Contrast Mode +- [ ] **Reduced motion:** Test with `prefers-reduced-motion: reduce` +- [ ] **Focus order:** Logical and follows visual order +- [ ] **Target size:** Interactive elements meet 24×24px minimum + +See the [screen reader commands reference](references/A11Y-PATTERNS.md#screen-reader-commands) for VoiceOver and NVDA shortcuts. + +--- + +## Common issues by impact + +### Critical (fix immediately) +1. Missing form labels +2. Missing image alt text +3. Insufficient color contrast +4. Keyboard traps +5. No focus indicators + +### Serious (fix before launch) +1. Missing page language +2. Missing heading structure +3. Non-descriptive link text +4. Auto-playing media +5. Missing skip links + +### Moderate (fix soon) +1. Missing ARIA labels on icons +2. Inconsistent navigation +3. Missing error identification +4. Timing without controls +5. Missing landmark regions + +## References + +- [WCAG 2.2 Quick Reference](https://www.w3.org/WAI/WCAG22/quickref/) +- [WAI-ARIA Authoring Practices](https://www.w3.org/WAI/ARIA/apg/) +- [Deque axe Rules](https://dequeuniversity.com/rules/axe/) +- [Web Quality Audit](../web-quality-audit/SKILL.md) +- [WCAG criteria reference](references/WCAG.md) +- [Accessibility code patterns](references/A11Y-PATTERNS.md) diff --git a/docs/agent/external/ext-accessibility/SOURCE.md b/docs/agent/external/ext-accessibility/SOURCE.md new file mode 100644 index 0000000..e752d96 --- /dev/null +++ b/docs/agent/external/ext-accessibility/SOURCE.md @@ -0,0 +1,14 @@ +# ext-accessibility + +Vendored by @intecion/ipal-kit (`ipal-skills --external`). Do not edit — regenerate with +`scripts/vendor-external-skills.mjs` in the ipal-kit repository. + +| | | +|---|---| +| Publisher | Addy Osmani | +| Source | https://github.com/addyosmani/web-quality-skills/tree/afa8da942115f2961fdbfa80807ea0b232ff6c00/skills/accessibility | +| Commit | `afa8da942115f2961fdbfa80807ea0b232ff6c00` | +| Licence | MIT (see the LICENSE file in this folder) | + +Changes from the upstream text: the `name` in the SKILL.md frontmatter is `ext-accessibility`, and an +override note (project rules win) is inserted after the frontmatter. Nothing else is changed. diff --git a/docs/agent/external/ext-accessibility/references/A11Y-PATTERNS.md b/docs/agent/external/ext-accessibility/references/A11Y-PATTERNS.md new file mode 100644 index 0000000..6d500ef --- /dev/null +++ b/docs/agent/external/ext-accessibility/references/A11Y-PATTERNS.md @@ -0,0 +1,233 @@ +# Accessibility Code Patterns + +Practical, copy-paste-ready patterns for common accessibility requirements. Each pattern is self-contained and linked from the main [SKILL.md](../SKILL.md). + +--- + +## Modal focus trap + +Trap keyboard focus inside a modal dialog so Tab/Shift+Tab cycle through its focusable elements and Escape closes it. + +```javascript +function openModal(modal) { + const focusableElements = modal.querySelectorAll( + 'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])' + ); + const firstElement = focusableElements[0]; + const lastElement = focusableElements[focusableElements.length - 1]; + + modal.addEventListener('keydown', (e) => { + if (e.key === 'Tab') { + if (e.shiftKey && document.activeElement === firstElement) { + e.preventDefault(); + lastElement.focus(); + } else if (!e.shiftKey && document.activeElement === lastElement) { + e.preventDefault(); + firstElement.focus(); + } + } + if (e.key === 'Escape') { + closeModal(); + } + }); + + firstElement.focus(); +} +``` + +The native `` element handles focus trapping automatically—prefer it when browser support allows. + +--- + +## Skip link + +Allows keyboard users to bypass repetitive navigation and jump straight to main content. + +```html + + +
+
+ +
+ +``` + +```css +.skip-link { + position: absolute; + top: -40px; + left: 0; + background: #000; + color: #fff; + padding: 8px 16px; + z-index: 100; +} + +.skip-link:focus { + top: 0; +} +``` + +--- + +## Error handling + +Announce errors to screen readers and focus the first invalid field on submit. + +```html +
+
+ + + +
+
+``` + +```javascript +form.addEventListener('submit', (e) => { + const firstError = form.querySelector('[aria-invalid="true"]'); + if (firstError) { + e.preventDefault(); + firstError.focus(); + + const errorSummary = document.getElementById('error-summary'); + errorSummary.textContent = + `${errors.length} errors found. Please fix them and try again.`; + errorSummary.focus(); + } +}); +``` + +--- + +## Form labels + +Every input needs an associated label—either explicit (`for`/`id`) or implicit (wrapping `