Skip to main content

AI-assisted development has made it easier to generate frontend code quickly. A developer can ask for a form, a dashboard widget, a settings page, or a modal flow and get a working first draft in seconds. That speed is useful, especially when teams are moving through routine UI work.AI 辅助开发让快速生成前端代码变得更加容易。开发者只需提出需求,比如创建一个表单、仪表盘小部件、设置页面或模态框流程,几秒钟内就能获得一份可用的初稿。这种速度非常有用,特别是在团队处理常规 UI 工作时。

But speed creates a problem that’s easy to miss at first. If every AI-generated feature introduces its own components, styling choices, interaction patterns, and accessibility decisions, the frontend can become inconsistent very quickly. A product may end up with forms that handle errors differently, modals that behave differently, buttons that look almost right but don’t behave the same way, and small interaction differences that slowly become expensive. This is where design systems become much more important.然而,这种速度带来了一个起初很容易被忽视的问题。如果每个 AI 生成的功能都引入自己的组件、样式选择、交互模式和无障碍决策,前端很快就会变得不一致。产品最终可能会出现处理错误方式各异的表单、行为不统一的模态框、外观相似但交互逻辑不同的按钮,以及逐渐累积成高昂维护成本的微小交互差异。这正是设计系统变得愈发重要的原因。

A design system is often described as a way to keep visual design consistent. It provides shared colors, typography, spacing, components, and usage rules. That still matters. But in an AI-assisted workflow, a design system can do more than make interfaces look consistent. It can become the control plane for AI-generated UI.设计系统通常被描述为保持视觉设计一致性的一种手段。它提供共享的颜色、排版、间距、组件和使用规则。这些依然很重要。但在 AI 辅助的工作流中,设计系统的作用不仅限于让界面看起来一致,它还可以成为 AI 生成式 UI 的控制平面。

By control plane, I mean the layer that guides how interfaces are created, what patterns are allowed, and which decisions should not be reinvented every time a new screen is built. A strong design system can encode accessibility, interaction behavior, content guidance, component boundaries, and safe defaults. It gives both developers and coding agents a shared set of rules to work from. Without that layer, AI tools have too much freedom.我所说的“控制平面”,是指指导界面如何创建、允许哪些模式、以及在构建新屏幕时无需重复决策的层级。一个强大的设计系统可以编码无障碍规范、交互行为、内容指南、组件边界和安全默认值。它为开发者和编码代理提供了一套共同的规则。如果没有这一层,AI 工具的自由度就会过高。

AI can generate UI faster than teams can standardize itAI 生成 UI 的速度快于团队对其进行标准化的速度

Frontend teams already struggle with consistency. Even without AI, it’s common to find several versions of the same pattern inside a product. Some of this happens because teams move fast. Some of it happens because older code stays around for years. Some of it happens because people solve local problems without seeing the whole system.前端团队本就在为一致性而挣扎。即使没有 AI,在一个产品中发现同一模式的多个版本也是常事。部分原因是团队节奏过快,部分是因为旧代码长期留存,还有部分是因为人们在解决局部问题时缺乏全局视角。

AI can accelerate that problem. When a coding agent is asked to build a new feature, it usually tries to satisfy the immediate request. If the prompt says “build a filter panel,” it may create a solution that works in isolation but doesn’t match how the rest of the product handles filtering, validation, loading states, or keyboard behavior.AI 会加剧这个问题。当要求编码代理构建一个新功能时,它通常会试图满足即时请求。如果提示词是“构建一个筛选面板”,它可能会创建一个孤立的解决方案,但却与产品其余部分处理筛选、验证、加载状态或键盘行为的方式不匹配。

That’s the risk. AI-generated UI can look reasonable in a single pull request while quietly increasing inconsistency across the product. Design systems help by reducing the number of decisions that need to be made from scratch. The question should not be, “Can the AI generate a working dropdown?” The better question is, “Should this feature use the existing dropdown pattern, and does that pattern already handle the behavior we need?” When the answer is yes, the AI should compose the existing pattern rather than inventing a new one.这就是风险所在。AI 生成的 UI 在单次拉取请求(Pull Request)中看起来可能没问题,但却在悄无声息地增加整个产品的不一致性。设计系统通过减少从零开始决策的数量来提供帮助。问题不应该是“AI 能否生成一个可用的下拉菜单?”,更好的问题是“这个功能是否应该使用现有的下拉菜单模式,且该模式是否已经处理了我们需要的行为?”当答案为是时,AI 应该组合现有模式,而不是发明一个新模式。

Design systems are not only component libraries设计系统不仅是组件库

