tribunal-kit 4.2.0 → 4.3.1

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 (186) hide show
  1. package/.agent/ARCHITECTURE.md +21 -14
  2. package/.agent/agents/swarm-worker-contracts.md +5 -5
  3. package/.agent/agents/ui-ux-auditor.md +292 -0
  4. package/.agent/rules/GEMINI.md +8 -8
  5. package/.agent/scripts/__pycache__/_colors.cpython-311.pyc +0 -0
  6. package/.agent/scripts/__pycache__/_utils.cpython-311.pyc +0 -0
  7. package/.agent/scripts/__pycache__/case_law_manager.cpython-311.pyc +0 -0
  8. package/.agent/scripts/_colors.js +18 -0
  9. package/.agent/scripts/_utils.js +42 -0
  10. package/.agent/scripts/auto_preview.js +197 -0
  11. package/.agent/scripts/bundle_analyzer.js +290 -0
  12. package/.agent/scripts/case_law_manager.js +684 -0
  13. package/.agent/scripts/checklist.js +266 -0
  14. package/.agent/scripts/colors.js +17 -0
  15. package/.agent/scripts/compress_skills.js +141 -0
  16. package/.agent/scripts/consolidate_skills.js +149 -0
  17. package/.agent/scripts/context_broker.js +609 -0
  18. package/.agent/scripts/deep_compress.js +150 -0
  19. package/.agent/scripts/dependency_analyzer.js +272 -0
  20. package/.agent/scripts/graph_builder.js +199 -0
  21. package/.agent/scripts/graph_zoom.js +154 -0
  22. package/.agent/scripts/inner_loop_validator.js +465 -0
  23. package/.agent/scripts/lint_runner.js +187 -0
  24. package/.agent/scripts/minify_context.js +100 -0
  25. package/.agent/scripts/patch_skills_meta.js +156 -0
  26. package/.agent/scripts/patch_skills_output.js +244 -0
  27. package/.agent/scripts/schema_validator.js +297 -0
  28. package/.agent/scripts/security_scan.js +303 -0
  29. package/.agent/scripts/session_manager.js +276 -0
  30. package/.agent/scripts/skill_evolution.js +644 -0
  31. package/.agent/scripts/skill_integrator.js +313 -0
  32. package/.agent/scripts/strengthen_skills.js +193 -0
  33. package/.agent/scripts/strip_tribunal.js +47 -0
  34. package/.agent/scripts/swarm_dispatcher.js +360 -0
  35. package/.agent/scripts/test_runner.js +193 -0
  36. package/.agent/scripts/utils.js +32 -0
  37. package/.agent/scripts/verify_all.js +256 -0
  38. package/.agent/skills/agent-organizer/SKILL.md +12 -4
  39. package/.agent/skills/agentic-patterns/SKILL.md +12 -4
  40. package/.agent/skills/ai-prompt-injection-defense/SKILL.md +12 -4
  41. package/.agent/skills/api-patterns/SKILL.md +209 -201
  42. package/.agent/skills/api-security-auditor/SKILL.md +12 -4
  43. package/.agent/skills/app-builder/SKILL.md +12 -4
  44. package/.agent/skills/app-builder/templates/SKILL.md +76 -68
  45. package/.agent/skills/app-builder/templates/astro-static/TEMPLATE.md +1 -1
  46. package/.agent/skills/app-builder/templates/chrome-extension/TEMPLATE.md +1 -1
  47. package/.agent/skills/app-builder/templates/cli-tool/TEMPLATE.md +1 -1
  48. package/.agent/skills/app-builder/templates/electron-desktop/TEMPLATE.md +1 -1
  49. package/.agent/skills/app-builder/templates/express-api/TEMPLATE.md +1 -1
  50. package/.agent/skills/app-builder/templates/flutter-app/TEMPLATE.md +1 -1
  51. package/.agent/skills/app-builder/templates/monorepo-turborepo/TEMPLATE.md +1 -1
  52. package/.agent/skills/app-builder/templates/nextjs-fullstack/TEMPLATE.md +1 -1
  53. package/.agent/skills/app-builder/templates/nextjs-saas/TEMPLATE.md +1 -1
  54. package/.agent/skills/app-builder/templates/nextjs-static/TEMPLATE.md +1 -1
  55. package/.agent/skills/app-builder/templates/nuxt-app/TEMPLATE.md +1 -1
  56. package/.agent/skills/app-builder/templates/python-fastapi/TEMPLATE.md +1 -1
  57. package/.agent/skills/app-builder/templates/react-native-app/TEMPLATE.md +1 -1
  58. package/.agent/skills/appflow-wireframe/SKILL.md +12 -4
  59. package/.agent/skills/architecture/SKILL.md +12 -4
  60. package/.agent/skills/authentication-best-practices/SKILL.md +12 -4
  61. package/.agent/skills/bash-linux/SKILL.md +12 -4
  62. package/.agent/skills/behavioral-modes/SKILL.md +12 -4
  63. package/.agent/skills/brainstorming/SKILL.md +12 -4
  64. package/.agent/skills/building-native-ui/SKILL.md +12 -4
  65. package/.agent/skills/clean-code/SKILL.md +12 -4
  66. package/.agent/skills/code-review-checklist/SKILL.md +12 -4
  67. package/.agent/skills/config-validator/SKILL.md +12 -4
  68. package/.agent/skills/csharp-developer/SKILL.md +12 -4
  69. package/.agent/skills/data-validation-schemas/SKILL.md +290 -282
  70. package/.agent/skills/database-design/SKILL.md +202 -194
  71. package/.agent/skills/deployment-procedures/SKILL.md +12 -4
  72. package/.agent/skills/devops-engineer/SKILL.md +12 -4
  73. package/.agent/skills/devops-incident-responder/SKILL.md +12 -4
  74. package/.agent/skills/doc.md +1 -1
  75. package/.agent/skills/documentation-templates/SKILL.md +12 -4
  76. package/.agent/skills/edge-computing/SKILL.md +12 -4
  77. package/.agent/skills/error-resilience/SKILL.md +390 -382
  78. package/.agent/skills/extract-design-system/SKILL.md +12 -4
  79. package/.agent/skills/framer-motion-expert/SKILL.md +206 -199
  80. package/.agent/skills/frontend-design/SKILL.md +163 -155
  81. package/.agent/skills/game-design-expert/SKILL.md +12 -4
  82. package/.agent/skills/game-engineering-expert/SKILL.md +12 -4
  83. package/.agent/skills/geo-fundamentals/SKILL.md +12 -4
  84. package/.agent/skills/github-operations/SKILL.md +12 -4
  85. package/.agent/skills/gsap-core/SKILL.md +54 -48
  86. package/.agent/skills/gsap-frameworks/SKILL.md +54 -48
  87. package/.agent/skills/gsap-performance/SKILL.md +54 -48
  88. package/.agent/skills/gsap-plugins/SKILL.md +54 -48
  89. package/.agent/skills/gsap-react/SKILL.md +54 -48
  90. package/.agent/skills/gsap-scrolltrigger/SKILL.md +54 -48
  91. package/.agent/skills/gsap-timeline/SKILL.md +54 -48
  92. package/.agent/skills/gsap-utils/SKILL.md +54 -48
  93. package/.agent/skills/i18n-localization/SKILL.md +12 -4
  94. package/.agent/skills/intelligent-routing/SKILL.md +41 -33
  95. package/.agent/skills/knowledge-graph/SKILL.md +36 -0
  96. package/.agent/skills/lint-and-validate/SKILL.md +12 -4
  97. package/.agent/skills/llm-engineering/SKILL.md +12 -4
  98. package/.agent/skills/local-first/SKILL.md +12 -4
  99. package/.agent/skills/mcp-builder/SKILL.md +12 -4
  100. package/.agent/skills/mobile-design/SKILL.md +225 -217
  101. package/.agent/skills/monorepo-management/SKILL.md +296 -288
  102. package/.agent/skills/motion-engineering/SKILL.md +195 -187
  103. package/.agent/skills/nextjs-react-expert/SKILL.md +196 -188
  104. package/.agent/skills/nodejs-best-practices/SKILL.md +12 -4
  105. package/.agent/skills/observability/SKILL.md +12 -4
  106. package/.agent/skills/parallel-agents/SKILL.md +12 -4
  107. package/.agent/skills/performance-profiling/SKILL.md +12 -4
  108. package/.agent/skills/plan-writing/SKILL.md +12 -4
  109. package/.agent/skills/platform-engineer/SKILL.md +12 -4
  110. package/.agent/skills/playwright-best-practices/SKILL.md +12 -4
  111. package/.agent/skills/powershell-windows/SKILL.md +12 -4
  112. package/.agent/skills/project-idioms/SKILL.md +12 -4
  113. package/.agent/skills/python-patterns/SKILL.md +12 -4
  114. package/.agent/skills/python-pro/SKILL.md +285 -277
  115. package/.agent/skills/react-specialist/SKILL.md +239 -231
  116. package/.agent/skills/readme-builder/SKILL.md +12 -4
  117. package/.agent/skills/realtime-patterns/SKILL.md +12 -4
  118. package/.agent/skills/red-team-tactics/SKILL.md +12 -4
  119. package/.agent/skills/rust-pro/SKILL.md +12 -4
  120. package/.agent/skills/seo-fundamentals/SKILL.md +12 -4
  121. package/.agent/skills/server-management/SKILL.md +12 -4
  122. package/.agent/skills/shadcn-ui-expert/SKILL.md +12 -4
  123. package/.agent/skills/skill-creator/SKILL.md +12 -4
  124. package/.agent/skills/sql-pro/SKILL.md +12 -4
  125. package/.agent/skills/supabase-postgres-best-practices/SKILL.md +12 -4
  126. package/.agent/skills/swiftui-expert/SKILL.md +12 -4
  127. package/.agent/skills/systematic-debugging/SKILL.md +12 -4
  128. package/.agent/skills/tailwind-patterns/SKILL.md +12 -4
  129. package/.agent/skills/tdd-workflow/SKILL.md +12 -4
  130. package/.agent/skills/test-result-analyzer/SKILL.md +12 -4
  131. package/.agent/skills/testing-patterns/SKILL.md +12 -4
  132. package/.agent/skills/trend-researcher/SKILL.md +12 -4
  133. package/.agent/skills/typescript-advanced/SKILL.md +297 -289
  134. package/.agent/skills/ui-ux-pro-max/SKILL.md +12 -4
  135. package/.agent/skills/ui-ux-researcher/SKILL.md +12 -4
  136. package/.agent/skills/vue-expert/SKILL.md +237 -229
  137. package/.agent/skills/vulnerability-scanner/SKILL.md +12 -4
  138. package/.agent/skills/web-accessibility-auditor/SKILL.md +12 -4
  139. package/.agent/skills/web-design-guidelines/SKILL.md +12 -4
  140. package/.agent/skills/webapp-testing/SKILL.md +12 -4
  141. package/.agent/skills/whimsy-injector/SKILL.md +12 -4
  142. package/.agent/skills/workflow-optimizer/SKILL.md +12 -4
  143. package/.agent/workflows/audit.md +6 -6
  144. package/.agent/workflows/deploy.md +1 -1
  145. package/.agent/workflows/generate.md +23 -6
  146. package/.agent/workflows/session.md +5 -5
  147. package/.agent/workflows/swarm.md +2 -2
  148. package/README.md +242 -186
  149. package/bin/tribunal-kit.js +297 -57
  150. package/package.json +81 -77
  151. package/scripts/changelog.js +167 -0
  152. package/scripts/sync-version.js +81 -0
  153. package/scripts/validate-payload.js +73 -0
  154. package/.agent/scripts/__pycache__/auto_preview.cpython-311.pyc +0 -0
  155. package/.agent/scripts/__pycache__/bundle_analyzer.cpython-311.pyc +0 -0
  156. package/.agent/scripts/__pycache__/checklist.cpython-311.pyc +0 -0
  157. package/.agent/scripts/__pycache__/dependency_analyzer.cpython-311.pyc +0 -0
  158. package/.agent/scripts/__pycache__/security_scan.cpython-311.pyc +0 -0
  159. package/.agent/scripts/__pycache__/session_manager.cpython-311.pyc +0 -0
  160. package/.agent/scripts/__pycache__/skill_integrator.cpython-311.pyc +0 -0
  161. package/.agent/scripts/__pycache__/swarm_dispatcher.cpython-311.pyc +0 -0
  162. package/.agent/scripts/__pycache__/test_runner.cpython-311.pyc +0 -0
  163. package/.agent/scripts/__pycache__/verify_all.cpython-311.pyc +0 -0
  164. package/.agent/scripts/auto_preview.py +0 -180
  165. package/.agent/scripts/bundle_analyzer.py +0 -259
  166. package/.agent/scripts/case_law_manager.py +0 -755
  167. package/.agent/scripts/checklist.py +0 -209
  168. package/.agent/scripts/compress_skills.py +0 -167
  169. package/.agent/scripts/consolidate_skills.py +0 -173
  170. package/.agent/scripts/deep_compress.py +0 -202
  171. package/.agent/scripts/dependency_analyzer.py +0 -247
  172. package/.agent/scripts/lint_runner.py +0 -188
  173. package/.agent/scripts/minify_context.py +0 -80
  174. package/.agent/scripts/patch_skills_meta.py +0 -177
  175. package/.agent/scripts/patch_skills_output.py +0 -285
  176. package/.agent/scripts/schema_validator.py +0 -279
  177. package/.agent/scripts/security_scan.py +0 -224
  178. package/.agent/scripts/session_manager.py +0 -261
  179. package/.agent/scripts/skill_evolution.py +0 -563
  180. package/.agent/scripts/skill_integrator.py +0 -234
  181. package/.agent/scripts/strengthen_skills.py +0 -220
  182. package/.agent/scripts/strip_tribunal.py +0 -41
  183. package/.agent/scripts/swarm_dispatcher.py +0 -350
  184. package/.agent/scripts/test_runner.py +0 -192
  185. package/.agent/scripts/test_swarm_dispatcher.py +0 -163
  186. package/.agent/scripts/verify_all.py +0 -195
