claudecode-omc 5.6.7 → 5.6.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (123) hide show
  1. package/.local/skills/THIRD_PARTY_LICENSES/AvdLee-SwiftUI-Agent-Skill.LICENSE +21 -0
  2. package/.local/skills/THIRD_PARTY_LICENSES/Dimillian-Skills.LICENSE +21 -0
  3. package/.local/skills/THIRD_PARTY_LICENSES/README.md +36 -0
  4. package/.local/skills/THIRD_PARTY_LICENSES/twostraws-swiftui-agent-skill.LICENSE +21 -0
  5. package/.local/skills/ios-debugger-agent/SKILL.md +51 -0
  6. package/.local/skills/ios-debugger-agent/agents/openai.yaml +4 -0
  7. package/.local/skills/swift-concurrency-expert/SKILL.md +105 -0
  8. package/.local/skills/swift-concurrency-expert/agents/openai.yaml +4 -0
  9. package/.local/skills/swift-concurrency-expert/references/approachable-concurrency.md +63 -0
  10. package/.local/skills/swift-concurrency-expert/references/swift-6-2-concurrency.md +272 -0
  11. package/.local/skills/swift-concurrency-expert/references/swiftui-concurrency-tour-wwdc.md +33 -0
  12. package/.local/skills/swiftui-expert-skill/SKILL.md +162 -0
  13. package/.local/skills/swiftui-expert-skill/references/accessibility-patterns.md +215 -0
  14. package/.local/skills/swiftui-expert-skill/references/animation-advanced.md +403 -0
  15. package/.local/skills/swiftui-expert-skill/references/animation-basics.md +284 -0
  16. package/.local/skills/swiftui-expert-skill/references/animation-transitions.md +326 -0
  17. package/.local/skills/swiftui-expert-skill/references/charts-accessibility.md +135 -0
  18. package/.local/skills/swiftui-expert-skill/references/charts.md +602 -0
  19. package/.local/skills/swiftui-expert-skill/references/focus-patterns.md +299 -0
  20. package/.local/skills/swiftui-expert-skill/references/image-optimization.md +203 -0
  21. package/.local/skills/swiftui-expert-skill/references/latest-apis.md +488 -0
  22. package/.local/skills/swiftui-expert-skill/references/layout-best-practices.md +266 -0
  23. package/.local/skills/swiftui-expert-skill/references/liquid-glass.md +423 -0
  24. package/.local/skills/swiftui-expert-skill/references/list-patterns.md +446 -0
  25. package/.local/skills/swiftui-expert-skill/references/macos-scenes.md +318 -0
  26. package/.local/skills/swiftui-expert-skill/references/macos-views.md +357 -0
  27. package/.local/skills/swiftui-expert-skill/references/macos-window-styling.md +303 -0
  28. package/.local/skills/swiftui-expert-skill/references/performance-patterns.md +403 -0
  29. package/.local/skills/swiftui-expert-skill/references/scroll-patterns.md +293 -0
  30. package/.local/skills/swiftui-expert-skill/references/sheet-navigation-patterns.md +363 -0
  31. package/.local/skills/swiftui-expert-skill/references/state-management.md +388 -0
  32. package/.local/skills/swiftui-expert-skill/references/text-patterns.md +32 -0
  33. package/.local/skills/swiftui-expert-skill/references/trace-analysis.md +295 -0
  34. package/.local/skills/swiftui-expert-skill/references/trace-recording.md +134 -0
  35. package/.local/skills/swiftui-expert-skill/references/view-structure.md +780 -0
  36. package/.local/skills/swiftui-expert-skill/scripts/__pycache__/analyze_trace.cpython-313.pyc +0 -0
  37. package/.local/skills/swiftui-expert-skill/scripts/__pycache__/record_trace.cpython-313.pyc +0 -0
  38. package/.local/skills/swiftui-expert-skill/scripts/analyze_trace.py +301 -0
  39. package/.local/skills/swiftui-expert-skill/scripts/instruments_parser/__init__.py +1 -0
  40. package/.local/skills/swiftui-expert-skill/scripts/instruments_parser/__pycache__/__init__.cpython-313.pyc +0 -0
  41. package/.local/skills/swiftui-expert-skill/scripts/instruments_parser/__pycache__/causes.cpython-313.pyc +0 -0
  42. package/.local/skills/swiftui-expert-skill/scripts/instruments_parser/__pycache__/correlate.cpython-313.pyc +0 -0
  43. package/.local/skills/swiftui-expert-skill/scripts/instruments_parser/__pycache__/events.cpython-313.pyc +0 -0
  44. package/.local/skills/swiftui-expert-skill/scripts/instruments_parser/__pycache__/hangs.cpython-313.pyc +0 -0
  45. package/.local/skills/swiftui-expert-skill/scripts/instruments_parser/__pycache__/hitches.cpython-313.pyc +0 -0
  46. package/.local/skills/swiftui-expert-skill/scripts/instruments_parser/__pycache__/summary.cpython-313.pyc +0 -0
  47. package/.local/skills/swiftui-expert-skill/scripts/instruments_parser/__pycache__/swiftui.cpython-313.pyc +0 -0
  48. package/.local/skills/swiftui-expert-skill/scripts/instruments_parser/__pycache__/time_profiler.cpython-313.pyc +0 -0
  49. package/.local/skills/swiftui-expert-skill/scripts/instruments_parser/__pycache__/xctrace.cpython-313.pyc +0 -0
  50. package/.local/skills/swiftui-expert-skill/scripts/instruments_parser/__pycache__/xml_utils.cpython-313.pyc +0 -0
  51. package/.local/skills/swiftui-expert-skill/scripts/instruments_parser/causes.py +187 -0
  52. package/.local/skills/swiftui-expert-skill/scripts/instruments_parser/correlate.py +179 -0
  53. package/.local/skills/swiftui-expert-skill/scripts/instruments_parser/events.py +291 -0
  54. package/.local/skills/swiftui-expert-skill/scripts/instruments_parser/hangs.py +108 -0
  55. package/.local/skills/swiftui-expert-skill/scripts/instruments_parser/hitches.py +145 -0
  56. package/.local/skills/swiftui-expert-skill/scripts/instruments_parser/summary.py +243 -0
  57. package/.local/skills/swiftui-expert-skill/scripts/instruments_parser/swiftui.py +195 -0
  58. package/.local/skills/swiftui-expert-skill/scripts/instruments_parser/time_profiler.py +135 -0
  59. package/.local/skills/swiftui-expert-skill/scripts/instruments_parser/xctrace.py +117 -0
  60. package/.local/skills/swiftui-expert-skill/scripts/instruments_parser/xml_utils.py +224 -0
  61. package/.local/skills/swiftui-expert-skill/scripts/record_trace.py +252 -0
  62. package/.local/skills/swiftui-liquid-glass/SKILL.md +90 -0
  63. package/.local/skills/swiftui-liquid-glass/agents/openai.yaml +4 -0
  64. package/.local/skills/swiftui-liquid-glass/references/liquid-glass.md +280 -0
  65. package/.local/skills/swiftui-performance-audit/SKILL.md +106 -0
  66. package/.local/skills/swiftui-performance-audit/agents/openai.yaml +4 -0
  67. package/.local/skills/swiftui-performance-audit/references/code-smells.md +150 -0
  68. package/.local/skills/swiftui-performance-audit/references/demystify-swiftui-performance-wwdc23.md +46 -0
  69. package/.local/skills/swiftui-performance-audit/references/optimizing-swiftui-performance-instruments.md +29 -0
  70. package/.local/skills/swiftui-performance-audit/references/profiling-intake.md +44 -0
  71. package/.local/skills/swiftui-performance-audit/references/report-template.md +47 -0
  72. package/.local/skills/swiftui-performance-audit/references/understanding-hangs-in-your-app.md +33 -0
  73. package/.local/skills/swiftui-performance-audit/references/understanding-improving-swiftui-performance.md +52 -0
  74. package/.local/skills/swiftui-pro/SKILL.md +108 -0
  75. package/.local/skills/swiftui-pro/agents/openai.yaml +10 -0
  76. package/.local/skills/swiftui-pro/assets/swiftui-pro-icon.png +0 -0
  77. package/.local/skills/swiftui-pro/assets/swiftui-pro-icon.svg +29 -0
  78. package/.local/skills/swiftui-pro/references/accessibility.md +13 -0
  79. package/.local/skills/swiftui-pro/references/api.md +39 -0
  80. package/.local/skills/swiftui-pro/references/data.md +43 -0
  81. package/.local/skills/swiftui-pro/references/design.md +32 -0
  82. package/.local/skills/swiftui-pro/references/hygiene.md +9 -0
  83. package/.local/skills/swiftui-pro/references/navigation.md +14 -0
  84. package/.local/skills/swiftui-pro/references/performance.md +46 -0
  85. package/.local/skills/swiftui-pro/references/swift.md +56 -0
  86. package/.local/skills/swiftui-pro/references/views.md +36 -0
  87. package/.local/skills/swiftui-ui-patterns/SKILL.md +95 -0
  88. package/.local/skills/swiftui-ui-patterns/agents/openai.yaml +4 -0
  89. package/.local/skills/swiftui-ui-patterns/references/app-wiring.md +201 -0
  90. package/.local/skills/swiftui-ui-patterns/references/async-state.md +96 -0
  91. package/.local/skills/swiftui-ui-patterns/references/components-index.md +50 -0
  92. package/.local/skills/swiftui-ui-patterns/references/controls.md +57 -0
  93. package/.local/skills/swiftui-ui-patterns/references/deeplinks.md +66 -0
  94. package/.local/skills/swiftui-ui-patterns/references/focus.md +90 -0
  95. package/.local/skills/swiftui-ui-patterns/references/form.md +97 -0
  96. package/.local/skills/swiftui-ui-patterns/references/grids.md +71 -0
  97. package/.local/skills/swiftui-ui-patterns/references/haptics.md +71 -0
  98. package/.local/skills/swiftui-ui-patterns/references/input-toolbar.md +51 -0
  99. package/.local/skills/swiftui-ui-patterns/references/lightweight-clients.md +93 -0
  100. package/.local/skills/swiftui-ui-patterns/references/list.md +86 -0
  101. package/.local/skills/swiftui-ui-patterns/references/loading-placeholders.md +38 -0
  102. package/.local/skills/swiftui-ui-patterns/references/macos-settings.md +71 -0
  103. package/.local/skills/swiftui-ui-patterns/references/matched-transitions.md +59 -0
  104. package/.local/skills/swiftui-ui-patterns/references/media.md +73 -0
  105. package/.local/skills/swiftui-ui-patterns/references/menu-bar.md +101 -0
  106. package/.local/skills/swiftui-ui-patterns/references/navigationstack.md +159 -0
  107. package/.local/skills/swiftui-ui-patterns/references/overlay.md +45 -0
  108. package/.local/skills/swiftui-ui-patterns/references/performance.md +62 -0
  109. package/.local/skills/swiftui-ui-patterns/references/previews.md +48 -0
  110. package/.local/skills/swiftui-ui-patterns/references/scroll-reveal.md +133 -0
  111. package/.local/skills/swiftui-ui-patterns/references/scrollview.md +87 -0
  112. package/.local/skills/swiftui-ui-patterns/references/searchable.md +71 -0
  113. package/.local/skills/swiftui-ui-patterns/references/sheets.md +155 -0
  114. package/.local/skills/swiftui-ui-patterns/references/split-views.md +72 -0
  115. package/.local/skills/swiftui-ui-patterns/references/tabview.md +114 -0
  116. package/.local/skills/swiftui-ui-patterns/references/theming.md +71 -0
  117. package/.local/skills/swiftui-ui-patterns/references/title-menus.md +93 -0
  118. package/.local/skills/swiftui-ui-patterns/references/top-bar.md +49 -0
  119. package/.local/skills/swiftui-view-refactor/SKILL.md +202 -0
  120. package/.local/skills/swiftui-view-refactor/agents/openai.yaml +4 -0
  121. package/.local/skills/swiftui-view-refactor/references/mv-patterns.md +161 -0
  122. package/bundled/manifest.json +1 -1
  123. package/package.json +1 -1
