opencode-skills-antigravity 1.0.12 → 1.0.14

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 (109) hide show
  1. package/bundled-skills/app-store-changelog/SKILL.md +75 -0
  2. package/bundled-skills/app-store-changelog/agents/openai.yaml +4 -0
  3. package/bundled-skills/app-store-changelog/references/release-notes-guidelines.md +34 -0
  4. package/bundled-skills/app-store-changelog/scripts/collect_release_changes.sh +33 -0
  5. package/bundled-skills/docs/integrations/jetski-cortex.md +3 -3
  6. package/bundled-skills/docs/integrations/jetski-gemini-loader/README.md +1 -1
  7. package/bundled-skills/docs/maintainers/repo-growth-seo.md +3 -3
  8. package/bundled-skills/docs/maintainers/skills-update-guide.md +1 -1
  9. package/bundled-skills/docs/sources/sources.md +10 -0
  10. package/bundled-skills/docs/users/bundles.md +9 -1
  11. package/bundled-skills/docs/users/claude-code-skills.md +1 -1
  12. package/bundled-skills/docs/users/faq.md +36 -0
  13. package/bundled-skills/docs/users/gemini-cli-skills.md +1 -1
  14. package/bundled-skills/docs/users/getting-started.md +1 -1
  15. package/bundled-skills/docs/users/kiro-integration.md +1 -1
  16. package/bundled-skills/docs/users/usage.md +14 -4
  17. package/bundled-skills/docs/users/visual-guide.md +4 -4
  18. package/bundled-skills/github/SKILL.md +76 -0
  19. package/bundled-skills/github/agents/openai.yaml +4 -0
  20. package/bundled-skills/ios-debugger-agent/SKILL.md +59 -0
  21. package/bundled-skills/ios-debugger-agent/agents/openai.yaml +4 -0
  22. package/bundled-skills/macos-menubar-tuist-app/SKILL.md +109 -0
  23. package/bundled-skills/macos-menubar-tuist-app/agents/openai.yaml +4 -0
  24. package/bundled-skills/macos-spm-app-packaging/SKILL.md +105 -0
  25. package/bundled-skills/macos-spm-app-packaging/agents/openai.yaml +4 -0
  26. package/bundled-skills/macos-spm-app-packaging/assets/templates/bootstrap/Package.swift +17 -0
  27. package/bundled-skills/macos-spm-app-packaging/assets/templates/bootstrap/Sources/MyApp/Resources/.keep +0 -0
  28. package/bundled-skills/macos-spm-app-packaging/assets/templates/bootstrap/Sources/MyApp/main.swift +11 -0
  29. package/bundled-skills/macos-spm-app-packaging/assets/templates/bootstrap/version.env +2 -0
  30. package/bundled-skills/macos-spm-app-packaging/assets/templates/build_icon.sh +49 -0
  31. package/bundled-skills/macos-spm-app-packaging/assets/templates/compile_and_run.sh +63 -0
  32. package/bundled-skills/macos-spm-app-packaging/assets/templates/launch.sh +28 -0
  33. package/bundled-skills/macos-spm-app-packaging/assets/templates/make_appcast.sh +82 -0
  34. package/bundled-skills/macos-spm-app-packaging/assets/templates/package_app.sh +206 -0
  35. package/bundled-skills/macos-spm-app-packaging/assets/templates/setup_dev_signing.sh +52 -0
  36. package/bundled-skills/macos-spm-app-packaging/assets/templates/sign-and-notarize.sh +52 -0
  37. package/bundled-skills/macos-spm-app-packaging/assets/templates/version.env +2 -0
  38. package/bundled-skills/macos-spm-app-packaging/references/packaging.md +17 -0
  39. package/bundled-skills/macos-spm-app-packaging/references/release.md +32 -0
  40. package/bundled-skills/macos-spm-app-packaging/references/scaffold.md +79 -0
  41. package/bundled-skills/orchestrate-batch-refactor/SKILL.md +97 -0
  42. package/bundled-skills/orchestrate-batch-refactor/agents/openai.yaml +4 -0
  43. package/bundled-skills/orchestrate-batch-refactor/references/agent-prompt-templates.md +53 -0
  44. package/bundled-skills/orchestrate-batch-refactor/references/work-packet-template.md +31 -0
  45. package/bundled-skills/project-skill-audit/SKILL.md +190 -0
  46. package/bundled-skills/project-skill-audit/agents/openai.yaml +4 -0
  47. package/bundled-skills/react-component-performance/SKILL.md +135 -0
  48. package/bundled-skills/react-component-performance/agents/openai.yaml +4 -0
  49. package/bundled-skills/react-component-performance/references/examples.md +88 -0
  50. package/bundled-skills/simplify-code/SKILL.md +179 -0
  51. package/bundled-skills/snowflake-development/SKILL.md +233 -0
  52. package/bundled-skills/swift-concurrency-expert/SKILL.md +113 -0
  53. package/bundled-skills/swift-concurrency-expert/agents/openai.yaml +4 -0
  54. package/bundled-skills/swift-concurrency-expert/references/approachable-concurrency.md +63 -0
  55. package/bundled-skills/swift-concurrency-expert/references/swift-6-2-concurrency.md +272 -0
  56. package/bundled-skills/swift-concurrency-expert/references/swiftui-concurrency-tour-wwdc.md +33 -0
  57. package/bundled-skills/swiftui-liquid-glass/SKILL.md +98 -0
  58. package/bundled-skills/swiftui-liquid-glass/agents/openai.yaml +4 -0
  59. package/bundled-skills/swiftui-liquid-glass/references/liquid-glass.md +280 -0
  60. package/bundled-skills/swiftui-performance-audit/SKILL.md +114 -0
  61. package/bundled-skills/swiftui-performance-audit/agents/openai.yaml +4 -0
  62. package/bundled-skills/swiftui-performance-audit/references/code-smells.md +150 -0
  63. package/bundled-skills/swiftui-performance-audit/references/demystify-swiftui-performance-wwdc23.md +46 -0
  64. package/bundled-skills/swiftui-performance-audit/references/optimizing-swiftui-performance-instruments.md +29 -0
  65. package/bundled-skills/swiftui-performance-audit/references/profiling-intake.md +44 -0
  66. package/bundled-skills/swiftui-performance-audit/references/report-template.md +47 -0
  67. package/bundled-skills/swiftui-performance-audit/references/understanding-hangs-in-your-app.md +33 -0
  68. package/bundled-skills/swiftui-performance-audit/references/understanding-improving-swiftui-performance.md +52 -0
  69. package/bundled-skills/swiftui-ui-patterns/SKILL.md +103 -0
  70. package/bundled-skills/swiftui-ui-patterns/agents/openai.yaml +4 -0
  71. package/bundled-skills/swiftui-ui-patterns/references/app-wiring.md +201 -0
  72. package/bundled-skills/swiftui-ui-patterns/references/async-state.md +96 -0
  73. package/bundled-skills/swiftui-ui-patterns/references/components-index.md +50 -0
  74. package/bundled-skills/swiftui-ui-patterns/references/controls.md +57 -0
  75. package/bundled-skills/swiftui-ui-patterns/references/deeplinks.md +66 -0
  76. package/bundled-skills/swiftui-ui-patterns/references/focus.md +90 -0
  77. package/bundled-skills/swiftui-ui-patterns/references/form.md +97 -0
  78. package/bundled-skills/swiftui-ui-patterns/references/grids.md +71 -0
  79. package/bundled-skills/swiftui-ui-patterns/references/haptics.md +71 -0
  80. package/bundled-skills/swiftui-ui-patterns/references/input-toolbar.md +51 -0
  81. package/bundled-skills/swiftui-ui-patterns/references/lightweight-clients.md +93 -0
  82. package/bundled-skills/swiftui-ui-patterns/references/list.md +86 -0
  83. package/bundled-skills/swiftui-ui-patterns/references/loading-placeholders.md +38 -0
  84. package/bundled-skills/swiftui-ui-patterns/references/macos-settings.md +71 -0
  85. package/bundled-skills/swiftui-ui-patterns/references/matched-transitions.md +59 -0
  86. package/bundled-skills/swiftui-ui-patterns/references/media.md +73 -0
  87. package/bundled-skills/swiftui-ui-patterns/references/menu-bar.md +101 -0
  88. package/bundled-skills/swiftui-ui-patterns/references/navigationstack.md +159 -0
  89. package/bundled-skills/swiftui-ui-patterns/references/overlay.md +45 -0
  90. package/bundled-skills/swiftui-ui-patterns/references/performance.md +62 -0
  91. package/bundled-skills/swiftui-ui-patterns/references/previews.md +48 -0
  92. package/bundled-skills/swiftui-ui-patterns/references/scroll-reveal.md +133 -0
  93. package/bundled-skills/swiftui-ui-patterns/references/scrollview.md +87 -0
  94. package/bundled-skills/swiftui-ui-patterns/references/searchable.md +71 -0
  95. package/bundled-skills/swiftui-ui-patterns/references/sheets.md +155 -0
  96. package/bundled-skills/swiftui-ui-patterns/references/split-views.md +72 -0
  97. package/bundled-skills/swiftui-ui-patterns/references/tabview.md +114 -0
  98. package/bundled-skills/swiftui-ui-patterns/references/theming.md +71 -0
  99. package/bundled-skills/swiftui-ui-patterns/references/title-menus.md +93 -0
  100. package/bundled-skills/swiftui-ui-patterns/references/top-bar.md +49 -0
  101. package/bundled-skills/swiftui-view-refactor/SKILL.md +210 -0
  102. package/bundled-skills/swiftui-view-refactor/agents/openai.yaml +4 -0
  103. package/bundled-skills/swiftui-view-refactor/references/mv-patterns.md +161 -0
  104. package/bundled-skills/wordpress/SKILL.md +281 -4
  105. package/bundled-skills/wordpress-penetration-testing/SKILL.md +106 -1
  106. package/bundled-skills/wordpress-plugin-development/SKILL.md +296 -3
  107. package/bundled-skills/wordpress-theme-development/SKILL.md +316 -3
  108. package/bundled-skills/wordpress-woocommerce-development/SKILL.md +442 -2
  109. package/package.json +1 -1