@@ -1,221 +1,221 @@
1
- ---
2
- name: mobile-design
3
- description: Mobile-first design for iOS, Android, Foldables, React Native, Flutter. Touch interaction, haptics, 120Hz performance, on-device AI, spatial UI, Reanimated 3. Use when building mobile UI, animations, or cross-platform apps.
4
- allowed-tools: Read, Write, Edit, Glob, Grep
5
- version: 3.1.0
6
- last-updated: 2026-04-06
7
- ---
8
-
9
- # Mobile Design — Dense Reference
10
-
11
- ## Hallucination Traps (Read First)
12
- - ❌ `Animated.View` for any animation → ✅ `Reanimated 3` worklets (Animated API is legacy, runs on JS thread)
13
- - ❌ `ScrollView` for lists → ✅ `FlashList` (Shopify) — ScrollView renders ALL items at once
14
- - ❌ `estimatedItemSize` optional in FlashList → ✅ **REQUIRED** or you get 0-height items
15
- - ❌ White backgrounds (`#FFFFFF`) → ✅ OLED: `#000000` true black; off-white: `#FAFAFA`
16
- - ❌ Linear animations (`easing: linear`) → ✅ Spring physics (`stiffness`, `damping`)
17
- - ❌ Touch targets < 48px → ✅ Min 48px hitbox (visual size can be smaller via padding)
18
- - ❌ `useAnimatedStyle` in worklet without `'worklet'` directive → crashes on native thread
19
- - ❌ iOS: `useSafeAreaInsets()` optional → ✅ Required — screen content goes under dynamic island/home indicator
20
- - ❌ Android: hardcoded status bar height (24dp) → ✅ `StatusBar.currentHeight` (varies per device)
21
- - ❌ Platform-specific code with `if (platform === 'ios')` scattered everywhere → ✅ centralize in platform/ files
22
- - ❌ `console.log` in production → ✅ blocks JS thread — remove before release
23
-
24
- ---
25
-
26
- ## React Native Performance
27
-
28
- ### FlashList (Required for Lists)
29
- ```tsx
30
- import { FlashList } from "@shopify/flash-list";
31
- <FlashList
32
- data={items}
33
- renderItem={({ item }) => <ItemCard item={item} />}
34
- estimatedItemSize={100} // REQUIRED — measure actual item height first
35
- keyExtractor={(item) => item.id}
36
- getItemType={(item) => item.type} // multi-type optimization
37
- />
38
- // ❌ NEVER: <ScrollView>{items.map(...)}</ScrollView> for lists
39
- // ❌ NEVER: <FlatList> for perf-critical lists — FlashList is 5-10x faster
40
- ```
41
-
42
- ### Reanimated 3 — Worklet Animations (Required for 120Hz)
43
- ```tsx
44
- import { useSharedValue, useAnimatedStyle, withSpring, withTiming, runOnJS } from 'react-native-reanimated';
45
-
46
- // Shared values run on the UI thread — never on JS thread
47
- const scale = useSharedValue(1);
48
- const opacity = useSharedValue(0);
49
-
50
- // Animated style — computed on UI thread (no bridge crossing)
51
- const animatedStyle = useAnimatedStyle(() => ({
52
- transform: [{ scale: scale.value }],
53
- opacity: opacity.value,
54
- }));
55
-
56
- // Triggers
57
- const onPress = () => {
58
- scale.value = withSpring(0.95, { stiffness: 400, damping: 15 });
59
- opacity.value = withTiming(1, { duration: 200 });
60
- };
61
-
62
- // Call JS function from worklet
63
- const onComplete = () => runOnJS(setVisible)(true);
64
- scale.value = withSpring(1, {}, onComplete);
65
-
66
- // ❌ TRAP: Accessing shared value with .value inside useAnimatedStyle is fine — but inside a gesture handler callback, you need runOnJS to call React setState
67
- ```
68
-
69
- ### 120Hz Animation Rules
70
- - ✅ Animate ONLY: `transform` (translateX/Y, scale, rotate), `opacity` — all GPU composited
71
- - ❌ Never animate: `width`, `height`, `margin`, `padding`, `top/left/bottom/right` — causes layout recalc at 60 times per second → janky, battery draining
72
- - ✅ Use `withSpring` for all UI interactions (feel alive) — `withTiming` only for intentional timed animations
73
- - ✅ `Gesture.Pan()` / `Gesture.Tap()` from `react-native-gesture-handler` v2 (not `PanResponder`)
74
-
75
- ---
76
-
77
- ## Haptics
78
- ```tsx
79
- import * as Haptics from 'expo-haptics';
80
- // light → switch toggle, tap feedback
81
- // medium → selection change, confirm
82
- // heavy → destructive action, strong confirm
83
- // notificationAsync('success' | 'warning' | 'error') → operation outcomes
84
- Haptics.impactAsync(Haptics.ImpactFeedbackStyle.Light); // tap, toggle
85
- Haptics.notificationAsync(Haptics.NotificationFeedbackType.Success); // save complete
86
- // ❌ Never overuse — haptics must mean something
87
- // ❌ Haptics not supported on Android emulators — test on device
88
- ```
89
-
90
- ---
91
-
92
- ## Safe Areas & Platform Layout
93
- ```tsx
94
- import { useSafeAreaInsets } from 'react-native-safe-area-context';
95
- import { Platform, StatusBar } from 'react-native';
96
-
97
- function Screen() {
98
- const insets = useSafeAreaInsets();
99
- return (
100
- <View style={{ paddingTop: insets.top, paddingBottom: insets.bottom }}>
101
- {/* Content safe from Dynamic Island, home indicator, status bar */}
102
- </View>
103
- );
104
- }
105
- // Android status bar
106
- const STATUS_BAR_HEIGHT = Platform.OS === 'android' ? StatusBar.currentHeight ?? 24 : 0;
107
-
108
- // Foldable/tablet — dual pane
109
- import { useWindowDimensions } from 'react-native';
110
- function AdaptiveLayout() {
111
- const { width } = useWindowDimensions();
112
- const isTablet = width >= 600;
113
- return isTablet ? <TwoPaneView /> : <SinglePaneView />;
114
- }
115
- ```
116
-
117
- ---
118
-
119
- ## Touch Psychology & Thumb Zones
120
- - **Thumb zone**: Bottom 40% of screen = primary actions, FABs, CTAs
121
- - **Dead zone**: Top 25% = destructive/rare actions only
122
- - **48px minimum hitbox**: Visual icon can be 24px, padding expands hitbox to 48px
123
- ```tsx
124
- // Magnetic padding — visually small, touch-friendly
125
- <TouchableOpacity style={{ padding: 12, margin: -4 }}>
126
- <Icon size={24} />
127
- </TouchableOpacity>
128
- ```
129
- - **Coyote time**: Allow 100–150ms buffer after button intent registers before processing — prevents mis-taps
130
-
131
- ---
132
-
133
- ## Navigation (Expo Router / React Navigation)
134
- ```tsx
135
- // Expo Router v3+ (file-based, recommended)
136
- // app/(tabs)/_layout.tsx — tab navigator
137
- // app/[id].tsx — dynamic segment
138
- // app/(modal)/settings.tsx — modal group
139
-
140
- // Stack navigation with gesture
141
- import { Stack } from 'expo-router';
142
- <Stack screenOptions={{ headerShown: false, animation: 'slide_from_right' }}>
143
- <Stack.Screen name="(tabs)" />
144
- <Stack.Screen name="[id]" options={{ presentation: 'modal' }} />
145
- </Stack>
146
-
147
- // Deep linking (Expo Router handles automatically via app.json scheme)
148
- // ❌ TRAP: Don't use react-navigation Link for deep links in Expo Router — use expo-router Link
149
- import { Link, useRouter } from 'expo-router';
150
- const router = useRouter();
151
- router.push('/user/42');
152
- ```
153
-
154
- ---
155
-
156
- ## On-Device AI UX Patterns
157
- - **Zero-wait illusion**: When model runs → immediately show contextual skeleton/partial tokens
158
- - **Progressive disclosure**: Low confidence → softer UI, soft colors, require confirmation
159
- - **Streaming UI**: `useEffect` + SSE or `StreamingText` component appending tokens
160
- - **Local models** (MediaPipe, Core ML, ONNX): always wrap in try/catch — device capability varies
161
-
162
- ---
163
-
164
- ## Color & Typography
165
- ```tsx
166
- // OLED-safe dark mode
167
- const colors = {
168
- background: '#000000', // true black — OLED pixel off
169
- surface: '#0A0A0A', // cards
170
- surfaceAlt: '#121212', // elevated surfaces
171
- border: '#1F1F1F',
172
- text: '#FFFFFF',
173
- textMuted: '#8E8E93', // iOS system gray
174
- };
175
- // Dynamic type (iOS) — always use system font with scalesWithContentSizeCategory
176
- import { Text } from 'react-native';
177
- <Text style={{ fontSize: 16, fontFamily: Platform.OS === 'ios' ? 'System' : 'Roboto' }}>
178
- ```
179
-
180
- ---
181
-
182
- ## Performance Checklist
183
- | Issue | Fix |
184
- |-------|-----|
185
- | JS thread jank | Move ALL animations to Reanimated worklets |
186
- | Slow list | Replace ScrollView/FlatList with FlashList |
187
- | Image flicker | `Image` from `expo-image` (faster cache, blurhash) |
188
- | Re-render cascade | `React.memo` + stable callbacks + Zustand selectors |
189
- | Large bundle | Dynamic imports + Metro tree shaking |
190
- | Memory leak | `useEffect` cleanup + cancel animation on unmount |
191
-
192
- ```tsx
193
- // Cancel animation on unmount
194
- useEffect(() => {
195
- opacity.value = withTiming(1);
196
- return () => cancelAnimation(opacity); // ← critical
197
- }, []);
198
- ```
199
-
200
- ---
201
-
202
- ## iOS-Specific
203
- - **BlurView**: Use `@react-native-community/blur` for frosted glass nav bars/modals
204
- - **SF Symbols**: Use `@expo/vector-icons/Ionicons` for system-native icons
205
- - **Haptics**: `expo-haptics` — rich feedback on iOS, limited on Android
206
- - **Dynamic Island**: Check `insets.top > 50` for Dynamic Island devices
207
- - **Sheet presentations**: `presentation: 'formSheet'` in Expo Router for iOS bottom sheet native feel
208
-
209
- ## Android-Specific
210
- - **Material You**: Use `react-native-paper` for M3 dynamic color theming
211
- - **Edge-to-edge**: Set `android:windowLayoutInDisplayCutoutMode="shortEdges"` in AndroidManifest
212
- - **Back gesture prediction**: Wrap routes in `GestureHandlerRootView` at root
213
- - **Splash**: Use `expo-splash-screen` — never hardcode a delay
1
+ ---
2
+ name: mobile-design
3
+ description: Mobile-first design for iOS, Android, Foldables, React Native, Flutter. Touch interaction, haptics, 120Hz performance, on-device AI, spatial UI, Reanimated 3. Use when building mobile UI, animations, or cross-platform apps.
4
+ allowed-tools: Read, Write, Edit, Glob, Grep
5
+ version: 3.1.0
6
+ last-updated: 2026-04-06
7
+ ---
8
+
9
+ # Mobile Design — Dense Reference
10
+
11
+ ## Hallucination Traps (Read First)
12
+ - ❌ `Animated.View` for any animation → ✅ `Reanimated 3` worklets (Animated API is legacy, runs on JS thread)
13
+ - ❌ `ScrollView` for lists → ✅ `FlashList` (Shopify) — ScrollView renders ALL items at once
14
+ - ❌ `estimatedItemSize` optional in FlashList → ✅ **REQUIRED** or you get 0-height items
15
+ - ❌ White backgrounds (`#FFFFFF`) → ✅ OLED: `#000000` true black; off-white: `#FAFAFA`
16
+ - ❌ Linear animations (`easing: linear`) → ✅ Spring physics (`stiffness`, `damping`)
17
+ - ❌ Touch targets < 48px → ✅ Min 48px hitbox (visual size can be smaller via padding)
18
+ - ❌ `useAnimatedStyle` in worklet without `'worklet'` directive → crashes on native thread
19
+ - ❌ iOS: `useSafeAreaInsets()` optional → ✅ Required — screen content goes under dynamic island/home indicator
20
+ - ❌ Android: hardcoded status bar height (24dp) → ✅ `StatusBar.currentHeight` (varies per device)
21
+ - ❌ Platform-specific code with `if (platform === 'ios')` scattered everywhere → ✅ centralize in platform/ files
22
+ - ❌ `console.log` in production → ✅ blocks JS thread — remove before release
23
+
24
+ ---
25
+
26
+ ## React Native Performance
27
+
28
+ ### FlashList (Required for Lists)
29
+ ```tsx
30
+ import { FlashList } from "@shopify/flash-list";
31
+ <FlashList
32
+ data={items}
33
+ renderItem={({ item }) => <ItemCard item={item} />}
34
+ estimatedItemSize={100} // REQUIRED — measure actual item height first
35
+ keyExtractor={(item) => item.id}
36
+ getItemType={(item) => item.type} // multi-type optimization
37
+ />
38
+ // ❌ NEVER: <ScrollView>{items.map(...)}</ScrollView> for lists
39
+ // ❌ NEVER: <FlatList> for perf-critical lists — FlashList is 5-10x faster
40
+ ```
41
+
42
+ ### Reanimated 3 — Worklet Animations (Required for 120Hz)
43
+ ```tsx
44
+ import { useSharedValue, useAnimatedStyle, withSpring, withTiming, runOnJS } from 'react-native-reanimated';
45
+
46
+ // Shared values run on the UI thread — never on JS thread
47
+ const scale = useSharedValue(1);
48
+ const opacity = useSharedValue(0);
49
+
50
+ // Animated style — computed on UI thread (no bridge crossing)
51
+ const animatedStyle = useAnimatedStyle(() => ({
52
+ transform: [{ scale: scale.value }],
53
+ opacity: opacity.value,
54
+ }));
55
+
56
+ // Triggers
57
+ const onPress = () => {
58
+ scale.value = withSpring(0.95, { stiffness: 400, damping: 15 });
59
+ opacity.value = withTiming(1, { duration: 200 });
60
+ };
61
+
62
+ // Call JS function from worklet
63
+ const onComplete = () => runOnJS(setVisible)(true);
64
+ scale.value = withSpring(1, {}, onComplete);
65
+
66
+ // ❌ TRAP: Accessing shared value with .value inside useAnimatedStyle is fine — but inside a gesture handler callback, you need runOnJS to call React setState
67
+ ```
68
+
69
+ ### 120Hz Animation Rules
70
+ - ✅ Animate ONLY: `transform` (translateX/Y, scale, rotate), `opacity` — all GPU composited
71
+ - ❌ Never animate: `width`, `height`, `margin`, `padding`, `top/left/bottom/right` — causes layout recalc at 60 times per second → janky, battery draining
72
+ - ✅ Use `withSpring` for all UI interactions (feel alive) — `withTiming` only for intentional timed animations
73
+ - ✅ `Gesture.Pan()` / `Gesture.Tap()` from `react-native-gesture-handler` v2 (not `PanResponder`)
74
+
75
+ ---
76
+
77
+ ## Haptics
78
+ ```tsx
79
+ import * as Haptics from 'expo-haptics';
80
+ // light → switch toggle, tap feedback
81
+ // medium → selection change, confirm
82
+ // heavy → destructive action, strong confirm
83
+ // notificationAsync('success' | 'warning' | 'error') → operation outcomes
84
+ Haptics.impactAsync(Haptics.ImpactFeedbackStyle.Light); // tap, toggle
85
+ Haptics.notificationAsync(Haptics.NotificationFeedbackType.Success); // save complete
86
+ // ❌ Never overuse — haptics must mean something
87
+ // ❌ Haptics not supported on Android emulators — test on device
88
+ ```
89
+
90
+ ---
91
+
92
+ ## Safe Areas & Platform Layout
93
+ ```tsx
94
+ import { useSafeAreaInsets } from 'react-native-safe-area-context';
95
+ import { Platform, StatusBar } from 'react-native';
96
+
97
+ function Screen() {
98
+ const insets = useSafeAreaInsets();
99
+ return (
100
+ <View style={{ paddingTop: insets.top, paddingBottom: insets.bottom }}>
101
+ {/* Content safe from Dynamic Island, home indicator, status bar */}
102
+ </View>
103
+ );
104
+ }
105
+ // Android status bar
106
+ const STATUS_BAR_HEIGHT = Platform.OS === 'android' ? StatusBar.currentHeight ?? 24 : 0;
107
+
108
+ // Foldable/tablet — dual pane
109
+ import { useWindowDimensions } from 'react-native';
110
+ function AdaptiveLayout() {
111
+ const { width } = useWindowDimensions();
112
+ const isTablet = width >= 600;
113
+ return isTablet ? <TwoPaneView /> : <SinglePaneView />;
114
+ }
115
+ ```
116
+
117
+ ---
214
118
 
