swiftui-mvvm

swiftui-mvvm is a skill for Claude Code from rusel95/ios-agent-skills. It costs 158 tokens per session (3,823 once invoked), scanned A, original, MIT.

A guide for structuring SwiftUI screen logic with MVVM, a pattern that separates the user interface from its state and application logic.

In plain words
What is it for?
Use it when creating, refactoring, or testing SwiftUI view models, handling screen state, navigation, or data loaded through repositories.
Why use it?
It makes screen behavior easier to test, review, and change safely, especially in larger iOS codebases.

Skill for Claude Code

Written for Claude Code: shipped in a Claude Code plugin.

Part of the ios-agent-skills plugin — 12 skills shipped together

Good fit Use it when creating, refactoring, or testing SwiftUI view models, handling screen state, navigation, or data loaded through repositories.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/rusel95/ios-agent-skills/swiftui-mvvm
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 rusel95/ios-agent-skills --skill swiftui-mvvm
Clone the repo
git clone --depth 1 https://github.com/rusel95/ios-agent-skills

Made for: Claude Code.

Or install ios-agent-skills, the plugin that ships this one along with the rest of its 12 skills.

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-mvvm

README.md
[![agentmods](https://agentmods.dev/badge/skills/rusel95/ios-agent-skills/swiftui-mvvm/github.svg)](https://agentmods.dev/skills/rusel95/ios-agent-skills/swiftui-mvvm)
Your own site
<a href="https://agentmods.dev/skills/rusel95/ios-agent-skills/swiftui-mvvm"><img src="https://agentmods.dev/badge/skills/rusel95/ios-agent-skills/swiftui-mvvm/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for swiftui-mvvm

Your own site · 80×15
<a href="https://agentmods.dev/skills/rusel95/ios-agent-skills/swiftui-mvvm"><img src="https://agentmods.dev/badge/skills/rusel95/ios-agent-skills/swiftui-mvvm.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 158 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 3,823 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 original No closer match found 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.00158 $0.03823
Opus 5 $0.00079 $0.01912
Sonnet 5 $0.00032 $0.00765
Haiku 4.5 $0.00016 $0.00382

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

Security

Grade A, and why

swiftui-mvvm 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 12d 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.

skills/swiftui-mvvm/SKILL.md · 227 lines

How it starts

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

Approach: Production-First Iterative Refactoring — This skill is built for production enterprise codebases where stability and reviewability matter more than speed. Architecture changes are delivered through iterative refactoring — small, focused PRs (≤200 lines, single concern) tracked in a refactoring/ directory. Critical safety issues ship first; cosmetic improvements come last.

SwiftUI MVVM Architecture (iOS 17+)

Enterprise-grade SwiftUI MVVM architecture skill. Opinionated: prescribes @Observable ViewModels, Router navigation, constructor injection, ViewState enum, and Repository-based networking. Adopts a production-first iterative refactoring approach — every pattern is chosen for testability, reviewability, and safe incremental adoption in large teams. For non-architectural SwiftUI API guidance (animations, modern API replacements, Liquid Glass), use a general SwiftUI skill instead.

Architecture Layers

View Layer         → SwiftUI Views. Declarative UI only. Owns ViewModel via @State.
ViewModel Layer    → @Observable @MainActor final class. Exposes ViewState<T>.
Repository Layer   → Protocol-based data access. Hides data source details.
Service Layer      → URLSession, persistence. Injected via protocol.

Quick Decision Trees

"Should this View have a ViewModel?"

Is there business logic, networking, or complex state?
├── YES → Create @Observable ViewModel
└── NO → Is it a reusable UI component (button, card, cell)?
    ├── YES → Plain struct with data parameters, NO ViewModel
    └── NO → No ViewModel needed unless it simplifies testing

"How should I own this ViewModel?"

Does THIS view create the ViewModel?
├── YES → @State private var viewModel = MyViewModel()
└── NO → Does the view need $ bindings to ViewModel properties?
    ├── YES → @Bindable var viewModel: MyViewModel
    └── NO → let viewModel: MyViewModel (plain property)

"Where do dependencies come from?"

ViewModel always receives dependencies via constructor:
  init(repository: ItemRepositoryProtocol)

How does the View get the dependency to pass?
├── Shared service (used across many screens)
│   └── Register via @Entry in EnvironmentValues
│       View reads @Environment(\.repo), passes to VM init
├── Screen-specific dependency (passed by parent)
│   └── View receives it as init parameter, passes to VM init
└── Outside view hierarchy (background service, deep utility)
    └── @Injected property wrapper (legacy/convenience only)

Read the full file on GitHub · 227 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. 12d ago First seen · 227 lines · 158 tokens per session scan A 2938efec0189

Subscribe to this mod's changes

swiftui-mvvm is a skill published in the GitHub repository rusel95/ios-agent-skills (9 stars, last pushed 4mo ago), licensed MIT. It adds 158 tokens to every session and 3,823 once invoked, about $0.0008 per session on Opus 5. 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-31.

Related

Other skills, from other repositories

Mobile Application Security

Android and iOS application security testing — static and dynamic analysis, APK/IPA inspection, OWASP MASVS/MASTG verification, secure-storage and transport review, and mobile malware triage for authorized assessments.

Masriyan/Claude-Code-CyberSecurity-Skill · 46 tokens

flutter

Use when building, structuring, testing or optimizing a Flutter app — feature-first layering, Riverpod 3 or Bloc, typed gorouter, freezed models, a dio data layer, Material 3, jank hunting, widget/golden tests. Targets Flutter 3.44 / Dart 3.12. NOT React Native (that is react-native), NOT Compose Multiplatform (that…

ericrisco/rsc-harness · 91 tokens

compose-multiplatform

Use when building one shared Compose UI in Kotlin across Android, iOS, and desktop — commonMain @Composables, expect/actual, source-set placement, native interop, multiplatform ViewModel/navigation/Koin. NOT a single-platform native build (that is kotlin-android / swift-ios), and NOT Dart/Flutter cross-platform UI…

ericrisco/rsc-harness · 80 tokens

react-native

Use when writing the JS/TS inside a React Native or Expo app — screens, Expo Router navigation, lists, Reanimated gestures, platform forks, offline state, native modules — or killing jank and render storms. NOT eas build/submit/OTA/config-plugin (that is expo), NOT a Dart app (that is flutter), NOT web React/DOM (that…

ericrisco/rsc-harness · 90 tokens

app-review-max

Pass Apple App Review the first time and recover fast when rejected. USE THIS SKILL whenever the user is submitting to the App Store, preparing a submission, asks 'will this get rejected', mentions App Review, a rejection, Resolution Center, an appeal, or any guideline number (2.1, 2.3, 3.1.1, 4.3, 5.1.x, etc.)…

Dev869/swift-tothemax · 218 tokens

swiftui-max

Expert SwiftUI guidance for building UI on iOS, iPadOS, macOS, watchOS, tvOS, and visionOS. Use whenever writing, reviewing, refactoring, or debugging ANY SwiftUI code — views, view modifiers, layout, navigation (NavigationStack/SplitView, deep links), lists and scrolling, animation and transitions, state management…

Dev869/swift-tothemax · 271 tokens