Pencil Design System generator. Use when the user asks to create a design system, build a UI kit, set up design tokens, or create components in a Pencil .pen file for any business domain. Creates themed tokens, visual foundations, reusable components, and composition patterns.
Install
npx skillscat add jsstechio/pencil-design-system/agent-skills-pds Install via the SkillsCat registry.
Pencil Design System Generator
Generate a complete design system in a Pencil .pen file. Research the business domain, create ~89 themed tokens (light + dark), build visual foundation documentation, ~25 reusable components, and 4 composition patterns.
⛔ GOLDEN RULES — Read These First
These rules prevent the #1 visual bug (overlapping elements). Violating any of these produces a broken design.
- EVERY frame MUST have
layout: "vertical"orlayout: "horizontal". No exceptions. Without it, children overlap at (0,0). - Category display rows MUST use
layout: "horizontal". Components shown side-by-side need a horizontal row frame. - Use
height: "fit_content"on section frames — never fixed pixel heights. - After EVERY
batch_design, screenshot and CHECK for overlap. Missinglayout→ add it immediately. - Copy exact operation code from reference files. Do NOT improvise layout code.
- NEVER call
open_document("new"). Always checkget_editor_statefirst — if a.penfile exists, use it. - NEVER put
"themes"key inset_variables. Crashes with "missing type". Themes auto-register from"theme": { "mode": "light" }inside each color value.
Getting Started
- Parse the user's input — extract domain, brand name, color preferences, font preferences, reference image
- Greet and confirm — show what was understood and the build plan
- Execute phases — pause at each review point for user approval (
ccontinue,rredo,sskip)
Workflow
Load reference files from references/ as each phase begins.
Phase 1 — Research the Domain
If collectui-mcp is available: Call design_search({ query: "[domain]", limit: 8 }) first (or collectui_search as fallback). Searches 6 design sites in parallel. Analyze returned screenshots — extract colors, typography, layouts.
If a reference image exists (on canvas, in chat, or URL), analyze it first — extract colors (hex), typography style, tone, radii, shadows. This is the PRIMARY design source. Then search the web for the domain's color palettes, font pairings, and UI conventions. Compile a design brief. Priority: reference image > Collect UI visual research > user preferences > web research.
REVIEW — Show design brief. Wait for user input.
Phase 2 — Initialize Pencil Document
Step 1 — CHECK for existing document FIRST:
Call get_editor_state({ include_schema: true }). Look at the filePath in the response.
⛔ STOP AND DECIDE:
- If
filePathcontains ANY.penfile: USE IT. Do NOT callopen_document. The document is already open. - ONLY if
filePathis empty/null: Create:open_document("./[domain]-design-system.pen"). - NEVER call
open_document("new")— this creates a generic file that ignores the existing one. - NEVER call
open_documentif a.penfile is already open.
Step 2 — get_guidelines({ topic: "design-system" })
Step 3 — get_style_guide_tags() then get_style_guide({ tags: [...] })
Step 4 — get_variables({ filePath }) — check for existing tokens
Phase 3 — Create Design Tokens (~89)
Call set_variables with all tokens.
⛔ FATAL ERRORS — avoid these or set_variables will crash:
- NEVER put
"themes": { "mode": ["light", "dark"] }in the variables object. This causes:Variable 'themes' is missing its 'type' property! - NEVER use
"theme": {}(empty object) — breaks theming - NEVER use
"values"(plural) — the key is"value"(singular) - Themes auto-register when you use
"theme": { "mode": "light" }inside each color's value array
CORRECT — color tokens (themed):
{
"--primary": {
"type": "color",
"value": [
{ "value": "#3E2723", "theme": { "mode": "light" } },
{ "value": "#D7CCC8", "theme": { "mode": "dark" } }
]
}
}CORRECT — non-color tokens: { "type": "number", "value": [{ "value": 6 }] }
Semantic colors MUST be derived from the primary palette — match temperature, saturation, lightness. Do NOT use default Tailwind green/amber/red/blue. See references/design-tokens-reference.md for examples.
After set_variables, call get_variables — every color MUST show "theme":{"mode":"light"} and "theme":{"mode":"dark"}. If any show "theme":{}, redo.
See references/design-tokens-reference.md for full payload.
💾 Save the file (Cmd+S / Ctrl+S).
REVIEW — Show token count by category. Wait for user input.
Phase 4 — Build Foundations
Foundations frame with width: 1440, height: "fit_content", layout: "vertical", fill: "#FFFFFF". Never use fixed heights — use height: "fit_content". Build: color palette, typography scale, spacing, elevation, border radius.
Color Palette: Split into rows of max 5-6 swatches to prevent horizontal overflow. Each swatch ~140-160px. Use a vertical container with multiple horizontal rows.
See references/foundations-specs.md.
⚠ MANDATORY — Post-Batch Validation (after EVERY batch_design call in ALL phases):
get_screenshoton the section just modified.- STOP and analyze the screenshot. Check for: overlapping/garbled text, stacked items that should be side-by-side, clipped content, invisible elements.
snapshot_layout({ problemsOnly: true, parentId: "sectionId" }).- Fix ALL issues BEFORE continuing. Missing
layout: "horizontal"→ add it. Garbled text → addwidth: "fill_container".
💾 Save the file (Cmd+S / Ctrl+S).
REVIEW — Show screenshot. Wait for user input.
Phase 5 — Build Components (~25)
Components frame with width: 1440, height: "fit_content", layout: "vertical", fill: "#FFFFFF". Build ~25 reusable components in explicit batches. Complete ALL batches — do NOT stop early.
⚠ CRITICAL STRUCTURE FOR EACH BATCH:
- Create a category frame (
layout: "vertical",width: "fill_container") inside Components section - Add a category title text
- Create a display row (
layout: "horizontal",gap: 16,width: "fill_container") inside the category - Insert components into the display row — NOT directly into the Components section
- If elements overlap after batch_design, the parent frame is missing
layout— fix immediately
After EVERY batch, run the Post-Batch Validation above.
- Buttons (5): Category (vertical) → Row (horizontal) → 5 buttons. Each:
layout: "horizontal". Validate. - Inputs (4): Category (vertical) → Row (horizontal) → 4 inputs. Each:
layout: "vertical". Validate. - Typography (6): Category (vertical) → 6 text components stacked. Validate.
- Badges+Alerts (8): Category (vertical) → Badges row (horizontal) → Alerts row (vertical). Validate.
- Card+Navigation (5): Category (vertical) → Row (horizontal). Card:
layout: "vertical". Sidebar:layout: "vertical". Validate. - Table+Tabs+Breadcrumbs (9): Category (vertical) → sub-rows. Containers:
layout: "vertical"or"horizontal". Validate. - Remaining (10): Category (vertical) → display rows (horizontal) → components. Validate.
All components: reusable: true, $-- tokens only. See references/component-specs.md.
💾 Save the file (Cmd+S / Ctrl+S).
REVIEW — Show component count and screenshot. Wait for user input.
Phase 6 — Build Patterns
Patterns frame with width: 1440, height: "fit_content", layout: "vertical". Build 4 showcases using component refs:
- Form Pattern —
layout: "vertical", InputGroup refs + Submit - Data Display — Table + Pagination, stacked vertically
- Navigation — horizontal: sidebar (
layout: "vertical", width: 240) + content (layout: "vertical") - Card Layout —
layout: "horizontal", Card refs withgap: 24
Every frame MUST have explicit layout. Sidebars are ALWAYS layout: "vertical".
Images: Use G() for domain visuals — card images: G(frame, "stock", "[domain keyword]"), avatars: G(frame, "stock", "portrait"). Insert frame first, then apply G().
After each pattern, run the Post-Batch Validation.
See references/screen-patterns.md.
💾 Save the file (Cmd+S / Ctrl+S).
REVIEW — Show screenshot. Wait for user input.
Phase 7 — Domain Screens (optional)
Only if user requests. Build 3-5 screens using component refs.
Phase 8 — Verify + Fix
Layout enforcement, shadow fix, visual check, token audit, component audit.
See references/verification-checklist.md.
Critical Rules
- Always reuse components — search with
batch_get({ patterns: [{ reusable: true }] })before creating - Never hardcode values — all colors use
$--tokens - Prevent overflow — use
width: "fill_container"and layout frames - Verify visually —
get_screenshotafter every major batch - Canvas organization — Foundations, Components, Patterns flow left-to-right
References
references/pencil-mcp-guide.md— Pencil MCP tool referencereferences/domain-research-guide.md— Research strategies, font pairingsreferences/design-tokens-reference.md— Token architecture, ~89 definitionsreferences/foundations-specs.md— Foundation documentation specsreferences/component-specs.md— Component batch_design codereferences/screen-patterns.md— Layout patterns, screen templatesreferences/verification-checklist.md— QA checklistreferences/code-export-guide.md— Tailwind CSS export