Skip to content
Back to search

prefire

MarketplaceWorks with Claude CodeGitHub

Prefire for Claude Code: render SwiftUI previews to images an agent can see.

Safety scan

A static text scan, not a guarantee. Select the badge to see what was scanned and every finding.

Checked today

Check it deeper on your machine

It has changed since its scan on 11 Nov 2026.

As a Claude Code plugin, install it and then ask Claude Code:

/plugin marketplace add keithmackay/mackayi/plugin install scanskillsafety@mackayiDo a deep scan of https://github.com/BarredEwe/Prefire with scanskillsafety

Or from a terminal, clone it and run it:

git clone https://github.com/keithmackay/scanskillsafety-skill ~/.claude/skills/scanskillsafetynode ~/.claude/skills/scanskillsafety/cli.cjs --deep 'https://github.com/BarredEwe/Prefire'

It checks the exact commit: every file, its packages against OSV (api.osv.dev), how it compares with this page's scan (findsafeskills.com receives the repository's address), and, if you agree, Claude reading every file with your own Claude subscription. It never runs the code.

Badge for your README
findsafeskills safety rating

Markdown

[![findsafeskills safety rating](/api/listings/barredewe--prefire/badge.svg)](/listings/barredewe--prefire)

HTML

<a href="/listings/barredewe--prefire"><img src="/api/listings/barredewe--prefire/badge.svg" alt="findsafeskills safety rating" /></a>

Install

Install instructions from the README

As written by the repo's author. findsafeskills has not verified these steps.

> πŸ“¦ Example project available at: [Prefire Example](https://github.com/BarredEwe/Prefire/tree/main/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.

> πŸ’‘ If your test target is empty, Prefire will still generate files and snapshot code during build.

---

What was scanned

The files the safety scan read, as written by the repository's author and shown as plain text. Lines with a finding are marked.

.claude-plugin/marketplace.json Β· Manifest Β· 24 lines

View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)

  1. {
  2. "name": "prefire",
  3. "owner": {
  4. "name": "BarredEwe",
  5. "url": "https://github.com/BarredEwe"
  6. },
  7. "description": "Prefire for Claude Code: render SwiftUI previews to images an agent can see.",
  8. "plugins": [
  9. {
  10. "name": "prefire",
  11. "source": "./claude-code-plugin",
  12. "description": "Lets Claude see SwiftUI: renders #Preview blocks to PNG on any iPhone or iPad, light or dark, through the Prefire MCP server, without Xcode Previews.",
  13. "category": "development",
  14. "tags": [
  15. "swiftui",
  16. "ios",
  17. "xcode",
  18. "previews",
  19. "snapshot-testing",
  20. "mcp"
  21. ]
  22. }
  23. ]
  24. }
README.md Β· README Β· 380 lines

