Skip to main content
skill CX Codex

design-systems-slds-validate — Claude Code skill: SLDS audit for LWC

Checks Lightning Web Components against SLDS, runs the linter plus its own CSS and markup analysis, and returns a graded scorecard.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add forcedotcom/sf-skills --skill design-systems-slds-validate -a claude-code
Open on GitHub

What design-systems-slds-validate does

The skill starts with the SLDS linter run over a component path, then runs a bundled analyzer at scripts/analyze-quality.cjs to cover ground the linter skips. In stylesheets it flags theming hooks with no fallback, --slds-g-* tokens absent from hooks-index.json, background hooks left without a matching foreground hook, stray !important, and hardcoded pixel values. In templates it catches lightning-input without a label, icons missing alternative-text, images missing alt, skipped heading levels, and clickable div elements standing in for buttons.

After that comes a manual pass: the agent inspects loading, error and empty states and separates findings into blocking and advisory. Scoring then rolls up into a report. The linter needs Node.js and network access, so a restricted CI sandbox skips that stage and the overall grade is recomputed from the four remaining categories.

This is an assessment tool, not a fixer. Violations get handed off to design-systems-slds2-migrate in the same collection, while new components belong to design-systems-slds-apply. Accessibility coverage is thin: attribute presence is checked, contrast ratios and keyboard flows are not. The analyzer reads .css, .html and .js files, so JSX or Vue templates need separate review.

What it helps with

  • grade a component's SLDS compliance before code review
  • find invented theming hooks in stylesheets
  • catch unlabeled inputs and icons in LWC templates
  • compare styling quality before and after a change
  • check that loading, error and empty states exist

Example prompts for the agent

  • Run an SLDS audit on force-app/main/default/lwc/myComponent and show me the scorecard
  • Is this LWC ready to ship by SLDS standards? Split the findings into blocking and advisory
  • Compare this component's SLDS grade with what it had before my edits

How to install design-systems-slds-validate

1Skills CLI (Vercel)

npx skills add forcedotcom/sf-skills --skill design-systems-slds-validate -a claude-code

2Manually: put the files in place

~/.claude/skills/design-systems-slds-validate/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/design-systems-slds-validate/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about design-systems-slds-validate

How do I install design-systems-slds-validate in Claude Code?

Run npx skills add forcedotcom/sf-skills --skill design-systems-slds-validate -a claude-code. The skill lands in ~/.claude/skills/design-systems-slds-validate/SKILL.md.

What does design-systems-slds-validate do?

It runs the SLDS linter and a supplementary analyzer over CSS, HTML and JS, then the agent reviews component states by hand. You get category scores and a production-readiness report.

How is it different from design-systems-slds2-migrate?

This skill only finds and scores problems. Fixing them is the job of design-systems-slds2-migrate, and building fresh components is covered by design-systems-slds-apply.

Source text

SKILL.md · Apache-2.0
---
name: design-systems-slds-validate
description: "Audit Lightning Web Components for SLDS design-system compliance and produce a scored quality report. Runs the SLDS linter and analyzes CSS for theming hook usage and pairing, scoring SLDS findings across categories into an overall grade. Use when asked to \"score my component's SLDS\", \"SLDS scorecard\", \"SLDS quality report\", \"audit SLDS compliance\", \"how good is my SLDS\", \"check SLDS quality\", \"rate my SLDS styling\", \"evaluate my component's SLDS\", \"is this component's SLDS ready to ship?\", \"look at my LWC for SLDS issues\", \"audit SLDS before I submit\", \"review my component's SLDS before code review\", or any time a user wants an SLDS quality assessment or SLDS production-readiness check on an LWC. Not for fixing violations (use design-systems-slds2-migrate), building new components (use design-systems-slds-apply), or accessibility/WCAG/ARIA audits (use experience-accessibility-validate)."
metadata:
  version: "1.0"
  domains: ["Design Systems"]
  relatedSkills:
    - "design-systems-slds-apply"
    - "design-systems-slds2-migrate"
    - "experience-accessibility-validate"
  cliTools:
    - tool: ["npx"]
      semver: ">=7.0.0"
    - tool: ["node"]
      semver: ">=18.0.0"
