技能创建器
skill-creator
创建、改进和评估自定义技能,把专业流程转化为可重复使用的 AI 能力。
swift-ui-architect【数据与研究】Opinionated SwiftUI architecture enforcement for iOS 26 / Swift 6.2 clinic modular MVVM-C apps using local SPM package boundaries. Enforces App-target `DependencyContainer` + route shells, @Observable ViewModels/coordinators, Domain repository/coordinator/error-routing protocols, Data-owned I/O, stale-while-revalidate reads, and optimistic queued syn…
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
DependencyContainer + route shells, @Observable ViewModels/coordinators, Domain repository/coordinator/error-routing protocols, Data-owned I/O, stale-while-revalidate reads, and optimistic queued sync. Use when writing, reviewing, or refactoring SwiftUI architecture, navigation, dependency wiring, or repository boundaries.Opinionated architecture enforcement for SwiftUI clinic-style apps. This skill aligns to the iOS 26 / Swift 6.2 clinic architecture: modular MVVM-C in local SPM packages, concrete coordinators and route shells in the App target, pure Domain protocols, and Data as the only I/O layer.
┌───────────────────────────────────────────────────────────────┐
│ App target: DependencyContainer, Coordinators, Route Shells │
├───────────────┬───────────────┬───────────────┬──────────────┤
│ Feature* SPM │ Feature* SPM │ Feature* SPM │ Feature* SPM │
│ View + VM │ View + VM │ View + VM │ View + VM │
├───────────────────────────────────────────────────────────────┤
│ Data SPM: repository impls, remote/local, retry, sync queue │
├───────────────────────────────────────────────────────────────┤
│ Domain SPM: models, repository protocols, coordinator protocols│
│ and ErrorRouting/AppError │
├───────────────────────────────────────────────────────────────┤
│ Shared SPMs: DesignSystem, SharedKit │
└───────────────────────────────────────────────────────────────┘
Dependency Rule: Feature modules import Domain + DesignSystem only. Features never import Data or other features. App target is the only convergence point.
All guidance in this skill assumes the clinic modular MVVM-C architecture:
Domain + DesignSystem only (never Data, never sibling features)DependencyContainer, concrete coordinators, and Route Shell wiringDomain stays pure Swift and defines models plus repository, *Coordinating, ErrorRouting, and AppError contractsData owns SwiftData/network/sync/retry/background I/O and implements Domain protocolsReference these guidelines when:
@Observable for ViewModels/coordinators, ObservableObject / @Published neverNavigationPath in App target.navigationDestination mappingAppError + ErrorRouting drive presentation policy; ViewModels do not hardcode global error UI| Priority | Category | Impact | Prefix | Rules |
|---|---|---|---|---|
| 1 | View Identity & Diffing | CRITICAL | diff- | 6 |
| 2 | State Architecture | CRITICAL | state- | 7 |
| 3 | View Composition | HIGH | view- | 6 |
| 4 | Navigation & Coordination | HIGH | nav- | 5 |
| 5 | Layer Architecture | HIGH | layer- | 6 |
| 6 | Dependency Injection | MEDIUM-HIGH | di- | 4 |
| 7 | List & Collection Performance | MEDIUM | list- | 4 |
| 8 | Async & Data Flow | MEDIUM | data- | 5 |
diff-equatable-views - Apply @Equatable macro to every SwiftUI viewdiff-closure-skip - Use @SkipEquatable for closure/handler propertiesdiff-reference-types - Never store reference types without Equatable conformancediff-identity-stability - Use stable O(1) identifiers in ForEachdiff-avoid-anyview - Never use AnyView — use @ViewBuilder or genericsdiff-printchanges-debug - Use _printChanges() to diagnose unnecessary re-rendersstate-observable-class - Use @Observable classes for all ViewModelsstate-ownership - @State for owned data, plain property for injected datastate-single-source - One source of truth per piece of statestate-scoped-observation - Leverage @Observable property-level trackingstate-binding-minimal - Pass @Binding only for two-way data flowstate-environment-global - Use @Environment for app-wide shared dependenciesstate-no-published - Never use @Published or ObservableObjectview-body-complexity - Maximum 10 nodes in view bodyview-extract-subviews - Extract computed properties/helpers into separate View structsview-no-logic-in-body - Zero business logic in bodyview-minimal-dependencies - Pass only needed properties, not entire modelsview-viewbuilder-composition - Use @ViewBuilder for conditional compositionview-no-init-sideeffects - Never perform work in View initnav-coordinator-pattern - Every feature has a coordinator owning NavigationStacknav-routes-enum - Define all routes as a Hashable enumnav-deeplink-support - Coordinators must support URL-based deep linkingnav-modal-sheets - Present modals via coordinator, not inlinenav-no-navigationlink - Never use NavigationLink(destination:) — use navigationDestination(for:)layer-dependency-rule - Domain layer has zero framework importslayer-usecase-protocol - Do not add a use-case layer; keep orchestration in ViewModel + repository protocolslayer-repository-protocol - Repository protocols in Domain, implementations in Datalayer-model-value-types - Domain models are structs, never classeslayer-no-view-repository - Views never access repositories directly; ViewModel calls repository protocolslayer-viewmodel-boundary - ViewModels expose display-ready state onlydi-environment-injection - Inject container-managed protocol dependencies via @Environmentdi-protocol-abstraction - All injected dependencies are protocol typesdi-container-composition - Compose DependencyContainer in App target and expose VM factoriesdi-mock-testing - Every protocol dependency has a mock for testinglist-constant-viewcount - ForEach must produce constant view count per elementlist-filter-in-model - Filter/sort in ViewModel, never inside ForEachlist-lazy-stacks - Use LazyVStack/LazyHStack for unbounded contentlist-id-keypath - Provide explicit id keyPath — never rely on implicit identitydata-task-modifier - Use .task(id:) as the primary feature data-loading triggerdata-async-init - Never perform async work in initdata-error-loadable - Model loading states as enum, not booleansdata-combine-avoid - Prefer async/await over Combine for new codedata-cancellation - Use .task automatic cancellation — never manage Tasks manuallyRead individual reference files for detailed explanations and code examples:
| File | Description |
|---|---|
| references/_sections.md | Category definitions and ordering |
| assets/templates/_template.md | Template for new rules |
| metadata.json | Version and reference information |