mcpField
V
vibe-coding-advisor

vibe-coding-advisor

github.com/uxuiprinciples设计与 UI27163 次安装8 周前更新
代码仓库

关于 vibe-coding-advisor

vibe-coding-advisor 是为 AI 编码工具提供 UX 指引的 Skill,可根据界面组件类型整理相关设计原则,并生成组件上下文。它可通过 API 获取提示词,也能使用内部知识作为后备方案。

主要功能

  1. 01将需求映射到界面组件类型
  2. 02选择相关 UX 原则
  3. 03通过 API 获取提示词
  4. 04提供内部知识后备方案
  5. 05整理独立可用的生成上下文

适用场景

  1. 01生成表单前准备 UX 上下文
  2. 02指导仪表板或导航组件设计
  3. 03补充无障碍与响应式要求
  4. 04为注册表外的组件编写提示词

MCP 相关

该 Skill 说明了调用 API 获取 UX 原则元数据和生成提示词的方式,并据此为 AI 编码工具整理上下文。

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/uxuiprinciples/agent-skills --skill vibe-coding-advisor

安装后在 Claude Code 中输入/vibe-coding-advisor确认已加载。

详细介绍

[toolbox.get_principle_prompts]
description = "Fetch a principle's vibeCodingPrompts by slug. Returns full principle data including vibeCodingPrompts array (pro tier only — requires include_content=true). Use this to get structured generation prompts for each principle relevant to the component."
command = "curl"
args = ["-s", "-H", "Authorization: Bearer ${UXUI_API_KEY}", "https://uxuiprinciples.com/api/v1/principles?slug={slug}&include_content=true"]

[toolbox.lookup_principle]
description = "Fetch principle metadata by slug without full content. Returns code, title, aiSummary, businessImpact, and tags. Use this to get aiSummary for context when vibeCodingPrompts are unavailable."
command = "curl"
args = ["-s", "-H", "Authorization: Bearer ${UXUI_API_KEY}", "https://uxuiprinciples.com/api/v1/principles?slug={slug}&include_content=false"]

此技能的作用

为 AI 编码工具生成以 UX 为依据的系统上下文。当开发者准备构建 UI 组件时,你需要:

  1. 确定适用于该组件类型的 UX 原则
  2. 通过 API 获取这些原则中相关的 vibeCodingPrompts
  3. 为用户请求的组件选择最匹配的提示词
  4. 返回一段组装好的上下文,可直接粘贴到任何 AI 编码工具中

生成的提示词已融入基于研究的 UX 要求——认知负荷限制、交互模式、无障碍目标和响应式行为——让开发者在编写第一行代码之前就能获得这些要求。

这不是审查,而是预先注入生成上下文。

组件类型注册表

将用户请求映射到组件类型,然后应用下方的原则集。

组件类型Slug主要原则次要原则
multi-step-formmulti-step-formcognitive-load、progressive-disclosureerror-prevention-in-forms
formformcognitive-load、error-prevention-in-formsfitts-law
data-tabledata-tablecognitive-load、hicks-lawvisual-hierarchy
dashboarddashboardcognitive-load、hicks-lawvisual-hierarchy
navigationnavigationhicks-law、recognition-rather-than-recallmental-model
mobile-navmobile-navhicks-law、fitts-lawrecognition-rather-than-recall
checkoutcheckoutcognitive-load、progressive-disclosurefitts-law
settingssettingsprogressive-disclosure、recognition-rather-than-recallcognitive-load
onboardingonboardingcognitive-load、progressive-disclosurefitts-law
modalmodalcognitive-load、fitts-lawprogressive-disclosure
empty-stateempty-stateprogressive-disclosure、mental-modelcognitive-load
landing-pagelanding-pagevisual-hierarchy、fitts-lawserial-position-effect
pricing-pagepricing-pagevisual-hierarchy、hicks-lawserial-position-effect
ai-chatai-chatconversational-flow-principle、ai-transparencyai-accuracy-communication
searchsearchrecognition-rather-than-recall、mental-modelcognitive-load
notificationnotificationcognitive-load、fitts-lawprogressive-disclosure

