pencil-design
chiroro-jr/pencil-design-skill
Design UIs in Pencil and generate production code from designs using design system components and tokens.
What is pencil-design?
This skill enables design-to-code workflows in Pencil (.pen files). Use it when designing screens or components in Pencil, generating code from designs, or working with design tokens and reusable components. It enforces best practices for design system reuse, variable usage, layout correctness, and visual verification.
- Design screens, pages, and components in Pencil with reusable design system components
- Generate production code (React, Next.js, Vue, Svelte, HTML/CSS) from Pencil designs
- Sync design tokens between Pencil and code using Tailwind v4 @theme and shadcn/ui tokens
- Build and extend design systems in Pencil with proper variable usage
- Import existing code into Pencil designs and verify layouts for overflow/alignment issues
How to install pencil-design
npx skills add https://github.com/chiroro-jr/pencil-design-skill --skill pencil-design- Pencil design file (.pen) with existing design system or components
- Access to Pencil MCP tools (pencil_batch_design, pencil_batch_get, etc.)
- frontend-design skill loaded for aesthetic direction and design quality standards
How to use pencil-design
- 1.Load the frontend-design skill first for aesthetic direction and design standards
- 2.Call pencil_get_editor_state to understand the file state and schema
- 3.Call pencil_batch_get with reusable: true to discover available design system components
- 4.Call pencil_get_variables to read all defined design tokens and variables
- 5.Build your design section by section, reusing components as ref instances and applying variables instead of hardcoded values
- 6.Call pencil_get_screenshot after each section to visually verify alignment and spacing
- 7.Call pencil_snapshot_layout with problemsOnly: true to detect overflow and layout issues
- 8.For code generation, call pencil_get_guidelines with topic 'code' and 'tailwind', then map variables to Tailwind @theme declarations
Use cases
- Creating a new product screen in Pencil and generating clean React code from it
- Extending a design system by adding new components while reusing existing ones
- Converting a Pencil design to Tailwind CSS with semantic token mapping
- Building responsive multi-artboard designs and generating breakpoint-aware code
- Syncing design tokens from Pencil variables to frontend code
- UI/UX designers working in Pencil
- Frontend developers generating code from design files
- Design system maintainers building reusable components
- Product teams doing design-to-code workflows
pencil-design FAQ
Always search for existing reusable components first using pencil_batch_get with patterns: [{ reusable: true }]. Only create a new component from scratch if no suitable match exists in the design system.
Always use variables instead of hardcoded values. Call pencil_get_variables to map your intended values to existing design tokens, then apply them using variable references. When generating code, use Tailwind semantic utility classes like bg-primary, not arbitrary values.
Set appropriate text wrapping and truncation for every text element, constrain widths to parent bounds (especially on mobile at 375px), use fill_container for width on text in auto-layout frames, and call pencil_snapshot_layout with problemsOnly: true to detect clipping issues.
Load frontend-design skill for aesthetic direction, call pencil_get_guidelines with topics 'code' and 'tailwind', call pencil_get_variables to map tokens, then generate code using Tailwind v4 @theme declarations and semantic utility classes based on your design tokens.
Yes. After completing each section, call pencil_get_screenshot to analyze alignment and spacing, then call pencil_snapshot_layout to catch layout problems. Fix any issues before moving to the next section.
Full instructions (SKILL.md)
Source of truth, from chiroro-jr/pencil-design-skill.
name: pencil-design description: Design UIs in Pencil (.pen files) and generate production code from them. Use when working with .pen files, designing screens or components in Pencil, or generating code from Pencil designs. Triggers on tasks involving Pencil, .pen files, design-to-code workflows, or UI design with the Pencil MCP tools. metadata: author: Nyasha Chiroro version: "1.0"
Pencil Design Skill
Design production-quality UIs in Pencil and generate clean, maintainable code from them. This skill enforces best practices for design system reuse, variable usage, layout correctness, visual verification, and design-to-code workflows.
When to Use This Skill
- Designing screens, pages, or components in a
.penfile - Generating code (React, Next.js, Vue, Svelte, HTML/CSS) from Pencil designs
- Building or extending a design system in Pencil
- Syncing design tokens between Pencil and code (Tailwind v4
@theme, shadcn/ui tokens) - Importing existing code into Pencil designs
- Working with any Pencil MCP tools (
pencil_batch_design,pencil_batch_get, etc.)
Critical Rules
These rules address the most common agent mistakes. Violating them produces designs that are inconsistent, hard to maintain, and generate poor code.
Rule 1: Always Reuse Design System Components
NEVER recreate a component from scratch when one already exists in the design file.
Before inserting any element, you MUST:
- Call
pencil_batch_getwithpatterns: [{ reusable: true }]to list all available reusable components - Search the results for a component that matches what you need (button, card, input, nav, etc.)
- If a match exists, insert it as a
refinstance usingI(parent, { type: "ref", ref: "<componentId>" }) - Customize the instance by updating its descendants with
U(instanceId + "/childId", { ... }) - Only create a new component from scratch if no suitable reusable component exists
See references/design-system-components.md for detailed workflow.
Rule 2: Always Use Variables Instead of Hardcoded Values
NEVER hardcode colors, border radius, spacing, or typography values when variables exist.
Before applying any style value, you MUST:
- Call
pencil_get_variablesto read all defined design tokens - Map your intended values to existing variables (e.g., use
primarynot#3b82f6, useradius-mdnot6) - Apply values using variable references, not raw values
- When generating code, use Tailwind v4 semantic utility classes (e.g.,
bg-primary,text-foreground,rounded-md). NEVER use arbitrary value syntax (bg-[#3b82f6],text-[var(--primary)],rounded-[6px])
See references/variables-and-tokens.md for detailed workflow.
Rule 3: Prevent Text and Content Overflow
NEVER allow text or child elements to overflow their parent or the artboard.
For every text element and container:
- Set appropriate text wrapping and truncation
- Constrain widths to parent bounds, especially on mobile screens (typically 375px wide)
- Use
"fill_container"for width on text elements inside auto-layout frames - After inserting content, call
pencil_snapshot_layoutwithproblemsOnly: trueto detect clipping/overflow - Fix any reported issues before proceeding
See references/layout-and-text-overflow.md for detailed workflow.
Rule 4: Visually Verify Every Section
NEVER skip visual verification after building a section or screen.
After completing each logical section (header, hero, sidebar, form, card grid, etc.):
- Call
pencil_get_screenshoton the section or full screen node - Analyze the screenshot for: alignment issues, spacing inconsistencies, text overflow, visual glitches, missing content
- Call
pencil_snapshot_layoutwithproblemsOnly: trueto catch clipping and overlap - Fix any issues found before moving to the next section
- Take a final full-screen screenshot when the entire design is complete
See references/visual-verification.md for detailed workflow.
Rule 5: Reuse Existing Assets (Logos, Icons, Images)
NEVER generate a new logo or duplicate asset when one already exists in the document.
Before generating any image or logo:
- Call
pencil_batch_getand search for existing image/logo nodes by name pattern (e.g.,patterns: [{ name: "logo|brand|icon" }]) - If a matching asset exists elsewhere in the document (another artboard/screen), copy it using the
C()(Copy) operation - Only use the
G()(Generate) operation for genuinely new images that don't exist anywhere in the document - For logos specifically: always copy from an existing instance, never regenerate
See references/asset-reuse.md for detailed workflow.
Rule 6: Always Load the frontend-design Skill
NEVER design in Pencil or generate code from Pencil without first loading the frontend-design skill.
The frontend-design skill provides the aesthetic direction and design quality standards that prevent generic, cookie-cutter UI. You MUST:
- Load the
frontend-designskill at the start of any Pencil design or code generation task - Follow its design thinking process: understand purpose, commit to a bold aesthetic direction, consider differentiation
- Apply its guidelines on typography, color, motion, spatial composition, and visual details — both when designing in Pencil and when generating code from Pencil designs
- Never produce generic AI aesthetics (overused fonts, cliched color schemes, predictable layouts)
This applies to both directions:
- Pencil design tasks: Use the skill's aesthetic guidelines to inform layout, typography, color, and composition choices in the .pen file
- Code generation from Pencil: Use the skill's guidelines to ensure the generated code includes distinctive typography, intentional color themes, motion/animations, and polished visual details — not just a mechanical translation of the design tree
Design Workflow
Starting a New Design
0. Load `frontend-design` skill -> Get aesthetic direction and design quality standards
1. pencil_get_editor_state -> Understand file state, get schema
2. pencil_batch_get (reusable) -> Discover design system components
3. pencil_get_variables -> Read design tokens
4. pencil_get_guidelines -> Get relevant design rules
5. pencil_get_style_guide_tags -> (optional) Get style inspiration
6. pencil_get_style_guide -> (optional) Apply style direction
7. pencil_find_empty_space_on_canvas -> Find space for new screen
8. pencil_batch_design -> Build the design (section by section)
9. pencil_get_screenshot -> Verify each section visually
10. pencil_snapshot_layout -> Check for layout problems
Building Section by Section
For each section of a screen (header, content area, footer, sidebar, etc.):
- Plan - Identify which design system components to reuse
- Build - Insert components as
refinstances, apply variables for styles - Verify - Screenshot the section + check layout for problems
- Fix - Address any overflow, alignment, or spacing issues
- Proceed - Move to the next section only after verification passes
Design-to-Code Workflow
See references/design-to-code-workflow.md for the complete workflow. See references/tailwind-shadcn-mapping.md for the full Pencil-to-Tailwind mapping table. See references/responsive-breakpoints.md for multi-artboard responsive code generation.
Summary:
- Load the
frontend-designskill for aesthetic direction - Call
pencil_get_guidelineswith topic"code"and"tailwind" - Call
pencil_get_variablesto map design tokens to Tailwind@themedeclarations - Read the design tree with
pencil_batch_get - Map reusable Pencil components to shadcn/ui components (Button, Card, Input, etc.)
- Generate code using semantic Tailwind classes (
bg-primary,rounded-md), never arbitrary values - Apply
frontend-designguidelines: distinctive typography, intentional color, motion, spatial composition - Use CVA for custom component variants,
cn()for class merging, Lucide for icons
MCP Tool Quick Reference
| Tool | When to Use |
|---|---|
pencil_get_editor_state | First call - understand file state and get .pen schema |
pencil_batch_get | Read nodes, search for components (reusable: true), inspect structure |
pencil_batch_design | Insert, copy, update, replace, move, delete elements; generate images |
pencil_get_variables | Read design tokens (colors, radius, spacing, fonts) |
pencil_set_variables | Create or update design tokens |
pencil_get_screenshot | Visual verification of any node |
pencil_snapshot_layout | Detect clipping, overflow, overlapping elements |
pencil_get_guidelines | Get design rules for: code, table, tailwind, landing-page, design-system |
pencil_find_empty_space_on_canvas | Find space for new screens/frames |
pencil_get_style_guide_tags | Browse available style directions |
pencil_get_style_guide | Get specific style inspiration |
pencil_search_all_unique_properties | Audit property values across the document |
pencil_replace_all_matching_properties | Bulk update properties (e.g., swap colors) |
pencil_open_document | Open a .pen file or create a new document |
Common Mistakes to Avoid
| Mistake | Correct Approach |
|---|---|
| Creating a button from scratch | Search for existing button component, insert as ref |
Using fill: "#3b82f6" | Use the variable: reference primary or the corresponding variable |
Using cornerRadius: 8 | Use the variable: reference radius-md or the corresponding variable |
Generating bg-[#3b82f6] in code | Use semantic Tailwind class: bg-primary |
Generating text-[var(--primary)] in code | Use semantic Tailwind class: text-primary |
Generating rounded-[6px] in code | Use semantic Tailwind class: rounded-md |
Using var(--primary) in className | Use semantic Tailwind class: bg-primary or text-primary |
| Not checking for overflow | Call pencil_snapshot_layout(problemsOnly: true) after every section |
| Skipping screenshots | Call pencil_get_screenshot after every section |
| Generating a new logo | Copy existing logo from another artboard with C() |
| Building entire screen, then checking | Build and verify section by section |
Ignoring pencil_get_guidelines | Always call it for the relevant topic before starting |
Using tailwind.config.ts | Use CSS @theme block (Tailwind v4) |
| Using Material Icons in code | Map to Lucide icons (<Search />, <ArrowRight />, etc.) |
Skipping frontend-design skill | Always load it before designing in Pencil or generating code |
| Generic AI aesthetics (Inter font, purple gradients) | Follow frontend-design guidelines for distinctive, intentional design |
Resources
Related skills
More from chiroro-jr/pencil-design-skill and the wider catalog.

stock-daily-analysis
LLM驱动的每日股票分析系统。支持A股/港股/美股自选股智能分析,生成决策仪表盘和大盘复盘报告。提供技术面分析(均线、MACD、RSI、乖离率)、趋势判断、买入信号评分。可与market-data skill集成获取更稳定的ETF数据。触发词:股票分析、分析股票、每日分析、技术面分析。

stock-monitor
全功能智能股票监控预警系统。支持成本百分比、均线金叉死叉、RSI超买超卖、成交量异动、跳空缺口、动态止盈等7大预警规则。符合中国投资者习惯(红涨绿跌)。

phaser-gamedev
>

compose-focus-navigation
Use when writing or reviewing Jetpack Compose UI for TV, keyboard, desktop, accessibility focus, D-pad navigation, FocusRequester, focusProperties, key events, or initial focus behavior.

compose-modifier-and-layout-style
Use when writing or reviewing Jetpack Compose layout APIs, modifier parameters, modifier chain construction, hardcoded root layout decisions, or layout wrappers around a single conditional.

compose-recomposition-performance
Use when investigating Jetpack Compose recomposition performance, skippable/restartable composables, composables.txt or compiler reports, Layout Inspector recomposition counts, back-writing snapshot state across phases, or frame-rate State reads in composition vs layout/draw, and it is not yet clear whether the cause is parameter stability, deferred reads, or cross-phase back-writing.