Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

swiftui-architecture

БесплатноБез исполняемых скриптовНе проверен

WHEN building SwiftUI views, managing state, setting up shared services, or making architectural decisions; NOT for UIKit or legacy patterns; provides pure…

mintuzот mintuz★ 38 звёзд на GitHub

Об этом скилле

Modern SwiftUI Architecture

Pure SwiftUI architecture without legacy ObservableObject ViewModels, combining clear ownership with Apple's SwiftUI performance and API guidance.

Scope

This skill covers evergreen SwiftUI views, data flow, performance, localisation, animations, and soft-deprecated APIs.

  • For new iOS 27 / macOS 27 SwiftUI APIs and @State macro migration errors, use swiftui-whats-new-27.
  • For SwiftUI document-based apps (Document protocol, DocumentGroup), use building-document-based-swiftui-applications.
  • When asked to restructure UIKit or AppKit code, state that this guidance does not cover UIKit/AppKit internals and leave them alone. Answer only at the boundary:
    • Wrap an existing view controller in UIViewControllerRepresentable (NSViewControllerRepresentable on macOS).
    • Wrap an existing view in UIViewRepresentable (NSViewRepresentable on macOS) only when it is already separated from its controller.
    • Use UIHostingController (NSHostingController on macOS) to show a SwiftUI view inside UIKit/AppKit.
    • Keep wrapped state where it already lives; pass SwiftUI values into the wrapper and send events back via callbacks.

Large-Codebase Review Workflow

When asked for general SwiftUI best-practice or performance guidance on a large codebase:

  1. Scan the project to identify discrete areas.
  2. Propose focus areas one at a time, offering choices where applicable.
  3. If the user asks for a whole-codebase review, divide the review into sections with a checklist.

References

Read a reference when its topic applies:

  • State ownership, value inputs, @State, KeyPath bindings, and .onChange isolation: references/state-management.md
  • @Observable services, @MainActor, Equatable, and invalidation granularity: references/observable-patterns.md
  • Async work and .task(id:) lifecycle: references/async-patterns.md
  • View structure, View.init, and single-child Group: references/structure.md
  • @Entry, EnvironmentValues, FocusedValues, closures, unstable defaults, and high-frequency updates: references/environment.md
  • ForEach, List, Table, identity, derived collections, and unary row fast path: references/foreach.md
  • Conditional modifiers and AnyShapeStyle: references/modifiers.md
  • Localisation, LocalizedStringResource, bundle: #bundle, and format styles: references/localization.md
  • Custom @Animatable views/shapes and AnimatableValues/AnimatablePair: references/animations.md
  • Soft-deprecated APIs policy and SDK 27 catalogue: references/soft-deprecation.md, references/soft-deprecated-apis.md
  • Navigation and components: references/navigation-patterns.md, references/lists.md, references/scrollview.md, references/forms.md, references/grids.md, references/sheets.md, references/tabs.md
  • Anti-patterns audit: references/anti-patterns.md

Core Architecture and Performance Flow

  1. Give every mutable value and dependency one owner and lifetime (references/state-management.md, principle-derive-from-one-owner):

    • Keep screen-local UI state in private @State in the view that uses it (private enables @State lazy initialisation).
    • Lift state to the nearest common ancestor when sibling views share it, passing narrow values down and @Binding or callbacks up.
    • Move state into an app-wide shared @Observable service only when it must outlive that ancestor, when unrelated features read it, or to avoid threading through unrelated intermediate views. State placed in a shared service persists after the screen closes and invalidates every reader when it changes (principle-narrow-state-lifetime).
    • Retain each shared service once with @State, inject each service separately via .environment(...), and mutate shared state through actions on the service.
    • A view-local @State private var model = ... @Observable model is allowed specifically for invalidation isolation, caching derived collections, or coarsening high-frequency geometry/scroll values; keep business logic in injected services (principle-keep-the-core-pure).
  2. Design @Observable models and view inputs for minimal invalidation (references/observable-patterns.md, references/structure.md):

    • Mark @Observable classes @MainActor (unless SWIFT_DEFAULT_ACTOR_ISOLATION is MainActor); @Observable is unsupported on actor.
    • Make @Observable stored property types and collection element types (Array, Set, Dictionary) Equatable so generated setters skip no-op invalidations.
    • Pass narrow value-type inputs (only the fields a view reads or forwards). Flatten nested value-type structs stored on @Observable models, and cache derived/filtered collections (via didSet or .onChange(of:)) instead of recomputing .filter/.sorted inline in body.
    • Never have row views index back into a parent @Observable collection (model.items[index]); pass narrow fields or persisted
Полный SKILL.md на GitHub

Установить swiftui-architecture в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

references/animations.mdreferences/anti-patterns.mdreferences/async-patterns.mdreferences/environment.mdreferences/foreach.mdreferences/forms.mdreferences/grids.mdreferences/lists.mdreferences/localization.mdreferences/modifiers.mdreferences/navigation-patterns.mdreferences/observable-patterns.mdreferences/scrollview.mdreferences/sheets.mdreferences/soft-deprecated-apis.mdreferences/soft-deprecation.mdreferences/state-management.mdreferences/structure.mdreferences/tabs.md

FAQ

Что делает скилл swiftui-architecture?

WHEN building SwiftUI views, managing state, setting up shared services, or making architectural decisions; NOT for UIKit or legacy patterns; provides pure SwiftUI data flow without ViewModels using @State, @Binding, @Observable, and @Environment.

Как установить скилл swiftui-architecture?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл swiftui-architecture запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить swiftui-architecture с