Pen Design
Use the current pen.dev runtime as the source of truth. The CLI and Pencil MCP
share .pen files but serve different workflows.
Choose the surface
- Use
pen agent mode for prompt-driven generation, headless work, model
selection, attachments, batch tasks, and direct export.
- Use
pen interactive for deterministic headless operations or live app mode
when MCP tools are not directly exposed.
- Use Pencil MCP for live editor state, precise node operations, component and
variable reuse, layout diagnosis, screenshots, and targeted export.
- Combine them when useful: generate broadly with CLI, refine and verify through
MCP.
- Never parse, grep, or hand-edit
.pen files. Use pen or Pencil MCP.
Read CLI workflow for authentication, generation,
iteration, and interactive use. Read MCP workflow
for the live editor tools and execute API.
Refresh and bind
This skill is maintained against the current @pen.dev/cli release. Runtime
schema, bundled official skill, and command help remain authoritative when the
installed version changes.
Before the first Pen task in a session:
- For CLI work, run
pen version, npm view @pen.dev/cli version, and
pen status. If behavior differs, inspect pen --help and the official
bundled SKILL.md.
- For MCP work, call
get_app_state with include_schema: true,
include_canvas_design: true, and include_scripts_and_shaders: false.
- Treat the returned schema and tool descriptions as authoritative. Never
assume a capability is unavailable because a legacy standalone tool name is
missing.
- Before writing, prove the requested target is the document being addressed.
Do not rely on
filePath alone when the active document differs.
Read Document safety before writing to a named
file, editing outside the workspace, using concurrent agents, or resolving a
.pen Git conflict.
Read Official integration at the start of
the first Pen task in a session. It routes to the official schema and guides
without duplicating their proprietary manuals in this repository.
Source priority
Resolve design decisions in this order:
- Explicit user direction, supplied references, and approved brand guidance.
- Live
.pen variables, reusable components, imported libraries, and assets.
- The target repository's tokens, components, fonts, icons, and conventions.
- Skill defaults only when the first three provide no answer.
Do not overwrite established tokens or components with a generic starter set.
Read Design governance for long-lived files,
multi-screen flows, component libraries, naming, and responsive organization.
Read Platform patterns only when the task is
an admin product, mobile app, mini program, data display, commerce surface,
design system, cross-platform family, or presentation deck.
Required hierarchy
Frames, groups, and their contents must have real parent-child relationships.
Never simulate grouping by placing unrelated nodes next to each other.
- Insert children under the intended frame or group, or move them there.
- Use frames for layout, sizing, clipping, backgrounds, and responsive
containers.
- Use groups for logical hierarchy without frame layout behavior.
- Verify hierarchy after copying, replacing, moving, or creating nodes.
- Prefer
fill_container and fit_content in layout-driven frames. Do not set
x/y on auto-layout children unless layoutPosition is absolute.
- Give every authored node a meaningful human-readable
name.
Schema guardrails
Apply the official .pen semantics rather than CSS assumptions:
- Use only schema-supported properties. Percentages,
margin, baseline/stretch
alignment, and CSS calc() values are invalid.
layout and padding belong on frames. Auto-layout ignores child x/y;
use layoutPosition: "absolute" only when deliberate.
- Text needs an explicit
fill. Use textGrowth: "fixed-width" for wrapping;
do not guess text box dimensions when layout can determine them.
- New, copied, or modified root frames use
placeholder: true while being
built, then clear it as soon as that frame is complete.
- Set
viewBox on every authored SVG path and prefer layout-driven charts over
manually positioned data marks.
Working loop
- Bind the target and inspect the selected or requested subtree.
- Inventory reusable components, variables, assets, and relevant imports.
- For ambiguous new work, choose or present a small number of concrete visual
directions. Skip broad exploration for a precise edit.
- Build one coherent section at a time with correct hierarchy.
- Read back the changed subtree, query
c.problems, and screenshot the smallest
meaningful completed root.
- Fix warnings, clipping, collapsed layout, accidental overflow, and broken
hierarchy before continuing.
- Export only after the canvas version passes visual inspection.
Use the current schema-documented functions inside execute:
Get(n => n.reusable && Print(n.id, n.name, n.type))
Print(GetVariables())
sectionId = Insert(parentId, {
type: "frame",
name: "Feature section",
layout: "vertical",
width: "fill_container",
gap: 16,
padding: 24
})
Get(sectionId, (n, c) =>
c.problems && Print(n.name, "|", c.parentCtx?.node.name, "|", c.problems)
)
TakeScreenshot([sectionId])
Keep execute snippets small and omit comments from the actual input. A failed
snippet is reverted; repair it with its returned editId and edits rather
than resending new input. Fix returned warnings in the next call.
Completeness
- Search reusable components before creating equivalents; use matching
ref
instances and grounded descendant overrides.
- Read
GetVariables() before styling or defining tokens. Merge missing tokens;
replace the full set only when explicitly intended.
- Reuse logos, icons, images, and components instead of regenerating them.
- For flows or production-ready screens, cover relevant component and screen
states rather than drawing only the happy path.
- Preserve accessibility intent and interaction behavior in
context or
metadata when the information is grounded and not visually inferable.
Read Design quality when creating or reviewing a
screen. Read States and accessibility for
forms, flows, interactive components, or production handoff. Read
Design to code only for implementation work.
For specialized work, also read the matching official guide through the routing
table in Official integration.
Export and completion
Use TakeScreenshot for inspection and Export for deliverables. Read
Export and handoff for multi-node, PDF, HTML,
deck, or cross-platform exports.
Before finishing:
- The requested target, parent-child hierarchy, and edited root were verified.
- No reported clipping or unintended overflow remains.
- Existing components, variables, assets, and project conventions were reused.
- Relevant states and accessibility requirements are represented.
- The final target was screenshotted and visually inspected.
- Requested exports were verified on disk and shown or linked to the user.
- Report canvas edits separately from confirmed disk saves or exports.
1---2name: pen-design3description: Create, edit, inspect, validate, export, and implement .pen visual designs with the pen.dev CLI or Pencil MCP. Use for UI mockups, app and web screens, dashboards, design systems, responsive variants, design-to-code work, or any task involving pen.dev, Pencil, Pen, or .pen files.4---56# Pen Design78Use the current pen.dev runtime as the source of truth. The CLI and Pencil MCP9share `.pen` files but serve different workflows.1011## Choose the surface1213- Use `pen` agent mode for prompt-driven generation, headless work, model14 selection, attachments, batch tasks, and direct export.15- Use `pen interactive` for deterministic headless operations or live app mode16 when MCP tools are not directly exposed.17- Use Pencil MCP for live editor state, precise node operations, component and18 variable reuse, layout diagnosis, screenshots, and targeted export.19- Combine them when useful: generate broadly with CLI, refine and verify through20 MCP.21- Never parse, grep, or hand-edit `.pen` files. Use `pen` or Pencil MCP.2223Read [CLI workflow](references/cli-workflow.md) for authentication, generation,24iteration, and interactive use. Read [MCP workflow](references/mcp-workflow.md)25for the live editor tools and `execute` API.2627## Refresh and bind2829This skill is maintained against the current `@pen.dev/cli` release. Runtime30schema, bundled official skill, and command help remain authoritative when the31installed version changes.3233Before the first Pen task in a session:34351. For CLI work, run `pen version`, `npm view @pen.dev/cli version`, and36 `pen status`. If behavior differs, inspect `pen --help` and the official37 bundled `SKILL.md`.382. For MCP work, call `get_app_state` with `include_schema: true`,39 `include_canvas_design: true`, and `include_scripts_and_shaders: false`.403. Treat the returned schema and tool descriptions as authoritative. Never41 assume a capability is unavailable because a legacy standalone tool name is42 missing.434. Before writing, prove the requested target is the document being addressed.44 Do not rely on `filePath` alone when the active document differs.4546Read [Document safety](references/document-safety.md) before writing to a named47file, editing outside the workspace, using concurrent agents, or resolving a48`.pen` Git conflict.4950Read [Official integration](references/official-integration.md) at the start of51the first Pen task in a session. It routes to the official schema and guides52without duplicating their proprietary manuals in this repository.5354## Source priority5556Resolve design decisions in this order:57581. Explicit user direction, supplied references, and approved brand guidance.592. Live `.pen` variables, reusable components, imported libraries, and assets.603. The target repository's tokens, components, fonts, icons, and conventions.614. Skill defaults only when the first three provide no answer.6263Do not overwrite established tokens or components with a generic starter set.64Read [Design governance](references/design-governance.md) for long-lived files,65multi-screen flows, component libraries, naming, and responsive organization.66Read [Platform patterns](references/platform-patterns.md) only when the task is67an admin product, mobile app, mini program, data display, commerce surface,68design system, cross-platform family, or presentation deck.6970## Required hierarchy7172Frames, groups, and their contents must have real parent-child relationships.73Never simulate grouping by placing unrelated nodes next to each other.7475- Insert children under the intended frame or group, or move them there.76- Use frames for layout, sizing, clipping, backgrounds, and responsive77 containers.78- Use groups for logical hierarchy without frame layout behavior.79- Verify hierarchy after copying, replacing, moving, or creating nodes.80- Prefer `fill_container` and `fit_content` in layout-driven frames. Do not set81 `x`/`y` on auto-layout children unless `layoutPosition` is `absolute`.82- Give every authored node a meaningful human-readable `name`.8384## Schema guardrails8586Apply the official `.pen` semantics rather than CSS assumptions:8788- Use only schema-supported properties. Percentages, `margin`, baseline/stretch89 alignment, and CSS `calc()` values are invalid.90- `layout` and `padding` belong on frames. Auto-layout ignores child `x`/`y`;91 use `layoutPosition: "absolute"` only when deliberate.92- Text needs an explicit `fill`. Use `textGrowth: "fixed-width"` for wrapping;93 do not guess text box dimensions when layout can determine them.94- New, copied, or modified root frames use `placeholder: true` while being95 built, then clear it as soon as that frame is complete.96- Set `viewBox` on every authored SVG path and prefer layout-driven charts over97 manually positioned data marks.9899## Working loop1001011. Bind the target and inspect the selected or requested subtree.1022. Inventory reusable components, variables, assets, and relevant imports.1033. For ambiguous new work, choose or present a small number of concrete visual104 directions. Skip broad exploration for a precise edit.1054. Build one coherent section at a time with correct hierarchy.1065. Read back the changed subtree, query `c.problems`, and screenshot the smallest107 meaningful completed root.1086. Fix warnings, clipping, collapsed layout, accidental overflow, and broken109 hierarchy before continuing.1107. Export only after the canvas version passes visual inspection.111112Use the current schema-documented functions inside `execute`:113114```javascript115Get(n => n.reusable && Print(n.id, n.name, n.type))116Print(GetVariables())117sectionId = Insert(parentId, {118 type: "frame",119 name: "Feature section",120 layout: "vertical",121 width: "fill_container",122 gap: 16,123 padding: 24124})125Get(sectionId, (n, c) =>126 c.problems && Print(n.name, "|", c.parentCtx?.node.name, "|", c.problems)127)128TakeScreenshot([sectionId])129```130131Keep `execute` snippets small and omit comments from the actual input. A failed132snippet is reverted; repair it with its returned `editId` and `edits` rather133than resending new input. Fix returned warnings in the next call.134135## Completeness136137- Search reusable components before creating equivalents; use matching `ref`138 instances and grounded descendant overrides.139- Read `GetVariables()` before styling or defining tokens. Merge missing tokens;140 replace the full set only when explicitly intended.141- Reuse logos, icons, images, and components instead of regenerating them.142- For flows or production-ready screens, cover relevant component and screen143 states rather than drawing only the happy path.144- Preserve accessibility intent and interaction behavior in `context` or145 `metadata` when the information is grounded and not visually inferable.146147Read [Design quality](references/design-quality.md) when creating or reviewing a148screen. Read [States and accessibility](references/states-accessibility.md) for149forms, flows, interactive components, or production handoff. Read150[Design to code](references/design-to-code.md) only for implementation work.151152For specialized work, also read the matching official guide through the routing153table in [Official integration](references/official-integration.md).154155## Export and completion156157Use `TakeScreenshot` for inspection and `Export` for deliverables. Read158[Export and handoff](references/export-handoff.md) for multi-node, PDF, HTML,159deck, or cross-platform exports.160161Before finishing:162163- The requested target, parent-child hierarchy, and edited root were verified.164- No reported clipping or unintended overflow remains.165- Existing components, variables, assets, and project conventions were reused.166- Relevant states and accessibility requirements are represented.167- The final target was screenshotted and visually inspected.168- Requested exports were verified on disk and shown or linked to the user.169- Report canvas edits separately from confirmed disk saves or exports.