/ios-swift-skills:ui-patternsfrom ios-swift-skills
Provides best practices and patterns for building SwiftUI views and components, including tab architecture, screen composition, sheet usage, and MV pattern over MVVM.
Ships in ios-swift-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
rg "TabView\(" or similarAppTab enum and RouterPath@State, @Binding, @Observable, @Environment).task and explicit loading/error states.sheet(item:) over .sheet(isPresented:) when state represents a selected modelif let inside a sheet bodydismiss() internally@Environment.task and explicit state enum if neededSwiftUI views should be lightweight state expressions. Avoid ViewModels unless truly necessary.
struct FeedView: View {
@Environment(APIClient.self) private var client
enum ViewState {
case loading
case error(String)
case loaded([Post])
}
@State private var viewState: ViewState = .loading
var body: some View {
NavigationStack {
List {
switch viewState {
case .loading:
ProgressView("Loading...")
case .error(let message):
ErrorView(message: message, retry: { await loadFeed() })
case .loaded(let posts):
ForEach(posts) { post in
PostRow(post: post)
}
}
}
.task { await loadFeed() }
}
}
private func loadFeed() async {
do {
let posts = try await client.getFeed()
viewState = .loaded(posts)
} catch {
viewState = .error(error.localizedDescription)
}
}
}
@State private var selectedItem: Item?
.sheet(item: $selectedItem) { item in
EditItemSheet(item: item)
}
struct EditItemSheet: View {
@Environment(\.dismiss) private var dismiss
@Environment(Store.self) private var store
let item: Item
@State private var isSaving = false
var body: some View {
VStack {
Button(isSaving ? "Saving..." : "Save") {
Task { await save() }
}
}
}
private func save() async {
isSaving = true
await store.save(item)
dismiss()
}
}
@main
struct MyApp: App {
@State var client: APIClient = .init()
@State var router: AppRouter = .init()
var body: some Scene {
WindowGroup {
TabView(selection: $router.selectedTab) {
ForEach(AppTab.allCases) { tab in
tab.rootView
.tag(tab)
}
}
.environment(client)
.environment(router)
}
}
}
| Wrapper | Use Case |
|---|---|
@State | Local, ephemeral view state |
@Binding | Two-way data flow from parent |
@Observable | Shared state across views (iOS 17+) |
@Environment | Dependency injection, app-wide concerns |
@Query | SwiftData queries directly in views |
// React to state changes
.task(id: searchText) {
guard !searchText.isEmpty else { return }
await search(query: searchText)
}
// Respond to state transitions
.onChange(of: isActive, initial: false) {
guard isActive else { return }
Task { await refresh() }
}
SwiftUI was designed without ViewModels in mind:
@State, @Environment, @Observable handle all data flow needs@Query works directly in viewsInstead:
@EnvironmentWhat SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
swiftui-patterns, view-composition, sheet-patterns, mv-pattern
Generated from the plugin's indexed repository (patrickserrano/skills) — no native marketplace selected
npx claudepluginhub p/patrickserrano-ios-swift-skills10 skills in this plugin
/issue-fix-flowEnd-to-end GitHub issue fix workflow using gh CLI, local code changes, builds/tests, and git push. Use when asked to take an issue number, implement a fix, run builds/tests, commit with a closing message, and push./debugger-agentBuild, run, and debug iOS apps on a simulator. Use when asked to run an iOS app, interact with the simulator UI, capture logs, or diagnose runtime behavior./native-app-profilingProfile native macOS/iOS apps using Time Profiler via CLI (xctrace). Use when asked to identify performance hotspots, profile CPU usage, or diagnose slow code paths without opening Instruments./app-store-changelogCreate user-facing App Store release notes from git history. Use when asked to generate release changelog, App Store "What's New" text, or release notes based on git tags./macos-spm-app-packagingScaffold, build, and package SwiftPM-based macOS apps without Xcode project. Use when you need a from-scratch macOS app layout, SwiftPM targets/resources, custom .app bundle assembly, or signing/notarization steps outside Xcode./concurrency-expertSwift Concurrency review and remediation for Swift 6.2+. Use when asked to review Swift Concurrency usage, improve concurrency compliance, or fix Swift concurrency compiler errors.Other plugins' skills for the same job