# pencilkit

Guides Apple Pencil drawing setup via PencilKit in Swift, configuring tool pickers and serializing strokes. Helpful when building signature pads or drawing screens on iOS.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode · 3100 installs · ★ 1237
- Author: dpearson2699
- License: LicenseRef-Unknown · policy=link-only · description only; the file stays with the author
- Source: https://github.com/dpearson2699/swift-ios-skills/tree/HEAD/skills/pencilkit/SKILL.md
- Updated: 2026-07-31
- HTML: https://affpapa.org/en/nevibecode/skills/pencilkit

## What it does

The skill guides an AI assistant through implementing PencilKit canvas views and stroke handling in Swift. It details how to set up `PKCanvasView` with suitable input policies and show the standard floating `PKToolPicker`. Drawing data gets converted to raw bytes via `PKDrawing` for atomic file storage and safe synchronization.

The framework functions without entitlements or Info.plist settings, though tailoring tool items relies on iOS 18+ alongside visionOS 2+. Version checks matter here. Targeting earlier operating systems with custom tool palettes will trigger build errors.

The workflow also covers rendering drawings to images using `image(from:scale:)`. It requires checking bounds before generating the output image.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add dpearson2699/swift-ios-skills --skill pencilkit -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/pencilkit/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/pencilkit/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add dpearson2699/swift-ios-skills --skill pencilkit -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/pencilkit/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add dpearson2699/swift-ios-skills --skill pencilkit -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/pencilkit/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install dpearson2699/swift-ios-skills pencilkit
```

2. **Manually: put the files in place**
- File: `.github/skills/pencilkit/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add dpearson2699/swift-ios-skills --skill pencilkit -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/dpearson2699/swift-ios-skills --path skills/pencilkit
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/pencilkit/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add dpearson2699/swift-ios-skills --skill pencilkit -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/dpearson2699/swift-ios-skills/tree/HEAD/skills/pencilkit/SKILL.md

## When to use it
- configure `PKCanvasView` with touch and stylus input policies
- attach `PKToolPicker` to switch pens, highlighters, and erasers
- serialize `PKDrawing` strokes into binary data for disk storage
- render canvas drawings to raster images with custom scaling

## Example prompts
- Configure PKCanvasView for a signature field accepting both finger and pencil
- Add PKDrawing atomic file serialization and safe decoding
- Display PKToolPicker alongside the active canvas in my view controller

## Similar
- [apple-hig](https://affpapa.org/en/nevibecode/skills/apple-hig.md) — skill · 3200 installs
- [hig-platforms](https://affpapa.org/en/nevibecode/skills/hig-platforms.md) — skill · 666 installs
- [hig-inputs](https://affpapa.org/en/nevibecode/skills/hig-inputs.md) — skill · 633 installs
- [clerk-swift](https://affpapa.org/en/nevibecode/skills/clerk-swift.md) — skill · 14500 installs
- [swiftui-patterns](https://affpapa.org/en/nevibecode/skills/affaan-m-swiftui-patterns.md) — skill · 4600 installs
- [mapbox-ios-patterns](https://affpapa.org/en/nevibecode/skills/mapbox-ios-patterns.md) — skill · 1500 installs

From the same set: [dpearson2699/swift-ios-skills](https://affpapa.org/en/nevibecode/by/dpearson2699/swift-ios-skills.md) — 86 cards

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
