Zing 论坛

正文

DSCP:让AI在生成代码前理解你的设计系统

Design System Context Protocol (DSCP) 是一个开源规范,通过结构化文档将设计系统的约束传递给生成式AI,确保AI生成的代码符合设计规范而非硬编码数值。

DSCPDesign SystemAIGenerative AIDesign TokensCode GenerationLapidistMCPLintFrontend
发布时间 2026/06/03 07:15最近活动 2026/06/03 07:18预计阅读 7 分钟
DSCP:让AI在生成代码前理解你的设计系统
1

章节 01

DSCP: Bridging Design Systems and AI Code Generation

Design System Context Protocol (DSCP) is an open-source规范 that addresses the gap between design systems and AI-generated code. It uses structured documents to pass design system constraints to generative AI, ensuring AI-generated code follows design规范 instead of hardcoding values. This protocol helps maintain consistency and reduce maintenance costs for teams using AI in development.

2

章节 02

The Gap Between Design Systems and AI Code Generation

When teams use AI for programming, a common issue arises: AI-generated code often contains hardcoded values (like #3B82F6, 16px) instead of referencing design system tokens. This breaks design consistency and increases maintenance costs. The root cause is AI's lack of knowledge about the team's design system—such as brand colors, spacing rules, or deprecated components.

3

章节 03

Definition of DSCP

DSCP is a versioned open-source规范 that defines a standardized way to pass complete design system constraints to generative AI models. It acts as a machine-readable "design system manual" containing:

  • Design Token图谱 (color, font, spacing tokens and their hierarchy)
  • Component registry (available components, versions, dependencies)
  • Deprecation records (deprecated tokens/components and their replacements)
  • Violation patterns (common past errors)
  • Lint rules (active code规范)

It ensures AI knows all necessary context before generating code.

4

章节 04

DSCPDocument: The Standardized Structure

DSCP defines a standard JSON document structure called DSCPDocument with key fields:

Field Description
$schema JSON Schema URI
specVersion 规范 version (current v1.0.0)
generatedAt Document generation timestamp
kernelSnapshotHash DSR kernel snapshot hash
tokenGraph Token图谱
componentRegistry Component registry
deprecationLedger Deprecation records
violations Violation patterns
rules Active Lint rules summary

This structure is tool-agnostic, allowing any tool (DSR, custom scripts, third-party tools) to generate valid DSCP documents.

5

章节 05

Key Components of DSCP

Token Graph: The core part of DSCPDocument, organizing tokens by type. Each token entry includes pointer (DTIF path), name (e.g., color.brand.primary), type (color/fontSize), value, deprecated status, and replacement (if deprecated). This lets AI reference correct tokens instead of hardcoding values.

Violation Patterns: Records past code errors like misused raw values (e.g., color: #3B82F6 instead of color.brand.primary). It includes CSS property, raw value, frequency, correct token, and whether AI introduced it. This helps AI learn from history and avoid repeating mistakes.

6

章节 06

DSCP Ecosystem and Tool Support

DSCP is tool-agnostic and works with various tools:

  • AI programming assistants (via MCP server protocol)
  • Code generation pipelines (inject design context before code generation)
  • Design system Lint tools (validate code against DSCP constraints)
  • CI hooks (check for violations in continuous integration)

DSCP documents can also be rendered as human-readable DESIGN_SYSTEM.md files with HTML comments for machine parsing.

7

章节 07

Practical Benefits of DSCP

For teams building/maintaining design systems, DSCP provides:

  1. Consistency: AI-generated code follows design规范, eliminating inconsistent values.
  2. Lower maintenance: Reduced hardcoding means fewer "magic numbers" to clean up.
  3. Faster development: Developers don't need to memorize all tokens—AI references the correct ones.
  4. Smooth migration: Deprecation records and replacements support gradual design system upgrades.
8

章节 08

Summary and Future of DSCP

DSCP offers a new approach to combining design systems and AI code generation: instead of AI guessing规范, it's given structured context upfront. This "context-first" protocol provides reliable infrastructure for AI-assisted development.

As generative AI becomes more prevalent in software development, protocols like DSCP may become key bridges between human design intent and machine code generation. Teams wanting to use AI without sacrificing design consistency should keep an eye on DSCP.