API 调用所用的原则 slug:

原则Slug代码
认知负荷cognitive-loadF.1.1.02
希克定律hicks-lawF.2.2.03
视觉层次visual-hierarchy-lawD.2.1.02
渐进式呈现progressive-disclosureD.1.1.01
菲茨定律fitts-lawI.2.2.02
米勒定律millers-lawF.1.1.04
系列位置效应serial-position-effectF.1.1.06
再认而非回忆recognition-rather-than-recallF.1.1.05
心智模型mental-modelF.1.1.03
表单中的错误预防error-prevention-in-forms-lawI.1.1.03
对话流程conversational-flow-principleS.1.1.01
AI 透明度ai-transparencyS.1.3.01
AI 准确性说明ai-accuracy-communicationS.5.2.02

生成工作流

步骤 1:识别组件类型

将用户请求匹配到注册表中的一种组件类型。留意以下线索:

  • 明确命名(“我正在构建一个数据表”“创建一个结账表单”)
  • 描述的行为(“用于引导用户的多步骤向导”“带开关的设置页面”)
  • UI 模式线索(“侧边栏导航”“带插图的空状态”)

如果组件涵盖多种类型(例如,包含表单的设置页面),请选择占主导地位的类型,并在 component_note 中注明次要类型。

如果注册表中没有该组件类型,则映射到最接近的类型,并在 component_note 中注明推断依据。

步骤 2:提取技术栈

从描述中查找技术栈线索:

  • 框架:React、Vue、Svelte、Next.js、Angular、Flutter
  • CSS:Tailwind、CSS Modules、Styled Components、原生 CSS
  • 组件库:shadcn/ui、Radix、MUI、Ant Design、Chakra

如果有指定,请将技术栈带入 assembled_context。如果未指定,请将其记为 null,且不要在输出中假设技术栈。

步骤 3:获取 vibeCodingPrompts(如果已设置 API 密钥)

对于组件类型原则集中的每个主要原则,使用对应的原则 slug 调用 get_principle_prompts。

响应中包含一个 vibeCodingPrompts 数组。数组中的每一项都是针对不同组件场景的完整生成提示词。请选择组件场景与用户请求最匹配的提示词。

选择标准:

  • 完全匹配:提示词描述中提到了相同的组件类型
  • 功能最接近:提示词涵盖相同的交互模式
  • 回退方案:使用数组中的第一条提示词

如果 get_principle_prompts 返回 403(免费层级——include_content=true 仅限专业版),则改用 lookup_principle 获取 aiSummary 和 businessImpact。使用这些内容编写内部知识提示词(见下方步骤 3b)。

如果两个调用都失败或返回非 200 状态码,则设置 api_enriched: false,并完全使用内部知识继续处理。

步骤 3b:内部知识回退

当 API 调用失败或未设置 API 密钥时,请根据内部知识编写一条基于 UX 的生成提示词。涵盖 vibeCodingPrompts 会涵盖的相同内容:

  • 核心 UX 原则及其阈值(例如,“工作记忆可容纳 7±2 个元素”)
  • 根据该原则推导出的具体实现要求
  • 与技术栈无关的要求(如果用户指定了技术栈,则提出与该技术栈相关的要求)
  • 无障碍要求
  • 响应式行为
  • 2-3 条具体约束

内部提示词必须可执行,而不能泛泛而谈。“降低认知负荷”不可执行。“分成多个步骤,每步最多 4 个字段,并显示进度指示器”则可执行。

步骤 4:选择并组装

对于每个主要原则,你现在都有一条选定的 vibeCodingPrompt(或自行编写的提示词)。