@@ -0,0 +1,13 @@
1
+ # Accessibility
2
+
3
+ - Respect the user’s accessibility settings for fonts, colors, animations, and more.
4
+ - Do not force specific font sizes. Prefer Dynamic Type (`.font(.body)`, `.font(.headline)`, etc.).
5
+ - If you *need* a custom font size, use `@ScaledMetric` when targeting iOS 18 and earlier. When targeting iOS 26 or later, `.font(.body.scaled(by:))` is also available to get font size adjustment.
6
+ - Flag instances where images have unclear or unhelpful VoiceOver readings, e.g. `Image(.newBanner2026)`. If they are decorative, suggest using `Image(decorative:)` or `accessibilityHidden()`, otherwise attach an `accessibilityLabel()`.
7
+ - If the user has “Reduce Motion” enabled, replace large, motion-based animations with opacity instead.
8
+ - If buttons have complex or frequently changing labels, recommend using `accessibilityInputLabels()` to provide better Voice Control commands. For example, if a button had a live-updating share price for Apple such as “AAPL $271.68”, adding an input label for “Apple” would be a big improvement.
9
+ - Buttons with image labels must always include text, even if the text is invisible: `Button("Label", systemImage: "plus", action: myAction)`. Flag icon-only buttons that lack a text label as being bad for VoiceOver. Usually SwiftUI will make labels use the correct label style based on their context – e.g. buttons in iOS toolbars will automatically be icon-only by default – but if there's a specific reason for a button to remain visually icon-only, apply `.labelStyle(.iconOnly)` to preserve the visual while keeping the text available for VoiceOver.
10
+ - If color is an important differentiator in the user interface, make sure to respect the environment’s `.accessibilityDifferentiateWithoutColor` setting by showing some kind of variation beyond just color – icons, patterns, strokes, etc.
11
+ - The same is true of `Menu`: using `Menu("Options", systemImage: "ellipsis.circle") { }` is much better than just using an image. In the rare case where the menu trigger should really display only the icon, `.labelStyle(.iconOnly)` can be used.
12
+ - Never use `onTapGesture()` unless you specifically need tap location or tap count. All other tappable elements should be a `Button`.
13
+ - If `onTapGesture()` must be used, make sure to add `.accessibilityAddTraits(.isButton)` or similar so it can be read by VoiceOver correctly.
@@ -0,0 +1,39 @@
1
+ # Using modern SwiftUI API
2
+
3
+ - Always use `foregroundStyle()` instead of `foregroundColor()`.
4
+ - Always use `clipShape(.rect(cornerRadius:))` instead of `cornerRadius()`.
5
+ - Always use the `Tab` API instead of `tabItem()`.
6
+ - Never use the `onChange()` modifier in its 1-parameter variant; either use the variant that accepts two parameters or accepts none.
7
+ - Do not use `GeometryReader` if a newer alternative works: `containerRelativeFrame()`, `visualEffect()`, or the `Layout` protocol. Flag `GeometryReader` usage and suggest the modern alternative.
8
+ - When designing haptic effects, prefer using `sensoryFeedback()` over older UIKit APIs such as `UIImpactFeedbackGenerator`.
9
+ - Use the `@Entry` macro to define custom `EnvironmentValues`, `FocusValues`, `Transaction`, and `ContainerValues` keys. This replaces the legacy pattern of manually creating a type conforming to (for example) `EnvironmentKey` with a `defaultValue`, then extending `EnvironmentValues` with a computed property.
10
+ - Strongly prefer `overlay(alignment:content:)` over the deprecated `overlay(_:alignment:)`. For example, use `.overlay { Text("Hello, world!") }` rather than `.overlay(Text("Hello, world!"))`.
11
+ - Never use `.navigationBarLeading` and `.navigationBarTrailing` for toolbar item placement; they are deprecated. The correct, modern placements are `.topBarLeading` and `.topBarTrailing`.
12
+ - Prefer to rely on automatic grammar agreement when dealing with English, French, German, Portuguese, Spanish, and Italian. For example, use `Text("^[\(people) person](inflect: true)")` to show a number of people.
13
+ - You can fill and stroke a shape with two chained modifiers; you do *not* need an overlay for the stroke. The overlay was required previously, but this is fixed in iOS 17 and later.
14
+ - When referencing images from an asset catalog, prefer the generated symbol asset API when the project is configured to use them: `Image(.avatar)` rather than `Image("avatar")`.
15
+ - When targeting iOS 26 and later, SwiftUI has a native `WebView` view type that replaces almost all uses of hand-wrapped `WKWebView` inside `UIViewRepresentable`. To use it, make sure to include `import WebKit`.
16
+ - `ForEach` over an `enumerated()` sequence should not convert to an array first. Use `ForEach(items.enumerated(), id: \.element.id)` directly.
17
+ - When hiding scroll indicators, use `.scrollIndicators(.hidden)` rather than `showsIndicators: false` in the initializer.
18
+ - Never use `Text` concatenation with `+`.
19
+
20
+ For example, the usage of `+` here is bad and deprecated:
21
+
22
+ ```swift
23
+ Text("Hello").foregroundStyle(.red)
24
+ +
25
+ Text("World").foregroundStyle(.blue)
26
+ ```
27
+
28
+ Instead, use text interpolation like this:
29
+
30
+ ```swift
31
+ let red = Text("Hello").foregroundStyle(.red)
32
+ let blue = Text("World").foregroundStyle(.blue)
33
+ Text("\(red)\(blue)")
34
+ ```
35
+
36
+
37
+ ## Using ObservableObject
38
+
39
+ If using `ObservableObject` is absolutely required – for example if you are trying to create a debouncer using a Combine publisher – you should always make sure `import Combine` is added. This was previously provided through SwiftUI, but that is no longer the case.
@@ -0,0 +1,43 @@
1
+ # Data flow, shared state, and property wrappers
2
+
3
+ It is important that SwiftUI body code and logic code be kept separate in order to make code easier to read, write, and maintain. That usually means placing code into methods rather than inline in the `body` property, but often also means carving functionality out into separate `@Observable` classes.
4
+
5
+ These rules help ensure code is efficient and works well in the long term.
6
+
7
+
8
+ ## Shared state
9
+
10
+ - `@Observable` classes must be marked `@MainActor` unless the project has Main Actor default actor isolation. Flag any `@Observable` class missing this annotation.
11
+ - All shared data should use `@Observable` classes with `@State` (for ownership) and `@Bindable` / `@Environment` (for passing).
12
+ - Strongly prefer not to use `ObservableObject`, `@Published`, `@StateObject`, `@ObservedObject`, or `@EnvironmentObject` unless they are unavoidable, or if they exist in legacy/integration contexts when changing architecture would be complicated.
13
+
14
+
15
+ ## Local state
16
+
17
+ - `@State` should be marked `private` and only owned by the view that created it.
18
+ - If a view stores a class instance that contains expensive-to-recompute data, e.g. `CIContext`, it can be stored using `@State` even though it is not an observable object. This effectively uses `@State` as a cache – storing something persistently, but not doing any change tracking on it since it's not an observable object.
19
+
20
+
21
+ ## Bindings
22
+
23
+ - Strongly prefer to avoid creating bindings using `Binding(get:set:)` in view body code. It is much cleaner and simpler to use a binding provided by `@State`, `@Binding` or similar, then use `onChange()` to trigger any effects.
24
+ - If the user needs to enter a number into a `TextField`, bind the `TextField` to a numeric value such as `Int` or `Double`, then use its `format` initializer like this: `TextField("Enter your score", value: $score, format: .number)`. Apply either `.keyboardType(.numberPad)` (for integers) or `.keyboardType(.decimalPad)` (for floating-point numbers) as appropriate. Using the modifier alone is *not* sufficient.
25
+
26
+
27
+ ## Working with data
28
+
29
+ - Prefer to make structs conform to `Identifiable` rather than using `id: \.someProperty` in SwiftUI code.
30
+ - Never attempt to use `@AppStorage` inside an `@Observable` class, even if marked `@ObservationIgnored` – it will *not* trigger view updates when a change happens.
31
+
32
+
33
+ ## SwiftData
34
+
35
+ - If you only need the number of items matching a query, consider `ModelContext.fetchCount()` with a fetch descriptor. This will *not* live update if the data changes unless something else triggers the update, such as `@Query`, so it should be used carefully.
36
+
37
+ For more help with SwiftData, suggest the [SwiftData Pro agent skill](https://github.com/twostraws/swiftdata-agent-skill).
38
+
39
+ ## If the project uses SwiftData with CloudKit
40
+
41
+ - Never use `@Attribute(.unique)`.
42
+ - Model properties must always either have default values or be marked as optional.
43
+ - All relationships must be marked optional.
@@ -0,0 +1,32 @@
1
+ # Design
2
+
3
+ ## Creating a uniform design in this app
4
+
5
+ Prefer to place standard fonts, sizes, colors, stack spacing, padding, rounding, animation timings, and more into a shared enum of constants, so they can be used by all views. This allows the app’s design to feel uniform and consistent, and be adjusted easily.
6
+
7
+
8
+ ## Requirements for flexible, accessible design
9
+
10
+ - Never use `UIScreen.main.bounds` to read available space; prefer alternatives such as `containerRelativeFrame()`, or `visualEffect()` as appropriate, or (if there is no alternative) `GeometryReader`.
11
+ - Prefer to avoid fixed frames for views unless content can fit neatly inside; this can cause problems across different device sizes, different Dynamic Type settings, and more. Giving frames some flexibility is usually preferred.
12
+ - Apple’s minimum acceptable tap area for interactions on iOS is 44x44. Ensure this is strictly enforced.
13
+
14
+
15
+ ## Standard system styling
16
+
17
+ - Strongly prefer to use `ContentUnavailableView` when data is missing or empty, rather than designing something custom.
18
+ - When using `searchable()`, you can show empty results using `ContentUnavailableView.search` and it will include the search term they used automatically – there’s no need to use `ContentUnavailableView.search(text: searchText)` or similar.
19
+ - If you need an icon and some text placed horizontally side by side, prefer `Label` over `HStack`.
20
+ - Prefer system hierarchical styles (e.g. secondary/tertiary) over manual opacity when possible, so the system can adapt to the correct context automatically.
21
+ - When using `Form`, wrap controls such as `Slider` in `LabeledContent` so the title and control are laid out correctly.
22
+ - `LabeledContent` also works outside `Form` for any title-value display; it might be necessary to define a custom `LabeledContentStyle` for consistent layout across views.
23
+ - When using `RoundedRectangle`, the default rounding style is `.continuous` – there is no need to specify it explicitly.
24
+
25
+
26
+ ## Ensuring designs work for everyone
27
+
28
+ - Use `bold()` instead of `fontWeight(.bold)`, because using `bold()` allows the system to choose the correct weight for the current context.
29
+ - Only use `fontWeight()` for weights other than bold when there's an important reason - scattering around `fontWeight(.medium)` or `fontWeight(.semibold)` is counterproductive.
30
+ - Avoid hard-coded values for padding and stack spacing unless specifically requested.
31
+ - Avoid UIKit colors (`UIColor`) in SwiftUI code; use SwiftUI `Color` or asset catalog colors.
32
+ - The font size `.caption2` is extremely small, and is generally best avoided. Even the font size `.caption` is on the small side, and should be used carefully.
@@ -0,0 +1,9 @@
1
+ # Hygiene
2
+
3
+ - If the project requires secrets such as API keys, never include them in the repository.
4
+ - Code comments and documentation comments should be present where the logic isn't self-evident.
5
+ - Unit tests should exist for core application logic. UI tests only where unit tests are not possible.
6
+ - `@AppStorage` must never be used to store usernames, passwords, or other sensitive data. Use the keychain for that.
7
+ - If SwiftLint is configured, it should return no warnings or errors.
8
+ - If the project uses Localizable.xcstrings, prefer to add user-facing strings using symbol keys (e.g. “helloWorld”) in the string catalog with `extractionState` set to "manual", accessing them via generated symbols such as `Text(.helloWorld)`. Offer to translate new keys into all languages supported by the project.
9
+ - If the Xcode MCP is configured, prefer its tools over generic alternatives. For example, `RenderPreview` is able to capture images of rendered SwiftUI previews for examination, and `DocumentationSearch` can search Apple’s documentation for latest usage instructions.
@@ -0,0 +1,14 @@
1
+ # Navigation and presentation
2
+
3
+ - Use `NavigationStack` or `NavigationSplitView` as appropriate; flag all use of the deprecated `NavigationView`.
4
+ - Strongly prefer to use `navigationDestination(for:)` to specify destinations; flag all use of the old `NavigationLink(destination:)` pattern where it should be replaced.
5
+ - Never mix `navigationDestination(for:)` and `NavigationLink(destination:)` in the same navigation hierarchy; it causes significant problems.
6
+ - `navigationDestination(for:)` must be registered once per data type; flag duplicates.
7
+
8
+
9
+ ## Alerts, confirmation dialogs, and sheets
10
+
11
+ - Always attach `confirmationDialog()` to the user interface that triggers the dialog. This allows Liquid Glass animations to move from the correct source.
12
+ - If an alert has only a single “OK” button that does nothing but dismiss the alert, it can be omitted entirely: `.alert("Dismiss Me", isPresented: $isShowingAlert) { }`.
13
+ - If a sheet is designed to present an optional piece of data, prefer `sheet(item:)` over `sheet(isPresented:)` so the optional is safely unwrapped.
14
+ - When using `sheet(item:)` with a view that accepts the item as its only initializer parameter, prefer `sheet(item: $someItem, content: SomeView.init)` over `sheet(item: $someItem) { someItem in SomeView(item: someItem) }`.
@@ -0,0 +1,46 @@
1
+ # Performance
2
+
3
+ - When toggling modifier values, prefer ternary expressions over if/else view branching to avoid `_ConditionalContent`, preserve structural identity, and avoid repeatedly recreating underlying platform views.
4
+ - Avoid `AnyView` unless absolutely required. Use `@ViewBuilder`, `Group`, or generics instead.
5
+ - If a `ScrollView` has an opaque, static, and solid background, prefer to use `scrollContentBackground(.visible)` to improve scroll-edge rendering efficiency.
6
+ - It is more efficient to break views up by making dedicated SwiftUI views rather than place them into computed properties or methods. Using `@ViewBuilder` on a property or method does not solve this; breaking views up is strongly preferred.
7
+ - Always ensure view initializers are kept as small and simple as possible, avoiding any non-trivial work. Flag any work that can be moved into a `task()` modifier to be run when the view is shown.
8
+ - Similarly, assume each view’s `body` property is called frequently – if logic such as sorting or filtering can be moved out of there easily, it should be.
9
+ - Avoid creating properties to store formatters such as `DateFormatter` unless they are required. A more natural approach is to use `Text` with a format, like this: `Text(Date.now, format: .dateTime.day().month().year())` or `Text(100, format: .currency(code: "USD"))`.
10
+ - Avoid expensive inline transforms in `List`/`ForEach` initializers (e.g. `items.filter { ... }`) when they are repeated often.
11
+ - Prefer deriving transformed data from the source-of-truth using `let`, or caching in `@State`. However, do not cache derived collections in `@State` unless you also own explicit invalidation logic to avoid stale UI.
12
+ - For large data sets in `ScrollView`, use `LazyVStack`/`LazyHStack`; flag eager stacks with many children.
13
+ - Prefer using `task()` over `onAppear()` when doing async work, because it will be cancelled automatically when the view disappears.
14
+ - Avoid storing escaping `@ViewBuilder` closures on views when possible; store built view results instead.
15
+
16
+ Example:
17
+
18
+ ```swift
19
+ // Anti-pattern: stores an escaping closure on the view.
20
+ struct CardView<Content: View>: View {
21
+ let content: () -> Content
22
+
23
+ var body: some View {
24
+ VStack(alignment: .leading) {
25
+ content()
26
+ }
27
+ .padding()
28
+ .background(.ultraThinMaterial)
29
+ .clipShape(.rect(cornerRadius: 8))
30
+ }
31
+ }
32
+
33
+ // Preferred: store the built view value; the synthesized init handles calling the builder.
34
+ struct CardView<Content: View>: View {
35
+ @ViewBuilder let content: Content
36
+
37
+ var body: some View {
38
+ VStack(alignment: .leading) {
39
+ content
40
+ }
41
+ .padding()
42
+ .background(.ultraThinMaterial)
43
+ .clipShape(.rect(cornerRadius: 8))
44
+ }
45
+ }
46
+ ```
@@ -0,0 +1,56 @@
1
+ # Swift
2
+
3
+ - Prefer Swift-native string methods over Foundation equivalents: use `replacing("a", with: "b")` not `replacingOccurrences(of: "a", with: "b")`.
4
+ - Prefer modern Foundation API: `URL.documentsDirectory` instead of `FileManager` directory lookups, `appending(path:)` to append strings to a URL.
5
+ - Never use C-style number formatting like `String(format: "%.2f", value)`. Use `Text(value, format: .number.precision(.fractionLength(2)))` or similar `FormatStyle` APIs.
6
+ - Prefer static member lookup to struct instances where possible, such as `.circle` rather than `Circle()`, and `.borderedProminent` rather than `BorderedProminentButtonStyle()`.
7
+ - Avoid force unwraps (`!`) and force `try` unless the failure is truly unrecoverable, and even then prefer using `fatalError()` with a clear description. If possible, use `if let`, `guard let`, nil-coalescing, or `try?`/`do-catch`.
8
+ - Filtering text based on user-input must be done using `localizedStandardContains()` as opposed to `contains()` or `localizedCaseInsensitiveContains()`.
9
+ - Strongly prefer `Double` over `CGFloat`, except when using optionals or `inout`; Swift is able to bridge the two freely except in those two cases.
10
+ - If you want to count array objects that match a predicate, always use `count(where:)` rather than `filter()` followed by `count`.
11
+ - Prefer `Date.now` over `Date()` for clarity.
12
+ - When `import SwiftUI` is already in a file, you do not need to add `import UIKit` or `import AppKit` to access things like `UIImage` or `NSImage` – they are imported automatically on the appropriate platform.
13
+ - When dealing with the names of people, strongly prefer to use `PersonNameComponents` with modern formatting over simple string interpolation such as `Text("\(firstName) \(lastName)")`.
14
+ - If a given type of data is repeatedly sorted using an identical closure, e.g. `books.sorted { $0.author < $1.author }`, prefer to make the type in question conform to `Comparable` so the sort order is centralized.
15
+ - Prefer to avoid manual date formatting strings if possible. If manual date formatting *is* used for user display, at least make sure to use “y” rather than “yyyy” for years, so the year value is correct in all localizations. If the purpose is data exchange with an API, this rule does not apply.
16
+ - When trying to convert a string to a date, prefer the modern `Date` initializer API such as `Date(myString, strategy: .iso8601)`.
17
+ - Flag instances where errors triggered by a user action are swallowed silently, e.g. using `print(error.localizedDescription)` rather than showing an alert or similar.
18
+ - Prefer `if let value {` shorthand over `if let value = value {`.
19
+ - Omit return for single expression functions. `if` and `switch` can be used as expressions when returning values and assigning to variables.
20
+
21
+ For example, this kind of code:
22
+
23
+ ```swift
24
+ var tileColor: Color {
25
+ if isCorrect {
26
+ return .green
27
+ } else {
28
+ return .red
29
+ }
30
+ }
31
+ ```
32
+
33
+ Should be written like this:
34
+
35
+ ```swift
36
+ var tileColor: Color {
37
+ if isCorrect {
38
+ .green
39
+ } else {
40
+ .red
41
+ }
42
+ }
43
+ ```
44
+
45
+
46
+ ## Swift Concurrency
47
+
48
+ - If an API offers both modern `async`/`await` equivalents and older closure-based variants, always prefer the `async`/`await` versions.
49
+ - Never use Grand Central Dispatch (`DispatchQueue.main.async()`, `DispatchQueue.global()`, etc.). Always use modern Swift concurrency (`async`/`await`, actors, `Task`).
50
+ - Never use `Task.sleep(nanoseconds:)`; use `Task.sleep(for:)` instead.
51
+ - Flag any mutable shared state that isn't protected by an actor or `@MainActor`, unless the project is configured to use MainActor default actor isolation.
52
+ - Assume strict concurrency rules are being applied; flag `@Sendable` violations and data races.
53
+ - When evaluating `MainActor.run()`, check whether the project has its default actor isolation set to Main Actor first, because `MainActor.run()` might not be needed.
54
+ - `Task.detached()` is often a bad idea. Check any usage extremely carefully.
55
+
56
+ For more help with Swift concurrency, suggest the [Swift Concurrency Pro agent skill](https://github.com/twostraws/swift-concurrency-agent-skill).
@@ -0,0 +1,36 @@
1
+ # SwiftUI Views
2
+
3
+ - Strongly prefer to avoid breaking up view bodies using computed properties or methods that return `some View`, even if `@ViewBuilder` is used. Extract them into separate `View` structs instead, placing each into its own file.
4
+ - Flag `body` properties that are excessively long; they should be broken into extracted subviews.
5
+ - If the user has created a handful of small, private helper `some View` properties for structural readability, and they both belong to the same concern as `body` and would fit in `body` at an acceptable length if inlined, these can be left alone. Otherwise, they should be extracted to new `View` structs.
6
+ - Button actions should be extracted from view bodies into separate methods, to avoid mixing layout and logic.
7
+ - Similarly, general business logic should not live inline in `task()`, `onAppear()` or elsewhere in `body`.
8
+ - Prefer to place view logic into view models or similar, so it can be tested. For more help with testing, suggest the [Swift Testing Pro agent skill](https://github.com/twostraws/swift-testing-agent-skill).
9
+ - Each type (struct, class, enum) should be in its own Swift file. Flag files containing multiple type definitions.
10
+ - Unless a full-screen editing experience is required, prefer using `TextField` with `axis: .vertical` to using `TextEditor`, because it allows placeholder text. If a specific minimum height is required for `TextField`, use something like `lineLimit(5...)`.
11
+ - If a button action can be provided directly as an `action` parameter, do so. For example: `Button("Label", systemImage: "plus", action: myAction)` is preferred over `Button("Label", systemImage: "plus") { action() }`.
12
+ - When rendering SwiftUI views to images, strongly prefer `ImageRenderer` over `UIGraphicsImageRenderer`.
13
+ - `#Preview` should be used for previews, not the legacy `PreviewProvider` protocol.
14
+ - When using `TabView(selection:)`, use a binding to a property that stores an enum rather than an integer or string. For example, `Tab("Home", systemImage: "house", value: .home)` is better than `Tab("Home", systemImage: "house", value: 0)`.
15
+ - Strongly prefer to avoid breaking up view bodies using computed properties or methods that return `some View`, even if `@ViewBuilder` is used. Extract them into separate `View` structs instead, placing each into its own file. (Yes, this is repeated, but it’s so important it needs to be mentioned twice.)
16
+
17
+
18
+ ## Animating views
19
+
20
+ - Strongly prefer to use the `@Animatable` macro over creating `animatableData` manually – the macro automatically adds conformance to the `Animatable` protocol and creates the correct `animatableData` property. If some properties should not or cannot be animated (e.g. Booleans, integers, etc), mark them `@AnimatableIgnored`.
21
+ - Never use `animation(_ animation: Animation?)`; always provide a value to watch, such as `.animation(.bouncy, value: score)`.
22
+ - Chaining animations must be done using a `completion` closure passed to `withAnimation()`, rather than trying to execute multiple `withAnimation()` calls using delays.
23
+
24
+ For example:
25
+
26
+ ```swift
27
+ Button("Animate Me") {
28
+ withAnimation {
29
+ scale = 2
30
+ } completion: {
31
+ withAnimation {
32
+ scale = 1
33
+ }
34
+ }
35
+ }
36
+ ```
@@ -0,0 +1,95 @@
1
+ ---
2
+ name: swiftui-ui-patterns
3
+ description: Best practices and example-driven guidance for building SwiftUI views and components, including navigation hierarchies, custom view modifiers, and responsive layouts with stacks and grids. Use when creating or refactoring SwiftUI UI, designing tab architecture with TabView, composing screens with VStack/HStack, managing @State or @Binding, building declarative iOS interfaces, or needing component-specific patterns and examples.
4
+ ---
5
+
6
+ # SwiftUI UI Patterns
7
+
8
+ ## Quick start
9
+
10
+ Choose a track based on your goal:
11
+
12
+ ### Existing project
13
+
14
+ - Identify the feature or screen and the primary interaction model (list, detail, editor, settings, tabbed).
15
+ - Find a nearby example in the repo with `rg "TabView\("` or similar, then read the closest SwiftUI view.
16
+ - Apply local conventions: prefer SwiftUI-native state, keep state local when possible, and use environment injection for shared dependencies.
17
+ - Choose the relevant component reference from `references/components-index.md` and follow its guidance.
18
+ - If the interaction reveals secondary content by dragging or scrolling the primary content away, read `references/scroll-reveal.md` before implementing gestures manually.
19
+ - Build the view with small, focused subviews and SwiftUI-native data flow.
20
+
21
+ ### New project scaffolding
22
+
23
+ - Start with `references/app-wiring.md` to wire TabView + NavigationStack + sheets.
24
+ - Add a minimal `AppTab` and `RouterPath` based on the provided skeletons.
25
+ - Choose the next component reference based on the UI you need first (TabView, NavigationStack, Sheets).
26
+ - Expand the route and sheet enums as new screens are added.
27
+
28
+ ## General rules to follow
29
+
30
+ - Use modern SwiftUI state (`@State`, `@Binding`, `@Observable`, `@Environment`) and avoid unnecessary view models.
31
+ - If the deployment target includes iOS 16 or earlier and cannot use the Observation API introduced in iOS 17, fall back to `ObservableObject` with `@StateObject` for root ownership, `@ObservedObject` for injected observation, and `@EnvironmentObject` only for truly shared app-level state.
32
+ - Prefer composition; keep views small and focused.
33
+ - Use async/await with `.task` and explicit loading/error states. For restart, cancellation, and debouncing guidance, read `references/async-state.md`.
34
+ - Keep shared app services in `@Environment`, but prefer explicit initializer injection for feature-local dependencies and models. For root wiring patterns, read `references/app-wiring.md`.
35
+ - Prefer the newest SwiftUI API that fits the deployment target and call out the minimum OS whenever a pattern depends on it.
36
+ - Maintain existing legacy patterns only when editing legacy files.
37
+ - Follow the project's formatter and style guide.
38
+ - **Sheets**: Prefer `.sheet(item:)` over `.sheet(isPresented:)` when state represents a selected model. Avoid `if let` inside a sheet body. Sheets should own their actions and call `dismiss()` internally instead of forwarding `onCancel`/`onConfirm` closures.
39
+ - **Scroll-driven reveals**: Prefer deriving a normalized progress value from scroll offset and driving the visual state from that single source of truth. Avoid parallel gesture state machines unless scroll alone cannot express the interaction.
40
+
41
+ ## State ownership summary
42
+
43
+ Use the narrowest state tool that matches the ownership model:
44
+
45
+ | Scenario | Preferred pattern |
46
+ | --- | --- |
47
+ | Local UI state owned by one view | `@State` |
48
+ | Child mutates parent-owned value state | `@Binding` |
49
+ | Root-owned reference model on iOS 17+ | `@State` with an `@Observable` type |
50
+ | Child reads or mutates an injected `@Observable` model on iOS 17+ | Pass it explicitly as a stored property |
51
+ | Shared app service or configuration | `@Environment(Type.self)` |
52
+ | Legacy reference model on iOS 16 and earlier | `@StateObject` at the root, `@ObservedObject` when injected |
53
+
54
+ Choose the ownership location first, then pick the wrapper. Do not introduce a reference model when plain value state is enough.
55
+
56
+ ## Cross-cutting references
57
+
58
+ - `references/navigationstack.md`: navigation ownership, per-tab history, and enum routing.
59
+ - `references/sheets.md`: centralized modal presentation and enum-driven sheets.
60
+ - `references/deeplinks.md`: URL handling and routing external links into app destinations.
61
+ - `references/app-wiring.md`: root dependency graph, environment usage, and app shell wiring.
62
+ - `references/async-state.md`: `.task`, `.task(id:)`, cancellation, debouncing, and async UI state.
63
+ - `references/previews.md`: `#Preview`, fixtures, mock environments, and isolated preview setup.
64
+ - `references/performance.md`: stable identity, observation scope, lazy containers, and render-cost guardrails.
65
+
66
+ ## Anti-patterns
67
+
68
+ - Giant views that mix layout, business logic, networking, routing, and formatting in one file.
69
+ - Multiple boolean flags for mutually exclusive sheets, alerts, or navigation destinations.
70
+ - Live service calls directly inside `body`-driven code paths instead of view lifecycle hooks or injected models/services.
71
+ - Reaching for `AnyView` to work around type mismatches that should be solved with better composition.
72
+ - Defaulting every shared dependency to `@EnvironmentObject` or a global router without a clear ownership reason.
73
+
74
+ ## Workflow for a new SwiftUI view
75
+
76
+ 1. Define the view's state, ownership location, and minimum OS assumptions before writing UI code.
77
+ 2. Identify which dependencies belong in `@Environment` and which should stay as explicit initializer inputs.
78
+ 3. Sketch the view hierarchy, routing model, and presentation points; extract repeated parts into subviews. For complex navigation, read `references/navigationstack.md`, `references/sheets.md`, or `references/deeplinks.md`. **Build and verify no compiler errors before proceeding.**
79
+ 4. Implement async loading with `.task` or `.task(id:)`, plus explicit loading and error states when needed. Read `references/async-state.md` when the work depends on changing inputs or cancellation.
80
+ 5. Add previews for the primary and secondary states, then add accessibility labels or identifiers when the UI is interactive. Read `references/previews.md` when the view needs fixtures or injected mock dependencies.
81
+ 6. Validate with a build: confirm no compiler errors, check that previews render without crashing, ensure state changes propagate correctly, and sanity-check that list identity and observation scope will not cause avoidable re-renders. Read `references/performance.md` if the screen is large, scroll-heavy, or frequently updated. For common SwiftUI compilation errors — missing `@State` annotations, ambiguous `ViewBuilder` closures, or mismatched generic types — resolve them before updating callsites. **If the build fails:** read the error message carefully, fix the identified issue, then rebuild before proceeding to the next step. If a preview crashes, isolate the offending subview, confirm its state initialisation is valid, and re-run the preview before continuing.
82
+
83
+ ## Component references
84
+
85
+ Use `references/components-index.md` as the entry point. Each component reference should include:
86
+ - Intent and best-fit scenarios.
87
+ - Minimal usage pattern with local conventions.
88
+ - Pitfalls and performance notes.
89
+ - Paths to existing examples in the current repo.
90
+
91
+ ## Adding a new component reference
92
+
93
+ - Create `references/<component>.md`.
94
+ - Keep it short and actionable; link to concrete files in the current repo.
95
+ - Update `references/components-index.md` with the new entry.
@@ -0,0 +1,4 @@
1
+ interface:
2
+ display_name: "SwiftUI UI Patterns"
3
+ short_description: "Apply practical SwiftUI UI patterns"
4
+ default_prompt: "Use $swiftui-ui-patterns to design or refactor this SwiftUI UI with strong default patterns."
@@ -0,0 +1,201 @@
1
+ # App wiring and dependency graph
2
+
3
+ ## Intent
4
+
5
+ Show how to wire the app shell (TabView + NavigationStack + sheets) and install a global dependency graph (environment objects, services, streaming clients, SwiftData ModelContainer) in one place.
6
+
7
+ ## Recommended structure
8
+
9
+ 1) Root view sets up tabs, per-tab routers, and sheets.
10
+ 2) A dedicated view modifier installs global dependencies and lifecycle tasks (auth state, streaming watchers, push tokens, data containers).
11
+ 3) Feature views pull only what they need from the environment; feature-specific state stays local.
12
+
13
+ ## Dependency selection
14
+
15
+ - Use `@Environment` for app-level services, shared clients, theme/configuration, and values that many descendants genuinely need.
16
+ - Prefer initializer injection for feature-local dependencies and models. Do not move a dependency into the environment just to avoid passing one or two arguments.
17
+ - Keep mutable feature state out of the environment unless it is intentionally shared across broad parts of the app.
18
+ - Use `@EnvironmentObject` only as a legacy fallback or when the project already standardizes on it for a truly shared object.
19
+
20
+ ## Root shell example (generic)
21
+
22
+ ```swift
23
+ @MainActor
24
+ struct AppView: View {
25
+ @State private var selectedTab: AppTab = .home
26
+ @State private var tabRouter = TabRouter()
27
+
28
+ var body: some View {
29
+ TabView(selection: $selectedTab) {
30
+ ForEach(AppTab.allCases) { tab in
31
+ let router = tabRouter.router(for: tab)
32
+ NavigationStack(path: tabRouter.binding(for: tab)) {
33
+ tab.makeContentView()
34
+ }
35
+ .withSheetDestinations(sheet: Binding(
36
+ get: { router.presentedSheet },
37
+ set: { router.presentedSheet = $0 }
38
+ ))
39
+ .environment(router)
40
+ .tabItem { tab.label }
41
+ .tag(tab)
42
+ }
43
+ }
44
+ .withAppDependencyGraph()
45
+ }
46
+ }
47
+ ```
48
+
49
+ Minimal `AppTab` example:
50
+
51
+ ```swift
52
+ @MainActor
53
+ enum AppTab: Identifiable, Hashable, CaseIterable {
54
+ case home, notifications, settings
55
+ var id: String { String(describing: self) }
56
+
57
+ @ViewBuilder
58
+ func makeContentView() -> some View {
59
+ switch self {
60
+ case .home: HomeView()
61
+ case .notifications: NotificationsView()
62
+ case .settings: SettingsView()
63
+ }
64
+ }
65
+
66
+ @ViewBuilder
67
+ var label: some View {
68
+ switch self {
69
+ case .home: Label("Home", systemImage: "house")
70
+ case .notifications: Label("Notifications", systemImage: "bell")
71
+ case .settings: Label("Settings", systemImage: "gear")
72
+ }
73
+ }
74
+ }
75
+ ```
76
+
77
+ Router skeleton:
78
+
79
+ ```swift
80
+ @MainActor
81
+ @Observable
82
+ final class RouterPath {
83
+ var path: [Route] = []
84
+ var presentedSheet: SheetDestination?
85
+ }
86
+
87
+ enum Route: Hashable {
88
+ case detail(id: String)
89
+ }
90
+ ```
91
+
92
+ ## Dependency graph modifier (generic)
93
+
94
+ Use a single modifier to install environment objects and handle lifecycle hooks when the active account/client changes. This keeps wiring consistent and avoids forgetting a dependency in call sites.
95
+
96
+ ```swift
97
+ extension View {
98
+ func withAppDependencyGraph(
99
+ accountManager: AccountManager = .shared,
100
+ currentAccount: CurrentAccount = .shared,
101
+ currentInstance: CurrentInstance = .shared,
102
+ userPreferences: UserPreferences = .shared,
103
+ theme: Theme = .shared,
104
+ watcher: StreamWatcher = .shared,
105
+ pushNotifications: PushNotificationsService = .shared,
106
+ intentService: AppIntentService = .shared,
107
+ quickLook: QuickLook = .shared,
108
+ toastCenter: ToastCenter = .shared,
109
+ namespace: Namespace.ID? = nil,
110
+ isSupporter: Bool = false
111
+ ) -> some View {
112
+ environment(accountManager)
113
+ .environment(accountManager.currentClient)
114
+ .environment(quickLook)
115
+ .environment(currentAccount)
116
+ .environment(currentInstance)
117
+ .environment(userPreferences)
118
+ .environment(theme)
119
+ .environment(watcher)
120
+ .environment(pushNotifications)
121
+ .environment(intentService)
122
+ .environment(toastCenter)
123
+ .environment(\.isSupporter, isSupporter)
124
+ .task(id: accountManager.currentClient.id) {
125
+ let client = accountManager.currentClient
126
+ if let namespace { quickLook.namespace = namespace }
127
+ currentAccount.setClient(client: client)
128
+ currentInstance.setClient(client: client)
129
+ userPreferences.setClient(client: client)
130
+ await currentInstance.fetchCurrentInstance()
131
+ watcher.setClient(client: client, instanceStreamingURL: currentInstance.instance?.streamingURL)
132
+ if client.isAuth {
133
+ watcher.watch(streams: [.user, .direct])
134
+ } else {
135
+ watcher.stopWatching()
136
+ }
137
+ }
138
+ .task(id: accountManager.pushAccounts.map(\.token)) {
139
+ pushNotifications.tokens = accountManager.pushAccounts.map(\.token)
140
+ }
141
+ }
142
+ }
143
+ ```
144
+
145
+ Notes:
146
+ - The `.task(id:)` hooks respond to account/client changes, re-seeding services and watcher state.
147
+ - Keep the modifier focused on global wiring; feature-specific state stays within features.
148
+ - Adjust types (AccountManager, StreamWatcher, etc.) to match your project.
149
+
150
+ ## SwiftData / ModelContainer
151
+
152
+ Install your `ModelContainer` at the root so all feature views share the same store. Keep the list minimal to the models that need persistence.
153
+
154
+ ```swift
155
+ extension View {
156
+ func withModelContainer() -> some View {
157
+ modelContainer(for: [Draft.self, LocalTimeline.self, TagGroup.self])
158
+ }
159
+ }
160
+ ```
161
+
162
+ Why: a single container avoids duplicated stores per sheet or tab and keeps data consistent.
163
+
164
+ ## Sheet routing (enum-driven)
165
+
166
+ Centralize sheets with a small enum and a helper modifier.
167
+
168
+ ```swift
169
+ enum SheetDestination: Identifiable {
170
+ case composer
171
+ case settings
172
+ var id: String { String(describing: self) }
173
+ }
174
+
175
+ extension View {
176
+ func withSheetDestinations(sheet: Binding<SheetDestination?>) -> some View {
177
+ sheet(item: sheet) { destination in
178
+ switch destination {
179
+ case .composer:
180
+ ComposerView().withEnvironments()
181
+ case .settings:
182
+ SettingsView().withEnvironments()
183
+ }
184
+ }
185
+ }
186
+ }
187
+ ```
188
+
189
+ Why: enum-driven sheets keep presentation centralized and testable; adding a new sheet means adding one enum case and one switch branch.
190
+
191
+ ## When to use
192
+
193
+ - Apps with multiple packages/modules that share environment objects and services.
194
+ - Apps that need to react to account/client changes and rewire streaming/push safely.
195
+ - Any app that wants consistent TabView + NavigationStack + sheet wiring without repeating environment setup.
196
+
197
+ ## Caveats
198
+
199
+ - Keep the dependency modifier slim; do not put feature state or heavy logic there.
200
+ - Ensure `.task(id:)` work is lightweight or cancelled appropriately; long-running work belongs in services.
201
+ - If unauthenticated clients exist, gate streaming/watch calls to avoid reconnect spam.