@istmx/skills 1.1.0 → 2.0.0

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 (153) hide show
  1. package/CODE_OF_CONDUCT.md +47 -0
  2. package/LICENSE +30 -0
  3. package/README.md +48 -22
  4. package/bin/cli.js +130 -119
  5. package/istm-animate/SKILL.md +28 -58
  6. package/istm-animate/core/motion-principles/SKILL.md +284 -0
  7. package/istm-animate/core/motion-principles/references/designers.md +127 -0
  8. package/istm-animate/core/motion-principles/references/easing-guide.md +231 -0
  9. package/istm-animate/core/motion-principles/references/enter-exit-recipes.md +466 -0
  10. package/istm-animate/frameworks/canvas-generative/SKILL.md +325 -0
  11. package/istm-animate/frameworks/canvas-generative/references/algorithms.md +925 -0
  12. package/istm-animate/frameworks/css-native/SKILL.md +319 -0
  13. package/istm-animate/frameworks/css-native/references/modern-css.md +465 -0
  14. package/istm-animate/frameworks/framer-motion/SKILL.md +187 -0
  15. package/istm-animate/frameworks/framer-motion/references/api.md +312 -0
  16. package/istm-animate/frameworks/gsap/SKILL.md +188 -0
  17. package/istm-animate/frameworks/gsap/references/core.md +218 -0
  18. package/istm-animate/frameworks/gsap/references/plugins.md +371 -0
  19. package/istm-animate/frameworks/gsap/references/scrolltrigger.md +325 -0
  20. package/istm-animate/frameworks/gsap/references/timeline.md +218 -0
  21. package/istm-animate/frameworks/threejs-r3f/SKILL.md +243 -0
  22. package/istm-animate/frameworks/threejs-r3f/references/scene-setup.md +392 -0
  23. package/istm-animate/frameworks/threejs-r3f/references/shaders.md +446 -0
  24. package/istm-animate/mobile/android/compose-graphics/SKILL.md +503 -0
  25. package/istm-animate/mobile/android/compose-graphics/references/agsl-recipes.md +356 -0
  26. package/istm-animate/mobile/android/compose-graphics/references/canvas-generative.md +282 -0
  27. package/istm-animate/mobile/android/compose-graphics/references/m3-expressive-deep.md +303 -0
  28. package/istm-animate/mobile/android/compose-motion/SKILL.md +359 -0
  29. package/istm-animate/mobile/android/compose-motion/references/gestures-compose.md +273 -0
  30. package/istm-animate/mobile/android/compose-motion/references/recomposition-and-anim.md +196 -0
  31. package/istm-animate/mobile/android/compose-motion/references/shared-transitions.md +281 -0
  32. package/istm-animate/mobile/android/compose-multiplatform/SKILL.md +311 -0
  33. package/istm-animate/mobile/android/compose-multiplatform/references/cmp-interop.md +288 -0
  34. package/istm-animate/mobile/android/compose-multiplatform/references/cmp-platform-quirks.md +156 -0
  35. package/istm-animate/mobile/apple/swiftui-graphics/SKILL.md +408 -0
  36. package/istm-animate/mobile/apple/swiftui-graphics/references/canvas-swiftui.md +239 -0
  37. package/istm-animate/mobile/apple/swiftui-graphics/references/liquid-glass-deep.md +252 -0
  38. package/istm-animate/mobile/apple/swiftui-graphics/references/metal-recipes.md +382 -0
  39. package/istm-animate/mobile/apple/swiftui-motion/SKILL.md +379 -0
  40. package/istm-animate/mobile/apple/swiftui-motion/references/gestures-swiftui.md +336 -0
  41. package/istm-animate/mobile/apple/swiftui-motion/references/phase-keyframe-deep.md +231 -0
  42. package/istm-animate/mobile/apple/swiftui-motion/references/springs-cheatsheet.md +129 -0
  43. package/istm-animate/references/animate.md +199 -0
  44. package/istm-animate/references/audit.md +115 -0
  45. package/istm-animate/references/design-engineering.md +674 -0
  46. package/istm-animate/references/improve.md +101 -0
  47. package/istm-animate/references/opportunities.md +132 -0
  48. package/istm-animate/references/plan-template.md +73 -0
  49. package/istm-animate/references/recipes.md +324 -0
  50. package/istm-animate/references/review.md +112 -0
  51. package/istm-animate/references/standards.md +187 -0
  52. package/istm-animate/references/vocabulary.md +173 -0
  53. package/istm-architecture/SKILL.md +10 -1
  54. package/istm-awwward-designer/SKILL.md +28 -20
  55. package/istm-design/SKILL.md +31 -58
  56. package/istm-design/core/design-audit/SKILL.md +248 -0
  57. package/istm-design/core/desktop-principles/SKILL.md +363 -0
  58. package/istm-design/core/desktop-principles/references/keyboard-patterns.md +137 -0
  59. package/istm-design/core/desktop-principles/references/multi-window.md +105 -0
  60. package/istm-design/core/mobile-principles/SKILL.md +289 -0
  61. package/istm-design/core/mobile-principles/references/accessibility-mobile.md +175 -0
  62. package/istm-design/core/mobile-principles/references/gestures-deep.md +220 -0
  63. package/istm-design/core/ui-ux-pro-max/SKILL.md +392 -0
  64. package/istm-design/core/ui-ux-pro-max/UPSTREAM.md +23 -0
  65. package/istm-design/core/ui-ux-pro-max/data/app-interface.csv +31 -0
  66. package/istm-design/core/ui-ux-pro-max/data/charts.csv +26 -0
  67. package/istm-design/core/ui-ux-pro-max/data/colors.csv +193 -0
  68. package/istm-design/core/ui-ux-pro-max/data/google-fonts.csv +1924 -0
  69. package/istm-design/core/ui-ux-pro-max/data/icons.csv +106 -0
  70. package/istm-design/core/ui-ux-pro-max/data/landing.csv +35 -0
  71. package/istm-design/core/ui-ux-pro-max/data/motion.csv +17 -0
  72. package/istm-design/core/ui-ux-pro-max/data/products.csv +193 -0
  73. package/istm-design/core/ui-ux-pro-max/data/react-performance.csv +45 -0
  74. package/istm-design/core/ui-ux-pro-max/data/stacks/angular.csv +51 -0
  75. package/istm-design/core/ui-ux-pro-max/data/stacks/astro.csv +54 -0
  76. package/istm-design/core/ui-ux-pro-max/data/stacks/avalonia.csv +57 -0
  77. package/istm-design/core/ui-ux-pro-max/data/stacks/flutter.csv +53 -0
  78. package/istm-design/core/ui-ux-pro-max/data/stacks/html-tailwind.csv +56 -0
  79. package/istm-design/core/ui-ux-pro-max/data/stacks/javafx.csv +76 -0
  80. package/istm-design/core/ui-ux-pro-max/data/stacks/jetpack-compose.csv +53 -0
  81. package/istm-design/core/ui-ux-pro-max/data/stacks/laravel.csv +51 -0
  82. package/istm-design/core/ui-ux-pro-max/data/stacks/nextjs.csv +53 -0
  83. package/istm-design/core/ui-ux-pro-max/data/stacks/nuxt-ui.csv +71 -0
  84. package/istm-design/core/ui-ux-pro-max/data/stacks/nuxtjs.csv +59 -0
  85. package/istm-design/core/ui-ux-pro-max/data/stacks/react-native.csv +52 -0
  86. package/istm-design/core/ui-ux-pro-max/data/stacks/react.csv +54 -0
  87. package/istm-design/core/ui-ux-pro-max/data/stacks/shadcn.csv +61 -0
  88. package/istm-design/core/ui-ux-pro-max/data/stacks/svelte.csv +54 -0
  89. package/istm-design/core/ui-ux-pro-max/data/stacks/swiftui.csv +51 -0
  90. package/istm-design/core/ui-ux-pro-max/data/stacks/threejs.csv +54 -0
  91. package/istm-design/core/ui-ux-pro-max/data/stacks/uno.csv +60 -0
  92. package/istm-design/core/ui-ux-pro-max/data/stacks/uwp.csv +56 -0
  93. package/istm-design/core/ui-ux-pro-max/data/stacks/vue.csv +50 -0
  94. package/istm-design/core/ui-ux-pro-max/data/stacks/winui.csv +60 -0
  95. package/istm-design/core/ui-ux-pro-max/data/stacks/wpf.csv +57 -0
  96. package/istm-design/core/ui-ux-pro-max/data/styles.csv +85 -0
  97. package/istm-design/core/ui-ux-pro-max/data/typography.csv +75 -0
  98. package/istm-design/core/ui-ux-pro-max/data/ui-reasoning.csv +162 -0
  99. package/istm-design/core/ui-ux-pro-max/data/ux-guidelines.csv +100 -0
  100. package/istm-design/core/ui-ux-pro-max/references/pro-rules.md +109 -0
  101. package/istm-design/core/ui-ux-pro-max/references/quick-reference.md +240 -0
  102. package/istm-design/core/ui-ux-pro-max/scripts/core.py +464 -0
  103. package/istm-design/core/ui-ux-pro-max/scripts/design_system.py +1371 -0
  104. package/istm-design/core/ui-ux-pro-max/scripts/search.py +162 -0
  105. package/istm-design/core/ui-ux-pro-max/scripts/tests/test_core.py +134 -0
  106. package/istm-design/core/ui-ux-pro-max/scripts/validate_data.py +114 -0
  107. package/istm-design/references/apple-design.md +282 -0
  108. package/istm-design/references/generation-guide.md +209 -0
  109. package/istm-design/references/pick-ui-library.md +77 -0
  110. package/istm-design/references/picker.md +197 -0
  111. package/istm-design/references/prototype.md +90 -0
  112. package/istm-design/references/schema.md +366 -0
  113. package/istm-workflow/istm-audit/SKILL.md +7 -7
  114. package/istm-workflow/istm-audit/agent-prompt.md +20 -20
  115. package/istm-workflow/istm-audit/modes/area.md +1 -1
  116. package/istm-workflow/istm-audit/modes/greenfield.md +4 -4
  117. package/istm-workflow/istm-audit/modes/tool-skills.md +1 -1
  118. package/istm-workflow/istm-check/SKILL.md +10 -10
  119. package/istm-workflow/istm-check/modes/review.md +9 -9
  120. package/istm-workflow/istm-check/modes/verify.md +19 -19
  121. package/istm-workflow/istm-check/review-agent-prompt.md +2 -2
  122. package/istm-workflow/istm-check/review-guide.md +4 -4
  123. package/istm-workflow/istm-craft/SKILL.md +20 -11
  124. package/istm-workflow/istm-craft/agent-modes/architecture.md +1 -1
  125. package/istm-workflow/istm-craft/agent-prompt.md +8 -8
  126. package/istm-workflow/istm-craft/internal/after-subagent.md +11 -11
  127. package/istm-workflow/istm-craft/internal/design-conversation.md +9 -9
  128. package/istm-workflow/istm-craft/internal/tool-discovery.md +2 -2
  129. package/istm-workflow/istm-craft/spec-template.md +18 -18
  130. package/istm-workflow/istm-debug/SKILL.md +6 -6
  131. package/istm-workflow/istm-develop/SKILL.md +31 -16
  132. package/istm-workflow/istm-develop/checklist.md +1 -1
  133. package/istm-workflow/istm-develop/flow/build.md +21 -21
  134. package/istm-workflow/istm-develop/flow/git.md +4 -4
  135. package/istm-workflow/istm-develop/logical-guide.md +5 -5
  136. package/istm-workflow/istm-develop/ui/implementation.md +2 -2
  137. package/istm-workflow/istm-develop/ui-guide.md +3 -3
  138. package/istm-workflow/istm-document/SKILL.md +6 -6
  139. package/istm-workflow/istm-document/templates/postmortem.md +1 -1
  140. package/istm-workflow/istm-scope/SKILL.md +20 -20
  141. package/istm-workflow/istm-scope/modes/add.md +1 -1
  142. package/istm-workflow/istm-scope/modes/plan-brownfield.md +2 -2
  143. package/istm-workflow/istm-scope/modes/plan-greenfield.md +4 -4
  144. package/istm-workflow/istm-scope/modes/plan-monorepo.md +3 -3
  145. package/istm-workflow/istm-scope/modes/plan.md +16 -16
  146. package/istm-workflow/istm-scope/modes/replan.md +2 -2
  147. package/istm-workflow/istm-scope/scope-template.md +29 -29
  148. package/istm-workflow/istm-sync/SKILL.md +37 -25
  149. package/istm-workflow/istm-sync/agent-prompt.md +37 -19
  150. package/istm-workflow/istm-test/SKILL.md +12 -12
  151. package/istm-workflow/istm-test/modes/setup.md +6 -6
  152. package/istm-workflow/istm-test/writing-guide.md +1 -1
  153. package/package.json +1 -1
