Harness accessibility

From Intense-Visions/harness-engineering · View interactive version

Harness accessibility is an AI agent skill from the GitHub repository Intense-Visions/harness-engineering. > WCAG compliance verification and remediation. Scan components for accessibility violations, evaluate severity against design strictness, generate actionable reports, and apply automated fixes for me

How to use this skill

Skill file

Harness Accessibility

WCAG compliance verification and remediation. Scan components for accessibility violations, evaluate severity against design strictness, generate actionable reports, and apply automated fixes for mechanical issues.

When to Use

Process

Phase 1: SCAN -- Detect Accessibility Violations

  1. Load design tokens. Read design-system/tokens.json (if it exists) to identify declared color values and contrast pairs. Token-defined colors are the source of truth -- hardcoded colors in components are themselves a violation.
  1. Read design strictness. Check harness.config.json for design.strictness:

2.5. Check for i18n skill overlap. Read harness.config.json for i18n.enabled:

2.6. Check for component-anatomy audit overlap. Read harness.config.json for design.audit.componentAnatomy.enabled (default true when absent):

2.7. Run the mechanical ARIA scanner first. Call AriaScanner.scanFiles() from @harness-engineering/core (the same load-bearing pattern by which harness-security-scan calls SecurityScanner.scanFiles()). It authoritatively produces A11Y-014 (aria-hidden="true" on a focusable element) and A11Y-042 (positive tabindex) — the two ARIA rules that are decidable from a single element at a near-zero false-positive rate. Treat its findings as the source of truth for those two codes; the grep heuristics below cover only the remaining rules. These two codes are the load-bearing enforcement of the a11y-aria-patterns domain skill.

  1. Scan component files. Search all files matching .tsx, .jsx, .vue, .svelte, .html for the following violations:

Images and media:

ARIA and semantics:

Heading structure:

Color and contrast:

Keyboard navigation:

Forms:

  1. Load anti-pattern catalogs. Read additional detection rules from agents/skills/shared/design-knowledge/ if available. These catalogs contain industry-specific accessibility patterns (e.g., healthcare forms require higher contrast, fintech requires screen reader-compatible data tables).
  1. Record all findings. Each finding includes:

Phase 2: EVALUATE -- Assess Severity and Categorize

  1. Assign severity based on design.strictness:
  1. Calculate contrast ratios. For every color pair found in scanned code:
  1. Cross-reference with design tokens. If design-system/tokens.json exists:
  1. Check graph constraints. If a graph exists at .harness/graph/, use DesignConstraintAdapter from packages/graph/src/constraints/DesignConstraintAdapter.ts to:
  1. Categorize findings. Group into categories:

Phase 3: REPORT -- Generate Accessibility Report

  1. Generate summary header:

```

Accessibility Report

====================

Scanned: 42 component files

Findings: 18 total (6 error, 8 warn, 4 info)

Strictness: standard

```

  1. List findings grouped by category. Each finding follows this format:

```

A11Y-001 [error] Missing alt attribute on <img>

File: src/components/UserAvatar.tsx

Line: 24

Element: <img src={user.avatarUrl} className="avatar" />

WCAG: 1.1.1 Non-text Content

Fix: Add alt={user.name} or alt="" if decorative

```

```

A11Y-031 [error] Contrast ratio 2.8:1 fails WCAG AA (requires 4.5:1)

File: src/components/Button.tsx

Line: 15

Element: color: #999 on background: #fff

WCAG: 1.4.3 Contrast (Minimum)

Fix: Use color token "neutral.600" (#475569, ratio 4.9:1) instead

```

  1. Provide category summaries with counts and severity breakdown.
  1. List actionable next steps:

Phase 4: FIX -- Apply Automated Remediation (Optional)

