home / skills / phrazzld / claude-config / pencil-renderer

pencil-renderer skill

/skills/pencil-renderer

This skill renders DNA codes into Pencil .pen frames for given component types, returning frame IDs and screenshots to support design exploration.

npx playbooks add skill phrazzld/claude-config --skill pencil-renderer

Review the files below or copy the command above to add this skill to your agents.

Files (3)
SKILL.md
3.9 KB
---
name: pencil-renderer
description: |
  Render DNA codes to Pencil .pen frames. Does ONE thing well.

  Input: DNA code + component type (hero, card, form, etc.)
  Output: .pen frame ID + screenshot

  Use when: design-exploration or other orchestrators need to render
  visual proposals using Pencil MCP backend.
---

# Pencil Renderer

Translate aesthetic DNA codes into Pencil .pen frames via MCP.

## Interface

**Input:**
- DNA code: `[layout, color, typography, motion, density, background]`
- Component type: `hero | card | form | nav | footer | section | button | input`
- Optional: Name, dimensions, parent frame ID

**Output:**
- Frame ID in .pen file
- Screenshot of rendered frame

## Workflow

### 1. Ensure Document Ready

```javascript
// Check if editor open
mcp__pencil__get_editor_state({ include_schema: false })

// If no editor, open or create
mcp__pencil__open_document({ filePathOrTemplate: "new" })
```

### 2. Get Style Foundation

```javascript
// Get available style guide tags
mcp__pencil__get_style_guide_tags()

// Get style guide matching DNA mood
// Map DNA to relevant tags:
// - dark color → ["dark-mode", "moody"]
// - light color → ["light", "clean"]
// - spacious density → ["airy", "whitespace"]
// etc.
mcp__pencil__get_style_guide({ tags: [mapped_tags] })
```

### 3. Translate DNA to Pencil Properties

Reference: `references/dna-to-pencil.md`

DNA axis → Pencil property mapping is deterministic.
Example: `centered` layout → `alignItems: "center"`, symmetric padding

### 4. Execute Design Operations

Reference: `references/batch-design-patterns.md`

```javascript
mcp__pencil__batch_design({
  filePath: "<path>.pen",
  operations: `
    frame=I(document, {type: "frame", name: "Hero-Brutalist", ...properties})
    heading=I(frame, {type: "text", content: "Headline", ...typography})
    // ... additional operations
  `
})
```

### 5. Capture Result

```javascript
// Screenshot for visual verification
mcp__pencil__get_screenshot({ nodeId: "frameId" })
```

### 6. Return

```markdown
Frame ID: [id]
DNA: [layout, color, typography, motion, density, background]
```

Plus screenshot image.

## Component Templates

| Type | Structure |
|------|-----------|
| `hero` | Container + headline + subhead + CTA buttons |
| `card` | Container + image area + content + actions |
| `form` | Container + labels + inputs + submit |
| `nav` | Container + logo + links + actions |
| `footer` | Container + columns + links + legal |
| `section` | Container + heading + content grid |
| `button` | Frame + text + icon slot |
| `input` | Frame + label + field + validation |

## DNA Translation Quick Reference

| DNA Axis | Key Pencil Properties |
|----------|----------------------|
| Layout: centered | `alignItems: "center"`, equal padding |
| Layout: asymmetric | Offset positions, varied gaps |
| Layout: bento | Grid with varied spans |
| Color: dark | Dark fill, light foreground |
| Color: gradient | `fill: {type: "linear", stops: [...]}` |
| Typography: display-heavy | Large heading sizes, high contrast |
| Typography: minimal | Restrained scale, single family |
| Density: spacious | gap: 24-48, generous padding |
| Density: compact | gap: 8-16, tight padding |
| Background: solid | Single fill color |
| Background: textured | G() for patterns/images |

## Constraints

- **Single concern**: Render DNA → frame. No interview, no iteration.
- **Pencil MCP required**: Fails fast if unavailable
- **Deterministic mapping**: Same DNA always produces same structure
- **Composable**: Called by orchestrators, not users directly

## References

- `references/dna-to-pencil.md` — Complete axis mapping
- `references/batch-design-patterns.md` — Common operation sequences
- `aesthetic-system/references/dna-codes.md` — DNA axis definitions

## Integration

**Called by:**
- `design-exploration` orchestrator (when Pencil backend available)

**Composes:**
- `aesthetic-system` (for DNA interpretation)

Overview

This skill renders aesthetic DNA codes into Pencil .pen frames using the Pencil MCP backend. It accepts a DNA vector and a component type, produces a deterministic .pen frame ID, and returns a screenshot for visual verification. The skill focuses on one responsibility: translate DNA → Pencil frame, fast and reliably.

How this skill works

The skill checks for a ready Pencil document via the MCP editor state and opens or creates one if needed. It maps DNA axes (layout, color, typography, motion, density, background) to Pencil properties using a deterministic reference mapping, applies a style guide that matches DNA mood tags, runs batch design operations to create the requested component template, and captures a screenshot of the created frame. If the Pencil MCP backend is unavailable, the skill fails fast.

When to use it

  • When an orchestrator needs programmatic visual proposals from DNA codes (design-exploration).
  • To generate consistent component frames for automated design reviews or demos.
  • When producing snapshots for UI regression or visual testing pipelines.
  • To export deterministic .pen frames as inputs for downstream layout tasks.
  • When composing larger layouts by assembling pre-rendered component frames.

Best practices

  • Provide a complete DNA vector and explicit component type (hero, card, form, etc.) for deterministic output.
  • Supply optional name, dimensions, or parent frame ID when integrating into existing documents.
  • Map DNA mood to style guide tags (dark-mode, airy, clean) before rendering to align visual tone.
  • Keep calls atomic: one DNA → one frame. Let orchestrators handle composition and iteration.
  • Expect a fast failure if Pencil MCP is unreachable; handle retries at orchestrator level.

Example use cases

  • Design-exploration orchestrator requests five hero variants from different DNA vectors and receives .pen frame IDs plus screenshots.
  • Automated visual QA pipeline renders card and form components from canonical DNA for pixel comparisons.
  • Rapid prototype generator converts a set of DNA codes into a library of button and input frames for a design system proof-of-concept.
  • Batch rendering job creates screenshots of nav and footer templates for stakeholder review slides.
  • Integration step that injects generated frame IDs into a higher-level layout builder to assemble pages.

FAQ

What inputs are required?

A DNA code array and a component type are required. Optional name, dimensions, and parent frame ID can be provided.

Is output deterministic?

Yes. The DNA → Pencil mapping is deterministic: identical DNA and parameters yield the same frame structure and ID.

What happens if Pencil MCP is unavailable?

The skill fails fast and returns an error. Retry and recovery should be implemented by the calling orchestrator.