119
+ ## Touch Psychology & Thumb Zones
120
+ - **Thumb zone**: Bottom 40% of screen = primary actions, FABs, CTAs
121
+ - **Dead zone**: Top 25% = destructive/rare actions only
122
+ - **48px minimum hitbox**: Visual icon can be 24px, padding expands hitbox to 48px
123
+ ```tsx
124
+ // Magnetic padding — visually small, touch-friendly
125
+ <TouchableOpacity style={{ padding: 12, margin: -4 }}>
126
+ <Icon size={24} />
127
+ </TouchableOpacity>
128
+ ```
129
+ - **Coyote time**: Allow 100–150ms buffer after button intent registers before processing — prevents mis-taps
215
130
 
216
131
  ---
217
132
 
218
- ## 🤖 LLM-Specific Traps
133
+ ## Navigation (Expo Router / React Navigation)
134
+ ```tsx
135
+ // Expo Router v3+ (file-based, recommended)
136
+ // app/(tabs)/_layout.tsx — tab navigator
137
+ // app/[id].tsx — dynamic segment
138
+ // app/(modal)/settings.tsx — modal group
139
+
140
+ // Stack navigation with gesture
141
+ import { Stack } from 'expo-router';
142
+ <Stack screenOptions={{ headerShown: false, animation: 'slide_from_right' }}>
143
+ <Stack.Screen name="(tabs)" />
144
+ <Stack.Screen name="[id]" options={{ presentation: 'modal' }} />
145
+ </Stack>
146
+
147
+ // Deep linking (Expo Router handles automatically via app.json scheme)
148
+ // ❌ TRAP: Don't use react-navigation Link for deep links in Expo Router — use expo-router Link
149
+ import { Link, useRouter } from 'expo-router';
150
+ const router = useRouter();
151
+ router.push('/user/42');
152
+ ```
153
+
154
+ ---
155
+
156
+ ## On-Device AI UX Patterns
157
+ - **Zero-wait illusion**: When model runs → immediately show contextual skeleton/partial tokens
158
+ - **Progressive disclosure**: Low confidence → softer UI, soft colors, require confirmation
159
+ - **Streaming UI**: `useEffect` + SSE or `StreamingText` component appending tokens
160
+ - **Local models** (MediaPipe, Core ML, ONNX): always wrap in try/catch — device capability varies
161
+
162
+ ---
163
+
164
+ ## Color & Typography
165
+ ```tsx
166
+ // OLED-safe dark mode
167
+ const colors = {
168
+ background: '#000000', // true black — OLED pixel off
169
+ surface: '#0A0A0A', // cards
170
+ surfaceAlt: '#121212', // elevated surfaces
171
+ border: '#1F1F1F',
172
+ text: '#FFFFFF',
173
+ textMuted: '#8E8E93', // iOS system gray
174
+ };
175
+ // Dynamic type (iOS) — always use system font with scalesWithContentSizeCategory
176
+ import { Text } from 'react-native';
177
+ <Text style={{ fontSize: 16, fontFamily: Platform.OS === 'ios' ? 'System' : 'Roboto' }}>
178
+ ```
179
+
180
+ ---
181
+
182
+ ## Performance Checklist
183
+ | Issue | Fix |
184
+ |-------|-----|
185
+ | JS thread jank | Move ALL animations to Reanimated worklets |
186
+ | Slow list | Replace ScrollView/FlatList with FlashList |
187
+ | Image flicker | `Image` from `expo-image` (faster cache, blurhash) |
188
+ | Re-render cascade | `React.memo` + stable callbacks + Zustand selectors |
189
+ | Large bundle | Dynamic imports + Metro tree shaking |
190
+ | Memory leak | `useEffect` cleanup + cancel animation on unmount |
191
+
192
+ ```tsx
193
+ // Cancel animation on unmount
194
+ useEffect(() => {
195
+ opacity.value = withTiming(1);
196
+ return () => cancelAnimation(opacity); // ← critical
197
+ }, []);
198
+ ```
199
+
200
+ ---
201
+
202
+ ## iOS-Specific
203
+ - **BlurView**: Use `@react-native-community/blur` for frosted glass nav bars/modals
204
+ - **SF Symbols**: Use `@expo/vector-icons/Ionicons` for system-native icons
205
+ - **Haptics**: `expo-haptics` — rich feedback on iOS, limited on Android
206
+ - **Dynamic Island**: Check `insets.top > 50` for Dynamic Island devices
207
+ - **Sheet presentations**: `presentation: 'formSheet'` in Expo Router for iOS bottom sheet native feel
208
+
209
+ ## Android-Specific
210
+ - **Material You**: Use `react-native-paper` for M3 dynamic color theming
211
+ - **Edge-to-edge**: Set `android:windowLayoutInDisplayCutoutMode="shortEdges"` in AndroidManifest
212
+ - **Back gesture prediction**: Wrap routes in `GestureHandlerRootView` at root
213
+ - **Splash**: Use `expo-splash-screen` — never hardcode a delay
214
+
215
+
216
+ ---
217
+
218
+
219
219
 