This phase is optional. It applies fixes only for mechanical issues -- violations with a single, unambiguous correct fix. Subjective issues (color choices, layout decisions, content writing) are never auto-fixed.

  1. Fixable violations:
  1. Apply each fix as a minimal, targeted edit. Use the Edit tool. Do not refactor surrounding code. Do not change formatting. The fix should be the smallest possible change that resolves the violation.
  1. Show before/after diff for each fix. Present the exact change to the user. This is a hard gate -- no fix is applied without showing the diff first.
  1. Re-scan after fixes. Run the scan phase again on fixed files to confirm violations are resolved. Report:
  1. Do NOT fix:

Harness Integration

Success Criteria

Examples

Example: Scanning a React Dashboard Component

Context: A React component DashboardCard.tsx with known accessibility issues.

Source file:

// src/components/DashboardCard.tsx
export function DashboardCard({ title, value, icon, onClick }) {
  return (
    <div className="card" onClick={onClick}>
      <img src={icon} />
      <h3>{title}</h3>
      <span style={{ color: '#999', fontSize: '14px' }}>{value}</span>
    </div>
  );
}

SCAN findings:

A11Y-001 [error] Missing alt attribute on <img>
  File:    src/components/DashboardCard.tsx
  Line:    5
  Element: <img src={icon} />
  WCAG:    1.1.1 Non-text Content

A11Y-012 [error] Clickable <div> without role="button" and keyboard handler
  File:    src/components/DashboardCard.tsx
  Line:    4
  Element: <div className="card" onClick={onClick}>
  WCAG:    2.1.1 Keyboard

A11Y-031 [warn] Contrast ratio 2.8:1 for #999 on #fff fails WCAG AA
  File:    src/components/DashboardCard.tsx
  Line:    7
  Element: <span style={{ color: '#999' }}>
  WCAG:    1.4.3 Contrast (Minimum)
  Note:    Hardcoded color -- not from token set

A11Y-030 [info] Hardcoded color value not from design token set
  File:    src/components/DashboardCard.tsx
  Line:    7
  Element: color: '#999'

FIX phase (auto-fixable only):

- <img src={icon} />
+ <img src={icon} alt="" />

- <div className="card" onClick={onClick}>
+ <div className="card" role="button" tabIndex={0} onClick={onClick} onKeyDown={(e) => { if (e.key === 'Enter' || e.key === ' ') onClick?.(); }}>

Remaining (requires human judgment):

Rationalizations to Reject

| Rationalization | Reality |

| --------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |

| "The contrast ratio is 4.4:1 — that's essentially 4.5:1 and the difference is imperceptible. I'll mark it passing." | WCAG AA requires exactly 4.5:1 for normal text. 4.4:1 fails. There is no rounding or visual perception exception in the standard. Flag the failure with the actual ratio and let the user decide how to remediate. |

| "This <div onClick> already has good visual styling — adding role='button' and a keyboard handler is unnecessary clutter." | A clickable <div> without role="button" and onKeyDown is inaccessible to keyboard-only users and screen reader users. Visual styling has no bearing on ARIA semantics or keyboard reachability. This is A11Y-012, always flagged. |

| "The automated fix for this <img> alt attribute is obvious — I'll apply it without showing the diff since it's just adding alt=''." | Every automated fix must be presented as a before/after diff before being written to disk. This is a hard gate. The correct alt value for non-decorative images requires human judgment, and even alt="" makes a semantic claim about decorativeness that must be confirmed. |

| "I18n is enabled, so I'll skip the lang and dir attribute checks entirely — harness-i18n will catch them." | Deferral to harness-i18n is conditional on i18n.enabled: true in config. If i18n is not configured, these checks remain part of this skill's scan. Always read the config before skipping any check category. |

| "There are 15 findings in this component — I'll fix the easy ones automatically and leave the rest without reporting them explicitly." | All findings must be reported, regardless of whether they are auto-fixable. The report is the primary deliverable of the REPORT phase. Selectively reporting only fixable violations hides the full accessibility debt from the team. |

Gates

These are hard stops. Violating any gate means the process has broken down.

Escalation

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.