@@ -0,0 +1,363 @@
1
+ ---
2
+ name: desktop-principles
3
+ description: "Desktop-specific UX principles - hover states, pointer precision, keyboard shortcuts, multi-window, focus management. Covers macOS, Windows, Linux, web desktop."
4
+ ---
5
+
6
+ # Desktop Principles
7
+
8
+ > Desktop UX context. Loaded when desktop is detected (macOS, Windows, Linux desktop, web desktop).
9
+ > Concise rules here. Deep-dive in `references/`.
10
+
11
+ ---
12
+
13
+ ## Hover States Are Mandatory
14
+
15
+ Hover is the primary affordance signal on desktop, the inverse of mobile. A pointer hovering over a target without immediate visual feedback feels broken: users rely on `:hover` to confirm an element is interactive before committing to a click. Every clickable surface must have a distinct hover style, ideally with a 100-200ms transition so the change is perceptible without feeling sluggish.
16
+
17
+ **CSS - hover styles for interactive elements:**
18
+ ```css
19
+ .button {
20
+ background: var(--surface);
21
+ transition: background 120ms ease-out, transform 120ms ease-out;
22
+ }
23
+
24
+ .button:hover {
25
+ background: var(--surface-hover);
26
+ transform: translateY(-1px);
27
+ }
28
+
29
+ .button:active {
30
+ transform: translateY(0);
31
+ }
32
+ ```
33
+
34
+ **SwiftUI - .onHover for macOS, .hoverEffect for iPadOS:**
35
+ ```swift
36
+ struct ToolbarButton: View {
37
+ @State private var hovering = false
38
+
39
+ var body: some View {
40
+ Image(systemName: "square.and.arrow.up")
41
+ .padding(8)
42
+ .background(hovering ? Color.gray.opacity(0.15) : .clear)
43
+ .onHover { hovering = $0 }
44
+ .animation(.easeOut(duration: 0.12), value: hovering)
45
+ .hoverEffect(.highlight) // iPadOS pointer support, no-op on macOS
46
+ }
47
+ }
48
+ ```
49
+
50
+ **Compose Desktop - onPointerEvent or hoverable + interactionSource:**
51
+ ```kotlin
52
+ @OptIn(ExperimentalComposeUiApi::class)
53
+ @Composable
54
+ fun ToolbarButton(onClick: () -> Unit) {
55
+ val interactionSource = remember { MutableInteractionSource() }
56
+ val hovered by interactionSource.collectIsHoveredAsState()
57
+
58
+ Box(
59
+ modifier = Modifier
60
+ .hoverable(interactionSource)
61
+ .background(if (hovered) Color.LightGray.copy(alpha = 0.15f) else Color.Transparent)
62
+ .clickable(onClick = onClick)
63
+ .padding(8.dp),
64
+ ) { Icon(Icons.Default.Share, contentDescription = "Share") }
65
+ }
66
+ ```
67
+
68
+ ---
69
+
70
+ ## Pointer Precision
71
+
72
+ Mouse and trackpad pointers are far more accurate than thumbs, so desktop targets can be smaller than the 44pt mobile minimum. Common ranges are 24-32px for icon buttons, 28-36px for toolbar items. WCAG 2.5.8 (AA, target size minimum) sets the absolute floor at **24x24 CSS pixels** for non-mobile pointer input. Sub-24px targets need spacing or be grouped with sibling targets.
73
+
74
+ **Fitts's Law in practice:** the time to acquire a target shrinks with size and grows with distance. Screen edges and corners are infinite-depth targets - the cursor stops there regardless of overshoot. Put high-frequency global controls (close window, system menu, app dock) in corners and along edges. macOS menubar and Windows taskbar are textbook applications: edge-anchored, zero-overshoot acquisition.
75
+
76
+ ---
77
+
78
+ ## Keyboard Shortcuts (first-class)
79
+
80
+ Desktop users expect parity with native conventions. Missing `⌘+F` in a list-heavy app is not minimalism, it is a bug.
81
+
82
+ | Action | macOS | Windows / Linux |
83
+ |---|---|---|
84
+ | New | `⌘+N` | `Ctrl+N` |
85
+ | Close window | `⌘+W` | `Ctrl+W` |
86
+ | Quit app | `⌘+Q` | `Alt+F4` |
87
+ | Settings / Preferences | `⌘+,` | `Ctrl+,` |
88
+ | Find | `⌘+F` | `Ctrl+F` |
89
+ | Toggle (comment, sidebar...) | `⌘+/` | `Ctrl+/` |
90
+ | Save | `⌘+S` | `Ctrl+S` |
91
+ | Command palette | `⌘+K` or `⌘+Shift+P` | `Ctrl+K` or `Ctrl+Shift+P` |
92
+
93
+ **Web - detect Ctrl vs Cmd correctly:**
94
+ ```js
95
+ // Prefer event.metaKey on macOS, event.ctrlKey elsewhere.
96
+ // navigator.platform is deprecated but still pragmatic; fall back to userAgent.
97
+ const isMac = /Mac|iPhone|iPad/.test(navigator.platform || navigator.userAgent);
98
+
99
+ window.addEventListener("keydown", (e) => {
100
+ const cmdOrCtrl = isMac ? e.metaKey : e.ctrlKey;
101
+ if (cmdOrCtrl && e.key.toLowerCase() === "k") {
102
+ e.preventDefault();
103
+ openCommandPalette();
104
+ }
105
+ });
106
+ ```
107
+
108
+ **SwiftUI - .keyboardShortcut binds to menu commands:**
109
+ ```swift
110
+ Button("New Document", action: newDoc)
111
+ .keyboardShortcut("n", modifiers: .command)
112
+
113
+ Button("Find", action: focusSearch)
114
+ .keyboardShortcut("f", modifiers: .command)
115
+ ```
116
+
117
+ **Compose Desktop - onKeyEvent + KeyShortcut:**
118
+ ```kotlin
119
+ @OptIn(ExperimentalComposeUiApi::class)
120
+ fun Modifier.commandShortcut(key: Key, onTrigger: () -> Unit) =
121
+ onKeyEvent { event ->
122
+ if (event.type == KeyEventType.KeyDown && event.isMetaPressed && event.key == key) {
123
+ onTrigger(); true
124
+ } else false
125
+ }
126
+
127
+ // In MenuBar:
128
+ MenuBar {
129
+ Menu("File") {
130
+ Item("New", shortcut = KeyShortcut(Key.N, meta = true), onClick = ::newDoc)
131
+ Item("Find", shortcut = KeyShortcut(Key.F, meta = true), onClick = ::focusSearch)
132
+ }
133
+ }
134
+ ```
135
+
136
+ ---
137
+
138
+ ## Multi-Window Patterns
139
+
140
+ Desktop users keep windows side by side. A new window is the right answer when:
141
+
142
+ - A task runs long enough that the user wants to keep working in the main window (rendering, export, sync log).
143
+ - The user is comparing two parallel contexts (two documents, two chats, two issues).
144
+ - The app is document-based and each document is a peer (Pages, Figma files, Xcode projects).
145
+
146
+ A new window is the wrong answer for transient confirmations, brief settings panels, or anything that can live in a sheet or popover.
147
+
148
+ **SwiftUI - WindowGroup for document-style, Window for singletons:**
149
+ ```swift
150
+ @main
151
+ struct MyApp: App {
152
+ var body: some Scene {
153
+ WindowGroup("Document") { DocumentView() } // peer windows, one per doc
154
+
155
+ Window("Inspector", id: "inspector") { InspectorView() }
156
+ .windowResizability(.contentSize) // tracks intrinsic content size
157
+
158
+ Settings { SettingsView() } // ⌘+, target on macOS
159
+ }
160
+ }
161
+ ```
162
+
163
+ **Compose Desktop - Window composables, application scope:**
164
+ ```kotlin
165
+ fun main() = application {
166
+ val docs = remember { mutableStateListOf(Document()) }
167
+
168
+ docs.forEach { doc ->
169
+ Window(onCloseRequest = { docs.remove(doc) }, title = doc.title) {
170
+ DocumentView(doc)
171
+ }
172
+ }
173
+
174
+ if (showInspector) {
175
+ Window(onCloseRequest = { showInspector = false }, title = "Inspector") {
176
+ InspectorView()
177
+ }
178
+ }
179
+ }
180
+ ```
181
+
182
+ **State sharing:** windows are *views* over the same model. Hold the source of truth in a singleton or a DI-scoped object (SwiftUI `@Observable` injected via environment, Compose `koin` or `viewModel`-equivalent). Never duplicate state per window - reconciling diverging copies is a graveyard of bugs.
183
+
184
+ ---
185
+
186
+ ## Focus Management
187
+
188
+ Keyboard navigation is a first-class input on desktop. Tab order must be sane, focus rings must be visible, and removing them without an alternative is an accessibility regression.
189
+
190
+ **SwiftUI - @FocusState drives field focus:**
191
+ ```swift
192
+ struct LoginForm: View {
193
+ enum Field { case email, password }
194
+
195
+ @State private var email = ""
196
+ @State private var password = ""
197
+ @FocusState private var focused: Field?
198
+
199
+ var body: some View {
200
+ VStack {
201
+ TextField("Email", text: $email)
202
+ .focused($focused, equals: .email)
203
+ .onSubmit { focused = .password }
204
+ SecureField("Password", text: $password)
205
+ .focused($focused, equals: .password)
206
+ .onSubmit(submit)
207
+ }
208
+ .onAppear { focused = .email }
209
+ }
210
+ }
211
+ ```
212
+
213
+ **Compose - FocusRequester + LocalFocusManager:**
214
+ ```kotlin
215
+ val emailFocus = remember { FocusRequester() }
216
+ val passwordFocus = remember { FocusRequester() }
217
+ val focusManager = LocalFocusManager.current
218
+
219
+ TextField(
220
+ value = email, onValueChange = { email = it },
221
+ modifier = Modifier.focusRequester(emailFocus).focusable(),
222
+ keyboardActions = KeyboardActions(onNext = { passwordFocus.requestFocus() }),
223
+ )
224
+
225
+ TextField(
226
+ value = password, onValueChange = { password = it },
227
+ modifier = Modifier.focusRequester(passwordFocus).focusable(),
228
+ keyboardActions = KeyboardActions(onDone = { focusManager.clearFocus(); submit() }),
229
+ )
230
+
231
+ LaunchedEffect(Unit) { emailFocus.requestFocus() }
232
+ ```
233
+
234
+ **Web - tabindex + :focus-visible:**
235
+ ```css
236
+ .button {
237
+ /* Never `outline: none` without an alternative. */
238
+ }
239
+
240
+ .button:focus-visible {
241
+ outline: 2px solid var(--ring);
242
+ outline-offset: 2px;
243
+ }
244
+ ```
245
+ ```html
246
+ <!-- tabindex="0" puts a non-interactive element in tab order -->
247
+ <div role="button" tabindex="0" class="button">Custom button</div>
248
+ ```
249
+
250
+ ---
251
+
252
+ ## Information Density
253
+
254
+ Desktop users sit on a 13-32 inch screen with a precise pointer and full keyboard. They can - and want to - parse more information per viewport than on mobile. Use an 8px base grid (vs 4-8px mobile), persistent sidebars instead of bottom tabs, command palettes (`⌘K`) for power users, and dense data tables when the data warrants it. Linear, Things 3, and Notion are the touchstones: information-rich without feeling cramped, every pixel earns its keep.
255
+
256
+ ---
257
+
258
+ ## Subtle Animations Doctrine
259
+
260
+ Desktop apps are stared at for hours. Animations that feel delightful once become unbearable on the hundredth repetition. Prefer short, purely functional motion: opacity and small translations under 200ms, no bounces on routine interactions, no playful overshoots on hover. Save expressive motion for one-shot moments (onboarding, success states), never daily UI.
261
+
262
+ ```css
263
+ /* BAD - every hover bounces for 600ms, exhausting after the third use */
264
+ .card {
265
+ transition: transform 600ms cubic-bezier(0.34, 1.56, 0.64, 1);
266
+ }
267
+ .card:hover { transform: scale(1.05); }
268
+ ```
269
+
270
+ ```css
271
+ /* GOOD - 100ms opacity, almost subliminal, never tires */
272
+ .card {
273
+ opacity: 0.92;
274
+ transition: opacity 100ms ease-out;
275
+ }
276
+ .card:hover { opacity: 1; }
277
+ ```
278
+
279
+ ---
280
+
281
+ ## Anti-Patterns (BAD / GOOD)
282
+
283
+ ### 1. Hiding navigation behind a hamburger on desktop
284
+
285
+ ```html
286
+ <!-- BAD - 1440px viewport, infinite room, but nav is collapsed -->
287
+ <header>
288
+ <button class="hamburger" aria-label="Menu">☰</button>
289
+ </header>
290
+ <nav class="drawer hidden">...</nav>
291
+ ```
292
+
293
+ ```html
294
+ <!-- GOOD - persistent sidebar on desktop, collapsible if the user wants it -->
295
+ <aside class="sidebar">
296
+ <nav>
297
+ <a href="/inbox">Inbox</a>
298
+ <a href="/projects">Projects</a>
299
+ <a href="/archive">Archive</a>
300
+ </nav>
301
+ <button class="collapse-toggle" aria-label="Collapse sidebar">⇤</button>
302
+ </aside>
303
+ ```
304
+
305
+ ### 2. No keyboard shortcuts for primary actions
306
+
307
+ ```jsx
308
+ // BAD - "New" is buried in a menu, no shortcut, every creation is 3 clicks
309
+ <Toolbar>
310
+ <Menu>
311
+ <MenuItem onClick={newDoc}>New document</MenuItem>
312
+ </Menu>
313
+ </Toolbar>
314
+ ```
315
+
316
+ ```jsx
317
+ // GOOD - ⌘N baseline, surfaced in the menu, mirrored on the toolbar tooltip
318
+ <Toolbar>
319
+ <button onClick={newDoc} title="New document (⌘N)">
320
+ <PlusIcon />
321
+ </button>
322
+ </Toolbar>
323
+ // Bound globally:
324
+ useShortcut("mod+n", newDoc);
325
+ useShortcut("mod+s", save);
326
+ useShortcut("mod+f", focusSearch);
327
+ ```
328
+
329
+ ### 3. Removing focus rings without an alternative
330
+
331
+ ```css
332
+ /* BAD - keyboard users now have no idea where focus is */
333
+ button:focus { outline: none; }
334
+ ```
335
+
336
+ ```css
337
+ /* GOOD - :focus-visible keeps mouse clicks ring-free, keyboard navigation visible */
338
+ button:focus { outline: none; }
339
+ button:focus-visible {
340
+ outline: 2px solid var(--brand-500);
341
+ outline-offset: 2px;
342
+ border-radius: 6px;
343
+ }
344
+ ```
345
+
346
+ ---
347
+
348
+ ## Quick Reference: Loading sub-skills
349
+
350
+ | Need | Load |
351
+ |---|---|
352
+ | Keyboard patterns deep-dive | `references/keyboard-patterns.md` |
353
+ | Multi-window state | `references/multi-window.md` |
354
+ | SwiftUI animations | `../swiftui-motion/SKILL.md` |
355
+ | Compose Desktop | `../compose-multiplatform/SKILL.md` (when desktop is a CMP target) |
356
+
357
+ ---
358
+
359
+ ## Sources
360
+
361
+ - Apple Human Interface Guidelines (macOS): https://developer.apple.com/design/human-interface-guidelines/macos
362
+ - Microsoft Fluent Design 2: https://fluent2.microsoft.design/
363
+ - GNOME Human Interface Guidelines: https://developer.gnome.org/hig/
@@ -0,0 +1,137 @@
1
+ # Keyboard Patterns Deep Dive
2
+
3
+ Deep dive on keyboard shortcuts across desktop platforms. Covers canonical bindings, cross-platform detection, chords, conflicts, and discoverability.
4
+
5
+ ---
6
+
7
+ ## Canonical shortcuts by domain
8
+
9
+ Stick to the conventions users already know. Reinventing `⌘+S` makes your app feel hostile within seconds.
10
+
11
+ ### App lifecycle
12
+
13
+ | Action | macOS | Windows / Linux |
14
+ |---|---|---|
15
+ | New | `⌘+N` | `Ctrl+N` |
16
+ | Open | `⌘+O` | `Ctrl+O` |
17
+ | Save | `⌘+S` | `Ctrl+S` |
18
+ | Save As | `⌘+Shift+S` | `Ctrl+Shift+S` |
19
+ | Close window | `⌘+W` | `Ctrl+W` or `Alt+F4` |
20
+ | Quit app | `⌘+Q` | `Alt+F4` (no global Quit on Windows) |
21
+
22
+ ### Editing
23
+
24
+ | Action | macOS | Windows / Linux |
25
+ |---|---|---|
26
+ | Undo | `⌘+Z` | `Ctrl+Z` |
27
+ | Redo | `⌘+Shift+Z` | `Ctrl+Y` (or `Ctrl+Shift+Z`) |
28
+ | Cut / Copy / Paste | `⌘+X` / `⌘+C` / `⌘+V` | `Ctrl+X` / `Ctrl+C` / `Ctrl+V` |
29
+ | Select All | `⌘+A` | `Ctrl+A` |
30
+ | Find | `⌘+F` | `Ctrl+F` |
31
+ | Replace | `⌘+Option+F` | `Ctrl+H` |
32
+
33
+ ### Navigation
34
+
35
+ | Action | macOS | Windows / Linux |
36
+ |---|---|---|
37
+ | Switch tab forward | `⌘+Option+→` | `Ctrl+Tab` |
38
+ | New tab | `⌘+T` | `Ctrl+T` |
39
+ | Go back | `⌘+[` | `Alt+Left` |
40
+ | History | `⌘+Y` | `Ctrl+H` |
41
+
42
+ ### App-specific (creative apps)
43
+
44
+ | Action | macOS | Windows / Linux |
45
+ |---|---|---|
46
+ | Command palette | `⌘+K` (or `⌘+Shift+P`) | `Ctrl+K` (or `Ctrl+Shift+P`) |
47
+ | Settings / Preferences | `⌘+,` | `Ctrl+,` |
48
+ | Toggle sidebar | `⌘+B` | `Ctrl+B` |
49
+ | Focus mode | `⌘+.` or `⌘+Shift+F` | `Ctrl+.` or `Ctrl+Shift+F` |
50
+
51
+ ---
52
+
53
+ ## Cross-platform detection
54
+
55
+ On the web, the modifier is `metaKey` on macOS and `ctrlKey` everywhere else. Detect once, then route every shortcut through a single helper.
56
+
57
+ ```js
58
+ // navigator.platform is deprecated but still pragmatic; fall back to userAgent.
59
+ const isMac = navigator.platform
60
+ ? navigator.platform.toUpperCase().indexOf('MAC') >= 0
61
+ : /Mac|iPhone|iPad/.test(navigator.userAgent);
62
+
63
+ window.addEventListener('keydown', (event) => {
64
+ const modKey = isMac ? event.metaKey : event.ctrlKey;
65
+ if (modKey && event.key.toLowerCase() === 'k') {
66
+ event.preventDefault();
67
+ openCommandPalette();
68
+ }
69
+ });
70
+ ```
71
+
72
+ SwiftUI handles the platform layer for you: `.keyboardShortcut("k", modifiers: [.command])` resolves to `⌘+K` on macOS and to the same physical key combo when an iPad has a hardware keyboard attached. No platform branching needed.
73
+
74
+ ```swift
75
+ Button("Command Palette", action: openPalette)
76
+ .keyboardShortcut("k", modifiers: [.command])
77
+ ```
78
+
79
+ Compose Desktop exposes `KeyShortcut(Key.K, meta = true, ctrl = false)` for menu items. For raw key handling, branch on `event.isMetaPressed` (macOS) vs `event.isCtrlPressed` (Windows / Linux) by reading `hostOs` from `System.getProperty("os.name")` once at startup.
80
+
81
+ ---
82
+
83
+ ## Chord shortcuts (multi-step)
84
+
85
+ VS Code popularized chords like `⌘+K, ⌘+S` (open keyboard shortcuts editor). The pattern: a leader combo arms a buffer, the next combo within ~300ms triggers the action, otherwise the buffer resets.
86
+
87
+ **SwiftUI** does not natively support chord shortcuts. Use `NSEvent.addLocalMonitorForEvents(matching: .keyDown)` on macOS to intercept the leader, then track state in a small coordinator object. Reset the buffer on a `Task.sleep(for: .milliseconds(300))` timeout.
88
+
89
+ **Web** - maintain a small state machine with a 300ms timeout:
90
+
91
+ ```js
92
+ let chordPending = false;
93
+ let chordTimer = null;
94
+
95
+ window.addEventListener('keydown', (event) => {
96
+ const modKey = isMac ? event.metaKey : event.ctrlKey;
97
+ if (modKey && event.key === 'k' && !chordPending) {
98
+ event.preventDefault();
99
+ chordPending = true;
100
+ chordTimer = setTimeout(() => { chordPending = false; }, 300);
101
+ return;
102
+ }
103
+ if (chordPending && modKey && event.key === 's') {
104
+ event.preventDefault();
105
+ clearTimeout(chordTimer);
106
+ chordPending = false;
107
+ openShortcutsEditor();
108
+ }
109
+ });
110
+ ```
111
+
112
+ **Compose Desktop** - hold a `var pendingLeader: Key?` in your top-level `onKeyEvent` handler, schedule a coroutine to clear it after 300ms, and check it on the next keydown.
113
+
114
+ ---
115
+
116
+ ## Conflicts to avoid
117
+
118
+ - Don't override OS shortcuts: `⌘+Q`, `⌘+Tab`, `⌘+Space` on macOS, `Alt+Tab`, `Ctrl+Alt+Del`, `Win+L` on Windows. The OS will swallow them anyway, and the user will think your app is broken.
119
+ - Don't override browser shortcuts on web (`⌘+L` address bar, `⌘+T` new tab, `⌘+W` close tab) without strong justification. If you must, scope the override to a specific element in focus, never globally.
120
+ - Avoid one-letter shortcuts without a modifier (`s` for save, `n` for new). They kill text input the moment a focusable field gains focus, and they clash with browser quick-find (`/` in Firefox).
121
+
122
+ ---
123
+
124
+ ## Discoverability
125
+
126
+ A shortcut nobody finds is a shortcut nobody uses. Three patterns, layered:
127
+
128
+ - **In the menu, next to the command.** Native menu APIs (NSMenu, Win32 menus, SwiftUI `MenuBar`, Compose `MenuBar`) render the shortcut on the right side automatically when you bind one. Never hide a primary action from the menu just because it has a shortcut.
129
+ - **In a tooltip on hover, after a 1s delay.** Format: `Action name (⌘N)`. The delay matters: instant tooltips feel noisy and trigger on every cursor sweep.
130
+ - **A `⌘+?` or `⌘+/` overlay listing every shortcut.** GitHub, Linear, Slack, Figma all use this. Group by domain (App, Editing, Navigation, View) and make the list searchable. Bonus: highlight the user's most-used shortcuts as a learning nudge.
131
+
132
+ ---
133
+
134
+ ## Sources
135
+
136
+ - macOS keyboard shortcuts (Apple): https://support.apple.com/en-us/HT201236
137
+ - Windows keyboard shortcuts (Microsoft): https://support.microsoft.com/en-us/windows/keyboard-shortcuts-in-windows-dcc61a57-8ff0-cffe-9796-cb9706c75eec
@@ -0,0 +1,105 @@
1
+ # Multi-Window Deep Dive
2
+
3
+ Deep dive on multi-window architectures across desktop platforms. Covers when to split UI into multiple windows, how to wire them in SwiftUI and Compose Desktop, how to share state, and the lifecycle pitfalls each platform hides.
4
+
5
+ ---
6
+
7
+ ## When to use multiple windows
8
+
9
+ Multi-window is not free: each window doubles your state surface, your testing matrix, and your "where did I put that panel" surface area. Reach for it only when one of these scenarios actually fits.
10
+
11
+ ### Document-based apps
12
+
13
+ Each open document is its own window with its own undo stack, dirty state, and title. Pages, Numbers, Xcode, Figma desktop. The mental model is "one window = one thing I'm editing", and tabs would conflate documents that should stay independent. Closing one window must not lose the others, and `⌘+W` should close just that document.
14
+
15
+ ### Long-running secondary task
16
+
17
+ Export progress, terminal output, render preview, log tail. The user wants to keep watching it while continuing to work in the main window. Forcing this into a sheet or a panel kills the parallelism. Bonus: a secondary window can survive on a second monitor while the main window stays focused on the canvas.
18
+
19
+ ### Companion / inspector windows
20
+
21
+ Floating palettes, a properties panel, a color picker, a debugger. Secondary tools the power user wants visible without stealing canvas space. They live above the main window, often on a second monitor, and they are summoned by a shortcut or a menu item rather than appearing on launch.
22
+
23
+ If none of those fit, prefer a tab, a sidebar, or a modal sheet. Adding a window because "it could be useful" is how you end up with seven floating panels nobody can find again.
24
+
25
+ ---
26
+
27
+ ## SwiftUI multi-window
28
+
29
+ SwiftUI exposes windows as `Scene`s. `WindowGroup` is for primary content (one per document or one per app), `Window` is for singletons like inspectors. Open them imperatively with `@Environment(\.openWindow)`.
30
+
31
+ ```swift
32
+ @main
33
+ struct MyApp: App {
34
+ var body: some Scene {
35
+ WindowGroup { ContentView() }
36
+ Window("Inspector", id: "inspector") { InspectorView() }
37
+ .windowResizability(.contentSize)
38
+ }
39
+ }
40
+
41
+ // Then in any view:
42
+ @Environment(\.openWindow) var openWindow
43
+ Button("Open Inspector") { openWindow(id: "inspector") }
44
+ ```
45
+
46
+ `.windowResizability(.contentSize)` sizes the window to fit its content and locks resizing to the intrinsic size. Use it for inspectors and palettes. Use `.automatic` (the default) for editable canvases. Pair the `id` with `openWindow(id:value:)` if you need to pass a payload (a document ID, a selected entity), and SwiftUI will reuse an existing window if one already matches that id + value pair.
47
+
48
+ ---
49
+
50
+ ## Compose Desktop multi-window
51
+
52
+ Compose Desktop models windows as composables inside the `application` block. Each `Window` call adds one to the OS, and removing it from the composition closes it. State for "is this window open" lives in a `remember` or a `MutableState` higher up.
53
+
54
+ ```kotlin
55
+ fun main() = application {
56
+ var inspectorOpen by remember { mutableStateOf(false) }
57
+ Window(onCloseRequest = ::exitApplication, title = "Main") {
58
+ Button(onClick = { inspectorOpen = true }) { Text("Open Inspector") }
59
+ }
60
+ if (inspectorOpen) {
61
+ Window(onCloseRequest = { inspectorOpen = false }, title = "Inspector") {
62
+ InspectorContent()
63
+ }
64
+ }
65
+ }
66
+ ```
67
+
68
+ The `application` block stays alive as long as at least one window is composed. `::exitApplication` on the main window ensures closing it shuts the whole app down, while the inspector just flips its boolean and disappears. Use `rememberWindowState(size = ..., position = ...)` to persist size and position between launches, otherwise every reopen starts at the default top-left corner.
69
+
70
+ ---
71
+
72
+ ## State sharing patterns
73
+
74
+ Two windows looking at the same data must never disagree. Pick one of these patterns and stick with it across the whole app.
75
+
76
+ - **Singleton model.** A top-level `object` (Kotlin) or a `static let shared` (Swift) holding observable state. Simplest to wire, fine for small apps and prototypes. Falls apart the moment you need scoped lifetimes or unit tests with isolated state.
77
+ - **DI container.** Koin or Hilt for Compose, an `ObservableObject` exposed via `.environmentObject(...)` for SwiftUI. The container owns lifetimes, you inject the model into each window's root composable / view. This scales to multi-document apps where each window needs its own scoped instance.
78
+ - **Shared `@Observable` class injected via `.environment(...)`.** SwiftUI iOS 17+ / macOS 14+ approach. Mark the model `@Observable`, attach it once at the `App` level with `.environment(model)`, read it in any window with `@Environment(MyModel.self) var model`. Cleaner than `@EnvironmentObject` and avoids the published-property boilerplate.
79
+
80
+ Whichever you pick, write down the rule "secondary windows never own primary state". Inspectors observe and edit the model held by the document window, they do not hold the canonical copy. That way closing an inspector never loses work.
81
+
82
+ ---
83
+
84
+ ## Window lifecycle gotchas
85
+
86
+ Each platform fires lifecycle events at moments that are easy to get wrong, and the wrong hook means autosave fires twice or never at all.
87
+
88
+ - **SwiftUI**: use `Scene.onChange(of: scenePhase)` to react to active / inactive / background transitions. `.onAppear` fires once when the view shows up but does not fire again when the user clicks back into a window from another app. For "save on focus loss", you want `scenePhase`, not `onDisappear`.
89
+ - **Compose Desktop**: `LifecycleEventObserver` is an Android lifecycle API and does **not** apply to Compose Desktop. Use the `WindowState` returned by `rememberWindowState()` to observe size and position, and a `LaunchedEffect(windowState.isMinimized)` (or `.placement`) for transitions. There is no `onResume` / `onPause` equivalent: model focus and visibility yourself.
90
+ - **Web**: there is no real multi-window unless you call `window.open(...)`, and that is usually a popup blocker fight. Most "secondary windows" on web should actually be a side panel, a modal, or a separate tab the user opens deliberately. If you truly need a popout (a presenter view, a dedicated player), gate it behind a user gesture and handle the `null` return from `window.open` gracefully.
91
+
92
+ Across all three platforms: persist window size, position, and "was open at last quit" state to disk. Restoring exactly the layout the user left is the single biggest quality signal a multi-window app gives.
93
+
94
+ One more cross-platform trap: a window saved at coordinates `(3000, 1200)` on a second monitor will reopen offscreen if the user unplugs that monitor. Always clamp restored positions to the current screen list before applying them.
95
+
96
+ - SwiftUI: enumerate `NSScreen.screens` and clamp manually before passing to `.defaultPosition(...)`.
97
+ - Compose Desktop: `Toolkit.getDefaultToolkit().screenSize` plus `GraphicsEnvironment.getLocalGraphicsEnvironment().screenDevices` for the multi-monitor case.
98
+ - Web: there is no public API to get all monitors, but `window.screen.availWidth / availHeight` at least lets you keep popouts on the active screen.
99
+
100
+ ---
101
+
102
+ ## Sources
103
+
104
+ - Apple multi-window (`Scene`): https://developer.apple.com/documentation/swiftui/scene
105
+ - JetBrains Compose Desktop window management: https://www.jetbrains.com/help/kotlin-multiplatform-dev/compose-desktop-window-management.html