---

# SLDS Quality Audit

Audit Lightning Web Components for SLDS compliance and produce an automated scorecard plus a required manual review gate. Combines SLDS linter output with supplementary static analysis to catch what the linter misses.

## Scope

Also valid for: auditing SLDS compliance across a project or component set, and before/after quality comparison after making changes.

Not for:
- **Fixing** linter violations — use `design-systems-slds2-migrate` instead
- **Building** new components — use `design-systems-slds-apply` instead
- **Just running the linter** — run `npx @salesforce-ux/slds-linter@latest lint .` directly
- **Full WCAG accessibility audit** — this skill checks attribute presence only (labels, alt text, focus indicators), not contrast ratios, keyboard flows, or screen reader behavior
- **Framework-specific template auditing** beyond `.css`, `.html`, and `.js` files — JSX/TSX/Vue/Svelte outputs need additional manual review

---

## Quality Validation Process

```text
1. Run SLDS Linter     → Collect violation counts (linter's job)
2. Run Analyze Script  → Check what linter doesn't cover (supplementary)
3. Agent Review        → Required manual review gate
4. Score & Grade       → Compute automated score + final recommendation
5. Generate Report     → Produce formatted scorecard
```

## Step 1: Run SLDS Linter

Run the linter to collect baseline violation data:

```bash
npx @salesforce-ux/slds-linter@latest lint <component-path> 2>&1
```

Count violations by rule. These feed directly into the **Linter Compliance** score:

| Rule | Impact |
|------|--------|
| `slds/class-override` | Breaks theming, dark mode |
| `slds/lwc-token-to-slds-hook` | SLDS 1 technical debt |
| `slds/no-hardcoded-values` | Breaks theming, accessibility |

**Linter Compliance Score** = `100 - (total_violations × 10)`, minimum 0.

**If the linter is unavailable** (no Node.js, no network access, CI sandbox restrictions): skip this step, note "Linter not run" in the report header, mark Linter Compliance as N/A, and compute the Overall score using the remaining 4 categories renormalized to 100%:

```text
Overall (linter unavailable) = (Theming × 0.29) + (Accessibility × 0.29)
                              + (CodeQuality × 0.21) + (ComponentUsage × 0.21)
```

## Step 2: Run Supplementary Analysis

Run the analyze script to catch issues the linter doesn't cover. The bundled analyzer scans `.css`, `.html`, and `.js` files only:

```bash
node scripts/analyze-quality.cjs <component-path>
```

The script outputs JSON with findings organized by severity. It checks:

### CSS Checks (linter-complementary)

| Check | What It Catches | Severity |
|-------|----------------|----------|
| Missing fallbacks | `var(--slds-g-*)` without a fallback value | Critical |
| Invented hooks (T051) | `--slds-g-*` tokens not found in `hooks-index.json` (requires `--hooks-index`) | Critical |
| Hook pairing | Background hooks without matching foreground hooks | Warning |
| `!important` | Specificity overrides | Warning |
| Magic pixel values | Hardcoded `px` not using spacing hooks | Warning |
| High z-index | z-index values > 99 | Warning |
| Outline removal | `outline: none` without alternative focus style | Warning |

### JS Checks

| Check | What It Catches | Severity |
|-------|----------------|----------|
| Inline style assignment | `.style.*=` direct property assignment | Warning |
| SLDS class manipulation | Dynamic `.classList.add('slds-*')` manipulation | Warning |

### HTML Checks

| Check | What It Catches | Severity |
|-------|----------------|----------|
| LBC input labels | `<lightning-input>` without `label` attribute | Critical |
| Icon alt text | `<lightning-icon>` without `alternative-text` | Critical |
| Image alt text | `<img>` without `alt` | Critical |
| Heading hierarchy | Skipped heading levels (h2 to h4) | Warning |
| Positive tabindex | `tabindex` values other than 0 or -1 | Warning |
| Clickable divs | `<div onclick>` instead of `<button>` | Warning |
| Inline styles | `style="..."` attributes | Warning |
| Native elements | `<input>`, `<button>`, `<select>` where LBC alternatives exist | Warning |