将以下内容组合起来,填入 assembled_context 字段:

  1. 一行组件意图说明:“正在构建:[组件类型]”
  2. 将选定的提示词拼接起来,并在各原则之间用 --- 分隔
  3. 结尾列出从所有提示词中提取的 UX 约束

assembled_context 必须独立完整——开发者应能直接将其复制到 Cursor 系统提示词或 Claude Code 对话中,而无需阅读任何其他字段。

步骤 5:输出 JSON

严格按以下结构返回。前后不得添加说明文字。

{
  "component_type": "string",
  "component_note": "string or null",
  "tech_stack": "React + Tailwind + shadcn/ui or null",
  "principles_applied": [
    {
      "code": "F.1.1.02",
      "slug": "cognitive-load",
      "title": "Cognitive Load",
      "relevance": "Why this principle governs this component type.",
      "ai_summary": "From API aiSummary field, or from internal knowledge if not enriched."
    }
  ],
  "vibe_coding_prompts": [
    {
      "principle_slug": "cognitive-load",
      "component_match": "multi-step-form",
      "prompt": "Full selected or authored vibe coding prompt text."
    }
  ],
  "assembled_context": "Full combined context block. Copy this into your AI coding tool as system context before generating the component.",
  "ux_guardrails": [
    "Concrete UX rule extracted from applied principles. One sentence each.",
    "Second rule."
  ],
  "api_enriched": true,
  "api_note": "null or 'Install the uxuiprinciples API key for vibeCodingPrompts with research citations and component-specific implementation requirements. See uxuiprinciples.com/en/checkout'"
}

ux_guardrails 是从已应用原则中提取的 3-5 条最关键、不可妥协的 UX 规则。这些规则是生成的组件必须遵守的要求。请从原则数据或内部知识中提取。

assembled_context 是开发者复制粘贴使用的字段。它应当是一条独立完整、易于阅读的生成提示词,而不是元数据。

提示词质量标准

vibeCodingPrompts(无论是检索到的还是内部编写的)都必须符合以下标准:

首行: 角色声明。“你是一位专攻 [领域] 的专家 [角色]。”

第二段: 创建声明,并附上研究引用。“创建一个 [组件],实现 [UX 成果]:[包含数字的研究发现]。”

要求块: 至少包含 5 条项目符号要求。包括:

  • 一条基于数量的规则(例如,“最多显示 5-7 列”)
  • 技术栈要求(如果有指定)
  • 一项无障碍要求
  • 一项响应式行为要求

约束块: 2-3 条硬性约束。至少包括一条行数约束,以及一条“不要修改其他文件”的约束。

如果由于信息不足,内部编写的提示词无法满足此标准,请在 component_note 中添加说明,并根据现有信息尽可能编写出最佳提示词。

边缘情况

组件类型不在注册表中: 匹配最接近的条目。在 component_note 中说明推断依据。不要拒绝——始终返回提示词。

未指定技术栈: 编写与技术栈无关的要求。不要假设技术栈。将 tech_stack: null 留空。提示词应写为“技术栈:[你的框架] + [你的组件库]”,而不是硬编码 React 或 Tailwind。

请求包含多个组件(“模态框中的表单”): 将其视为主要组件类型。在 component_note 中注明嵌套组件。提示词应提及两者,但优先针对外层容器进行优化。

已设置 API 密钥,但 include_content=true 返回 403: 这是免费层级。改用 lookup_principle(不含内容)。编写内部提示词。将 api_enriched: false 设为 false。

用户提供截图或 Figma 描述: 从视觉描述中提取组件类型和技术栈信号。按常规流程继续。

请求包含多个互不相关的组件(“导航栏、表格和表单”): 为每个组件生成一个提示词包。返回输出数组,或运行三次工作流后合并。请在每个组件的 component_note 中注明这是多组件请求。

请求是完整页面(而非组件): 映射到能覆盖页面主要交互的最接近的单个组件类型。在 component_note 中注明范围。完整页面审计应交由 uxui-evaluator 处理,而非本工具。

