shadcn-registry-first
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseShadcn registry first
优先使用Shadcn注册表
Darkmatter pays for the block registry and wires both it and the
free registry into the shadcn MCP. That means most common UI surfaces —
heroes, navbars, footers, pricing tables, feature grids, dashboards, login
screens, data tables — already exist as production-quality, accessible,
themeable blocks you can install in one command. Reaching for them first is
faster and produces better output than writing JSX from a blank file.
@shadcnblocks@shadcnThe default failure mode this skill corrects: an agent silently hand-rolls a
hero or a pricing table that the registry already has, burning tokens and
shipping something less polished. Before you write a new component from scratch,
check whether the registry already carries it.
Darkmatter 付费采购了块注册表,并将其与免费的注册表一同接入shadcn MCP。这意味着大多数常见的UI界面——hero区、导航栏、页脚、定价表、功能网格、仪表盘、登录页、数据表——都已经有生产级质量、无障碍支持、可自定义主题的块组件,你只需一条命令即可安装。优先使用这些组件比从零编写JSX效率更高,输出质量也更好。
@shadcnblocks@shadcn本技能旨在纠正的常见错误模式:Agent悄无声息地手动编写了注册表中已有的hero区或定价表组件,既消耗token,最终产出的完成度也更低。在从零编写新组件之前,请先检查注册表中是否已有对应组件。
When to use
适用场景
- Building a new marketing/landing section: hero, feature grid, CTA band, testimonial, logo cloud, footer, pricing.
- Building app chrome: navbar, sidebar, dashboard shell, settings panel.
- Building common interactive surfaces: forms, auth screens, data tables, command palettes, file upload, calendars, charts.
- Restyling or replacing an existing component where a cleaner registry block would do.
- The user says "add a X section", "build a Y page", "I need a Z component" and Z is a recognizable web UI pattern.
- 构建新的营销/落地页区块:hero区、功能网格、CTA栏、客户评价、logo墙、页脚、定价模块。
- 构建应用框架:导航栏、侧边栏、仪表盘外壳、设置面板。
- 构建常见交互界面:表单、认证页面、数据表、命令面板、文件上传、日历、图表。
- 对现有组件进行样式重设或替换,且注册表中有更简洁的块组件可满足需求。
- 用户提出“添加一个X区块”、“构建一个Y页面”、“我需要一个Z组件”,且Z是可识别的通用Web UI模式。
When NOT to use
不适用场景
- The component is genuinely domain-specific (e.g. a liquidity-range tick chart, a protocol-specific position card) — no general registry will carry it, so build it, ideally composing registry primitives.
- The project isn't React, or has no with registries configured. Check first (see below); if nothing is configured, this skill doesn't apply.
components.json - A tiny one-off element (a single styled button, a label) where installing a block is heavier than writing the line.
- You're editing an existing component's internals, not adding a new surface.
- 组件是真正的特定领域组件(例如流动性区间tick图表、特定协议的持仓卡片)——通用注册表不会提供这类组件,因此需要自行构建,最好是基于注册表的基础组件组合实现。
- 项目不是React技术栈,或者没有配置注册表的文件。请先检查(见下文);如果没有配置任何注册表,本技能不适用。
components.json - 极小的一次性元素(单个带样式的按钮、一个标签),安装块组件的成本比直接写代码更高。
- 你正在编辑现有组件的内部逻辑,而非添加新的界面模块。
Workflow
工作流程
1. Confirm registries are configured
1. 确认注册表已配置
Use the shadcn MCP tool (or read ). You
want to see and/or listed. If is
present but the API key isn't resolving, see "Registry access" below — don't
fall back to hand-rolling just because the key is missing; fix the key.
get_project_registriescomponents.json@shadcnblocks@shadcn@shadcnblocks使用shadcn MCP的工具(或读取文件),确认列表中包含和/或。如果已配置但API密钥无法解析,请参阅下文的“注册表访问”部分——不要因为缺少密钥就退而求其次手动编写组件,先修复密钥问题。
get_project_registriescomponents.json@shadcnblocks@shadcn@shadcnblocks2. Search and shortlist at least three candidates
2. 搜索并筛选至少三个候选组件
Use with the pattern you need, scoped to the
configured registries. Search the thing, not keywords:
search_items_in_registriessearch_items_in_registries(registries=["@shadcnblocks"], query="hero dark")search_items_in_registries(registries=["@shadcnblocks"], query="pricing toggle")search_items_in_registries(registries=["@shadcnblocks"], query="dashboard analytics")
@shadcnblocksFrom the results, pick at least three distinct candidates that each plausibly
satisfy the brief. Favour genuine variety — different layouts, density, or visual
emphasis — not three near-identical blocks. The point is to give the user a real
choice, the same way you'd offer multiple font or palette options rather than
deciding silently.
The search output can be very large. If a single call returns a giant truncated
list, don't read the whole dump into your own context — delegate processing to an
agent with Grep/Read over the saved tool-output file, or re-run with a
tighter query.
explore使用工具,在已配置的注册表范围内搜索你需要的UI模式。要搜索具体的组件类型,而非零散关键词:
search_items_in_registriessearch_items_in_registries(registries=["@shadcnblocks"], query="hero dark")search_items_in_registries(registries=["@shadcnblocks"], query="pricing toggle")search_items_in_registries(registries=["@shadcnblocks"], query="dashboard analytics")
@shadcnblocks从搜索结果中挑选至少三个不同的候选组件,每个都应能合理满足需求。优先选择真正有差异的方案——不同的布局、信息密度或视觉重点——而不是三个几乎一模一样的块。这样做的目的是给用户提供真实的选择,就像你会提供多种字体或配色方案供选择,而不是悄悄自己做决定。
搜索输出可能非常大。如果单次调用返回了被截断的超长列表,不要把整个输出都塞进你的上下文里——可以将处理工作委派给 Agent,让它通过Grep/读取操作处理保存的工具输出文件,或者用更精准的查询重新运行搜索。
explore3. Preview each candidate
3. 预览每个候选组件
For every shortlisted candidate, inspect what you're committing to:
- — find the demo and its full source so you see the actual markup and props.
get_item_examples_from_registries - — see the item's files, dependencies, and registry dependencies (other components it pulls in).
view_items_in_registries
Confirm each fits the project's design system (theme tokens, fonts, radius). Many
blocks assume the default shadcn theme; if the project overrides tokens (e.g. a
terminal theme with ), the block will adapt to those tokens, but
check for hardcoded colors or rounded corners you'll need to reconcile.
--radius: 0对于每个入围的候选组件,都要检查清楚你将要引入的内容:
- — 查找演示示例及其完整源码,这样你可以看到实际的标记结构和props。
get_item_examples_from_registries - — 查看组件的文件、依赖项,以及注册表依赖(它会引入的其他组件)。
view_items_in_registries
确认每个组件都适配项目的设计系统(主题token、字体、圆角半径)。很多块组件默认使用shadcn的默认主题;如果项目覆盖了token(例如设置了的终端主题),块组件会适配这些token,但仍需检查是否有硬编码的颜色或圆角需要调整。
--radius: 04. Install all the variations
4. 安装所有变体
Get each add command with and run it (typically
). This writes each component into
the project's / aliases and installs dependencies. Keep the
variations isolated from each other — install them under clearly named files or a
scratch directory so swapping or deleting one doesn't disturb the others.
get_add_command_for_itemsbunx shadcn@latest add @shadcnblocks/<name>uicomponents使用获取每个组件的安装命令并运行(通常是)。这会将每个组件写入项目的/别名路径,并安装依赖项。请让各个变体相互隔离——将它们安装在命名清晰的文件或临时目录下,这样替换或删除其中一个不会影响其他变体。
get_add_command_for_itemsbunx shadcn@latest add @shadcnblocks/<name>uicomponents5. Build a comparison surface
5. 构建对比界面
Always give the user a way to see the variations side by side and built, not just
names in chat. Mirror the font-comparison pattern: render every variation on one
screen, each clearly labelled, wired with the same representative content so the
only difference is the block itself.
- Web app with routing (TanStack Router, Next): add a temporary route such as
that imports and stacks all variations with a heading per option. Mark it clearly as throwaway (a
/compare/<feature>comment) and make sure it bypasses any auth/boot gating so it's viewable.// TODO: remove after selection - Component / Storybook: a gallery story rendering each variation in a row.
- Run the dev server and hand the user a working preview URL (e.g. the Tailscale-served dev URL for this environment). Don't ask them to imagine the result — let them look at it.
The comparison surface must build cleanly (, , and
the project build) before you present it.
lsp_diagnosticscheck-types始终要让用户能够看到已构建好的、并排展示的变体,而不仅仅是聊天中的名称。参考字体对比的模式:将所有变体渲染在同一个页面上,每个都有清晰的标签,并且使用相同的代表性内容,这样唯一的区别就是块组件本身。
- 带路由的Web应用(TanStack Router、Next):添加一个临时路由,例如,导入所有变体并堆叠展示,每个选项都有标题。明确标记这是临时内容(添加
/compare/<feature>注释),并确保它绕过所有认证/启动拦截,以便可以直接访问。// TODO: remove after selection - 组件 / Storybook:创建一个画廊式的story,将所有变体排成一行渲染。
- 运行开发服务器,给用户提供一个可访问的预览URL(例如本环境的Tailscale提供的开发URL)。不要让用户去想象效果——让他们直接看到实际效果。
在展示给用户之前,对比界面必须能够无错误构建(通过、检查,以及项目构建)。
lsp_diagnosticscheck-types6. Let the user choose, then adapt the winner
6. 让用户选择,然后适配选中的方案
Present the labelled options and the preview URL, and ask which to keep. Once they
pick:
- Wire the winner to real data and routes, strip demo placeholder copy, reconcile theme mismatches, and remove parts you don't need.
- Delete the other variations and the temporary comparison surface so they don't rot in the codebase.
The win is starting from a polished, accessible structure and letting the user
choose between real, built options — not shipping the first block you found or
leaving lorem ipsum behind.
展示带标签的选项和预览URL,询问用户要保留哪一个。用户选定后:
- 将选中的组件接入真实数据和路由,移除演示占位文本,调整主题不匹配的地方,删除不需要的部分。
- 删除其他变体和临时对比界面,避免它们在代码库中遗留变质。
这样做的好处是从一个完善、无障碍的结构开始,让用户在真实的、已构建的选项中做选择——而不是直接交付你找到的第一个块,或者留下一堆占位文本。
7. Audit
7. 审计
After settling on the winner and removing the rest, run the shadcn MCP
and work through it (imports resolve, dependencies
installed, no leftover demo data or comparison scaffolding, types clean). Then run
the project's own checks (, , build).
get_audit_checklistlsp_diagnosticscheck-types确定最终方案并删除其他内容后,运行shadcn MCP的并逐项检查(导入可解析、依赖已安装、无遗留的演示数据或对比脚手架、类型无错误)。然后运行项目自身的检查(、、构建)。
get_audit_checklistlsp_diagnosticscheck-typesRegistry access
注册表访问
The registry requires an API key in the header
of . In darkmatter repos this is handled per-project:
@shadcnblocksAuthorizationcomponents.json- is gitignored and carries the resolved key (or the shadcn MCP reads
components.jsonfrom the environment).${SHADCNBLOCKS_API_KEY} - is committed with the
components.json.templateplaceholder.${SHADCNBLOCKS_API_KEY} - The key lives in the secret store (himitsu: , or a SOPS-encrypted secret). A small
himitsu read shadcnblocks-api-keyrenders the template with the key.scripts/setup-components-json.ts
@shadcnblockscomponents.jsonAuthorization- 被加入gitignore,包含解析后的密钥(或者shadcn MCP从环境变量中读取
components.json)。${SHADCNBLOCKS_API_KEY} - 会被提交到仓库,其中包含
components.json.template占位符。${SHADCNBLOCKS_API_KEY} - 密钥存储在密钥仓库中(himitsu:运行获取,或者是SOPS加密的密钥)。有一个小型脚本
himitsu read shadcnblocks-api-key会用密钥渲染模板。scripts/setup-components-json.ts
Before running any bunx shadcn
command
bunx shadcn运行任何bunx shadcn
命令之前
bunx shadcnThe rendered must exist and be fresh — a stale one from a
previous session may carry an expired key. Always do these two steps first:
components.json- Build components.json: run from the repo root. This reads the current key from himitsu and writes the gitignored
bun scripts/setup-components-json.ts. Skip this and you'll get 401 auth failures.components.json - into the app directory (e.g.
cd) before runningapps/web/. The CLI resolves registries frombunx shadcn@latest add ...in the current working directory. Running from the monorepo root will fail.components.json - Use flag to skip interactive prompts about existing files (
--overwrite,utils.ts, etc.) that the block may depend on but already exist in the project.button.tsx
Typical invocation:
bash
undefined渲染后的必须存在且是最新的——上一次会话留下的旧文件可能包含已过期的密钥。请始终先执行以下两个步骤:
components.json- 构建components.json:在仓库根目录运行。这会从himitsu读取当前密钥,并写入被gitignore的
bun scripts/setup-components-json.ts文件。跳过这一步会导致401认证错误。components.json - 运行之前,
bunx shadcn@latest add ...到应用目录(例如cd)。CLI会从当前工作目录的apps/web/中解析注册表配置。从monorepo根目录运行会失败。components.json - 使用标志,跳过关于项目中已存在的、块组件可能依赖的文件(
--overwrite、utils.ts等)的交互式提示。button.tsx
典型调用示例:
bash
undefinedFrom repo root:
From repo root:
bun scripts/setup-components-json.ts
cd apps/web
bunx shadcn@latest add @shadcnblocks/hero253 --overwrite
If a registry call fails with a missing-env-var or auth error, the fix is to
populate the key from the secret store — not to abandon the registry and
hand-roll the component. See the `sops-secret-access` skill for the encrypted-
config side of this and the expected secret-handling pattern.
Graduate stable pieces from the screen into the repo's shared UI package (name
is per-repo; see [ADR-0013](../../docs/adr/0013-shared-ui-is-its-own-package.md)).bun scripts/setup-components-json.ts
cd apps/web
bunx shadcn@latest add @shadcnblocks/hero253 --overwrite
如果注册表调用因缺少环境变量或认证错误而失败,解决方法是从密钥仓库中填充密钥——而不是放弃使用注册表,手动编写组件。关于加密配置部分和预期的密钥处理模式,请参阅`sops-secret-access`技能。
将稳定的组件从临时界面迁移到仓库的共享UI包中(包名因仓库而异;参见[ADR-0013](../../docs/adr/0013-shared-ui-is-its-own-package.md))。Relationship to other skills
与其他技能的关系
- — how to access the encrypted registry config and keys. This skill is about preferring registry components; that one is about the plumbing to reach a private registry.
sops-secret-access - — design intelligence (styles, palettes, layout, a11y). Use it to decide what good UI looks like; use this skill to source the components that realize it. They compose: pick the aesthetic with
ui-ux-pro-max, then search the registry for blocks that match.ui-ux-pro-max - — performance patterns for the React you write around and inside installed blocks.
vercel-react-best-practices
- — 如何访问加密的注册表配置和密钥。本技能是关于优先使用注册表组件;而该技能是关于访问私有注册表的底层配置。
sops-secret-access - — 设计能力(样式、配色、布局、无障碍)。用它来决定好的UI应该是什么样;用本技能来寻找实现该UI的组件。两者是互补的:用
ui-ux-pro-max确定美学风格,然后在注册表中搜索匹配的块组件。ui-ux-pro-max - — 你在已安装的块组件周围和内部编写的React代码的性能优化模式。
vercel-react-best-practices