@@ -0,0 +1,86 @@
1
+ # List and Section
2
+
3
+ ## Intent
4
+
5
+ Use `List` for feed-style content and settings-style rows where built-in row reuse, selection, and accessibility matter.
6
+
7
+ ## Core patterns
8
+
9
+ - Prefer `List` for long, vertically scrolling content with repeated rows.
10
+ - Use `Section` headers to group related rows.
11
+ - Pair with `ScrollViewReader` when you need scroll-to-top or jump-to-id.
12
+ - Use `.listStyle(.plain)` for modern feed layouts.
13
+ - Use `.listStyle(.grouped)` for multi-section discovery/search pages where section grouping helps.
14
+ - Apply `.scrollContentBackground(.hidden)` + a custom background when you need a themed surface.
15
+ - Use `.listRowInsets(...)` and `.listRowSeparator(.hidden)` to tune row spacing and separators.
16
+ - Use `.environment(\\.defaultMinListRowHeight, ...)` to control dense list layouts.
17
+
18
+ ## Example: feed list with scroll-to-top
19
+
20
+ ```swift
21
+ @MainActor
22
+ struct TimelineListView: View {
23
+ @Environment(\.selectedTabScrollToTop) private var selectedTabScrollToTop
24
+ @State private var scrollToId: String?
25
+
26
+ var body: some View {
27
+ ScrollViewReader { proxy in
28
+ List {
29
+ ForEach(items) { item in
30
+ TimelineRow(item: item)
31
+ .id(item.id)
32
+ .listRowInsets(.init(top: 12, leading: 16, bottom: 6, trailing: 16))
33
+ .listRowSeparator(.hidden)
34
+ }
35
+ }
36
+ .listStyle(.plain)
37
+ .environment(\\.defaultMinListRowHeight, 1)
38
+ .onChange(of: scrollToId) { _, newValue in
39
+ if let newValue {
40
+ proxy.scrollTo(newValue, anchor: .top)
41
+ scrollToId = nil
42
+ }
43
+ }
44
+ .onChange(of: selectedTabScrollToTop) { _, newValue in
45
+ if newValue == 0 {
46
+ withAnimation {
47
+ proxy.scrollTo(ScrollToView.Constants.scrollToTop, anchor: .top)
48
+ }
49
+ }
50
+ }
51
+ }
52
+ }
53
+ }
54
+ ```
55
+
56
+ ## Example: settings-style list
57
+
58
+ ```swift
59
+ @MainActor
60
+ struct SettingsView: View {
61
+ var body: some View {
62
+ List {
63
+ Section("General") {
64
+ NavigationLink("Display") { DisplaySettingsView() }
65
+ NavigationLink("Haptics") { HapticsSettingsView() }
66
+ }
67
+ Section("Account") {
68
+ Button("Sign Out", role: .destructive) {}
69
+ }
70
+ }
71
+ .listStyle(.insetGrouped)
72
+ }
73
+ }
74
+ ```
75
+
76
+ ## Design choices to keep
77
+
78
+ - Use `List` for dynamic feeds, settings, and any UI where row semantics help.
79
+ - Use stable IDs for rows to keep animations and scroll positioning reliable.
80
+ - Prefer `.contentShape(Rectangle())` on rows that should be tappable end-to-end.
81
+ - Use `.refreshable` for pull-to-refresh feeds when the data source supports it.
82
+
83
+ ## Pitfalls
84
+
85
+ - Avoid heavy custom layouts inside a `List` row; use `ScrollView` + `LazyVStack` instead.
86
+ - Be careful mixing `List` and nested `ScrollView`; it can cause gesture conflicts.
@@ -0,0 +1,38 @@
1
+ # Loading & Placeholders
2
+
3
+ Use this when a view needs a consistent loading state (skeletons, redaction, empty state) without blocking interaction.
4
+
5
+ ## Patterns to prefer
6
+
7
+ - **Redacted placeholders** for list/detail content to preserve layout while loading.
8
+ - **ContentUnavailableView** for empty or error states after loading completes.
9
+ - **ProgressView** only for short, global operations (use sparingly in content-heavy screens).
10
+
11
+ ## Recommended approach
12
+
13
+ 1. Keep the real layout, render placeholder data, then apply `.redacted(reason: .placeholder)`.
14
+ 2. For lists, show a fixed number of placeholder rows (avoid infinite spinners).
15
+ 3. Switch to `ContentUnavailableView` when load finishes but data is empty.
16
+
17
+ ## Pitfalls
18
+
19
+ - Don’t animate layout shifts during redaction; keep frames stable.
20
+ - Avoid nesting multiple spinners; use one loading indicator per section.
21
+ - Keep placeholder count small (3–6) to reduce jank on low-end devices.
22
+
23
+ ## Minimal usage
24
+
25
+ ```swift
26
+ VStack {
27
+ if isLoading {
28
+ ForEach(0..<3, id: \.self) { _ in
29
+ RowView(model: .placeholder())
30
+ }
31
+ .redacted(reason: .placeholder)
32
+ } else if items.isEmpty {
33
+ ContentUnavailableView("No items", systemImage: "tray")
34
+ } else {
35
+ ForEach(items) { item in RowView(model: item) }
36
+ }
37
+ }
38
+ ```
@@ -0,0 +1,71 @@
1
+ # macOS Settings
2
+
3
+ ## Intent
4
+
5
+ Use this when building a macOS Settings window backed by SwiftUI's `Settings` scene.
6
+
7
+ ## Core patterns
8
+
9
+ - Declare the Settings scene in the `App` and compile it only for macOS.
10
+ - Keep settings content in a dedicated root view (`SettingsView`) and drive values with `@AppStorage`.
11
+ - Use `TabView` to group settings sections when you have more than one category.
12
+ - Use `Form` inside each tab to keep controls aligned and accessible.
13
+ - Use `OpenSettingsAction` or `SettingsLink` for in-app entry points to the Settings window.
14
+
15
+ ## Example: settings scene
16
+
17
+ ```swift
18
+ @main
19
+ struct MyApp: App {
20
+ var body: some Scene {
21
+ WindowGroup {
22
+ ContentView()
23
+ }
24
+ #if os(macOS)
25
+ Settings {
26
+ SettingsView()
27
+ }
28
+ #endif
29
+ }
30
+ }
31
+ ```
32
+
33
+ ## Example: tabbed settings view
34
+
35
+ ```swift
36
+ @MainActor
37
+ struct SettingsView: View {
38
+ @AppStorage("showPreviews") private var showPreviews = true
39
+ @AppStorage("fontSize") private var fontSize = 12.0
40
+
41
+ var body: some View {
42
+ TabView {
43
+ Form {
44
+ Toggle("Show Previews", isOn: $showPreviews)
45
+ Slider(value: $fontSize, in: 9...96) {
46
+ Text("Font Size (\(fontSize, specifier: "%.0f") pts)")
47
+ }
48
+ }
49
+ .tabItem { Label("General", systemImage: "gear") }
50
+
51
+ Form {
52
+ Toggle("Enable Advanced Mode", isOn: .constant(false))
53
+ }
54
+ .tabItem { Label("Advanced", systemImage: "star") }
55
+ }
56
+ .scenePadding()
57
+ .frame(maxWidth: 420, minHeight: 240)
58
+ }
59
+ }
60
+ ```
61
+
62
+ ## Skip navigation
63
+
64
+ - Avoid wrapping `SettingsView` in a `NavigationStack` unless you truly need deep push navigation.
65
+ - Prefer tabs or sections; Settings is already presented as a separate window and should feel flat.
66
+ - If you must show hierarchical settings, use a single `NavigationSplitView` with a sidebar list of categories.
67
+
68
+ ## Pitfalls
69
+
70
+ - Don’t reuse iOS-only settings layouts (full-screen stacks, toolbar-heavy flows).
71
+ - Avoid large custom view hierarchies inside `Form`; keep rows focused and accessible.
@@ -0,0 +1,59 @@
1
+ # Matched transitions
2
+
3
+ ## Intent
4
+
5
+ Use matched transitions to create smooth continuity between a source view (thumbnail, avatar) and a destination view (sheet, detail, viewer).
6
+
7
+ ## Core patterns
8
+
9
+ - Use a shared `Namespace` and a stable ID for the source.
10
+ - Use `matchedTransitionSource` + `navigationTransition(.zoom(...))` on iOS 26+.
11
+ - Use `matchedGeometryEffect` for in-place transitions within a view hierarchy.
12
+ - Keep IDs stable across view updates (avoid random UUIDs).
13
+
14
+ ## Example: media preview to full-screen viewer (iOS 26+)
15
+
16
+ ```swift
17
+ struct MediaPreview: View {
18
+ @Namespace private var namespace
19
+ @State private var selected: MediaAttachment?
20
+
21
+ var body: some View {
22
+ ThumbnailView()
23
+ .matchedTransitionSource(id: selected?.id ?? "", in: namespace)
24
+ .sheet(item: $selected) { item in
25
+ MediaViewer(item: item)
26
+ .navigationTransition(.zoom(sourceID: item.id, in: namespace))
27
+ }
28
+ }
29
+ }
30
+ ```
31
+
32
+ ## Example: matched geometry within a view
33
+
34
+ ```swift
35
+ struct ToggleBadge: View {
36
+ @Namespace private var space
37
+ @State private var isOn = false
38
+
39
+ var body: some View {
40
+ Button {
41
+ withAnimation(.spring) { isOn.toggle() }
42
+ } label: {
43
+ Image(systemName: isOn ? "eye" : "eye.slash")
44
+ .matchedGeometryEffect(id: "icon", in: space)
45
+ }
46
+ }
47
+ }
48
+ ```
49
+
50
+ ## Design choices to keep
51
+
52
+ - Prefer `matchedTransitionSource` for cross-screen transitions.
53
+ - Keep source and destination sizes reasonable to avoid jarring scale changes.
54
+ - Use `withAnimation` for state-driven transitions.
55
+
56
+ ## Pitfalls
57
+
58
+ - Don’t use unstable IDs; it breaks the transition.
59
+ - Avoid mismatched shapes (e.g., square to circle) unless the design expects it.
@@ -0,0 +1,73 @@
1
+ # Media (images, video, viewer)
2
+
3
+ ## Intent
4
+
5
+ Use consistent patterns for loading images, previewing media, and presenting a full-screen viewer.
6
+
7
+ ## Core patterns
8
+
9
+ - Use `LazyImage` (or `AsyncImage`) for remote images with loading states.
10
+ - Prefer a lightweight preview component for inline media.
11
+ - Use a shared viewer state (e.g., `QuickLook`) to present a full-screen media viewer.
12
+ - Use `openWindow` for desktop/visionOS and a sheet for iOS.
13
+
14
+ ## Example: inline media preview
15
+
16
+ ```swift
17
+ struct MediaPreviewRow: View {
18
+ @Environment(QuickLook.self) private var quickLook
19
+
20
+ let attachments: [MediaAttachment]
21
+
22
+ var body: some View {
23
+ ScrollView(.horizontal, showsIndicators: false) {
24
+ HStack {
25
+ ForEach(attachments) { attachment in
26
+ LazyImage(url: attachment.previewURL) { state in
27
+ if let image = state.image {
28
+ image.resizable().aspectRatio(contentMode: .fill)
29
+ } else {
30
+ ProgressView()
31
+ }
32
+ }
33
+ .frame(width: 120, height: 120)
34
+ .clipped()
35
+ .onTapGesture {
36
+ quickLook.prepareFor(
37
+ selectedMediaAttachment: attachment,
38
+ mediaAttachments: attachments
39
+ )
40
+ }
41
+ }
42
+ }
43
+ }
44
+ }
45
+ }
46
+ ```
47
+
48
+ ## Example: global media viewer sheet
49
+
50
+ ```swift
51
+ struct AppRoot: View {
52
+ @State private var quickLook = QuickLook.shared
53
+
54
+ var body: some View {
55
+ content
56
+ .environment(quickLook)
57
+ .sheet(item: $quickLook.selectedMediaAttachment) { selected in
58
+ MediaUIView(selectedAttachment: selected, attachments: quickLook.mediaAttachments)
59
+ }
60
+ }
61
+ }
62
+ ```
63
+
64
+ ## Design choices to keep
65
+
66
+ - Keep previews lightweight; load full media in the viewer.
67
+ - Use shared viewer state so any view can open media without prop-drilling.
68
+ - Use a single entry point for the viewer (sheet/window) to avoid duplicates.
69
+
70
+ ## Pitfalls
71
+
72
+ - Avoid loading full-size images in list rows; use resized previews.
73
+ - Don’t present multiple viewer sheets at once; keep a single source of truth.
@@ -0,0 +1,101 @@
1
+ # Menu Bar
2
+
3
+ ## Intent
4
+
5
+ Use this when adding or customizing the macOS/iPadOS menu bar with SwiftUI commands.
6
+
7
+ ## Core patterns
8
+
9
+ - Add commands at the `Scene` level with `.commands { ... }`.
10
+ - Use `SidebarCommands()` when your UI includes a navigation sidebar.
11
+ - Use `CommandMenu` for app-specific menus and group related actions.
12
+ - Use `CommandGroup` to insert items before/after system groups or replace them.
13
+ - Use `FocusedValue` for context-sensitive menu items that depend on the active scene.
14
+
15
+ ## Example: basic command menu
16
+
17
+ ```swift
18
+ @main
19
+ struct MyApp: App {
20
+ var body: some Scene {
21
+ WindowGroup {
22
+ ContentView()
23
+ }
24
+ .commands {
25
+ CommandMenu("Actions") {
26
+ Button("Run", action: run)
27
+ .keyboardShortcut("R")
28
+ Button("Stop", action: stop)
29
+ .keyboardShortcut(".")
30
+ }
31
+ }
32
+ }
33
+
34
+ private func run() {}
35
+ private func stop() {}
36
+ }
37
+ ```
38
+
39
+ ## Example: insert and replace groups
40
+
41
+ ```swift
42
+ WindowGroup {
43
+ ContentView()
44
+ }
45
+ .commands {
46
+ CommandGroup(before: .systemServices) {
47
+ Button("Check for Updates") { /* open updater */ }
48
+ }
49
+
50
+ CommandGroup(after: .newItem) {
51
+ Button("New from Clipboard") { /* create item */ }
52
+ }
53
+
54
+ CommandGroup(replacing: .help) {
55
+ Button("User Manual") { /* open docs */ }
56
+ }
57
+ }
58
+ ```
59
+
60
+ ## Example: focused menu state
61
+
62
+ ```swift
63
+ @Observable
64
+ final class DataModel {
65
+ var items: [String] = []
66
+ }
67
+
68
+ struct ContentView: View {
69
+ @State private var model = DataModel()
70
+
71
+ var body: some View {
72
+ List(model.items, id: \.self) { item in
73
+ Text(item)
74
+ }
75
+ .focusedSceneValue(model)
76
+ }
77
+ }
78
+
79
+ struct ItemCommands: Commands {
80
+ @FocusedValue(DataModel.self) private var model: DataModel?
81
+
82
+ var body: some Commands {
83
+ CommandGroup(after: .newItem) {
84
+ Button("New Item") {
85
+ model?.items.append("Untitled")
86
+ }
87
+ .disabled(model == nil)
88
+ }
89
+ }
90
+ }
91
+ ```
92
+
93
+ ## Menu bar and Settings
94
+
95
+ - Defining a `Settings` scene adds the Settings menu item on macOS automatically.
96
+ - If you need a custom entry point inside the app, use `OpenSettingsAction` or `SettingsLink`.
97
+
98
+ ## Pitfalls
99
+
100
+ - Avoid registering the same keyboard shortcut in multiple command groups.
101
+ - Don’t use menu items as the only discoverable entry point for critical features.
@@ -0,0 +1,159 @@
1
+ # NavigationStack
2
+
3
+ ## Intent
4
+
5
+ Use this pattern for programmatic navigation and deep links, especially when each tab needs an independent navigation history. The key idea is one `NavigationStack` per tab, each with its own path binding and router object.
6
+
7
+ ## Core architecture
8
+
9
+ - Define a route enum that is `Hashable` and represents all destinations.
10
+ - Create a lightweight router (or use a library such as `https://github.com/Dimillian/AppRouter`) that owns the `path` and any sheet state.
11
+ - Each tab owns its own router instance and binds `NavigationStack(path:)` to it.
12
+ - Inject the router into the environment so child views can navigate programmatically.
13
+ - Centralize destination mapping with a single `navigationDestination(for:)` block (or a `withAppRouter()` modifier).
14
+
15
+ ## Example: custom router with per-tab stack
16
+
17
+ ```swift
18
+ @MainActor
19
+ @Observable
20
+ final class RouterPath {
21
+ var path: [Route] = []
22
+ var presentedSheet: SheetDestination?
23
+
24
+ func navigate(to route: Route) {
25
+ path.append(route)
26
+ }
27
+
28
+ func reset() {
29
+ path = []
30
+ }
31
+ }
32
+
33
+ enum Route: Hashable {
34
+ case account(id: String)
35
+ case status(id: String)
36
+ }
37
+
38
+ @MainActor
39
+ struct TimelineTab: View {
40
+ @State private var routerPath = RouterPath()
41
+
42
+ var body: some View {
43
+ NavigationStack(path: $routerPath.path) {
44
+ TimelineView()
45
+ .navigationDestination(for: Route.self) { route in
46
+ switch route {
47
+ case .account(let id): AccountView(id: id)
48
+ case .status(let id): StatusView(id: id)
49
+ }
50
+ }
51
+ }
52
+ .environment(routerPath)
53
+ }
54
+ }
55
+ ```
56
+
57
+ ## Example: centralized destination mapping
58
+
59
+ Use a shared view modifier to avoid duplicating route switches across screens.
60
+
61
+ ```swift
62
+ extension View {
63
+ func withAppRouter() -> some View {
64
+ navigationDestination(for: Route.self) { route in
65
+ switch route {
66
+ case .account(let id):
67
+ AccountView(id: id)
68
+ case .status(let id):
69
+ StatusView(id: id)
70
+ }
71
+ }
72
+ }
73
+ }
74
+ ```
75
+
76
+ Then apply it once per stack:
77
+
78
+ ```swift
79
+ NavigationStack(path: $routerPath.path) {
80
+ TimelineView()
81
+ .withAppRouter()
82
+ }
83
+ ```
84
+
85
+ ## Example: binding per tab (tabs with independent history)
86
+
87
+ ```swift
88
+ @MainActor
89
+ struct TabsView: View {
90
+ @State private var timelineRouter = RouterPath()
91
+ @State private var notificationsRouter = RouterPath()
92
+
93
+ var body: some View {
94
+ TabView {
95
+ TimelineTab(router: timelineRouter)
96
+ NotificationsTab(router: notificationsRouter)
97
+ }
98
+ }
99
+ }
100
+ ```
101
+
102
+ ## Example: generic tabs with per-tab NavigationStack
103
+
104
+ Use this when tabs are built from data and each needs its own path without hard-coded names.
105
+
106
+ ```swift
107
+ @MainActor
108
+ struct TabsView: View {
109
+ @State private var selectedTab: AppTab = .timeline
110
+ @State private var tabRouter = TabRouter()
111
+
112
+ var body: some View {
113
+ TabView(selection: $selectedTab) {
114
+ ForEach(AppTab.allCases) { tab in
115
+ NavigationStack(path: tabRouter.binding(for: tab)) {
116
+ tab.makeContentView()
117
+ }
118
+ .environment(tabRouter.router(for: tab))
119
+ .tabItem { tab.label }
120
+ .tag(tab)
121
+ }
122
+ }
123
+ }
124
+ }
125
+ ```
126
+
127
+ @MainActor
128
+ @Observable
129
+ final class TabRouter {
130
+ private var routers: [AppTab: RouterPath] = [:]
131
+
132
+ func router(for tab: AppTab) -> RouterPath {
133
+ if let router = routers[tab] { return router }
134
+ let router = RouterPath()
135
+ routers[tab] = router
136
+ return router
137
+ }
138
+
139
+ func binding(for tab: AppTab) -> Binding<[Route]> {
140
+ let router = router(for: tab)
141
+ return Binding(get: { router.path }, set: { router.path = $0 })
142
+ }
143
+ }
144
+
145
+ ## Design choices to keep
146
+
147
+ - One `NavigationStack` per tab to preserve independent history.
148
+ - A single source of truth for navigation state (`RouterPath` or library router).
149
+ - Use `navigationDestination(for:)` to map routes to views.
150
+ - Reset the path when app context changes (account switch, logout, etc.).
151
+ - Inject the router into the environment so child views can navigate and present sheets without prop-drilling.
152
+ - Keep sheet presentation state on the router if you want a single place to manage modals.
153
+
154
+ ## Pitfalls
155
+
156
+ - Do not share one path across all tabs unless you want global history.
157
+ - Ensure route identifiers are stable and `Hashable`.
158
+ - Avoid storing view instances in the path; store lightweight route data instead.
159
+ - If using a router object, keep it outside other `@Observable` objects to avoid nested observation.
@@ -0,0 +1,45 @@
1
+ # Overlay and toasts
2
+
3
+ ## Intent
4
+
5
+ Use overlays for transient UI (toasts, banners, loaders) without affecting layout.
6
+
7
+ ## Core patterns
8
+
9
+ - Use `.overlay(alignment:)` to place global UI without changing the underlying layout.
10
+ - Keep overlays lightweight and dismissible.
11
+ - Use a dedicated `ToastCenter` (or similar) for global state if multiple features trigger toasts.
12
+
13
+ ## Example: toast overlay
14
+
15
+ ```swift
16
+ struct AppRootView: View {
17
+ @State private var toast: Toast?
18
+
19
+ var body: some View {
20
+ content
21
+ .overlay(alignment: .top) {
22
+ if let toast {
23
+ ToastView(toast: toast)
24
+ .transition(.move(edge: .top).combined(with: .opacity))
25
+ .onAppear {
26
+ DispatchQueue.main.asyncAfter(deadline: .now() + 2) {
27
+ withAnimation { self.toast = nil }
28
+ }
29
+ }
30
+ }
31
+ }
32
+ }
33
+ }
34
+ ```
35
+
36
+ ## Design choices to keep
37
+
38
+ - Prefer overlays for transient UI rather than embedding in layout stacks.
39
+ - Use transitions and short auto-dismiss timers.
40
+ - Keep the overlay aligned to a clear edge (`.top` or `.bottom`).
41
+
42
+ ## Pitfalls
43
+
44
+ - Avoid overlays that block all interaction unless explicitly needed.
45
+ - Don’t stack many overlays; use a queue or replace the current toast.
@@ -0,0 +1,62 @@
1
+ # Performance guardrails
2
+
3
+ ## Intent
4
+
5
+ Use these rules when a SwiftUI screen is large, scroll-heavy, frequently updated, or at risk of unnecessary recomputation.
6
+
7
+ ## Core rules
8
+
9
+ - Give `ForEach` and list content stable identity. Do not use unstable indices as identity when the collection can reorder or mutate.
10
+ - Keep expensive filtering, sorting, and formatting out of `body`; precompute or move it into a model/helper when it is not trivial.
11
+ - Narrow observation scope so only the views that read changing state need to update.
12
+ - Prefer lazy containers for larger scrolling content and extract subviews when only part of a screen changes frequently.
13
+ - Avoid swapping entire top-level view trees for small state changes; keep a stable root view and vary localized sections or modifiers.
14
+
15
+ ## Example: stable identity
16
+
17
+ ```swift
18
+ ForEach(items) { item in
19
+ Row(item: item)
20
+ }
21
+ ```
22
+
23
+ Prefer that over index-based identity when the collection can change order:
24
+
25
+ ```swift
26
+ ForEach(Array(items.enumerated()), id: \.offset) { _, item in
27
+ Row(item: item)
28
+ }
29
+ ```
30
+
31
+ ## Example: move expensive work out of body
32
+
33
+ ```swift
34
+ struct FeedView: View {
35
+ let items: [FeedItem]
36
+
37
+ private var sortedItems: [FeedItem] {
38
+ items.sorted(using: KeyPathComparator(\.createdAt, order: .reverse))
39
+ }
40
+
41
+ var body: some View {
42
+ List(sortedItems) { item in
43
+ FeedRow(item: item)
44
+ }
45
+ }
46
+ }
47
+ ```
48
+
49
+ If the work is more expensive than a small derived property, move it into a model, store, or helper that updates less often.
50
+
51
+ ## When to investigate further
52
+
53
+ - Janky scrolling in long feeds or grids
54
+ - Typing lag from search or form validation
55
+ - Overly broad view updates when one small piece of state changes
56
+ - Large screens with many conditionals or repeated formatting work
57
+
58
+ ## Pitfalls
59
+
60
+ - Recomputing heavy transforms every render
61
+ - Observing a large object from many descendants when only one field matters
62
+ - Building custom scroll containers when `List`, `LazyVStack`, or `LazyHGrid` would already solve the problem