Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
npx agentmods add commands/iron-ham/xcodepreviews/previewgit clone --depth 1 https://github.com/Iron-Ham/XcodePreviewsWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/commands/iron-ham/xcodepreviews/preview)<a href="https://agentmods.dev/commands/iron-ham/xcodepreviews/preview"><img src="https://agentmods.dev/badge/commands/iron-ham/xcodepreviews/preview.svg" alt="Measured on agentmods" height="20"></a>What it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5 | $0.00000 | $0.00997 |
| Opus 5 | $0.00000 | $0.00498 |
| Sonnet 5 | $0.00000 | $0.00199 |
| Haiku 4.5 | $0.00000 | $0.00100 |
Grade A, and why
preview scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 4d ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 147 lines — stays where its author put it; the contents beside it link to each section on GitHub.
/preview - Build and Capture SwiftUI Preview
Build a SwiftUI view and capture its rendered output for visual analysis.
Arguments
$ARGUMENTS - File path, or options like --scheme, --workspace, --capture-only
Instructions
You are the preview capture assistant. Your job is to build SwiftUI previews and analyze their visual output.
Path Resolution: Scripts default to ~/XcodePreviews. If that directory doesn't exist, fall back to ~/Claude-XcodePreviews (legacy name). The PREVIEW_BUILD_PATH environment variable overrides both.
Unified Entry Point
For most cases, use the unified preview script which auto-detects the best approach:
"${PREVIEW_BUILD_PATH:-$HOME/XcodePreviews}"/scripts/preview \
"<path-to-file.swift>" \
--output /tmp/preview.png
This will automatically:
- Detect if the file has a
#Previewblock - Find the associated Xcode project or SPM package
- Use dynamic preview injection for fast builds (~3-4 seconds)
- Fall back to full scheme builds when needed
Preview Modes
The unified preview script auto-detects the best mode. You can also be explicit:
Xcode Project with #Preview (Fastest)
Injects a minimal PreviewHost target, builds only required modules (~3-4 seconds):
"${PREVIEW_BUILD_PATH:-$HOME/XcodePreviews}"/scripts/preview \
"<path-to-file.swift>" \
--project "<path.xcodeproj>" \
--output /tmp/preview.png
SPM Package
Auto-detected from Package.swift in parent directories:
"${PREVIEW_BUILD_PATH:-$HOME/XcodePreviews}"/scripts/preview \
"<path-to-file.swift>" \
--output /tmp/preview.png
Standalone Swift File (No Dependencies)
For Swift files that only use system frameworks (SwiftUI, UIKit, Foundation):
"${PREVIEW_BUILD_PATH:-$HOME/XcodePreviews}"/scripts/preview \
"<path-to-file.swift>" \
--output /tmp/preview.png
Select a Named Preview
When a file has multiple #Preview blocks, select one by name:
"${PREVIEW_BUILD_PATH:-$HOME/XcodePreviews}"/scripts/preview \
"<path-to-file.swift>" \
--project "<path.xcodeproj>" \
--preview-name "Dark Mode" \
--output /tmp/preview.png
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 4d ago First seen · 147 lines · 0 tokens per session scan A c6b7baee51b5
preview is a command published in the GitHub repository Iron-Ham/XcodePreviews (151 stars, last pushed 2mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 997 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.
Other commands, from other repositories
mobile-specialist
Use when a design will be used on phones. Touch targets too small, controls outside thumb reach, bottom navigation, gestures, safe areas and notches, or behaviour with no connection.
port_to_platform
Take an existing design or implementation to another platform (iOS ↔ Android ↔ macOS ↔ web) — porting the intent and IA, not the components.
ios-icon
Create or review iOS app icon and launch screen requirements.
design-mobile
Design a mobile screen or flow. This command never writes SwiftUI or Compose — the deliverable is a device-framed HTML mockup plus a handoff spec for the platform developer.
git
Git operations with intelligent commit messages and workflow optimization.
checklist
Generate a custom checklist for the current feature based on user requirements.