### Hook Pairing Validation

The script checks that background/foreground hooks are semantically paired:

```text
surface-* backgrounds     → on-surface-* text
surface-container-* bg    → on-surface-* text
accent-* backgrounds      → on-accent-* text
accent-container-* bg     → on-accent-* text
```

> **Limitation:** Hook pairing is checked at the file level, not per-selector. A file with `surface-1` in `.classA` and `on-accent-1` in `.classB` would pass because both surface and accent families are present. Review pairing correctness per-selector during manual review (Step 3).

### Invented Hook Detection (T051)

The script cross-references every `--slds-g-*` token in CSS against `hooks-index.json`. Any hook not found in metadata is flagged as critical — this catches the most common agent mistake of inventing hooks from naming patterns.

## Step 3: Agent Manual Review

These checks require understanding the component's purpose and cannot be automated reliably. Review each and classify findings as either:

- **Blocking** — incorrect blueprint structure, missing required states, or semantic/interaction issues that make the component not production-ready
- **Advisory** — worthwhile improvements that do not block shipping on their own

| Review Area | What to Look For |
|-------------|-----------------|
| Loading states | Does the component show a spinner or skeleton when fetching data? |
| Error states | Are errors surfaced to the user with actionable messages? |
| Empty states | Is there a meaningful empty state when no data exists? |
| Disabled states | Do interactive elements visually and functionally handle disabled? |
| Semantic HTML | Are `<nav>`, `<article>`, `<section>` used where appropriate? |
| SLDS blueprint compliance | Do cards, modals, forms follow SLDS blueprint structure? |

> Manual review findings are not automated, but they do affect the final recommendation. Do not report an automated grade as the only verdict.

## Step 4: Calculate Automated Scores and Final Recommendation

### Component Complexity

Before scoring, classify the component to give the score context:

| Complexity | Criteria | Report Note |
|------------|----------|-------------|
| Small | 1-2 files, < 100 total lines | Score is high-confidence (small surface area) |
| Medium | 3-6 files, 100-500 total lines | Score reflects typical component |
| Large | 7+ files, 500+ total lines | Score reflects absolute issue count — even well-built large components may score lower |

Include the complexity classification in the report header. This prevents misreading a "B" on a 1000-line component vs. a "B" on a 20-line component.

### Automated Scoring Formula

```text
Category Score = 100 - (critical_issues × 10) - (warnings × 3) - (info × 1)
Minimum score: 0
```

### Categories and Weights

| Category | Weight | Source |
|----------|--------|--------|
| Linter Compliance | 30% | SLDS linter output (Step 1) |
| Theming | 20% | Script: fallbacks, hook pairing (Step 2) |
| Accessibility | 20% | Script: labels, alt text, focus (Step 2) |
| Code Quality | 15% | Script: !important, inline styles, z-index (Step 2) |
| Component Usage | 15% | Script: native elements (Step 2) plus manual semantic/blueprint review (Step 3) |

### Automated Overall Score

```text
Overall = (Linter × 0.30) + (Theming × 0.20) + (Accessibility × 0.20)
        + (CodeQuality × 0.15) + (ComponentUsage × 0.15)
```

### Automated Grade Thresholds

| Score | Grade | Meaning |
|-------|-------|---------|
| 90-100 | A | Excellent automated score |
| 80-89 | B | Good automated score |
| 70-79 | C | Acceptable automated score |
| 60-69 | D | Weak automated score |
| 0-59 | F | Failing automated score |

### Manual Review Gate

After computing the automated score, apply the manual review outcome:

| Gate | When to use it | Effect on final recommendation |
|------|----------------|-------------------------------|
| Pass | No manual findings | Final recommendation can follow the automated score |
| Advisory | Only non-blocking manual findings | Final recommendation can be "Ready with follow-ups" at best |
| Blocking | One or more blocking manual findings | Final recommendation is **not ready for production**, regardless of automated grade |

### Final Recommendation Rules

Use both the automated score and the manual review gate:

| Final Recommendation | Conditions |
|----------------------|------------|
| Ready for production | Automated grade A/B, no critical findings, manual gate = Pass |
| Ready with follow-ups | Automated grade A/B, no critical findings, manual gate = Advisory |
| Needs work | Any critical findings, automated grade C/D, or manual gate = Blocking |
| Failing | Automated grade F |

## Step 5: Generate Quality Report

Use the template in **[report-format.md](references/report-format.md)** to produce the final report. Default to the **compact format** for initial output and expand sections on request.

The report includes:
- Executive summary with automated grade and final recommendation
- Manual review gate outcome (`Pass`, `Advisory`, or `Blocking`)
- Scores by category with visual indicators
- Detailed findings organized by severity
- Specific code locations and recommendations
- Checklist of required actions

---

## Quick Validation Mode

For a rapid quality check without full analysis:

1. Run linter: `npx @salesforce-ux/slds-linter@latest lint <path>`
2. Count violations by type
3. Report summary only

```text
Quick Quality Check: <component-name>
─────────────────────────────────────
Linter Violations:
  • Class Override:     0
  • Deprecated Tokens:  3
  • Hardcoded Values:   5

Quick Automated Grade: C (estimated)
Run full validation for detailed report.
```

---

## Edge Cases and False Positives

| Situation | Guidance |
|-----------|----------|
| **Headless components** (JS-only, no HTML) | Skip HTML checks; score only CSS + linter categories |
| **Wrapper/container components** | May legitimately have minimal CSS; don't penalize low hook usage |
| **Intentional native elements** | `<button>` inside custom SLDS blueprints is correct; suppress C002 if inside an `slds-*` blueprint structure |
| **Components outside LEX** | LWR/Experience Cloud components may not use Lightning Base Components; note context in report |
| **Test/demo components** | Lower the bar — note in report but don't block on warnings |

If a check produces a false positive, note it in the report as "suppressed" with justification rather than silently dropping it.

---

## References

- **[Quality Checks](references/quality-checks.md)** - Complete list of all quality checks with detection patterns
- **[Report Format](references/report-format.md)** - Quality report template and formatting guide
- **[Analyze Script](scripts/analyze-quality.cjs)** - Automated analysis for linter-complementary checks
- **design-systems-slds2-migrate skill** - How to fix linter violations
- **design-systems-slds-apply skill** - Guide for building new components with correct patterns

© forcedotcom · Apache-2.0 · forcedotcom/sf-skills

Similar skills

Everything for Design →

From the same set181

platform-flexipage-generate Builds and validates Salesforce Lightning FlexiPages using CLI scaffolding. It prevents XML structure errors when editing RecordPage, AppPage, and HomePage layouts. CX Codex +1 6,000installs design-systems-slds-apply A skill that teaches the agent to build Salesforce Lightning Design System interfaces: blueprints, styling hooks, utility classes and icons. CX Codex +1 6,000installs platform-metadata-api-context-get Hands the agent the exact schema for 604 Salesforce Metadata API types so generated -meta.xml files deploy cleanly. CX Codex +1 6,000installs dx-org-manage Executes Salesforce scratch org operations directly using the sf CLI without shell scripts. Useful for creating, listing, and deleting orgs inside agent sessions. CX Codex +1 6,100installs agentforce-generate Builds, audits, and debugs Salesforce Agentforce agents using Agent Script. Automates .agent files, AiAuthoringBundle metadata, and deployment via sf CLI. CX Codex +1 5,900installs platform-custom-application-generate Generates Salesforce Lightning CustomApplication metadata with tab navigation, custom branding, and action overrides. Useful when structuring role-specific apps. CX Codex +1 5,800installs agentforce-architecture-analyze Builds a metadata tree for one Agentforce agent: planner, topics, actions, flows, Apex, prompts and NGA plugins. Renders a document and a Mermaid invocation graph. CX Codex +1 5,800installs platform-custom-tab-generate Writes Salesforce custom tab metadata for objects, external web pages and Visualforce pages. Useful when an app needs new navigation or a tab file keeps failing to deploy. CX Codex +1 5,800installs

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor