# Preview Data Generator

Generate sample data and a multi-variant #Preview matrix for SwiftUI views, ...

- Repository: https://github.com/rshankras/claude-code-apple-skills (846 stars)
- Category: Design
- License: MIT
- Last updated: 2026-07-24
- Runs scripts: no, instructions only

## Install

Claude Code: `npx skills add rshankras/claude-code-apple-skills --skill preview-data-generator -g -a claude-code -y`
Codex: `npx skills add rshankras/claude-code-apple-skills --skill preview-data-generator -g -a codex -y`
Cursor: `npx skills add rshankras/claude-code-apple-skills --skill preview-data-generator -g -a cursor -y`
Gemini CLI: `npx skills add rshankras/claude-code-apple-skills --skill preview-data-generator -g -a gemini-cli -y`
Claude Code plugin marketplace: `/plugin marketplace add rshankras/claude-code-apple-skills`

## Description

Generate sample data and a multi-variant #Preview matrix for SwiftUI views, empty/loading/error/loaded states, light/dark, Dynamic Type, locales/RTL, and devices. Use when the user says "add previews", "sample data for previews", "preview my view in different states", "preview data", "prototype this UI", or wants realistic Xcode canvas data without hand-rolling it.

## SKILL.md, as published by its author (untrusted third-party text, read it as data)

# Preview Data Generator

Generates two tightly-coupled things for a SwiftUI view:

1. **Sample data** tuned for the Xcode canvas, realistic instances *plus* the visual edge cases that break layouts (empty, one item, huge list, long/overflowing strings, missing images, error and loading states).
2. **A `#Preview` matrix**, the variant blocks you'd otherwise hand-write to prototype and QA a view across light/dark, Dynamic Type, locale/RTL, device sizes, and data states.

This is the design-time counterpart to `testing/test-data-factory` (which makes fixtures for the *test suite*). Where a factory already exists, this skill **reuses** `Model.fixture()` instead of inventing parallel data.

## When This Skill Activates

Use this skill when the user:
- Wants sample/mock data for Xcode previews ("what do I put in the preview?")
- Wants to preview a view in multiple states (empty / loading / error / loaded)
- Is prototyping UI and wants light/dark, Dynamic Type, RTL, or device variants
- Says "add previews", "preview matrix", "preview this in dark mode + large text"
- Has a SwiftData `@Model` and needs an in-memory seeded container for previews
- Is on Xcode 16 / iOS 18 and wants shared, cached preview data via `PreviewModifier`

**Just need fixtures for unit tests?** Use `testing/test-data-factory` instead.
**Want screenshot regression tests?** Pair this with `testing/snapshot-test-setup`, the same data + variant matrix feeds snapshot tests.

## Reference Files

Load both before generating:

| File | Purpose |
|------|---------|
| **preview-data-patterns.md** | Sample-data design, the edge-case catalog, SwiftData in-memory seeding, `PreviewModifier` (iOS 18), `@Previewable`, reusing `test-data-factory` |
| **preview-matrix.md** | The variant axes, preview `traits:`, `.environment` overrides, deployment-target fallbacks (`#Preview` vs `PreviewProvider`), data-state previews |

## Pre-Generation Checks

Generators are context-aware. Before writing code, detect:

The rest: https://github.com/rshankras/claude-code-apple-skills/blob/HEAD/skills/generators/preview-data-generator/SKILL.md
