swiftui-patterns

swiftui-patterns is a skill for Claude Code, Codex from ronmkr/PromptBook. It costs 34 tokens per session (1,565 once invoked), scanned A, a copy of swiftui-patterns, Apache-2.0.

A guide to building Apple-platform interfaces with SwiftUI, Apple's framework for describing screens in Swift code. It covers screen structure, app state, navigation, and rendering performance.

In plain words
What is it for?
Use it when creating iOS or macOS screens, managing forms and shared data, designing navigation, structuring view models, or improving list performance.
Why use it?
It helps keep changing data flowing correctly through views and avoids slow or difficult-to-maintain interface code.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it when creating iOS or macOS screens, managing forms and shared data, designing navigation, structuring view models, or improving list performance.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/ronmkr/promptbook/swiftui-patterns
Install

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.

Any agent
npx skills add ronmkr/PromptBook --skill swiftui-patterns
Clone the repo
git clone --depth 1 https://github.com/ronmkr/PromptBook

Made for: Claude Code, Codex.

Wrote 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.

agentmods badge for swiftui-patterns

README.md
[![agentmods](https://agentmods.dev/badge/skills/ronmkr/promptbook/swiftui-patterns.svg)](https://agentmods.dev/skills/ronmkr/promptbook/swiftui-patterns)
Your own site
<a href="https://agentmods.dev/skills/ronmkr/promptbook/swiftui-patterns"><img src="https://agentmods.dev/badge/skills/ronmkr/promptbook/swiftui-patterns.svg" alt="Measured on agentmods" height="20"></a>
Per session 34 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,565 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin 94% copy Near-identical to another mod in the catalogue.
Token cost

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.

ModelPer sessionOnce invoked
Fable 5.1 $0.00034 $0.01565
Opus 5 $0.00017 $0.00783
Sonnet 5 $0.00007 $0.00313
Haiku 4.5 $0.00003 $0.00156

Measured 4d ago against content hash c27f90145101, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-07, from the pricing page.

Security

Grade A, and why

swiftui-patterns 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.

Origin

This is a copy

94% identical to swiftui-patterns — 3 lines differ, which has more behind it and is treated as the original. This page carries a canonical link to it rather than competing with it.

skills/patterns/swiftui-patterns/SKILL.md · 260 lines

How it starts

The opening of the file, as written. The whole thing — 260 lines — stays where its author put it; the contents beside it link to each section on GitHub.

SwiftUI Patterns

Modern SwiftUI patterns for building declarative, performant user interfaces on Apple platforms. Covers the Observation framework, view composition, type-safe navigation, and performance optimization.

When to Activate

  • Building SwiftUI views and managing state (@State, @Observable, @Binding)
  • Designing navigation flows with NavigationStack
  • Structuring view models and data flow
  • Optimizing rendering performance for lists and complex layouts
  • Working with environment values and dependency injection in SwiftUI

State Management

Property Wrapper Selection

Choose the simplest wrapper that fits:

Wrapper Use Case
@State View-local value types (toggles, form fields, sheet presentation)
@Binding Two-way reference to parent's @State
@Observable class + @State Owned model with multiple properties
@Observable class (no wrapper) Read-only reference passed from parent
@Bindable Two-way binding to an @Observable property
@Environment Shared dependencies injected via .environment()

@Observable ViewModel

Use @Observable (not ObservableObject) — it tracks property-level changes so SwiftUI only re-renders views that read the changed property:

@Observable
final class ItemListViewModel {
    private(set) var items: [Item] = []
    private(set) var isLoading = false
    var searchText = ""

    private let repository: any ItemRepository

    init(repository: any ItemRepository = DefaultItemRepository()) {
        self.repository = repository
    }

    func load() async {
        isLoading = true
        defer { isLoading = false }
        items = (try? await repository.fetchAll()) ?? []
    }
}

View Consuming the ViewModel

struct ItemListView: View {
    @State private var viewModel: ItemListViewModel

    init(viewModel: ItemListViewModel = ItemListViewModel()) {
        _viewModel = State(initialValue: viewModel)
    }

    var body: some View {
        List(viewModel.items) { item in
            ItemRow(item: item)
        }
        .searchable(text: $viewModel.searchText)
        .overlay { if viewModel.isLoading { ProgressView() } }
        .task { await viewModel.load() }
    }
}

Read the full file on GitHub · 260 lines

Changes

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.

  1. 4d ago First seen · 260 lines · 34 tokens per session scan A c27f90145101

Subscribe to this mod's changes

swiftui-patterns is a skill published in the GitHub repository ronmkr/PromptBook (2 stars, last pushed 3mo ago), licensed Apache-2.0. It adds 34 tokens to every session and 1,565 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. It is 94% identical to swiftui-patterns, differing in 3 lines, and is treated as a copy.