Many teams treat the design system as a component library. That’s a good start, but it isn’t enough. A component library gives developers reusable building blocks. A design system should also explain when to use those building blocks, how they behave, what content they require, and what constraints they carry. This becomes especially important when AI tools are involved because the agent needs context, not just code.许多团队将设计系统视为组件库。这是一个好的开始,但还不够。组件库为开发者提供了可重用的构建块。设计系统还应说明何时使用这些构建块、它们如何表现、需要什么内容以及它们带有何种约束。当涉及 AI 工具时,这一点尤为重要,因为代理需要的是上下文,而不仅仅是代码。

A button component, for example, is not only a styled element. It carries decisions about hierarchy, states, labels, disabled behavior, loading behavior, and focus visibility. A modal carries decisions about focus movement, escape behavior, headings, accessible names, background interaction, and what happens when it closes. A form field carries decisions about labels, helper text, validation, error messages, required state, and programmatic relationships.例如,按钮组件不仅仅是一个带样式的元素。它还承载了关于层级、状态、标签、禁用行为、加载行为和焦点可见性的决策。模态框承载了关于焦点移动、退出行为、标题、无障碍名称、背景交互以及关闭时触发事件的决策。表单字段则承载了关于标签、辅助文本、验证、错误消息、必填状态和程序化关联的决策。

If these rules live only in people’s heads, AI tools will not know them. If they live in the design system, they can be reused, documented, tested, and referenced. The design system becomes a source of truth for both humans and agents.如果这些规则只存在于人们的脑海中,AI 工具将无法获知。如果它们存在于设计系统中,就可以被复用、记录、测试和引用。设计系统成为了人类和代理共同的“事实来源”。

The design system gives AI safer defaults设计系统为 AI 提供了更安全的默认值

AI-generated code is shaped by context. If the agent has no project context, it will rely on general patterns and whatever the developer includes in the prompt. Sometimes that works. Often, it produces code that’s close but not quite aligned with the product.AI 生成的代码受上下文影响。如果代理没有项目上下文,它将依赖通用模式和开发者在提示词中包含的内容。有时这行得通,但往往会产生与产品不完全契合的代码。

A design system gives the agent safer defaults. Instead of asking an AI tool to “create a confirmation modal,” the team can instruct it to use the existing modal component, the standard button variants, the approved alert pattern, and the documented content structure for destructive actions. The agent still helps assemble the feature, but the riskiest decisions are already handled by the system.设计系统为代理提供了更安全的默认值。团队无需让 AI 工具“创建一个确认模态框”,而是可以指示它使用现有的模态框组件、标准按钮变体、已批准的警告模式以及针对破坏性操作的记录内容结构。代理仍然负责组装功能,但风险最高的决策已由系统处理。

This matters because many UI decisions aren’t just visual preferences. They affect whether people can use the product. A custom modal might forget to manage focus. A custom button might lose visible focus styles. A custom form field might show an error visually but fail to connect it to the input. These details are easy to miss when a generated interface looks polished, and they are exactly the kind of details that good design-system components can carry by default.这一点至关重要,因为许多 UI 决策不仅仅是视觉偏好,它们直接影响用户能否使用产品。自定义模态框可能会忘记管理焦点,自定义按钮可能会丢失可见的焦点样式,自定义表单字段可能会在视觉上显示错误,却无法将其与输入框关联。当生成的界面看起来很精致时,这些细节很容易被忽视,而这正是优秀的设计系统组件默认就能处理好的细节。

Project instructions should point agents to the design system项目指令应引导代理参考设计系统

Prompts are useful, but they aren’t the whole workflow. If developers have to repeat every design-system rule in every prompt, the process becomes fragile. Someone will forget. Someone will write a shorter prompt. Someone will assume the tool already knows the standard.提示词很有用,但它们并非工作流的全部。如果开发者必须在每个提示词中重复设计系统的每一条规则,流程就会变得脆弱。总会有人忘记,有人会写出简略的提示词,或者有人会假设工具已经了解标准。

A better approach is to make design-system expectations part of the agent’s persistent project context. For some teams, that might mean a CLAUDE.md file, an agent startup file, or another project-level instruction source. The exact mechanism will vary by tool, but the principle is the same: The agent should know the standing rules before it starts generating feature code.更好的方法是将设计系统的期望纳入代理的持久化项目上下文中。对于某些团队来说,这可能意味着一个 CLAUDE.md 文件、代理启动文件或其他项目级指令源。具体的机制因工具而异,但原则是一样的:代理在开始生成功能代码之前,就应该了解既定规则。

Those rules might include instructions to use existing design-system components before creating new ones, prefer native HTML elements when possible, avoid custom controls without a clear reason, follow documented form and modal patterns, include meaningful loading and error states, and follow the project’s accessibility expectations.这些规则可能包括:在创建新组件前优先使用现有设计系统组件、尽可能使用原生 HTML 元素、无明确理由避免使用自定义控件、遵循记录在案的表单和模态框模式、包含有意义的加载和错误状态,以及遵循项目的无障碍期望。

