Quick Start ·
Installation ·
Usage ·
AI agents ·
Configuration ·
Docs ·
Website
🔥 What is Prefire?
Your previews are already tests. Prefire turns the #Preview blocks you write anyway into snapshot tests, a Playbook catalog and images your AI agent can see. You don't write a line of test code.
📸 Snapshot tests
Every preview becomes a snapshot test on the devices you pick. A changed padding fails the build, not the release.
How it works →
|
📚 Playbook
A catalog of every component and user story inside your app, with their states and render times.
See Playbook →
|
🤖 Renders for AI agents
Claude Code, Cursor and Codex render your previews through an MCP server and see the UI they just changed.
Set up →
|
🤖 Using an AI agent? brew install barredewe/prefire/prefire, then claude mcp add prefire -- prefire mcp in your project. The agent renders SwiftUI previews on any iPhone or iPad, light or dark, without Xcode Previews. Setup →
🚀 Key Features
- 🧠 Smart Preview Parsing — including
#Preview, @Previewable
- 📸 Snapshot Testing — automatic test generation from previews (iOS, tvOS, macOS)
- 📚 Playbook View — auto-generated interactive component catalog (iOS)
- 🏃 Flow-aware — build user stories from multiple preview steps
- 🤖 AI-ready — render previews to PNG for agents with
prefire render and an MCP server
- 🧩 UIKit + AppKit Support — support for
UIView/UIViewController and NSView/NSViewController
- ⚙️ SPM + Xcode Plugins — works in CLI, Xcode build phases, or CI
- 🧠 Fast Caching — fingerprint-based AST and body caching avoids redundant work
- ✍️ Stencil Templates — customize output with your own templates
Why Prefire?
- 🔥 No second set of UI states. Tests come from the previews you already keep up to date.
- 🔥 Regressions fail CI. Snapshots are compared on every run, on every device you list.
- 🔥 Designers and QA see every state. Playbook shows components and user stories on a device.
- 🔥 Agents check their own UI work. They render the previews they changed before calling a task done.
⚡ Quick Start
📦 Example project available at: Prefire Example
1. Add Prefire to Your Project
// Package.swift
dependencies: [
.package(url: "https://github.com/BarredEwe/Prefire.git", from: "6.3.0"),
.package(url: "https://github.com/pointfreeco/swift-snapshot-testing", from: "1.18.0"),
],
.testTarget(
dependencies: [
.product(name: "Prefire", package: "Prefire"),
.product(name: "SnapshotTesting", package: "swift-snapshot-testing"),
],
plugins: [
.plugin(name: "PrefireTestsPlugin", package: "Prefire")
]
)
2. Write #Preview
#Preview {
Button("Submit")
}
3. Run tests
Just run the test target 🚀 — Prefire will auto-generate snapshots based on your previews.