Skip to main content

preset_compliance_score

Returns a 0-100 compliance score for code against the design system.

Reference

Parameters

  • Name
    code
    Type
    string · required
    Description

    The code to score

  • Name
    componentName
    Type
    string · optional
    Description

    Component name for context

  • Name
    fileContext
    Type
    string · optional
    Description

    File path for context-aware rule matching

  • Name
    intent
    Type
    string · optional
    Description

    What the code is meant to do

  • Name
    layerId
    Type
    string · optional
    Description

    Design system layer UUID

Returns

{
  score                  0-100 overall compliance score, or null when unchecked
  grade                  A/B/C/D/F letter grade, or null when unchecked
  breakdown              { tokens, patterns, accessibility, consistency } — per-dimension 0-100 scores, or null when unchecked
  unchecked              true when no rule at warn or block applied and nothing was found. Then score, grade and breakdown are null and nothing is logged: there is no compliance score for code nothing binding checked. Not a pass.
  bindingRules           how many design system rules at warn or block applied
  violationCounts        { errors, warnings, advisories, total } — advisories are findings from rules the design system does not enforce. They deduct NOTHING from the score and are excluded from the warnings count; they are reported so they stay visible, not so they are acted on.
  violationsByDimension  violations grouped by scoring dimension
  suggestions            actionable improvement suggestions
}

Description

Returns a 0-100 compliance score for code against the design system.

Use this as a quality gate — run after generating or fixing code to get a single metric that tells you whether the code meets design system standards.

Parameters:

  • code (required): The code to score
  • componentName (optional): Component name for context
  • fileContext (optional): File path for context-aware rule matching
  • intent (optional): What the code is meant to do
  • layerId (optional): Design system layer UUID

Scoring weights: tokens 30%, patterns 25%, accessibility 25%, consistency 20%. Score >= 80 (grade B or above) is generally acceptable for production code.

Source

Defined in packages/mcp/src/tools.ts. The request handler lives alongside its registration in packages/mcp/src/tools/.

Was this page helpful?

Last reviewed by @jschuyler