Then the feature prompt can stay focused on what’s unique about the task. The persistent instructions describe how the team builds UI. The task prompt describes what this particular feature needs to do. That separation makes AI-assisted development less dependent on prompt quality alone and more dependent on shared engineering standards.这样,功能提示词就可以专注于任务的独特性。持久化指令描述团队如何构建 UI,而任务提示词描述该特定功能需要做什么。这种分离使得 AI 辅助开发不再仅仅依赖提示词质量,而是更多地依赖共享的工程标准。

A design system can reduce review burden设计系统可以减轻审查负担

Code review becomes harder when AI generates large amounts of plausible-looking code. Reviewers may see a clean diff and assume the obvious decisions were handled correctly. But frontend quality is full of details that don’t always show up in a quick scan.当 AI 生成大量看起来像模像样的代码时,代码审查变得更加困难。审查者可能会看到一个干净的差异对比(diff),并假设显而易见的决策处理得当。但前端质量充满了在快速扫描中无法体现的细节。

A design system can reduce the number of things reviewers need to check manually. If the feature uses the approved modal component, the reviewer doesn’t need to reevaluate focus handling from scratch every time. If the form uses the standard FormField component, the reviewer can have more confidence that labels, descriptions, and error messages are connected properly. The review can shift from “Did the generated code invent this pattern correctly?” to “Did the generated code use the right pattern in the right way?”设计系统可以减少审查者需要手动检查的项目数量。如果功能使用了已批准的模态框组件,审查者就不必每次都从头重新评估焦点处理。如果表单使用了标准的 FormField 组件,审查者可以更确信标签、描述和错误消息已正确关联。审查过程可以从“生成的代码是否正确发明了这个模式?”转变为“生成的代码是否以正确的方式使用了正确的模式?”

That’s a much better question. It also helps teams avoid the slow drift that happens when every feature is slightly different. Small differences may not matter in a prototype. In a production product, they add up. They make the UI harder to maintain, harder to test, and harder for users to learn.这是一个好得多的问题。它还有助于团队避免因每个功能略有不同而产生的缓慢偏离。微小的差异在原型中可能无关紧要,但在生产环境中,它们会累积起来,使得 UI 更难维护、更难测试,也更难让用户学习。

The design system should include behavior设计系统应包含行为规范

For AI-generated UI, the most useful design systems are the ones that document behavior clearly. A visual example of a component is helpful, but it isn’t enough. Agents and developers also need to know how the component should behave in real situations.对于 AI 生成的 UI,最有用的设计系统是那些能清晰记录行为的系统。组件的视觉示例很有帮助,但还不够。代理和开发者还需要知道组件在真实场景中应如何表现。

A modal page in the design system should not only show what a modal looks like. It should explain when to use a modal, when not to use one, how focus should behave, what kind of heading is required, and how destructive actions should be confirmed. A form pattern should explain labels, helper text, validation timing, error recovery, and submit behavior.设计系统中的模态框页面不仅应展示模态框的样子,还应解释何时使用模态框、何时不该使用、焦点应如何表现、需要什么样的标题,以及如何确认破坏性操作。表单模式应解释标签、辅助文本、验证时机、错误恢复和提交行为。

The more clearly these patterns are documented, the easier they are to use as AI context. That context does not have to be perfect. It just has to be better than asking an agent to guess.这些模式记录得越清晰,就越容易作为 AI 上下文来使用。上下文不必完美,只需比让代理猜测要好即可。

The harder part is discipline更困难的部分是纪律

The technical side is only part of the story. Design systems fail when people don’t use them, don’t trust them, or can’t find what they need. AI adds another version of that problem. If an agent can’t discover the right component or doesn’t have enough context to use it correctly, it may generate something new. That doesn’t always mean the agent failed. Sometimes it means the system wasn’t easy enough to follow.技术层面只是故事的一部分。当人们不使用、不信任或无法找到所需内容时,设计系统就会失败。AI 增加了这个问题的另一个版本。如果代理无法发现合适的组件,或者没有足够的上下文来正确使用它,它可能会生成新的东西。这并不总是意味着代理失败了,有时意味着系统不够易于遵循。

Teams need to make the right path easier than the wrong one. Components should be discoverable. Documentation should be readable. Examples should be realistic. Usage guidance should be specific. Deprecated patterns should be clearly marked. If a component shouldn’t be used anymore, both the agent and the developer should be able to see that.团队需要让正确的路径比错误的路径更容易走。组件应该是可发现的,文档应该是可读的,示例应该是真实的,使用指南应该是具体的。已弃用的模式应被明确标记。如果某个组件不再应被使用,代理和开发者都应该能看出来。