View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)

  1. <p align="center">
  2. <a href="https://prefire.ru"><img alt="Prefire: your previews are already tests. Snapshot tests, a Playbook and renders your AI agent can see, all from #Preview" src="Documentation/Images/hero.webp" width="100%"></a>
  3. </p>
  4. <p align="center">
  5. <a href="https://github.com/BarredEwe/Prefire/releases/latest"><img alt="Release" src="https://img.shields.io/github/release/BarredEwe/Prefire.svg"/></a>
  6. <a href="https://github.com/BarredEwe/Prefire/stargazers"><img alt="Stars" src="https://img.shields.io/github/stars/BarredEwe/Prefire?style=flat&logo=github&color=ff6a35"/></a>
  7. <a href="https://developer.apple.com/"><img alt="Platform" src="https://img.shields.io/badge/platform-iOS%20%7C%20macOS%20%7C%20tvOS-green.svg"/></a>
  8. <a href="https://developer.apple.com/swift"><img alt="Swift6" src="https://img.shields.io/badge/language-Swift_6-green.svg"/></a>
  9. <a href="https://swift.org/package-manager"><img alt="Swift Package Manager" src="https://img.shields.io/badge/SwiftPM-compatible-yellowgreen.svg"/></a>
  10. <img alt="Xcode Plugins" src="https://img.shields.io/badge/Xcode%20Plugins-Supported-brightgreen.svg"/>
  11. </p>
  12. <p align="center">
  13. <a href="#-quick-start"><b>Quick Start</b></a> Β·
  14. <a href="#-installation"><b>Installation</b></a> Β·
  15. <a href="#-usage"><b>Usage</b></a> Β·
  16. <a href="#-let-ai-agents-see-swiftui"><b>AI agents</b></a> Β·
  17. <a href="#-configuration-prefireyml"><b>Configuration</b></a> Β·
  18. <a href="Documentation"><b>Docs</b></a> Β·
  19. <a href="https://prefire.ru"><b>Website</b></a>
  20. </p>
  21. ## πŸ”₯ What is Prefire?
  22. 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.
  23. <table>
  24. <tr>
  25. <td width="33%" valign="top">
  26. <h3>πŸ“Έ Snapshot tests</h3>
  27. Every preview becomes a snapshot test on the devices you pick. A changed padding fails the build, not the release.
  28. <br><br><a href="#snapshot-tests">How it works β†’</a>
  29. </td>
  30. <td width="33%" valign="top">
  31. <h3>πŸ“š Playbook</h3>
  32. A catalog of every component and user story inside your app, with their states and render times.
  33. <br><br><a href="#playbook-demo-view">See Playbook β†’</a>
  34. </td>
  35. <td width="33%" valign="top">
  36. <h3>πŸ€– Renders for AI agents</h3>
  37. Claude Code, Cursor and Codex render your previews through an MCP server and see the UI they just changed.
  38. <br><br><a href="#-let-ai-agents-see-swiftui">Set up β†’</a>
  39. </td>
  40. </tr>
  41. </table>
  42. > πŸ€– **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 β†’](Documentation/AI.md)
  43. ## πŸš€ Key Features
  44. <img src="Documentation/Images/playbook.webp" alt="Playbook: user stories built from previews" width="230" align="right">
  45. - 🧠 **Smart Preview Parsing** β€” including `#Preview`, `@Previewable`
  46. - πŸ“Έ **Snapshot Testing** β€” automatic test generation from previews (iOS, tvOS, macOS)
  47. - πŸ“š **Playbook View** β€” auto-generated interactive component catalog (iOS)
  48. - πŸƒ **Flow-aware** β€” build user stories from multiple preview steps
  49. - πŸ€– **AI-ready** β€” render previews to PNG for agents with `prefire render` and an [MCP server](Documentation/AI.md)
  50. - 🧩 **UIKit + AppKit Support** β€” support for `UIView`/`UIViewController` and `NSView`/`NSViewController`
  51. - βš™οΈ **SPM + Xcode Plugins** β€” works in CLI, Xcode build phases, or CI
  52. - 🧠 **Fast Caching** β€” fingerprint-based AST and body caching avoids redundant work
  53. - ✍️ **Stencil Templates** β€” customize output with [your own templates](Documentation/Templates.md)
  54. ### Why Prefire?
  55. - πŸ”₯ **No second set of UI states.** Tests come from the previews you already keep up to date.
  56. - πŸ”₯ **Regressions fail CI.** Snapshots are compared on every run, on every device you list.
  57. - πŸ”₯ **Designers and QA see every state.** Playbook shows components and user stories on a device.
  58. - πŸ”₯ **Agents check their own UI work.** They render the previews they changed before calling a task done.
  59. <br clear="all">
  60. ---
  61. ## ⚑ Quick Start
  62. > πŸ“¦ Example project available at: [Prefire Example](https://github.com/BarredEwe/Prefire/tree/main/Example)
  63. ### 1. Add Prefire to Your Project
  64. ```swift
  65. // Package.swift
  66. dependencies: [
  67. .package(url: "https://github.com/BarredEwe/Prefire.git", from: "6.3.0"),
  68. .package(url: "https://github.com/pointfreeco/swift-snapshot-testing", from: "1.18.0"),
  69. ],
  70. .testTarget(
  71. dependencies: [
  72. .product(name: "Prefire", package: "Prefire"),
  73. .product(name: "SnapshotTesting", package: "swift-snapshot-testing"),
  74. ],
  75. plugins: [
  76. .plugin(name: "PrefireTestsPlugin", package: "Prefire")
  77. ]
  78. )
  79. ```
  80. ### 2. Write `#Preview`
  81. ```swift
  82. #Preview {
  83. Button("Submit")
  84. }
  85. ```
  86. ### 3. Run tests
  87. Just run the test target πŸš€ β€” Prefire will auto-generate snapshots based on your previews.
  88. > πŸ’‘ If your test target is empty, Prefire will still generate files and snapshot code during build.
  89. <img src="https://i.postimg.cc/XNPVPL1G/Untitled-2.gif" width="300">
  90. ---
  91. ## πŸ“¦ Installation
  92. | Method | How |
  93. |--------|-----|
  94. | SPM Plugin | `PrefireTestsPlugin` / `PrefirePlaybookPlugin` in `Package.swift` |
  95. | Xcode Build Tool Plugin | Add `PrefireTestsPlugin` to the test target's build phases |
  96. | CLI | `brew install barredewe/prefire/prefire` |
  97. | Mint (*Beta*) | `mint install BarredEwe/Prefire` |
  98. | GitHub Actions / CI | Any of the above, see [Troubleshooting](#-troubleshooting) |
  99. Step-by-step setup is in the [Installation guide](Documentation/Installation.md).
  100. ### Requirements
  101. - Swift 6.0 or higher
  102. - Xcode 16.0 or higher
  103. - iOS 14 or higher; macOS 13 or higher (macOS: snapshot tests only, see [Configuration](Documentation/Configuration.md#macos-snapshot-tests))
  104. ---
  105. ## πŸ›  Usage
  106. ### Choose previews
  107. Prefire finds every **`#Preview`** automatically. For `PreviewProvider`, add the `PrefireProvider` protocol:
  108. ```swift
  109. struct Text_Previews: PreviewProvider, PrefireProvider {
  110. static var previews: some View { ... }
  111. }
  112. ```
  113. Exclude a preview with `.prefireIgnored()`:
  114. ```swift
  115. #Preview {
  116. Text("")
  117. .prefireIgnored()
  118. }
  119. ```
  120. To opt in instead of opting out, set `preview_default_enabled: false` in [`.prefire.yml`](#-configuration-prefireyml) and mark the previews you want with `.prefireEnabled()`:
  121. ```swift
  122. #Preview {
  123. Text("")
  124. .prefireEnabled()
  125. }
  126. ```
  127. ### Snapshot tests
  128. `PrefireTestsPlugin` generates the tests into the DerivedData folder when the test target builds. Run the test target as usual.
  129. Tune the timing and precision of a single snapshot:
  130. ```swift
  131. #Preview {
  132. TestView()
  133. .snapshot(delay: 0.3, precision: 0.95, perceptualPrecision: 0.98)
  134. }
  135. ```
  136. For previews that load or animate, wait instead of guessing a delay:
  137. ```swift
  138. .snapshot(waitForIdle: true) // until nothing changes on screen
  139. .snapshot(waitUntil: { viewModel.isLoaded }) // until a condition is true
  140. ```
  141. How waiting works, its limits and how the modifiers combine: [Snapshot timing and precision](Documentation/Snapshots.md).
  142. Snapshots are compared with [swift-snapshot-testing](https://github.com/pointfreeco/swift-snapshot-testing).
  143. ### Playbook (Demo) View
  144. Show all previews as an interactive catalog with `PlaybookView`:
  145. - `isComponent: true` lists all the Views
  146. - `isComponent: false` groups them by UserStory
  147. ```swift
  148. import Prefire
  149. struct ContentView: View {
  150. var body: some View {
  151. PlaybookView(isComponent: true, previewModels: PreviewModels.models)
  152. }
  153. }
  154. ```
  155. To keep previews and `PreviewModels` out of release builds, see [Excluding previews from release builds](Documentation/Installation.md#excluding-previews-from-release-builds).
  156. ### Flows
  157. <img src="Documentation/Images/flow.webp" alt="The auth user story in Playbook: PrefireView, then AuthView" width="350" align="right">
  158. Connect previews into one **Flow** with `.previewUserStory`. Playbook shows them together, in order:
  159. ```swift
  160. static var previews: some View {
  161. PrefireView()
  162. .previewUserStory(.auth)
  163. }
  164. static var previews: some View {
  165. AuthView()
  166. .previewUserStory(.auth)
  167. }
  168. ```
  169. <br clear="all">
  170. ### States
  171. <img src="Documentation/Images/states.webp" alt="TestView in the Default and Loading states" width="350" align="right">
  172. If a preview contains more than one `View`, mark the `State` of each:
  173. ```swift
  174. static var previews: some View {
  175. TestView("Default")
  176. TestView("Loading")
  177. .previewState(.loading)
  178. }
  179. ```
  180. <br clear="all">
  181. ### Parameterized previews
  182. Prefire expands each argument of a native SwiftUI parameterized preview into its own snapshot and Playbook preview:
  183. ```swift
  184. #Preview("TextView", traits: .sizeThatFitsLayout, arguments: ["- A", "- B", "- C"]) { suffix in
  185. Text("1 \(suffix)")
  186. }
  187. ```
  188. ---
  189. ## 🧰 API
  190. | Feature | Modifier |
  191. |--------|----------|
  192. | Include in snapshot | `.prefireEnabled()` |
  193. | Exclude from snapshot | `.prefireIgnored()` |
  194. | Group in a flow | `.previewUserStory(.auth)` |
  195. | Mark a UI state | `.previewState(.error)` |
  196. | Customize snapshot | `.snapshot(delay: 0.3, precision: 0.95)` |
  197. | Wait until the preview settles | `.snapshot(waitForIdle: true, timeout: 2.0)` |
  198. | Wait for a condition | `.snapshot(waitUntil: { viewModel.isLoaded })` |
  199. | Parameterized preview | `#Preview(..., arguments: values)` |
  200. ---
  201. ## πŸ’‘ CLI Usage
  202. ```bash
  203. # Generate snapshot tests
  204. prefire tests
  205. # Generate playbook models
  206. prefire playbook
  207. ```
  208. Run `prefire tests --help` or `prefire playbook --help` for more options.
  209. ---
  210. ## πŸ€– Let AI agents see SwiftUI
  211. Prefire renders previews in its snapshot tests, built anew and on the devices you choose, so it can
  212. show them to an AI agent as images, which Xcode Previews can't do reliably outside Xcode.
  213. <img src="Documentation/Images/ai-agents.webp" alt="An agent calls render_previews for three previews of the Trip screen and gets dark mode PNGs back" width="100%">
  214. ```bash
  215. # Render previews to PNG + JSON
  216. prefire render "Sign in" --device "iPhone 16 Pro" --color-scheme dark
  217. # An HTML board of the last render, grouped by user story
  218. prefire board
  219. ```
  220. Add the MCP server to your agent, from the folder with `.prefire.yml`:
  221. | Agent | Install |
  222. | --- | --- |
  223. | Claude Code | `claude mcp add prefire -- prefire mcp`, or the plugin with a skill: `/plugin marketplace add BarredEwe/Prefire` then `/plugin install prefire@prefire` |
  224. | Cursor | [![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en/install-mcp?name=prefire&config=eyJjb21tYW5kIjoicHJlZmlyZSIsImFyZ3MiOlsibWNwIl19) |
  225. | Codex | `codex mcp add prefire -- prefire mcp` |
  226. | VS Code | `code --add-mcp '{"name":"prefire","command":"prefire","args":["mcp"]}'` |
  227. An agent then calls `list_previews`, `render_previews` and `build_board`. Set the scheme to build in
  228. `render_configuration` of `.prefire.yml`; see the [AI guide](Documentation/AI.md). Why not Xcode's own
  229. `RenderPreview`? Prefire needs no running Xcode, renders many previews in one build, on the devices,
  230. color scheme and Dynamic Type you ask for, and works in CI.
  231. ---
  232. ## πŸ—‚ Configuration: `.prefire.yml`
  233. ```yaml
  234. test_configuration:
  235. target: MyApp
  236. playbook_configuration:
  237. preview_default_enabled: true
  238. ```
  239. All options are in the [Configuration guide](Documentation/Configuration.md). To change the generated code, see [Templates](Documentation/Templates.md).
  240. ---
  241. ## 🧠 How It Works
  242. 1. πŸ” **Parses all source files** β€” finds `#Preview` and `PreviewProvider` blocks and the `.prefireEnabled()` / `.prefireIgnored()` modifiers
  243. 2. πŸ“‚ **Caches `Types` and `PreviewBodies`** β€” keyed by file modification date + SHA-256 of inputs, so nothing is re-parsed if nothing changed
  244. 3. πŸ”’ **Generates snapshot tests** β€” from `Stencil` templates, respecting `.prefire.yml`
  245. 4. πŸ“˜ **Generates Playbook models** β€” groups by `UserStory` and `State` into `PreviewModels.generated.swift`
  246. ---
  247. ## 🩺 Troubleshooting
  248. | Problem | Fix |
  249. |---------|-----|
  250. | `NavigationView` in a preview doesn't work in Playbook | Use other views or layouts for your Playbook needs |
  251. | Plugins don't run on CI | `defaults write com.apple.dt.Xcode IDESkipPackagePluginFingerprintValidatation -bool YES` |
  252. | Xcode can't generate tests in a custom path | Disable the plugin sandbox: `defaults write com.apple.dt.Xcode IDEPackageSupportDisablePluginExecutionSandbox -bool YES` |
  253. ---
  254. ## 🐱 Also by the author
  255. <img src="https://mewmori.com/assets/press/gifs/en/01-hello.gif" alt="Mewmori" width="200" align="right">
  256. [**Mewmori**](https://mewmori.com/?src=prefire) is a pixel cat that lives on your Mac desktop.
  257. He reads what's on screen, says something about it, and remembers you between sessions.
  258. A 2B model runs on the machine through llama.cpp, so screen text, chats and memory stay on your Mac.
  259. Swift, AppKit + SwiftUI, 29 MB. Free; only skins are paid.
  260. <br clear="all">
  261. ## 🀝 Contributing
  262. We welcome contributions! Development setup, tests and the internal architecture are described in [CONTRIBUTING.md](CONTRIBUTING.md).
  263. Logo, colors and templates for talks and posts about Prefire are in the [brand kit](https://prefire.ru/brand/).
  264. ## ⭐ Star history
  265. If Prefire saves you time, give it a star: it helps other iOS developers find it.
  266. <a href="https://star-history.com/#BarredEwe/Prefire&Date">
  267. <picture>
  268. <source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/svg?repos=BarredEwe/Prefire&type=Date&theme=dark">
  269. <img alt="Star history of Prefire" src="https://api.star-history.com/svg?repos=BarredEwe/Prefire&type=Date" width="600">
  270. </picture>
  271. </a>
  272. ## πŸ“„ License
  273. Prefire is released under the Apache License 2.0. See [LICENSE](https://github.com/BarredEwe/Prefire/blob/main/LICENSE) for details.

Ratings and comments

Sign in to rate this skill.

Sign in

Free to use. If it’s helped, pass it on.