Add comprehensive accessibility testing agent with: - Full WCAG 2.2 Level AA compliance scanning via axe-core - EN 301 549 EU compliance mapping - ARIA Authoring Practices Guide (APG) patterns - EU Accessibility Act legal framework support - AccName (Accessible Name) computation Enhanced remediation code generation: - Framework detection (Slick, Swiper, Bootstrap, Owl Carousel, etc.) - Context-aware HTML/CSS/JS fix templates - WebVTT caption file generation with multi-language support - Playwright + axe-core test generation for violations - CSS accessibility utilities (skip links, focus indicators, etc.) Agent registration: - Added ACCESSIBILITY_ALLY to QEAgentType enum - Created AccessibilityAllyAgent with full task implementation - Registered in AgentRegistry with 'qe-a11y-ally' and 'a11y-ally' aliases - Added to QEAgentFactory with 10 capabilities 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
22 KiB
A11y-Ally Agent Implementation Plan
Executive Summary
The a11y-ally (Accessibility Ally) agent is a specialized QE agent for comprehensive accessibility testing, validation, and remediation. It extends the existing qe-visual-tester agent and accessibility-testing skill to provide context-aware accessibility recommendations, automated violation detection, and intelligent remediation strategies.
Target Impact:
- Detect 95%+ of WCAG 2.2 violations automatically
- Provide context-specific remediation (e.g., appropriate ARIA labels, caption generation recommendations)
- Reduce accessibility violation fix time by 70%
- Enable shift-left accessibility testing in CI/CD pipelines
1. Agent Architecture
1.1 Core Identity
---
name: qe-a11y-ally
description: Intelligent accessibility testing agent with context-aware remediation and WCAG 2.2 compliance validation
---
<qe_agent_definition>
<identity>
You are the Accessibility Ally Agent, a specialized QE agent for comprehensive accessibility testing and intelligent remediation.
Mission: Detect accessibility violations, provide context-specific solutions, and guide developers toward WCAG 2.2 compliance.
</identity>
1.2 Capabilities
Core Capabilities:
-
Comprehensive Violation Detection
- WCAG 2.2 Level A, AA, AAA validation
- axe-core integration for automated scanning
- Playwright accessibility tree analysis
- Custom heuristics for complex violations
-
Context-Aware Remediation
- Intelligent ARIA label generation based on element context
- Video/audio content analysis for caption recommendations
- Form field relationship inference for proper labeling
- Interactive element keyboard navigation fixes
- Color contrast optimization suggestions
-
Multi-Layer Testing
- Automated scanning (axe-core, Playwright)
- Keyboard navigation simulation
- Screen reader compatibility testing (VoiceOver, NVDA, JAWS simulation)
- Responsive accessibility across viewports
- Focus management validation
-
Intelligent Learning
- Learn from past violation patterns
- Optimize remediation strategies based on success rates
- Build domain-specific accessibility knowledge
- Predict likely violations in similar code
1.3 Integration Points
// Integration with existing infrastructure
- Extends: qe-visual-tester (shares screenshot/visual capabilities)
- Uses: accessibility-testing skill (WCAG knowledge base)
- Coordinates with: qe-test-generator (for a11y test generation)
- Reports to: qe-quality-gate (for compliance enforcement)
2. Technical Implementation
2.1 Tool Architecture
New MCP Tools to Create:
src/mcp/tools/qe/accessibility/
├── index.ts # Tool exports
├── scan-comprehensive.ts # Full WCAG 2.2 scan with axe-core
├── analyze-context.ts # Analyze element context for remediation
├── generate-remediation.ts # Context-aware fix suggestions
├── validate-aria.ts # ARIA attribute validation
├── test-keyboard-navigation.ts # Keyboard accessibility testing
├── simulate-screen-reader.ts # Screen reader compatibility
├── analyze-color-contrast.ts # Advanced contrast analysis
├── generate-captions-recommendation.ts # Video/audio caption guidance
└── validate-semantic-html.ts # Semantic HTML structure check
2.2 Core Tool: Comprehensive Accessibility Scan
/**
* Comprehensive accessibility scan with context-aware remediation
*/
export interface ScanComprehensiveParams {
/** URL or HTML content to scan */
target: string | { html: string; baseUrl?: string };
/** WCAG compliance level */
level: 'A' | 'AA' | 'AAA';
/** Specific areas to scan */
scope?: {
/** CSS selectors to include */
include?: string[];
/** CSS selectors to exclude */
exclude?: string[];
};
/** Validation options */
options?: {
/** Enable axe-core scanning */
axeCore?: boolean;
/** Enable keyboard navigation testing */
keyboardTest?: boolean;
/** Enable screen reader simulation */
screenReaderTest?: boolean;
/** Enable color contrast analysis */
contrastAnalysis?: boolean;
/** Enable context-aware remediation */
intelligentRemediation?: boolean;
/** Generate test cases for violations */
generateTests?: boolean;
};
}
export interface AccessibilityScanResult {
/** Unique scan ID */
scanId: string;
/** Overall compliance status */
compliance: {
status: 'compliant' | 'partially-compliant' | 'non-compliant';
score: number; // 0-100
level: 'A' | 'AA' | 'AAA';
};
/** Violations detected */
violations: AccessibilityViolation[];
/** Context-aware remediation suggestions */
remediations: RemediationSuggestion[];
/** Generated test cases */
testCases?: GeneratedTestCase[];
/** Detailed analysis by category */
analysis: {
perceivable: CategoryAnalysis;
operable: CategoryAnalysis;
understandable: CategoryAnalysis;
robust: CategoryAnalysis;
};
/** Performance metrics */
metrics: {
scanTime: number;
elementsAnalyzed: number;
violationsDetected: number;
autoFixableCount: number;
};
}
export interface AccessibilityViolation {
/** Violation ID */
id: string;
/** WCAG success criterion */
wcagCriterion: string; // e.g., "1.4.3 Contrast (Minimum)"
/** Severity */
severity: 'critical' | 'serious' | 'moderate' | 'minor';
/** Impact on users */
impact: {
description: string;
affectedUsers: string[]; // e.g., ["blind", "low-vision", "motor-impaired"]
userCount?: number; // Estimated affected users (if analytics available)
};
/** Affected elements */
elements: ViolationElement[];
/** Detection source */
detectedBy: 'axe-core' | 'playwright' | 'custom-heuristic';
/** Confidence score */
confidence: number; // 0-1
}
export interface RemediationSuggestion {
/** Related violation ID */
violationId: string;
/** Remediation type */
type: 'aria-label' | 'alt-text' | 'color-contrast' | 'keyboard-nav' |
'semantic-html' | 'captions' | 'focus-management' | 'other';
/** Priority */
priority: 'critical' | 'high' | 'medium' | 'low';
/** Context-aware suggestion */
suggestion: {
/** Human-readable description */
description: string;
/** Specific code changes */
codeChanges: CodeChange[];
/** Why this suggestion works */
reasoning: string;
/** Estimated effort */
effort: 'trivial' | 'low' | 'medium' | 'high';
};
/** Automated fix available */
autoFixable: boolean;
/** Auto-fix code (if available) */
autoFix?: {
/** Before code */
before: string;
/** After code */
after: string;
/** Safe to auto-apply */
safe: boolean;
};
/** Confidence in suggestion */
confidence: number; // 0-1
}
export interface CodeChange {
/** Element selector */
selector: string;
/** Change type */
type: 'add-attribute' | 'modify-attribute' | 'add-element' |
'modify-structure' | 'add-css';
/** Before state */
before: string;
/** After state */
after: string;
/** Explanation */
explanation: string;
}
2.3 Context-Aware Remediation Engine
The core innovation is the Context Analysis Engine that:
-
Analyzes Element Context
// Example: Button without label <button class="icon-btn"> <svg>...</svg> </button> // Context analysis: // - Surrounding text: "Add to cart" // - Parent container: product card // - Icon type: shopping cart // - User flow: e-commerce checkout // Generated suggestion: <button class="icon-btn" aria-label="Add to cart"> <svg aria-hidden="true">...</svg> </button> -
Semantic Understanding
// Video element without captions <video src="product-demo.mp4" /> // Context analysis: // - Content type: product demonstration // - Duration: 2:30 // - Audio present: yes // Generated recommendation: { type: 'captions', recommendation: 'Add closed captions for product demo video', reasoning: 'Video contains spoken content explaining product features', actionItems: [ 'Generate transcript from audio (use speech-to-text API)', 'Create WebVTT caption file', 'Add <track> element with captions', 'Consider adding audio descriptions for visual elements' ], tools: ['OpenAI Whisper', 'Google Speech-to-Text', 'AWS Transcribe'], estimatedTime: '30-60 minutes', compliance: 'Required for WCAG 2.2 Level A (1.2.2)' } -
Form Field Relationship Inference
// Form with unlabeled input <div class="form-group"> <span>Email Address</span> <input type="email" name="email" /> </div> // Suggested fix: <div class="form-group"> <label for="email-input">Email Address</label> <input type="email" name="email" id="email-input" /> </div>
3. Integration with Existing Infrastructure
3.1 Extend qe-visual-tester
The qe-visual-tester already has basic accessibility validation. We'll:
-
Enhance existing
validateAccessibilityWCAGfunction- Add context analysis
- Integrate intelligent remediation
- Connect to learning system
-
Share screenshot capabilities
- Use existing screenshot infrastructure
- Add accessibility tree visualization
- Annotate violations on screenshots
3.2 Leverage accessibility-testing Skill
The existing skill provides:
- POUR principles
- WCAG knowledge base
- axe-core integration patterns
- Keyboard testing patterns
We'll extend with:
- Context-aware remediation strategies
- AI-powered suggestion generation
- Automated test case creation
3.3 Coordinate with Other Agents
// Integration patterns
const a11yFleet = {
// Generate tests from violations
'qe-test-generator': {
input: 'aqe/accessibility/violations',
output: 'aqe/test-generation/a11y-tests'
},
// Enforce compliance gates
'qe-quality-gate': {
input: 'aqe/accessibility/compliance-score',
output: 'aqe/quality/gate-results'
},
// Track production a11y
'qe-production-intelligence': {
input: 'aqe/accessibility/production-violations',
output: 'aqe/test-plan/a11y-scenarios'
},
// Visual regression for a11y
'qe-visual-tester': {
input: 'aqe/accessibility/visual-issues',
output: 'aqe/visual/regressions'
}
};
4. Implementation Milestones
Milestone 1: Foundation (Week 1-2)
Goal: Basic agent structure and axe-core integration
Success Criteria:
- ✅ Agent definition file created (
.claude/agents/qe-a11y-ally.md) - ✅ Basic MCP tool:
scan-comprehensive.ts - ✅ axe-core integration working
- ✅ WCAG 2.2 violation detection
- ✅ Basic remediation suggestions (non-context-aware)
- ✅ Unit tests passing (90%+ coverage)
Deliverables:
/workspaces/agentic-qe/.claude/agents/qe-a11y-ally.md/workspaces/agentic-qe/src/mcp/tools/qe/accessibility/scan-comprehensive.ts/workspaces/agentic-qe/tests/unit/mcp/tools/qe/accessibility/scan-comprehensive.test.ts- Integration with MCP server
- Basic CLI command:
aqe a11y scan <url>
Test Criteria:
# Must pass these tests
npm run test:unit -- scan-comprehensive.test.ts
aqe a11y scan https://example.com --level AA
# Should detect: missing alt text, form labels, contrast issues
Milestone 2: Context-Aware Remediation (Week 3-4)
Goal: Intelligent, context-specific fix suggestions
Success Criteria:
- ✅ Context analysis engine implemented
- ✅ ARIA label generation with semantic understanding
- ✅ Video/audio caption recommendations
- ✅ Form field relationship inference
- ✅ Color contrast optimization
- ✅ Confidence scoring for suggestions
- ✅ Integration tests passing
Deliverables:
analyze-context.ts- Element context analysisgenerate-remediation.ts- Smart fix generationgenerate-captions-recommendation.ts- Caption guidance- Learning integration for pattern recognition
- CLI command:
aqe a11y remediate <scan-id>
Test Criteria:
// Must correctly infer context and suggest appropriate fixes
test('generates ARIA label from surrounding context', async () => {
const html = `
<div class="product-card">
<h3>Blue Widget</h3>
<button><svg>...</svg></button>
</div>
`;
const result = await analyzeContextAndRemediate(html);
expect(result.remediations[0].suggestion.codeChanges[0].after)
.toContain('aria-label="Add Blue Widget to cart"');
});
Milestone 3: Advanced Testing Capabilities (Week 5-6)
Goal: Keyboard navigation, screen reader simulation, automated test generation
Success Criteria:
- ✅ Keyboard navigation testing (Tab, Enter, Escape, Arrow keys)
- ✅ Screen reader compatibility simulation
- ✅ Focus management validation
- ✅ Generated test cases from violations
- ✅ Multi-browser testing support
- ✅ E2E tests passing
Deliverables:
test-keyboard-navigation.ts- Keyboard testingsimulate-screen-reader.ts- Screen reader simulation- Auto-generated Playwright tests for violations
- CLI command:
aqe a11y test <url> - Integration with
qe-test-generator
Test Criteria:
# Comprehensive a11y testing
aqe a11y test https://example.com \
--keyboard \
--screen-reader \
--generate-tests \
--output tests/a11y/
Milestone 4: Fleet Integration & Learning (Week 7-8)
Goal: Full integration with Agentic QE Fleet and learning system
Success Criteria:
- ✅ Learning protocol integration
- ✅ Pattern recognition for common violations
- ✅ Coordination with other QE agents
- ✅ Memory namespace implementation
- ✅ Quality gate integration
- ✅ CI/CD pipeline support
- ✅ Journey tests passing
Deliverables:
- Learning integration in all tools
- Memory namespace:
aqe/accessibility/* - Fleet coordination hooks
- GitHub Actions workflow
- Comprehensive documentation
- CLI command:
aqe a11y fleet <url>
Test Criteria:
# Full fleet coordination
npm run test:journeys -- a11y-fleet.journey.test.ts
# CI/CD integration
# .github/workflows/accessibility.yml should pass
5. Success Metrics
5.1 Technical Metrics
| Metric | Target | Measurement |
|---|---|---|
| Violation Detection Rate | 95%+ | Compare with manual audits |
| False Positive Rate | <5% | Manual verification of flagged issues |
| Remediation Accuracy | 90%+ | Suggestions actually fix violations |
| Context Inference Accuracy | 85%+ | Appropriate ARIA labels generated |
| Test Generation Coverage | 100% | All critical violations get tests |
| Performance | <10s scan | Average scan time for typical page |
5.2 User Impact Metrics
| Metric | Target | Measurement |
|---|---|---|
| Time to Fix Violations | -70% | Before/after comparison |
| Developer Satisfaction | 4.5+/5 | Survey feedback |
| Accessibility Compliance | 100% WCAG 2.2 AA | Before production release |
| Legal Risk Reduction | 100% | No accessibility lawsuits |
5.3 Learning Metrics
| Metric | Target | Measurement |
|---|---|---|
| Pattern Recognition | 50+ patterns | Learned common violation patterns |
| Remediation Optimization | +20% accuracy | Over 100 scans |
| Domain Adaptation | 90%+ | Accuracy in specific domains (e.g., e-commerce) |
6. Integration with Tools & Libraries
6.1 Core Dependencies
{
"dependencies": {
// Existing
"axe-core": "^4.8.0",
"@axe-core/playwright": "^4.8.0",
"playwright": "^1.40.0",
// New for a11y-ally
"axe-core-extended": "^1.0.0", // Extended WCAG 2.2 rules
"html-validator": "^6.0.0", // Semantic HTML validation
"color-contrast-checker": "^2.1.0", // Advanced contrast
"aria-query": "^5.3.0", // ARIA validation
"dom-accessibility-api": "^0.6.0" // Accessibility tree
}
}
6.2 AI/ML Integration (Optional Future Enhancement)
// Future: Use LLM for context understanding
import { OpenAI } from 'openai';
async function generateAriaLabelWithAI(element: Element, context: Context) {
const prompt = `
Given this HTML element and context, suggest an appropriate aria-label:
Element: ${element.outerHTML}
Surrounding text: ${context.surroundingText}
Parent container: ${context.parentDescription}
User flow: ${context.userFlow}
Provide a concise, descriptive aria-label.
`;
const completion = await openai.chat.completions.create({
model: 'gpt-4',
messages: [{ role: 'user', content: prompt }],
temperature: 0.3
});
return completion.choices[0].message.content;
}
7. Documentation Requirements
7.1 Agent Documentation
-
Agent Definition (
.claude/agents/qe-a11y-ally.md)- Identity and mission
- Capabilities
- Memory namespace
- Learning protocol
- Examples
-
User Guide (
docs/guides/a11y-ally-guide.md)- Getting started
- Common workflows
- Best practices
- Troubleshooting
-
API Reference (
docs/api/a11y-ally-api.md)- All MCP tools
- Parameters and return types
- Examples
- Integration patterns
7.2 Update Existing Docs
- docs/reference/agents.md - Add qe-a11y-ally section
- docs/reference/skills.md - Update accessibility-testing skill
- docs/reference/usage.md - Add a11y-ally usage examples
- README.md - Update agent count (19 → 20)
8. Testing Strategy
8.1 Unit Tests
tests/unit/mcp/tools/qe/accessibility/
├── scan-comprehensive.test.ts
├── analyze-context.test.ts
├── generate-remediation.test.ts
├── validate-aria.test.ts
├── test-keyboard-navigation.test.ts
├── simulate-screen-reader.test.ts
└── analyze-color-contrast.test.ts
Coverage Target: 95%+
8.2 Integration Tests
tests/integration/agents/
└── qe-a11y-ally.integration.test.ts
Test Scenarios:
- Full scan with all options enabled
- Context analysis pipeline
- Remediation generation accuracy
- Fleet coordination
8.3 Journey Tests
tests/journeys/
└── a11y-ally-workflow.journey.test.ts
Test Workflows:
- Developer scans page → Gets violations → Applies fixes → Rescans → Pass
- CI/CD integration → Scan on PR → Block if critical violations
- Fleet coordination → Generate tests → Execute → Report
8.4 Real-World Testing
Test Sites:
- https://www.w3.org/WAI/demos/bad/ (Intentionally inaccessible)
- https://www.boia.org/ (Accessibility-focused)
- https://webaim.org/ (WebAIM resources)
- Internal test pages with known violations
9. Rollout Plan
Phase 1: Internal Dogfooding (Week 9)
- Use on Agentic QE project itself
- Fix all accessibility issues found
- Refine remediation suggestions
- Gather team feedback
Phase 2: Beta Release (Week 10)
- Release as beta feature (v2.4.0-beta)
- Invite external beta testers
- Monitor learning system performance
- Collect usage metrics
Phase 3: General Availability (Week 11-12)
- Full release (v2.4.0)
- Blog post and documentation
- Tutorial videos
- Community engagement
10. Risk Mitigation
10.1 Technical Risks
| Risk | Impact | Mitigation |
|---|---|---|
| Context analysis inaccuracy | High | Confidence scoring, human review option |
| Performance on large sites | Medium | Progressive scanning, caching, pagination |
| False positives | Medium | Multiple detection methods, confidence thresholds |
| Integration complexity | Low | Gradual rollout, comprehensive testing |
10.2 Adoption Risks
| Risk | Impact | Mitigation |
|---|---|---|
| Learning curve | Medium | Extensive docs, tutorials, examples |
| Overwhelming violation count | Medium | Priority filtering, progressive fixes |
| Resistance to change | Low | Show time savings, quick wins |
11. Future Enhancements (Post-v1)
-
AI-Powered Context Understanding (Q2 2025)
- LLM integration for semantic analysis
- Natural language remediation explanations
- Conversational accessibility guidance
-
Automated Fix Application (Q3 2025)
- Safe auto-fixes for simple violations
- Git integration for automated PRs
- Before/after validation
-
Accessibility Monitoring (Q3 2025)
- Continuous production monitoring
- Regression detection
- User impact tracking with analytics
-
Design System Integration (Q4 2025)
- Component library analysis
- Accessible component recommendations
- Design token validation
12. Open Questions & Decisions Needed
-
Should we auto-apply safe fixes?
- Pro: Faster remediation
- Con: Developers may want control
- Decision: Offer as opt-in feature
-
Caption generation: Full automation or guidance?
- Option A: Integrate Whisper API for auto-transcription
- Option B: Provide detailed guidance only
- Decision: Start with guidance (Option B), add automation in v2
-
Screen reader testing: Simulation vs real?
- Simulation: Faster, automated
- Real: More accurate, requires infrastructure
- Decision: Both - simulation in CI/CD, real for critical flows
-
Integration with design tools (Figma, etc.)?
- Shift-left to design phase
- Requires additional effort
- Decision: Future enhancement (Q4 2025)
13. Conclusion
The a11y-ally agent represents a significant advancement in automated accessibility testing for the Agentic QE Fleet. By combining:
- Comprehensive WCAG 2.2 violation detection
- Context-aware, intelligent remediation
- Seamless integration with existing infrastructure
- Continuous learning and optimization
We can dramatically reduce accessibility barriers, ensure legal compliance, and make the web more inclusive for 1 billion people with disabilities.
Next Steps:
- Review and approve this plan
- Create implementation tasks in GitHub
- Begin Milestone 1 development
- Weekly progress reviews
Document Version: 1.0 Date: 2025-12-12 Author: Agentic QE Team Status: Awaiting Approval