But there is also a human discipline problem. AI tools don’t automatically know which inconsistencies matter to a product, which patterns are worth protecting, or when a small UI change may affect users who have built habits around the existing interface. Those decisions require people to care about consistency before it breaks. If a team hasn’t already defined that discipline, AI tools are unlikely to supply it on their own. They may make it easier to generate slightly different versions of the same idea unless the team gives them clearer boundaries.但这同时也存在一个人类纪律问题。AI 工具不会自动知道哪些不一致对产品至关重要,哪些模式值得保护,或者微小的 UI 变动何时会影响已习惯现有界面的用户。这些决策需要人们在问题爆发前就关注一致性。如果团队尚未建立这种纪律,AI 工具不太可能自行提供。除非团队给出更明确的界限,否则它们可能会更容易生成同一想法的略有不同的版本。

That doesn’t mean the design system should block every new pattern. Sometimes a new pattern is necessary. But new patterns should be intentional, reviewed, and eventually folded back into the system if they become reusable. Without that discipline, AI-generated UI can lead to many almost-standard components. They look close to the system but behave differently, which often makes them harder to clean up than obviously custom code.这并不意味着设计系统应该阻止每一个新模式。有时新模式是必要的,但新模式应该是经过深思熟虑、审查过的,并且如果它们变得可复用,最终应被纳入系统。缺乏这种纪律,AI 生成的 UI 可能会导致许多“准标准”组件。它们看起来很像系统的一部分,但行为却不同,这通常使它们比明显的自定义代码更难清理。

The frontend engineer’s role becomes more architectural前端工程师的角色变得更具架构性

As AI tools write more code, frontend engineering becomes less about producing every line by hand and more about shaping the environment in which code is produced.随着 AI 工具编写的代码越来越多,前端工程不再仅仅是手动编写每一行代码,而是更多地塑造代码产生的环境。

That includes defining component APIs, documenting patterns, setting accessibility expectations, creating project-level agent instructions, reviewing generated code, and deciding when a new pattern belongs in the design system. These are architectural decisions that influence many features over time.这包括定义组件 API、记录模式、设定无障碍期望、创建项目级代理指令、审查生成的代码,以及决定何时将新模式纳入设计系统。这些都是随着时间推移影响许多功能的架构决策。

This is where experienced frontend engineers become even more important. They understand the difference between a component that works once and a component that can be reused safely. They know when a custom interaction is worth the cost. They know where accessibility issues usually hide. They can see when a generated solution works for one feature but doesn’t fit the broader frontend system.这正是经验丰富的前端工程师变得更加重要的原因。他们理解“一次性组件”与“可安全复用组件”之间的区别。他们知道何时自定义交互是值得的,知道无障碍问题通常隐藏在哪里,也能看出生成的解决方案何时适用于单个功能,却不符合更广泛的前端系统。

AI can generate code quickly. It can’t decide, on its own, what kind of frontend system a team should have.AI 可以快速生成代码,但它无法独自决定团队应该拥有什么样的前端系统。

The control plane for generated interfaces生成式界面的控制平面

AI-generated UI will only become more common, and many teams are already using AI to build interfaces. But will these generated interfaces become more consistent, accessible, and maintainable, or will they just add another layer of drift?AI 生成的 UI 只会越来越普遍,许多团队已经在利用 AI 构建界面。但这些生成的界面会变得更加一致、无障碍且易于维护,还是只会增加另一层偏离?

Design systems can help teams choose the better path. When a design system includes clear components, documented behavior, accessibility expectations, tested patterns, and persistent instructions for coding agents, it becomes a control plane for generated UI. It gives AI tools boundaries. It gives developers a shared language. It gives reviewers something concrete to enforce. Most importantly, it gives users a more consistent experience.设计系统可以帮助团队选择更好的路径。当设计系统包含清晰的组件、记录在案的行为、无障碍期望、经过测试的模式以及针对编码代理的持久化指令时,它就成为了生成式 UI 的控制平面。它为 AI 工具设定了边界,为开发者提供了共同语言,为审查者提供了具体的执行依据。最重要的是,它为用户提供了更一致的体验。

The future of AI-assisted frontend development won’t be shaped only by better prompts. It will be shaped by the systems we give those prompts to work within.AI 辅助前端开发的未来,不仅取决于更好的提示词,更取决于我们为这些提示词提供的工作系统。

. . .. . .

AI use acknowledgmentAI 使用声明

AI assistance was used lightly for phrasing, editing, and tightening parts of this draft. The article’s ideas, structure, examples, and final review are my own.本文草稿在措辞、编辑和精简部分内容时适度使用了 AI 辅助。文章的观点、结构、示例和最终审核均由我本人完成。

Post topics: AI & MLAI 与机器学习•Design设计文章主题:AI 与机器学习 • 设计