agentsclimarketplace

Swift patterns

Skill harshii0509/swift-skill-pack/skills/swift-patterns

Apply production Swift architecture patterns for session-based dependency injection, Swift package modularization, UIKit and SwiftUI bridging, Combine-to-concurrency migration, and rendering performance. Use when structuring an iOS app, splitting modules, introducing dependencies, or cleaning up complex app architecture.From its SKILL.md

Install
npx -y skills add harshii0509/swift-skill-pack --skill swift-patterns

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

SKILL.md

6.3 KB, ~1.3k tokens by cl100k_base, as published. Nobody here has run it

You are a Swift architecture expert. Load the relevant reference files and give concrete, production-tested guidance.

Architecture Decision Guide

ProblemRecommended PatternReference
Shared mutable state across multiple viewsSession (@Observable class + .environment())references/session-architecture.md
Singleton everywhere, hard to testDependency injection via swift-dependenciesreferences/session-architecture.md
App growing past 50k lines, slow buildsSPM modularizationreferences/spm-modularization.md
Need UIKit component in SwiftUIUIViewRepresentablereferences/uikit-swiftui-bridge.md
UIKit app adding SwiftUI screensUIHostingControllerreferences/uikit-swiftui-bridge.md
Need mature UIKit/AppKit-backed SwiftUI controls fastSwiftUIX behind a local boundaryreferences/swiftuix-patterns.md
Combine publishers → async/awaitpublisher.values async sequencereferences/combine-to-async.md
60fps custom animation, Metal renderingCADisplayLink + TimelineViewreferences/rendering-performance.md
One codebase across iPhone, iPad, Mac, widgets, live activitiesFeature-rooted multiplatform compositionreferences/food-truck-patterns.md
Navigation state getting complex, deep links matterState-driven destinationsreferences/swift-navigation-patterns.md
Need Observation on older OS versionsBackported observation boundaryreferences/swift-perception-patterns.md

Topic Router

Reference files live in the sibling references/ folder for this skill. If the problem spans multiple architectural options, consult references/example-prompts.md before locking in a recommendation. If the question depends on precise iOS 26 SwiftUI UI-surface language, also consult ../swift/references/swiftui-vocabulary.md.

TopicFile
Session, DI, ViewModel, @Observable, environmentreferences/session-architecture.md
SPM, modularization, packages, build timesreferences/spm-modularization.md
UIViewRepresentable, UIHostingController, bridgereferences/uikit-swiftui-bridge.md
SwiftUIX, Cocoa views, missing SwiftUI controlsreferences/swiftuix-patterns.md
Combine, async/await, Publisher, sink, Taskreferences/combine-to-async.md
Metal, CADisplayLink, TimelineView, GPU, performancereferences/rendering-performance.md
Multiplatform, widgets, live activities, app surfacesreferences/food-truck-patterns.md
NavigationStack, NavigationSplitView, deep links, enum destinationsreferences/swift-navigation-patterns.md
Observation, backport, deployment target, WithPerceptionTrackingreferences/swift-perception-patterns.md

Which Pattern for Which Problem

MVVM vs Session

  • MVVM (ViewModel per screen): works for isolated screens with local state
  • Session: use when the same state is needed by 3+ screens, or when it persists across navigation (auth state, user profile, selected conversation)

ObservableObject vs @Observable (iOS 17+)

  • ObservableObject / @Published: use when you need iOS 16 support or are in a codebase already using Combine
  • @Observable (Observation framework): use for new code on iOS 17+; fine-grained dependency tracking, no manual @Published

Combine vs async/await

  • Combine: best for multi-publisher composition (combineLatest, merge, withLatestFrom)
  • async/await: best for sequential async work, error propagation, structured concurrency
  • Hybrid: expose AnyPublisher at the public interface, use async/await internally

SwiftUIX vs writing your own wrapper

  • SwiftUIX: use when the missing control is well-understood, reusable, and already maps cleanly to app needs
  • Custom representable: use when the behavior is app-specific, tightly scoped, or you need exact lifecycle control
  • Native SwiftUI: prefer when the platform now provides the feature and the bridge would only add dependency surface

Plain SwiftUI navigation vs Swift Navigation

  • Plain SwiftUI navigation: use when the flow is shallow and navigation state does not need to be modeled or restored explicitly
  • Swift Navigation: use when enum-driven destinations, deep linking, testable path state, or UIKit/AppKit parity matter

Observation vs Swift Perception

  • Native Observation: use for new code when your minimum OS already includes Apple's Observation framework
  • Swift Perception: use when you want the same mental model on older deployment targets or need a migration bridge without rewriting ownership boundaries twice

Bridge design vs bridge bug

  • Broken wrapper behavior: start in swift-debug
  • Wrapper or dependency choice: stay in swift-patterns

Modern surface vocabulary

  • If the answer depends on distinguishing tab bar, bottom bar, safe-area bar, or bottom accessory, use the exact SwiftUI terms before describing architecture consequences.

Correctness Rules (Non-Negotiable)

  1. Expose protocols, not implementations — every session/manager the rest of the app depends on must be a protocol so it can be mocked in tests.
  2. Never mutate @Observable state off the main thread — decorate the class with @MainActor or gate mutations through DispatchQueue.main.async.
  3. Use DependencyKey liveValue + testValue — every injectable dependency must have a mock so tests don't hit Firebase/network.
  4. Store AnyCancellable in a Set, not as a local var — a local AnyCancellable cancels immediately when it goes out of scope.
  5. Don't use weak self inside Task { } unless the task outlives the object — tasks created inside a class method capture self safely via structured concurrency.
  6. Hide third-party UI dependencies behind local adapters — app code should depend on your wrapper or feature view, not directly on a broad package everywhere.

If a prompt says a bridge already behaves incorrectly, do not start with architecture redesign. Hand the first pass to swift-debug, then return here only after the root cause is visible.

What ships with it: 11 files

58.4 KB alongside SKILL.md

agents/

Keep looking

Skills are one crate of 326,851. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.