ask-shadcn-architect
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinese<critical_constraints>
❌ NO custom if shadcn Button exists → import from @/components/ui
❌ NO manual implementation of standard components → use CLI
❌ NO hardcoded colors → use semantic (bg-primary, text-muted-foreground)
✅ MUST check @/components/ui first before creating
✅ MUST use cn() utility for className merging
✅ MUST use lucide-react for icons
</critical_constraints>
<detection>
Active when: `components/ui/` exists OR `components.json` exists
</detection>
<button><cli_first>
Missing component? Don't write from scratch:
</cli_first>
npx shadcn@latest add [component-name]<style_merging>
❌ Bad: bg-red-500 ${className}`}className={cn("bg-red-500", className)}`
</style_merging>
<example>
User: "Make a red delete button"
className={\✅ Good:❌ Weak:
tsx
<button className="bg-red-500 text-white p-2 rounded">Delete</button>✅ Correct:
tsx
import { Button } from "@/components/ui/button"
<Button variant="destructive">Delete</Button><critical_constraints>
❌ 若shadcn Button组件已存在,禁止自定义 → 从@/components/ui导入
❌ 禁止手动实现标准组件 → 使用CLI
❌ 禁止硬编码颜色 → 使用语义化颜色(bg-primary、text-muted-foreground)
✅ 创建组件前必须先检查@/components/ui
✅ 必须使用cn()工具函数合并className
✅ 必须使用lucide-react提供图标
</critical_constraints>
<detection>
触发条件:当`components/ui/`目录存在 或 `components.json`文件存在时激活
</detection>
<button><cli_first>
缺少组件?不要从零开始编写:
</cli_first>
npx shadcn@latest add [component-name]<style_merging>
❌ 错误写法:bg-red-500 ${className}`}className={cn("bg-red-500", className)}`
</style_merging>
<example>
用户需求:“创建一个红色的删除按钮”
className={\ ✅ 正确写法:❌ 不规范写法:
tsx
<button className="bg-red-500 text-white p-2 rounded">Delete</button>✅ 规范写法:
tsx
import { Button } from "@/components/ui/button"
<Button variant="destructive">Delete</Button>