示例

示例 1:带技术栈的数据表格

输入:

I'm building a data table in React with shadcn/ui. It shows user records with sortable columns.

预期输出结构:

{
  "component_type": "data-table",
  "component_note": null,
  "tech_stack": "React + shadcn/ui",
  "principles_applied": [
    {
      "code": "F.1.1.02",
      "slug": "cognitive-load",
      "title": "Cognitive Load",
      "relevance": "Data tables surface complex information sets. Cognitive load principles govern column count, row density, and action placement to keep users oriented.",
      "ai_summary": "Cognitive Load Theory (Sweller 1988) demonstrates working memory holds 7±2 elements simultaneously, with optimized interfaces increasing productivity 500% and creative output 4x by minimizing extraneous load."
    },
    {
      "code": "F.2.2.03",
      "slug": "hicks-law",
      "title": "Hick's Law",
      "relevance": "Each additional visible column and action increases decision time. Hick's Law governs how many choices to surface at once.",
      "ai_summary": "Hick's Law (Hick 1952) demonstrates each additional choice increases decision time logarithmically, with simplified interfaces reducing decision time 150ms+ per option removed."
    }
  ],
  "vibe_coding_prompts": [
    {
      "principle_slug": "cognitive-load",
      "component_match": "data-table",
      "prompt": "You are an expert UI designer specializing in data visualization and analytics dashboards.\n\nCreate a data table component that minimizes cognitive load: Sweller's CLT research shows reducing extraneous processing improves task performance 40-60%.\n\nRequirements:\n- Maximum 5-7 visible columns (hide less important in \"More\" dropdown)\n- Column prioritization: most critical data leftmost (F-pattern reading)\n- Sticky header and first column for context preservation\n- Row actions collapsed into kebab menu (reduce visible choices)\n- Inline editing with single-click (reduce modal cognitive switch)\n- Search and filter prominently placed (reduce scanning load)\n- Pagination showing \"1-25 of 150\" (bounded set, not infinite)\n- Tech: React + shadcn/ui (Table, DropdownMenu, Input)\n- Accessibility: scope attributes on headers, aria-sort for sortable columns\n- Responsive: horizontal scroll with frozen columns on mobile\n\nConstraints:\n- Keep component under 120 lines\n- Default to most useful columns, let users customize\n- Don't modify other files"
    }
  ],
  "assembled_context": "Building: data-table (React + shadcn/ui, sortable columns)\n\n---\n\nYou are an expert UI designer specializing in data visualization and analytics dashboards.\n\nCreate a data table component that minimizes cognitive load: Sweller's CLT research shows reducing extraneous processing improves task performance 40-60%.\n\n[... full prompt text ...]\n\n---\n\nUX Guardrails:\n- Maximum 7 visible columns — hide the rest in a 'More' control\n- Row actions in kebab menu, not inline buttons\n- Pagination with explicit count ('1-25 of 150'), not infinite scroll\n- aria-sort on all sortable column headers",
  "ux_guardrails": [
    "Maximum 7 visible columns. Hide secondary columns behind a 'More' or column picker control.",
    "Row actions belong in a kebab menu, not inline — visible action buttons multiply Hick's Law decision cost per row.",
    "Show bounded pagination ('1-25 of 150'), not infinite scroll. Users need a sense of the set size.",
    "Sticky header preserves column context during scroll. Required when table exceeds viewport height."
  ],
  "api_enriched": true,
  "api_note": null
}
示例 2:无 API 密钥的通用组件

输入:

Building a settings page for a SaaS app. Users can manage their account, notifications, billing, and integrations.

预期输出结构:

