PR

preview-data-generator

Automatically generates mock data and multi-variant SwiftUI #Preview matrices to test UI states like dark mode, RTL, and dynamic type.

Install

mkdir -p .claude/skills/preview-data-generator && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/19457" && unzip -o skill.zip -d .claude/skills/preview-data-generator && rm skill.zip

Installs to .claude/skills/preview-data-generator

Activation

This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.

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.
368 chars✓ has a “when” triggerlonger than Claude Code's old 250-char listing cap (fine on current versions)
Intermediate

Key capabilities

  • Generate realistic sample data for Xcode canvas
  • Create multi-variant preview matrices for SwiftUI views
  • Implement edge case data for empty, loading, and error states
  • Support accessibility testing for Dynamic Type and locale variants
  • Seed in-memory containers for SwiftData models

How it works

The skill generates a preview namespace for models including realistic and edge-case instances, then constructs a matrix of #Preview blocks to visualize the view across various states and environments.

Inputs & outputs

You give it
SwiftUI view file and associated model types
You get back
Preview support files and matrix of #Preview blocks

When to use preview-data-generator

  • Creating UI mock data
  • Previewing dark mode and RTL layouts
  • Testing accessibility with Dynamic Type
  • Prototyping view states

About this skill

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:

FilePurpose
preview-data-patterns.mdSample-data design, the edge-case catalog, SwiftData in-memory seeding, PreviewModifier (iOS 18), @Previewable, reusing test-data-factory
preview-matrix.mdThe 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:

CheckHowWhy it matters
Deployment targetRead project/.xcodeproj or Package.swiftiOS 17+ → #Preview macro; iOS 18+ → PreviewModifier + @Previewable; below 17 → PreviewProvider fallback
Target view + its modelsRead the view file; Grep its init/properties for model typesDetermines which types need sample data
Existing fixturesGrep "static func fixture|extension .*{ static (let|var) preview"Reuse Model.fixture() / existing .preview — never duplicate
SwiftDataGrep "@Model" on the model typesUse the in-memory .modelContainer(inMemory:) seed pattern, not plain structs
View shapeDoes it take a model, a ViewModel, or fetch its own data?Drives whether to inject data, a mock VM, or a seeded container
PlatformiOS / macOS / multiplatformDevice variants and some traits differ

Ask via AskUserQuestion only what you can't infer — e.g. "Which states matter for this view: empty, loading, error, loaded, or all four?"

Generation Process

Step 1: Build the Sample Data

For each model the view needs, generate a Model.preview namespace with the realistic case and the edge cases (see preview-data-patterns.md for the full catalog):

extension Article {
    /// A typical, realistic instance for the canvas.
    static var preview: Article {
        Article(id: UUID(), title: "Designing for the Smallest Screen",
                author: "Mei Chen", body: String(repeating: "Lorem ipsum. ", count: 40),
                imageURL: URL(string: "https://picsum.photos/seed/1/600/400"),
                readMinutes: 6, isBookmarked: false)
    }

    /// Edge cases that expose layout bugs.
    static var previewLongTitle: Article { .preview.with(title: "An Extraordinarily, Almost Unreasonably Long Headline That Wraps") }
    static var previewNoImage: Article   { .preview.with(imageURL: nil) }
    static var previewList: [Article]    { (1...12).map { .preview.with(id: UUID(), title: "Article \($0)") } }
    static var previewEmpty: [Article]   { [] }
}

If Article.fixture() already exists (from test-data-factory), build .preview on top of it rather than re-specifying every field.

Step 2: Build the Preview Matrix

Generate the #Preview blocks for the axes that matter (see preview-matrix.md). Always include data states — that's the UI-prototyping payoff:

#Preview("Loaded")  { ArticleListView(state: .loaded(Article.previewList)) }
#Preview("Empty")   { ArticleListView(state: .empty) }
#Preview("Loading") { ArticleListView(state: .loading) }
#Preview("Error")   { ArticleListView(state: .error("No connection")) }

#Preview("Dark")        { ArticleListView(state: .loaded(Article.previewList)).preferredColorScheme(.dark) }
#Preview("XXL Text")    { ArticleListView(state: .loaded(Article.previewList)).dynamicTypeSize(.accessibility3) }
#Preview("German / RTL", traits: .sizeThatFitsLayout) {
    ArticleDetailView(article: .previewLongTitle).environment(\.locale, .init(identifier: "de"))
}

Scale the matrix to the request — don't emit 20 previews for a label. A reasonable default per view: the relevant data states + dark mode + one large Dynamic Type + (if the view has text that localizes) one long-language/RTL check.

Step 3: Wire Up Infrastructure (when needed)

  • SwiftData view → generate an in-memory previewContainer seeded with sample models, attached via .modelContainer(previewContainer).
  • Xcode 16 / iOS 18 → offer a PreviewModifier so the seeded container/data is built once and cached across every preview, applied with #Preview(traits: .modifier(SampleData())).
  • View needs @State/@Bindable → use @Previewable so state lives directly in the #Preview body.

