create-design-system-rules by dedalus-erp-pas/foundation-skills
npx skills add https://github.com/dedalus-erp-pas/foundation-skills --skill create-design-system-rules此技能可帮助您生成根据项目特定需求量身定制的设计系统规则。这些规则指导 Claude 在实现 Figma 设计时生成一致、高质量的代码,确保自动遵循团队的约定、组件模式和架构决策。
设计系统规则是项目级的指令,用于编码代码库的“隐性知识”——那种经验丰富的开发者知道并会传授给新团队成员的专业知识:
一旦定义,这些规则将显著减少重复提示,并确保所有 Figma 实现任务输出的一致性。
在以下情况使用此技能:
按顺序执行以下步骤。不要跳过任何步骤。
调用 Figma MCP 服务器的 create_design_system_rules 工具以获取基础提示和模板。
参数:
clientLanguages:项目中使用的语言列表,以逗号分隔(例如:"typescript,javascript"、"python"、"javascript")广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
clientFrameworks:正在使用的框架(例如:"react"、"vue"、"svelte"、"angular"、"unknown")此工具返回创建设计系统规则的指导和模板。请按照工具响应中提供的模板格式来构建您的设计系统规则。
在最终确定规则之前,分析项目以了解现有模式:
组件组织:
src/components/、app/ui/、lib/components/)样式方法:
组件模式:
架构决策:
基于您的代码库分析,创建一套全面的规则。包括:
- 重要:尽可能使用来自 `[YOUR_PATH]` 的组件
- 将新的 UI 组件放置在 `[COMPONENT_DIRECTORY]`
- 组件名称遵循 `[NAMING_CONVENTION]` 命名约定
- 组件必须以 `[EXPORT_PATTERN]` 模式导出
- 使用 `[CSS_FRAMEWORK/APPROACH]` 进行样式设计
- 设计令牌定义在 `[TOKEN_LOCATION]`
- 重要:切勿硬编码颜色 - 始终使用来自 `[TOKEN_FILE]` 的令牌
- 间距值必须使用 `[SPACING_SYSTEM]` 比例尺
- 排版遵循 `[TYPOGRAPHY_LOCATION]` 中定义的比例尺
## Figma MCP 集成规则
这些规则定义了如何将 Figma 输入转换为此项目的代码,并且必须为每个 Figma 驱动的变更所遵循。
### 必需流程(请勿跳过)
1. 首先运行 get_design_context 以获取确切节点(们)的结构化表示
2. 如果响应过大或被截断,运行 get_metadata 以获取高级节点映射,然后仅使用 get_design_context 重新获取所需的节点(们)
3. 运行 get_screenshot 以获取正在实现的节点变体的视觉参考
4. 只有在同时拥有 get_design_context 和 get_screenshot 之后,才下载任何所需的资源并开始实现
5. 将输出(通常是 React + Tailwind)转换为此项目的约定、样式和框架
6. 在标记完成前,对照 Figma 验证 1:1 的外观和行为
### 实现规则
- 将 Figma MCP 输出(React + Tailwind)视为设计和行为的表示,而非最终代码风格
- 在适用时,将 Tailwind 工具类替换为 `[YOUR_STYLING_APPROACH]`
- 重用来自 `[COMPONENT_PATH]` 的现有组件,而不是重复功能
- 一致地使用项目的颜色系统、排版比例尺和间距令牌
- 尊重现有的路由、状态管理和数据获取模式
- 力求与 Figma 设计达到 1:1 的视觉一致性
- 对照 Figma 截图验证最终 UI 的外观和行为
## 资源处理
- Figma MCP 服务器提供了一个资源端点,可以服务图像和 SVG 资源
- 重要:如果 Figma MCP 服务器为图像或 SVG 返回一个 localhost 源,请直接使用该源
- 重要:请勿导入/添加新的图标包 - 所有资源都应在 Figma 有效载荷中
- 重要:如果提供了 localhost 源,请勿使用或创建占位符
- 将下载的资源存储在 `[ASSET_DIRECTORY]`
## 项目特定约定
- [添加任何独特的架构模式]
- [添加任何特殊的导入要求]
- [添加任何测试要求]
- [添加任何无障碍访问标准]
- [添加任何性能考虑]
引导用户将生成的规则保存到其项目根目录的 CLAUDE.md 文件中:
# MCP 服务器
## Figma MCP 服务器规则
[在此处粘贴生成的规则]
保存后,规则将被 Claude Code 自动加载并应用于所有 Figma 实现任务。
创建规则后:
组件发现:
- UI 组件位于 `src/components/ui/`
- 功能组件位于 `src/components/features/`
- 布局基元位于 `src/components/layout/`
设计令牌使用:
- 颜色在 `src/styles/tokens.css` 中定义为 CSS 变量
- 切勿硬编码十六进制颜色 - 使用 `var(--color-*)` 令牌
- 间距使用 4px 基准比例尺:`--space-1` (4px)、`--space-2` (8px) 等
样式方法:
- 使用 Tailwind 工具类进行样式设计
- 自定义样式放在组件级 CSS 模块中
- 主题自定义在 `tailwind.config.js` 中
组件模式:
- 所有组件必须接受 `className` prop 以进行组合
- 变体 props 应使用联合类型:`variant: 'primary' | 'secondary'`
- 图标组件应接受 `size` 和 `color` props
导入约定:
- 使用路径别名:`@/components`、`@/styles`、`@/utils`
- 分组导入:React、第三方、内部、类型
- 不要使用超出父目录的相对导入
代码质量:
- 为导出的组件添加 JSDoc 注释
- 为所有 props 包含 PropTypes 或 TypeScript 类型
- 将魔法数字提取为命名常量
无障碍访问:
- 所有交互元素必须具有 aria-labels
- 颜色对比度必须满足 WCAG AA 标准
- 所有交互都需要键盘导航
性能:
- 使用来自 `@/components/Image` 的 `Image` 组件懒加载图像
- 对接收复杂 props 的组件使用 React.memo
- 图标应为 SVG 组件,而非图标字体
测试:
- 在 `__tests__/` 目录中包含新组件的单元测试
- 使用 Testing Library 查询(getByRole、getByLabelText)
- 测试所有交互状态和变体
用户说:“为我的 React 项目创建设计系统规则”
操作:
create_design_system_rules(clientLanguages="typescript,javascript", clientFrameworks="react")# Figma MCP 集成规则
## 组件组织
- UI 组件位于 `src/components/ui/`
- 页面组件位于 `src/app/`
- 使用 Tailwind 进行样式设计
## Figma 实现流程
1. 为节点运行 get_design_context
2. 运行 get_screenshot 获取视觉参考
3. 将 Figma 颜色映射到 `tailwind.config.js` 中定义的 Tailwind 颜色
4. 尽可能重用来自 `src/components/ui/` 的组件
5. 在完成前对照截图进行验证
## 样式规则
- 重要:使用 Tailwind 工具类,而非内联样式
- 颜色在 `tailwind.config.js` 的 theme.colors 中定义
- 间距使用 Tailwind 的默认比例尺
- 自定义组件放在 `src/components/ui/`
## 资源规则
- 重要:直接使用来自 Figma MCP 服务器的 localhost 源
- 将静态资源存储在 `public/assets/`
- 请勿安装新的图标库
4. 保存到项目根目录的 CLAUDE.md
5. 使用一个简单的按钮实现进行测试
结果: Claude 现在在实现 Figma 设计时始终遵循项目的约定。
用户说:“为我的 Vue 应用设置 Figma 规则”
操作:
create_design_system_rules(clientLanguages="typescript,javascript", clientFrameworks="vue")# Figma MCP 集成规则
## 组件组织
- 组件位于 `src/components/`
- 可组合项位于 `src/composables/`
- Vue SFC 结构:<script setup>、<template>、<style scoped>
## 设计令牌
- 重要:所有颜色在 `src/styles/tokens.css` 中定义为 CSS 变量
- 使用 `var(--color-primary)`、`var(--color-secondary)` 等
- 间距:`var(--space-xs)` 到 `var(--space-xl)`
- 排版:`var(--text-sm)` 到 `var(--text-2xl)`
## Figma 实现流程
1. 运行 get_design_context 和 get_screenshot
2. 将 React 输出转换为 Vue 3 Composition API
3. 将 Figma 颜色映射到 `src/styles/tokens.css` 中的 CSS 变量
4. 使用 CSS Modules 处理组件样式
5. 在创建新组件前检查 `src/components/` 中是否存在现有组件
## 样式规则
- 使用 CSS Modules(`.module.css` 文件)
- 重要:引用设计令牌,切勿硬编码值
- 使用 CSS 模块的作用域样式
4. 保存到项目根目录的 CLAUDE.md
5. 使用卡片组件进行验证
结果: Claude 现在能正确地将 Figma 设计转换为使用项目设计令牌系统的 Vue 组件。
用户说:“为我们的设计系统库生成规则”
操作:
create_design_system_rules(clientLanguages="typescript", clientFrameworks="react")# 设计系统规则
## 仓库结构
- 设计系统组件:`packages/design-system/src/components/`
- 文档:`packages/docs/`
- 设计令牌:`packages/tokens/src/`
## 组件开发
- 重要:所有组件必须在 `packages/design-system/src/components/` 中
- 组件文件结构:`ComponentName/index.tsx`、`ComponentName.stories.tsx`、`ComponentName.test.tsx`
- 从 `packages/design-system/src/index.ts` 导出所有组件
## 设计令牌
- 颜色:`packages/tokens/src/colors.ts`
- 排版:`packages/tokens/src/typography.ts`
- 间距:`packages/tokens/src/spacing.ts`
- 重要:切勿硬编码值 - 从令牌包导入
## 文档要求
- 为每个组件添加 Storybook 故事
- 包含带有 @example 的 JSDoc
- 描述所有 props 并添加说明
- 添加无障碍访问说明
## Figma 集成
1. 从 Figma 获取设计上下文和截图
2. 将 Figma 令牌映射到设计系统令牌
3. 在设计系统包中创建或扩展组件
4. 添加展示所有变体的 Storybook 故事
5. 对照 Figma 截图进行验证
6. 更新文档
4. 保存到 CLAUDE.md 并与团队分享
5. 添加到团队文档
结果: 整个团队在将组件从 Figma 添加到设计系统时遵循一致的模式。
不要试图一开始就捕获所有规则。从最重要的约定开始,在遇到不一致时添加规则。
而不是:“使用设计系统”
写成:“始终使用来自 src/components/ui/Button.tsx 的 Button 组件,并带有 variant prop('primary' | 'secondary' | 'ghost')”
每条规则都应明确告诉 Claude 该做什么,而不仅仅是避免什么。
好的:“颜色在 src/theme/colors.ts 中定义 - 导入并使用这些常量”
差的:“不要硬编码颜色”
为绝不能违反的规则加上“重要:”前缀,以确保 Claude 优先处理它们。
- 重要:切勿在客户端代码中暴露 API 密钥
- 重要:在渲染前始终对用户输入进行清理
当规则看起来随意时,解释其背后的原因:
- 将所有数据获取放在服务器组件中(减少客户端包大小并提高性能)
- 使用带有 `@/` 别名的绝对导入(使重构更容易并防止相对路径损坏)
原因: 规则可能过于模糊或未正确加载到 IDE/MCP 客户端中。
解决方案:
原因: 规则相互矛盾或重叠。
解决方案:
原因: 过多的规则增加了上下文大小和处理时间。
解决方案:
原因: 代码库发生变化但规则未更新。
解决方案:
设计系统规则改变了 Claude 处理 Figma 设计的方式:
规则之前:
规则之后:
在创建良好规则上投入的时间,将在每个 Figma 实现任务中获得指数级的回报。
每周安装量
65
仓库
GitHub 星标数
2
首次出现
2026年1月21日
安全审计
安装于
github-copilot48
claude-code48
opencode47
codex45
cursor45
gemini-cli44
This skill helps you generate custom design system rules tailored to your project's specific needs. These rules guide Claude to produce consistent, high-quality code when implementing Figma designs, ensuring that your team's conventions, component patterns, and architectural decisions are followed automatically.
Design system rules are project-level instructions that encode the "unwritten knowledge" of your codebase - the kind of expertise that experienced developers know and would pass on to new team members:
Once defined, these rules dramatically reduce repetitive prompting and ensure consistent output across all Figma implementation tasks.
Use this skill when:
Follow these steps in order. Do not skip steps.
Call the Figma MCP server's create_design_system_rules tool to get the foundational prompt and template.
Parameters:
clientLanguages: Comma-separated list of languages used in the project (e.g., "typescript,javascript", "python", "javascript")clientFrameworks: Framework being used (e.g., "react", "vue", "svelte", "angular", "unknown")This tool returns guidance and a template for creating design system rules. Structure your design system rules following the template format provided in the tool's response.
Before finalizing rules, analyze the project to understand existing patterns:
Component Organization:
src/components/, app/ui/, lib/components/)Styling Approach:
Component Patterns:
Architecture Decisions:
Based on your codebase analysis, create a comprehensive set of rules. Include:
- IMPORTANT: Always use components from `[YOUR_PATH]` when possible
- Place new UI components in `[COMPONENT_DIRECTORY]`
- Follow `[NAMING_CONVENTION]` for component names
- Components must export as `[EXPORT_PATTERN]`
- Use `[CSS_FRAMEWORK/APPROACH]` for styling
- Design tokens are defined in `[TOKEN_LOCATION]`
- IMPORTANT: Never hardcode colors - always use tokens from `[TOKEN_FILE]`
- Spacing values must use the `[SPACING_SYSTEM]` scale
- Typography follows the scale defined in `[TYPOGRAPHY_LOCATION]`
## Figma MCP Integration Rules
These rules define how to translate Figma inputs into code for this project and must be followed for every Figma-driven change.
### Required Flow (do not skip)
1. Run get_design_context first to fetch the structured representation for the exact node(s)
2. If the response is too large or truncated, run get_metadata to get the high-level node map, then re-fetch only the required node(s) with get_design_context
3. Run get_screenshot for a visual reference of the node variant being implemented
4. Only after you have both get_design_context and get_screenshot, download any assets needed and start implementation
5. Translate the output (usually React + Tailwind) into this project's conventions, styles, and framework
6. Validate against Figma for 1:1 look and behavior before marking complete
### Implementation Rules
- Treat the Figma MCP output (React + Tailwind) as a representation of design and behavior, not as final code style
- Replace Tailwind utility classes with `[YOUR_STYLING_APPROACH]` when applicable
- Reuse existing components from `[COMPONENT_PATH]` instead of duplicating functionality
- Use the project's color system, typography scale, and spacing tokens consistently
- Respect existing routing, state management, and data-fetch patterns
- Strive for 1:1 visual parity with the Figma design
- Validate the final UI against the Figma screenshot for both look and behavior
## Asset Handling
- The Figma MCP server provides an assets endpoint which can serve image and SVG assets
- IMPORTANT: If the Figma MCP server returns a localhost source for an image or SVG, use that source directly
- IMPORTANT: DO NOT import/add new icon packages - all assets should be in the Figma payload
- IMPORTANT: DO NOT use or create placeholders if a localhost source is provided
- Store downloaded assets in `[ASSET_DIRECTORY]`
## Project-Specific Conventions
- [Add any unique architectural patterns]
- [Add any special import requirements]
- [Add any testing requirements]
- [Add any accessibility standards]
- [Add any performance considerations]
Guide the user to save the generated rules to the CLAUDE.md file in their project root:
# MCP Servers
## Figma MCP Server Rules
[Paste generated rules here]
After saving, the rules will be automatically loaded by Claude Code and applied to all Figma implementation tasks.
After creating rules:
Component Discovery:
- UI components are located in `src/components/ui/`
- Feature components are in `src/components/features/`
- Layout primitives are in `src/components/layout/`
Design Token Usage:
- Colors are defined as CSS variables in `src/styles/tokens.css`
- Never hardcode hex colors - use `var(--color-*)` tokens
- Spacing uses the 4px base scale: `--space-1` (4px), `--space-2` (8px), etc.
Styling Approach:
- Use Tailwind utility classes for styling
- Custom styles go in component-level CSS modules
- Theme customization is in `tailwind.config.js`
Component Patterns:
- All components must accept a `className` prop for composition
- Variant props should use union types: `variant: 'primary' | 'secondary'`
- Icon components should accept `size` and `color` props
Import Conventions:
- Use path aliases: `@/components`, `@/styles`, `@/utils`
- Group imports: React, third-party, internal, types
- No relative imports beyond parent directory
Code Quality:
- Add JSDoc comments for exported components
- Include PropTypes or TypeScript types for all props
- Extract magic numbers to named constants
Accessibility:
- All interactive elements must have aria-labels
- Color contrast must meet WCAG AA standards
- Keyboard navigation required for all interactions
Performance:
- Lazy load images with the `Image` component from `@/components/Image`
- Use React.memo for components that receive complex props
- Icons should be SVG components, not icon fonts
Testing:
- Include unit tests for new components in `__tests__/` directory
- Use Testing Library queries (getByRole, getByLabelText)
- Test all interactive states and variants
User says: "Create design system rules for my React project"
Actions:
create_design_system_rules(clientLanguages="typescript,javascript", clientFrameworks="react")# Figma MCP Integration Rules
## Component Organization
- UI components are in `src/components/ui/`
- Page components are in `src/app/`
- Use Tailwind for styling
## Figma Implementation Flow
1. Run get_design_context for the node
2. Run get_screenshot for visual reference
3. Map Figma colors to Tailwind colors defined in `tailwind.config.js`
4. Reuse components from `src/components/ui/` when possible
5. Validate against screenshot before completing
## Styling Rules
- IMPORTANT: Use Tailwind utility classes, not inline styles
- Colors are defined in `tailwind.config.js` theme.colors
- Spacing uses Tailwind's default scale
- Custom components go in `src/components/ui/`
## Asset Rules
- IMPORTANT: Use localhost sources from Figma MCP server directly
- Store static assets in `public/assets/`
- DO NOT install new icon libraries
4. Save to CLAUDE.md in project root
5. Test with a simple button implementation
Result: Claude now consistently follows the project's conventions when implementing Figma designs.
User says: "Set up Figma rules for my Vue app"
Actions:
create_design_system_rules(clientLanguages="typescript,javascript", clientFrameworks="vue")# Figma MCP Integration Rules
## Component Organization
- Components are in `src/components/`
- Composables are in `src/composables/`
- Vue SFC structure: <script setup>, <template>, <style scoped>
## Design Tokens
- IMPORTANT: All colors defined in `src/styles/tokens.css` as CSS variables
- Use `var(--color-primary)`, `var(--color-secondary)`, etc.
- Spacing: `var(--space-xs)` through `var(--space-xl)`
- Typography: `var(--text-sm)` through `var(--text-2xl)`
## Figma Implementation Flow
1. Run get_design_context and get_screenshot
2. Translate React output to Vue 3 Composition API
3. Map Figma colors to CSS variables in `src/styles/tokens.css`
4. Use CSS Modules for component styles
5. Check for existing components in `src/components/` before creating new ones
## Styling Rules
- Use CSS Modules (`.module.css` files)
- IMPORTANT: Reference design tokens, never hardcode values
- Scoped styles with CSS modules
4. Save to CLAUDE.md in project root
5. Validate with a card component
Result: Claude now correctly translates Figma designs to Vue components using the project's design token system.
User says: "Generate rules for our design system library"
Actions:
create_design_system_rules(clientLanguages="typescript", clientFrameworks="react")# Design System Rules
## Repository Structure
- Design system components: `packages/design-system/src/components/`
- Documentation: `packages/docs/`
- Design tokens: `packages/tokens/src/`
## Component Development
- IMPORTANT: All components must be in `packages/design-system/src/components/`
- Component file structure: `ComponentName/index.tsx`, `ComponentName.stories.tsx`, `ComponentName.test.tsx`
- Export all components from `packages/design-system/src/index.ts`
## Design Tokens
- Colors: `packages/tokens/src/colors.ts`
- Typography: `packages/tokens/src/typography.ts`
- Spacing: `packages/tokens/src/spacing.ts`
- IMPORTANT: Never hardcode values - import from tokens package
## Documentation Requirements
- Add Storybook story for every component
- Include JSDoc with @example
- Document all props with descriptions
- Add accessibility notes
## Figma Integration
1. Get design context and screenshot from Figma
2. Map Figma tokens to design system tokens
3. Create or extend component in design system package
4. Add Storybook stories showing all variants
5. Validate against Figma screenshot
6. Update documentation
4. Save to CLAUDE.md and share with team
5. Add to team documentation
Result: Entire team follows consistent patterns when adding components from Figma to the design system.
Don't try to capture every rule upfront. Start with the most important conventions and add rules as you encounter inconsistencies.
Instead of: "Use the design system" Write: "Always use Button components from src/components/ui/Button.tsx with variant prop ('primary' | 'secondary' | 'ghost')"
Each rule should tell Claude exactly what to do, not just what to avoid.
Good: "Colors are defined in src/theme/colors.ts - import and use these constants" Bad: "Don't hardcode colors"
Prefix rules that must never be violated with "IMPORTANT:" to ensure Claude prioritizes them.
- IMPORTANT: Never expose API keys in client-side code
- IMPORTANT: Always sanitize user input before rendering
When rules seem arbitrary, explain the reasoning:
- Place all data-fetching in server components (reduces client bundle size and improves performance)
- Use absolute imports with `@/` alias (makes refactoring easier and prevents broken relative paths)
Cause: Rules may be too vague or not properly loaded into the IDE/MCP client.
Solution:
Cause: Contradictory or overlapping rules.
Solution:
Cause: Excessive rules increase context size and processing time.
Solution:
Cause: Codebase changes but rules don't.
Solution:
Design system rules transform how Claude works with your Figma designs:
Before rules:
After rules:
The time invested in creating good rules pays off exponentially across every Figma implementation task.
Weekly Installs
65
Repository
GitHub Stars
2
First Seen
Jan 21, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykWarn
Installed on
github-copilot48
claude-code48
opencode47
codex45
cursor45
gemini-cli44
前端设计技能指南:避免AI垃圾美学,打造独特生产级界面
45,300 周安装