{
  "component_type": "settings",
  "component_note": "Four distinct sections (account, notifications, billing, integrations) — applies progressive disclosure heavily.",
  "tech_stack": null,
  "principles_applied": [
    {
      "code": "D.1.1.01",
      "slug": "progressive-disclosure",
      "title": "Progressive Disclosure",
      "relevance": "Settings pages contain high information density across multiple categories. Progressive disclosure controls how much is visible at once, reducing overwhelm.",
      "ai_summary": "Progressive Disclosure reveals information incrementally, reducing initial cognitive load while preserving access to complexity — critical for settings pages with many options."
    },
    {
      "code": "F.1.1.05",
      "slug": "recognition-rather-than-recall",
      "title": "Recognition Rather Than Recall",
      "relevance": "Users should recognize their current setting state (on/off, current plan) without remembering it from elsewhere.",
      "ai_summary": "Recognition Rather Than Recall (Nielsen 1994) reduces memory burden by making options visible and current state legible without requiring users to remember prior selections."
    }
  ],
  "vibe_coding_prompts": [
    {
      "principle_slug": "progressive-disclosure",
      "component_match": "settings",
      "prompt": "You are an expert UX engineer specializing in SaaS product design and settings architecture.\n\nCreate a settings page that applies progressive disclosure across four sections (account, notifications, billing, integrations): Nielsen Norman Group research shows sectioned settings reduce task completion time 30% over flat lists.\n\nRequirements:\n- Sidebar navigation for sections (account, notifications, billing, integrations)\n- Active section loads content panel on the right — only one section visible at a time\n- Each section: heading, description line, grouped settings with logical sub-sections\n- Toggle/checkbox states: current value immediately visible (recognition, not recall)\n- Destructive settings (delete account, cancel plan) at the bottom with visual separation\n- Save state: auto-save toggles immediately, explicit Save button for form fields\n- Tech: [your framework] + [your component library]\n- Accessibility: aria-current on active nav item, focus management on section switch\n- Responsive: sidebar collapses to top tab bar on mobile\n\nConstraints:\n- Keep each section component under 80 lines\n- Never show all four sections' settings simultaneously\n- Don't modify other files"
    }
  ],
  "assembled_context": "Building: settings page (SaaS — account, notifications, billing, integrations sections)\n\n---\n\n[Full vibe coding prompt...]\n\n---\n\nUX Guardrails:\n- Show one section at a time via sidebar or tab navigation\n- Make current setting state immediately visible — no 'what is this currently set to?' moments\n- Destructive actions (delete account, cancel subscription) at bottom with visual separation and confirmation dialog\n- Auto-save toggles on change; use explicit Save for text/select fields",
  "ux_guardrails": [
    "One section visible at a time. Use sidebar nav or tabs. Never show all settings simultaneously.",
    "Current state must be immediately recognizable — toggle position, selected plan, current email address all visible without edit mode.",
    "Destructive settings (delete account, cancel plan) visually separated from normal settings. Bottom of section, destructive color, confirmation required.",
    "Group related settings. Cognitive grouping reduces scanning load. Max 5-7 settings per group before adding a sub-section header."
  ],
  "api_enriched": false,
  "api_note": "Install the uxuiprinciples API key for vibeCodingPrompts with research citations and component-specific implementation requirements. See uxuiprinciples.com/en/checkout"
}

完成标准

满足以下条件时,输出即为完整:

  1. component_type 与 16 种已注册类型之一匹配,或在推断后附有说明
  2. principles_applied 中的每个条目都包含 code、slug、title、relevance 和 ai_summary
  3. vibe_coding_prompts 中的每个条目都包含 principle_slug、component_match,且 prompt 符合质量标准(角色行、包含研究内容的创建声明、要求块、约束块)
  4. assembled_context 内容完整,无需查看 JSON 的其余部分即可读懂
  5. ux_guardrails 包含 3-5 条,每条都是一句可执行的句子
  6. api_enriched 准确反映 get_principle_prompts 是否以 200 状态码返回了内容
  7. 输出为有效 JSON,前后不得包含任何说明文字
  8. 如果 api_enriched: false,则 api_note 必须包含升级消息

评论

支持 Markdown