设计系统验证器 design-system-validator

设计系统验证器是一个用于自动化检查前端代码是否符合设计系统规范的技能工具。它能够扫描CSS、SCSS、TypeScript和JavaScript文件,检测设计令牌使用违规、硬编码样式值、组件属性合规性等问题,生成详细的合规报告和修复建议。关键词:设计系统验证、前端代码检查、设计令牌合规、样式一致性检测、自动化代码审计、UI组件规范、CSS验证工具、前端开发规范、代码质量检查、设计系统工具。

前端开发 0 次安装 0 次浏览 更新于 2/26/2026

name: design-system-validator description: 验证代码是否符合设计系统规范,检查令牌使用、组件属性和样式一致性 allowed-tools:

  • Read
  • Write
  • Edit
  • Bash
  • Glob
  • Grep

设计系统验证器技能

目的

验证代码是否遵循设计系统规范,检查令牌使用、组件属性使用和样式一致性。

能力

  • 检查CSS/SCSS中的设计令牌使用
  • 验证组件属性使用
  • 检测应使用令牌的硬编码值
  • 确保命名约定合规性
  • 生成合规性报告
  • 与代码检查工具集成

目标流程

  • design-system.js
  • component-library.js

集成点

  • 用于设计系统的ESLint插件
  • 用于CSS验证的Stylelint
  • 自定义AST分析器
  • 令牌文档

输入模式

{
  "type": "object",
  "properties": {
    "scanPath": {
      "type": "string",
      "description": "要验证的代码路径"
    },
    "tokenDefinitions": {
      "type": "string",
      "description": "设计令牌定义文件路径"
    },
    "rules": {
      "type": "object",
      "properties": {
        "enforceTokenColors": { "type": "boolean", "default": true },
        "enforceTokenSpacing": { "type": "boolean", "default": true },
        "enforceTokenTypography": { "type": "boolean", "default": true },
        "allowHardcodedValues": { "type": "array", "items": { "type": "string" } }
      }
    },
    "fileTypes": {
      "type": "array",
      "items": { "type": "string" },
      "default": ["css", "scss", "tsx", "jsx"]
    },
    "severity": {
      "type": "string",
      "enum": ["error", "warning", "info"],
      "default": "warning"
    }
  },
  "required": ["scanPath", "tokenDefinitions"]
}

输出模式

{
  "type": "object",
  "properties": {
    "violations": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "file": { "type": "string" },
          "line": { "type": "number" },
          "rule": { "type": "string" },
          "message": { "type": "string" },
          "suggestion": { "type": "string" }
        }
      }
    },
    "summary": {
      "type": "object",
      "properties": {
        "filesScanned": { "type": "number" },
        "totalViolations": { "type": "number" },
        "byRule": { "type": "object" },
        "complianceScore": { "type": "number" }
      }
    },
    "tokenCoverage": {
      "type": "object",
      "description": "令牌使用统计"
    }
  }
}

使用示例

const result = await skill.execute({
  scanPath: './src/components',
  tokenDefinitions: './tokens/design-tokens.json',
  rules: {
    enforceTokenColors: true,
    enforceTokenSpacing: true,
    enforceTokenTypography: true
  },
  severity: 'warning'
});