pencil-to-code by phrazzld/claude-config
npx skills add https://github.com/phrazzld/claude-config --skill pencil-to-code将 Pencil .pen 设计导出为可用于生产的 React/Tailwind 代码。
输入:
输出:
// 获取完整的框架树
mcp__pencil__batch_get({
filePath: "<path>.pen",
nodeIds: ["frameId"],
readDepth: 10,
resolveInstances: true,
resolveVariables: true
})
// 获取设计变量/主题
mcp__pencil__get_variables({ filePath: "<path>.pen" })
转换 .pen 变量 → Tailwind 主题:
/* 来自 .pen 变量 */
@theme {
--color-primary: [from variables.colors.primary];
--color-background: [from variables.colors.background];
--font-sans: [from variables.fonts.body];
/* ... */
}
参考:references/token-extraction.md
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
| .pen 节点类型 | React 输出 |
|---|---|
带布局的 frame | <div className="flex ..."> |
带子元素的 frame | 包含子元素的组件 |
text | <p>、<h1-6> 或 <span> |
ref(实例) | 可复用组件 |
rectangle | 带填充的 <div> |
ellipse | <div className="rounded-full"> |
image | <img> 或 fill: url() |
参考:references/node-mapping.md
组件结构:
// components/[ComponentName].tsx
import { cn } from "@/lib/utils"
interface [ComponentName]Props {
className?: string
// 从设计中提取的属性
}
export function [ComponentName]({ className, ...props }: [ComponentName]Props) {
return (
<div className={cn("[tailwind classes]", className)}>
{/* 嵌套结构 */}
</div>
)
}
Tailwind 映射:
.pen 属性 → Tailwind 类
--------------------------------
fill: #000 → bg-black
layout: horizontal → flex flex-row
gap: 16 → gap-4
padding: [16,24,16,24] → py-4 px-6
fontSize: 24 → text-2xl
fontWeight: 700 → font-bold
cornerRadius: [8,8,8,8] → rounded-lg
// 截图 .pen 框架
mcp__pencil__get_screenshot({ nodeId: "frameId" })
// 与渲染的 React 进行视觉比较
// (手动步骤或浏览器自动化)
## 生成的组件
### [ComponentName]
- 文件:`components/[ComponentName].tsx`
- 属性:[列出提取的属性]
### 主题配置
- 文件:`app/globals.css`(添加内容)
## 验证
截图对比:[已附加]
.pen Tailwind
--------------------------------------
layout: "vertical" → flex flex-col
layout: "horizontal" → flex flex-row
layout: "grid" → grid
alignItems: "center" → items-center
justifyContent: "center" → justify-center
gap: 8 → gap-2
gap: 16 → gap-4
gap: 24 → gap-6
width: "fill_container" → w-full
height: "fill_container" → h-full
.pen 内边距 Tailwind
----------------------------------------
[8,8,8,8] → p-2
[16,16,16,16] → p-4
[16,24,16,24] → py-4 px-6
[24,32,24,32] → py-6 px-8
.pen Tailwind
----------------------------------------
fontSize: 12 → text-xs
fontSize: 14 → text-sm
fontSize: 16 → text-base
fontSize: 20 → text-xl
fontSize: 24 → text-2xl
fontSize: 32 → text-3xl
fontSize: 48 → text-5xl
fontWeight: 400 → font-normal
fontWeight: 500 → font-medium
fontWeight: 600 → font-semibold
fontWeight: 700 → font-bold
.pen Tailwind
----------------------------------------
fill: "#FFFFFF" → bg-white
fill: "#000000" → bg-black
fill: variable → bg-[var(--color-name)]
textColor: "#6B7280" → text-gray-500
stroke: "#E5E5E5" → border-gray-200
.pen 圆角半径 Tailwind
----------------------------------------
[0,0,0,0] → rounded-none
[4,4,4,4] → rounded
[8,8,8,8] → rounded-lg
[16,16,16,16] → rounded-2xl
[9999,9999,9999,9999] → rounded-full
references/node-mapping.md — 完整的节点 → 组件映射references/token-extraction.md — 变量 → 主题提取design-tokens/ — 令牌系统约定调用方:
design-exploration 编排器(在方向选择之后)组合:
design-tokens(用于主题结构)每周安装次数
172
代码仓库
GitHub 星标数
5
首次出现
2026 年 1 月 26 日
安全审计
安装于
opencode150
codex150
gemini-cli141
claude-code136
github-copilot123
cursor119
Export Pencil .pen designs to production React/Tailwind code.
Input:
Output:
// Get full frame tree
mcp__pencil__batch_get({
filePath: "<path>.pen",
nodeIds: ["frameId"],
readDepth: 10,
resolveInstances: true,
resolveVariables: true
})
// Get design variables/theme
mcp__pencil__get_variables({ filePath: "<path>.pen" })
Transform .pen variables → Tailwind theme:
/* From .pen variables */
@theme {
--color-primary: [from variables.colors.primary];
--color-background: [from variables.colors.background];
--font-sans: [from variables.fonts.body];
/* ... */
}
Reference: references/token-extraction.md
| .pen Node Type | React Output |
|---|---|
frame with layout | <div className="flex ..."> |
frame with children | Component with children |
text | <p>, <h1-6>, or <span> |
ref (instance) |
Reference: references/node-mapping.md
Component structure:
// components/[ComponentName].tsx
import { cn } from "@/lib/utils"
interface [ComponentName]Props {
className?: string
// Extracted props from design
}
export function [ComponentName]({ className, ...props }: [ComponentName]Props) {
return (
<div className={cn("[tailwind classes]", className)}>
{/* Nested structure */}
</div>
)
}
Tailwind mapping:
.pen property → Tailwind class
--------------------------------
fill: #000 → bg-black
layout: horizontal → flex flex-row
gap: 16 → gap-4
padding: [16,24,16,24] → py-4 px-6
fontSize: 24 → text-2xl
fontWeight: 700 → font-bold
cornerRadius: [8,8,8,8] → rounded-lg
// Screenshot the .pen frame
mcp__pencil__get_screenshot({ nodeId: "frameId" })
// Compare visually with rendered React
// (Manual step or browser automation)
## Generated Components
### [ComponentName]
- File: `components/[ComponentName].tsx`
- Props: [list extracted props]
### Theme Configuration
- File: `app/globals.css` (additions)
## Verification
Screenshot comparison: [attached]
.pen Tailwind
--------------------------------------
layout: "vertical" → flex flex-col
layout: "horizontal" → flex flex-row
layout: "grid" → grid
alignItems: "center" → items-center
justifyContent: "center" → justify-center
gap: 8 → gap-2
gap: 16 → gap-4
gap: 24 → gap-6
width: "fill_container" → w-full
height: "fill_container" → h-full
.pen padding Tailwind
----------------------------------------
[8,8,8,8] → p-2
[16,16,16,16] → p-4
[16,24,16,24] → py-4 px-6
[24,32,24,32] → py-6 px-8
.pen Tailwind
----------------------------------------
fontSize: 12 → text-xs
fontSize: 14 → text-sm
fontSize: 16 → text-base
fontSize: 20 → text-xl
fontSize: 24 → text-2xl
fontSize: 32 → text-3xl
fontSize: 48 → text-5xl
fontWeight: 400 → font-normal
fontWeight: 500 → font-medium
fontWeight: 600 → font-semibold
fontWeight: 700 → font-bold
.pen Tailwind
----------------------------------------
fill: "#FFFFFF" → bg-white
fill: "#000000" → bg-black
fill: variable → bg-[var(--color-name)]
textColor: "#6B7280" → text-gray-500
stroke: "#E5E5E5" → border-gray-200
.pen cornerRadius Tailwind
----------------------------------------
[0,0,0,0] → rounded-none
[4,4,4,4] → rounded
[8,8,8,8] → rounded-lg
[16,16,16,16] → rounded-2xl
[9999,9999,9999,9999] → rounded-full
references/node-mapping.md — Complete node → component mappingreferences/token-extraction.md — Variable → theme extractiondesign-tokens/ — Token system conventionsCalled by:
design-exploration orchestrator (after direction selection)Composes:
design-tokens (for theme structure)Weekly Installs
172
Repository
GitHub Stars
5
First Seen
Jan 26, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykWarn
Installed on
opencode150
codex150
gemini-cli141
claude-code136
github-copilot123
cursor119
agent-browser 浏览器自动化工具 - Vercel Labs 命令行网页操作与测试
152,900 周安装
| Reusable component |
rectangle | <div> with fill |
ellipse | <div className="rounded-full"> |
image | <img> or fill: url() |