mcpField
P
Pencil Basics

Pencil Basics

github.com/gyejoonDesign & UI245 installsUpdated 39w ago
Repository

About Pencil Basics

Pencil Basics is a skill for using Pencil MCP tools to inspect, edit, and create designs in .pen files. It guides design workflows and visual verification without accessing the encrypted files directly.

Key features

  1. 01Read and search design nodes
  2. 02Insert, update, copy, move, and delete nodes
  3. 03Apply AI-generated or stock images
  4. 04Inspect layouts and verify screenshots

Use cases

  1. 01Create a new screen using existing components
  2. 02Edit a component and check the result
  3. 03Diagnose overflow or clipping in a layout

MCP support

The skill uses Pencil MCP tools to access and modify .pen files. It describes editor-state, node-query, design-operation, and screenshot tools.

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/gyejoon/pencil-plugin --skill pencil-basics

After installing, type/pencil-basicsin Claude Code to confirm it loaded.

Bundled filesreferences/layout-examples.mdreferences/node-properties.md

Details

From the project README

Pencil Basics

Pencil MCP 서버를 사용하여 .pen 파일을 읽고, 수정하고, 디자인을 생성하는 방법을 제공한다.

Core Concepts

.pen 파일 구조

.pen 파일은 디자인 데이터를 저장하는 암호화된 형식이다. 반드시 Pencil MCP 도구만 사용하여 접근한다.

중요: Read, Grep, Write 도구로 .pen 파일을 직접 읽거나 쓰지 않는다. 항상 Pencil MCP 도구를 사용한다.

노드 타입
Type용도주요 속성
frame컨테이너, 레이아웃layout, gap, padding, fill
text텍스트 콘텐츠content, fontSize, fontWeight, textColor
rectangle사각형 도형fill, stroke, cornerRadius
ellipse원/타원fill, stroke
ref컴포넌트 인스턴스ref (컴포넌트 ID 참조)
image이미지 프레임G() 오퍼레이션으로 적용
icon_font아이콘icon, iconSize
레이아웃 시스템

Auto Layout 속성:

layout: "horizontal" | "vertical" | "grid"
gap: number (자식 간 간격)
padding: number | [top, right, bottom, left]
alignItems: "start" | "center" | "end" | "stretch"
justifyContent: "start" | "center" | "end" | "space-between"

크기 지정:

width: number | "fill_container" | "hug_contents"
height: number | "fill_container" | "hug_contents"

Essential Tools

1. get_editor_state

현재 에디터 상태와 선택된 노드 정보를 가져온다.

mcp__pencil__get_editor_state(include_schema: boolean)

디자인 작업 시작 전 항상 호출하여 활성 파일과 선택 상태를 확인한다.

2. batch_get

노드를 검색하거나 ID로 읽는다.

mcp__pencil__batch_get(
  filePath: string,
  patterns?: [{ reusable?: boolean, type?: string, name?: string }],
  nodeIds?: string[],
  readDepth?: number,
  searchDepth?: number
)

사용 예시:

  • 재사용 컴포넌트 목록: patterns: [{ reusable: true }]
  • 특정 노드 읽기: nodeIds: ["nodeId1", "nodeId2"]
  • 텍스트 노드 검색: patterns: [{ type: "text" }]
3. batch_design

디자인 수정 오퍼레이션을 실행한다.

mcp__pencil__batch_design(
  filePath: string,
  operations: string  // JavaScript 유사 구문
)
4. get_screenshot

노드의 스크린샷을 가져와 시각적으로 검증한다.

mcp__pencil__get_screenshot(filePath: string, nodeId: string)

디자인 작업 후 항상 스크린샷으로 결과를 확인한다.

batch_design Operations

Insert (I)

새 노드를 삽입한다.

// 기본 삽입
frame1=I("parentId", { type: "frame", layout: "vertical", gap: 16 })
text1=I(frame1, { type: "text", content: "Hello", fontSize: 16 })

// 컴포넌트 인스턴스 삽입
button=I("parentId", { type: "ref", ref: "ButtonComponentId" })
Update (U)

기존 노드의 속성을 업데이트한다.

// 직접 업데이트
U("nodeId", { fill: "#FF0000", padding: 16 })

// 컴포넌트 인스턴스 내부 노드 업데이트
U("instanceId/labelId", { content: "New Label" })
Copy (C)

노드를 복사한다.

// 단순 복사
copy1=C("sourceId", "parentId", { x: 100, y: 100 })

// 속성 오버라이드와 함께 복사
copy2=C("sourceId", "parentId", {
  descendants: {
    "labelId": { content: "Copied Label" }
  }
})
Replace (R)

노드를 새 노드로 교체한다.

newNode=R("oldNodeId", { type: "text", content: "Replaced" })
Delete (D)

노드를 삭제한다.

D("nodeId")
Move (M)

노드를 다른 위치로 이동한다.

M("nodeId", "newParentId", 0)  // index는 선택사항
Generate Image (G)

프레임에 이미지를 적용한다.

// AI 생성 이미지
imgFrame=I("parentId", { type: "frame", width: 400, height: 300 })
G(imgFrame, "ai", "modern office workspace")

// 스톡 이미지
G("existingFrameId", "stock", "nature landscape")

Workflow Patterns

새 화면 생성
  1. get_editor_state로 현재 상태 확인
  2. batch_get으로 사용 가능한 컴포넌트 확인
  3. get_guidelines로 디자인 가이드라인 로드
  4. get_style_guide_tags + get_style_guide로 스타일 영감 얻기
  5. batch_design으로 화면 구성
  6. get_screenshot으로 결과 검증
컴포넌트 수정
  1. batch_get으로 대상 노드 구조 파악
  2. batch_design의 U() 오퍼레이션으로 속성 수정
  3. get_screenshot으로 변경사항 확인
레이아웃 문제 해결
  1. snapshot_layout으로 레이아웃 구조 분석
  2. 오버플로우, 클리핑 문제 확인
  3. batch_design으로 수정
  4. get_screenshot으로 검증

Best Practices

Do
  • 매 batch_design 후 get_screenshot으로 검증
  • 작은 단위로 오퍼레이션 실행 (최대 25개)
  • 바인딩 이름은 매번 새로 생성
  • 컴포넌트 수정 시 인스턴스 경로 사용 (instanceId/childId)
Don't
  • Read, Write, Grep으로 .pen 파일 직접 접근
  • 한 번에 너무 많은 오퍼레이션 실행
  • 바인딩 이름 재사용
  • id 속성 직접 지정 (자동 생성됨)

Additional Resources

Reference Files
  • references/node-properties.md - 모든 노드 타입의 상세 속성
  • references/layout-examples.md - 레이아웃 패턴 예시

Comments

Markdown supported