220
220
  AI coding assistants often fall into specific bad habits when dealing with this domain. These are strictly forbidden:
221
221
 
@@ -227,7 +227,7 @@ AI coding assistants often fall into specific bad habits when dealing with this
227
227
 
228
228
  ---
229
229
 
230
- ## 🏛️ Tribunal Integration (Anti-Hallucination)
230
+
231
231
 
232
232
  **Slash command: `/review` or `/tribunal-full`**
233
233
  **Active reviewers: `logic-reviewer` · `security-auditor`**
@@ -238,7 +238,7 @@ AI coding assistants often fall into specific bad habits when dealing with this
238
238
  2. **Silent Degradation:** Catching and suppressing errors without logging or handling.
239
239
  3. **Context Amnesia:** Forgetting the user's constraints and offering generic advice instead of tailored solutions.
240
240
 
241
- ### ✅ Pre-Flight Self-Audit
241
+
242
242
 
243
243
  Review these questions before confirming output:
244
244
  ```
@@ -252,4 +252,12 @@ Review these questions before confirming output:
252
252
 
253
253
  **CRITICAL:** You must follow a strict "evidence-based closeout" state machine.
254
254
  - ❌ **Forbidden:** Declaring a task complete because the output "looks correct."
255
- - ✅ **Required:** You are explicitly forbidden from finalizing any task without providing **concrete evidence** (terminal output, passing tests, compile success, or equivalent proof) that your output works as intended.
255
+ - ✅ **Required:** You are explicitly forbidden from finalizing any task without providing **concrete evidence** (terminal output, passing tests, compile success, or equivalent proof) that your output works as intended.
256
+
257
+
258
+ ## Pre-Flight Checklist
259
+ - [ ] Have I reviewed the user's specific constraints and requests?
260
+ - [ ] Have I checked the environment for relevant existing implementations?
261
+
262
+ ## VBC Protocol (Verification-Before-Completion)
263
+ You MUST verify existing code signatures and variables before attempting to modify or call them. No hallucination is permitted.