Step 4: Place the Code

  • Sample data → Article+Preview.swift (one file per model, in the model's group).
  • Preview blocks → either appended to the view file (Apple's convention) or a sibling ArticleListView+Previews.swift for large matrices. Ask if unsure.
  • Wrap preview-only data in #if DEBUG so it never ships in release builds.

Output Format

After generating, always provide:

  • Files created — full paths (Article+Preview.swift, PreviewSupport.swift, etc.)
  • Integration steps — where the #Preview blocks went, how to open the canvas
  • Deployment-target notes — which API was used and why (#Preview / PreviewModifier / PreviewProvider)
  • Testing instructions — open the canvas, cycle the variants; if pairing with snapshots, how the data feeds snapshot-test-setup

Example Output Summary

✅ Generated previews for ArticleListView (iOS 18 target)

Files created:
  • Article+Preview.swift        — .preview, .previewLongTitle, .previewNoImage, .previewList, .previewEmpty
  • PreviewSupport.swift         — SampleData: PreviewModifier (cached in-memory container)
  • ArticleListView+Previews.swift — 7 #Preview blocks (4 states, dark, XXL text, German)

Integration:
  • Reused Article.fixture() from test-data-factory for base fields
  • Open ArticleListView+Previews.swift → canvas shows all 7 variants

API used: #Preview + PreviewModifier (.modifier) — shared container built once, cached.

When NOT to Use This Skill

  • Fixtures for the test suitetesting/test-data-factory
  • Snapshot/regression image teststesting/snapshot-test-setup (feed it this data)
  • A trivial view with no data → Xcode's autogenerated #Preview {} is enough
  • Locale-only preview helpersgenerators/localization-setup already covers locale preview helpers; reuse them

Cross-Skill Integration

generators/persistence-setup   → defines @Model types
        ↓
testing/test-data-factory      → Model.fixture() for tests
        ↓
generators/preview-data-generator (THIS SKILL)
   • reuses .fixture() for canvas data
   • builds the #Preview state/appearance matrix
        ↓
testing/snapshot-test-setup    → renders the same matrix for regression

Deliverables

  • Sample data per model: realistic instance + edge cases (empty, long, missing, list)
  • Existing .fixture()/.preview reused, not duplicated
  • #Preview matrix covering the view's data states + relevant appearance axes
  • Correct API for the deployment target (#Preview / PreviewModifier / PreviewProvider)
  • SwiftData views get a seeded in-memory container
  • Preview-only code guarded with #if DEBUG
  • Output summary with files, integration, and testing steps

Generate the data and the variants together. A preview is only as useful as the data in it — and a view is only proven when you've seen it empty, overflowing, in the dark, and at AX5.

When not to use it

  • When creating fixtures for unit test suites
  • When setting up snapshot regression tests
  • When the view is trivial and requires no data

Prerequisites

Xcode 16 or later for modern preview macrosSwiftData @Model definitions for seeded containers

Limitations

  • Requires manual detection of deployment targets for API selection
  • Limited to UI prototyping and design-time visualization

How it compares

It automates the creation of a complete preview matrix for UI edge cases rather than requiring the developer to hand-write individual preview variants.

Compared to similar skills

preview-data-generator side by side with the closest alternatives in the catalog.

SkillInstallsUpdatedSafetyDifficulty
preview-data-generator (this skill)011dNo flagsIntermediate
liquid-glass-developer233moNo flagsIntermediate
swiftui-liquid-glass154moNo flagsIntermediate
swiftui-ui-patterns14moNo flagsIntermediate

Try saying

Example prompts that trigger this skill in your AI assistant.

You might also like

liquid-glass-developer

anyproto

Context-aware routing to iOS 26 Liquid Glass implementation patterns. Use when working with glass effects, GlassEffectContainer, morphing transitions, or iOS 26 visual effects.

2367

swiftui-liquid-glass

Dimillian

Implement, review, or improve SwiftUI features using the iOS 26+ Liquid Glass API. Use when asked to adopt Liquid Glass in new SwiftUI UI, refactor an existing feature to Liquid Glass, or review Liquid Glass usage for correctness, performance, and design alignment.

1567

swiftui-ui-patterns

Dimillian

Best practices and example-driven guidance for building SwiftUI views and components. Use when creating or refactoring SwiftUI UI, designing tab architecture with TabView, composing screens, or needing component-specific patterns and examples.

13

design-system-developer

anyproto

Context-aware routing to the Anytype iOS design system including icons, typography, colors, and spacing. Use when working with Figma-to-code translation, design assets, or UI components.

111

verify-bulk-action-bar

junnv93

BulkActionBar 패턴 SSOT 검증 — count chip aria-live, role=toolbar, Esc clear, indeterminate Radix, focus management, IME guard. 일괄 작업 UI 변경 시 트리거. canonical = components/common/BulkActionBar.tsx (도메인 무관 generic), components/approvals/BulkActionBar.tsx는 approvals 특화 wrapper.

00

campusway-frontend-quality

md-muntasir-shihab

CampusWay frontend quality workflow for Vite React and Tailwind with optional Next.js surface. Use when: improve UI, refactor components, fix layout, optimize bundle, enforce design consistency, prepare frontend PR.

00

Search skills

Search the agent skills registry