Claude Skills Guide

Color Contrast Checking Workflow with Claude Code

Color contrast checking is a critical yet often overlooked aspect of web accessibility. Ensuring your text meets WCAG guidelines protects users with visual impairments and keeps your project legally compliant. This guide walks you through a practical workflow using Claude Code skills to systematically check and verify color contrast across your entire project.

Why Color Contrast Checking Matters

Web Content Accessibility Guidelines (WCAG) 2.1 specify minimum contrast ratios: 4.5:1 for normal text and 3:1 for large text. Failure to meet these standards excludes users with low vision, color blindness, or those viewing content on poorly calibrated displays. Many development teams treat accessibility as an afterthought, discovering issues only during expensive audits or, worse, after legal complaints.

Integrating color contrast checking into your regular development workflow catches problems early. The key is automation—manual checking becomes impractical as codebases grow. Claude Code skills provide the tooling to make contrast checking a seamless part of your development process.

Prerequisites and Skill Setup

Before implementing this workflow, ensure Claude Code is installed and configured. You will need several skills available in the Claude Skills ecosystem:

To install skills, clone community skill repositories from GitHub and place the .md files in ~/.claude/skills/. Skills activate automatically when their trigger patterns match your prompts.

Step 1: Audit Existing Color Values

Begin by cataloging all color values used throughout your project. Create a dedicated file to track these values and their usage contexts. This inventory becomes your reference point for systematic checking.

Use Claude Code to scan your project files:

grep -rE "#[0-9A-Fa-f]{3,6}|rgb\(|rgba\(|hsl\(" --include="*.css" --include="*.scss" --include="*.ts" --include="*.tsx" src/

Feed the results to Claude with a prompt like: “Organize these color values into a table with their file locations and usage contexts (background, text, borders, etc.).”

Step 2: Calculate Contrast Ratios

Once you have your color inventory, calculate contrast ratios for each text-on-background combination. Claude Code can perform these calculations directly:

function getContrastRatio(foreground, background) {
  const getLuminance = (color) => {
    const rgb = color.match(/\d+/g).map(Number);
    const [r, g, b] = rgb.map(c => {
      c = c / 255;
      return c <= 0.03928 ? c / 12.92 : Math.pow((c + 0.055) / 1.055, 2.4);
    });
    return 0.2126 * r + 0.7152 * g + 0.0722 * b;
  };
  
  const l1 = getLuminance(foreground);
  const l2 = getLuminance(background);
  const lighter = Math.max(l1, l2);
  const darker = Math.min(l1, l2);
  
  return (lighter + 0.05) / (darker + 0.05);
}

Ask Claude to evaluate each color pair against WCAG requirements and flag combinations that fail. Group failures by severity: below 3:1 is a critical failure, 3:1 to 4.5:1 fails for normal text but passes large text.

Step 3: Integrate Automated Testing

Incorporate contrast checking into your test suite using the tdd skill. Create visual regression tests that capture contrast failures:

import { checkContrast } from 'axe-core';

describe('Color Contrast Compliance', () => {
  it('primary text meets WCAG AA requirements', async () => {
    const violations = await checkContrast();
    const failures = violations.filter(v => 
      v.impact === 'serious' || v.impact === 'critical'
    );
    
    expect(failures).toHaveLength(0);
  });
});

Run these tests in your CI pipeline to prevent accessibility regressions. The super-memory skill can track historical contrast test results, helping you identify patterns in where violations typically occur.

Step 4: Generate Comprehensive Reports

For stakeholder communication and documentation, generate detailed contrast audit reports. Use the pdf skill to create professional documents:

# Color Contrast Audit Report

## Executive Summary
Total color pairs checked: 47
Passing: 38 (81%)
Failing: 9 (19%)

## Critical Failures
[Detailed table of failing combinations with suggested fixes]

## Recommendations
[Prioritized list of remediation steps]

Claude Code can generate these reports automatically after running contrast analysis, saving hours of manual documentation work.

Step 5: Continuous Monitoring

Implement pre-commit hooks that block code with obvious contrast violations:

# .git/hooks/pre-commit
npx @axe-core/cli https://localhost:3000 --exit

For design systems, create living documentation that specifies approved color combinations. The frontend-design skill can generate these guidelines automatically based on your project’s color palette and WCAG requirements.

Handling Dynamic Content

Color contrast checking becomes more complex with dynamic content. User-generated content, dark mode switches, and theme variations multiply the number of color combinations to verify. Address this through:

  1. Theme matrices: Test all color scheme combinations (light/dark, high contrast modes)
  2. Content sampling: Check representative samples of user content types
  3. Runtime validation: Implement client-side contrast checking that alerts users to problematic combinations

Common Pitfalls to Avoid

Several mistakes weaken color contrast checking workflows:

Addressing these gaps requires expanding your testing matrix and automating checks across environments.

Measuring Success

Track your accessibility metrics over time. Aim for zero critical contrast failures in automated tests. Use Lighthouse accessibility scores as a baseline metric:

lhci autorun --config=lighthouserc.json

Improvement shows in rising scores, reduced test failures, and faster remediation cycles.


Built by theluckystrike — More at zovo.one