@buivietphi/skill-mobile-mt 1.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.
@@ -0,0 +1,121 @@
1
+ # Code Review — Senior Protocol
2
+
3
+ > 🔴 Always loaded. All platforms.
4
+
5
+ ---
6
+
7
+ ## Checklist
8
+
9
+ ### Architecture
10
+ - [ ] Single responsibility per file (max 300 lines)
11
+ - [ ] Dependencies flow inward (UI → Domain → Data)
12
+ - [ ] Follows existing project patterns
13
+ - [ ] New files in correct directory
14
+
15
+ ### Correctness
16
+ - [ ] All states handled: loading, success, error, empty
17
+ - [ ] Edge cases: null, empty, timeout, concurrent
18
+ - [ ] Async errors caught with meaningful handling
19
+ - [ ] Cleanup on unmount/dispose (listeners, timers, subscriptions)
20
+ - [ ] No race conditions (double-tap, concurrent API calls)
21
+
22
+ ### Performance
23
+ - [ ] Lists virtualized (FlatList / ListView.builder / LazyColumn)
24
+ - [ ] Memoized where needed (memo / const / remember)
25
+ - [ ] No inline functions in render/build
26
+ - [ ] Images cached and resized
27
+ - [ ] No main thread blocking
28
+
29
+ ### Security
30
+ - [ ] No hardcoded secrets
31
+ - [ ] Secure storage for tokens (Keychain / EncryptedSharedPreferences)
32
+ - [ ] Input validated and sanitized
33
+ - [ ] Deep links validated before navigation
34
+ - [ ] No sensitive data in logs
35
+
36
+ ### Platform
37
+ - [ ] Both iOS + Android tested (if cross-platform)
38
+ - [ ] Safe areas / notch handled
39
+ - [ ] Keyboard handled (dismiss, avoidance)
40
+ - [ ] Back button handled (Android)
41
+ - [ ] Accessibility labels on interactive elements
42
+
43
+ ---
44
+
45
+ ## Severity
46
+
47
+ | Level | Action | Example |
48
+ |-------|--------|---------|
49
+ | 🔴 CRITICAL | Must fix before merge | Crash, security hole, data loss |
50
+ | 🟠 HIGH | Should fix before merge | Memory leak, missing error state, race condition |
51
+ | 🟡 MEDIUM | Fix in follow-up | Naming inconsistency, missing memoization |
52
+ | 🔵 LOW | Nice to have | Minor style, comment improvement |
53
+
54
+ ---
55
+
56
+ ## Auto-Fail
57
+
58
+ **Any of these → block merge immediately:**
59
+
60
+ ```
61
+ ❌ console.log / print in production code
62
+ ❌ Hardcoded secrets or API keys
63
+ ❌ Force unwrap without null check (! / !! / as!)
64
+ ❌ Empty catch blocks (error silently swallowed)
65
+ ❌ 500+ line files
66
+ ❌ Network call in render / build / Composable
67
+ ❌ Index as list key
68
+ ❌ Missing loading / error / empty state (blank screen)
69
+ ```
70
+
71
+ ---
72
+
73
+ ## Review Comment Templates
74
+
75
+ ```
76
+ 🔴 CRITICAL — [file:line]
77
+ Issue: [description]
78
+ Impact: [what breaks]
79
+ Fix: [specific code change]
80
+
81
+ 🟠 HIGH — [file:line]
82
+ Issue: [description]
83
+ Fix: [suggestion]
84
+
85
+ 🟡 MEDIUM — [file:line]
86
+ Suggestion: [improvement]
87
+ ```
88
+
89
+ ---
90
+
91
+ ## Example Issues
92
+
93
+ ### Before (Bad)
94
+ ```typescript
95
+ // ❌ No error handling, no loading state, index as key
96
+ function ProductList() {
97
+ const [data, setData] = useState([]);
98
+ useEffect(() => { api.get('/products').then(r => setData(r.data)); }, []);
99
+ return data.map((item, i) => <ProductCard key={i} item={item} />);
100
+ }
101
+ ```
102
+
103
+ ### After (Good)
104
+ ```typescript
105
+ // ✅ All states, cleanup, stable key, error handling
106
+ function ProductList() {
107
+ const [state, setState] = useState({ data: [], loading: true, error: null });
108
+ useEffect(() => {
109
+ let cancelled = false;
110
+ api.get('/products')
111
+ .then(r => { if (!cancelled) setState({ data: r.data, loading: false, error: null }); })
112
+ .catch(e => { if (!cancelled) setState({ data: [], loading: false, error: e.message }); });
113
+ return () => { cancelled = true; };
114
+ }, []);
115
+
116
+ if (state.loading) return <LoadingSkeleton />;
117
+ if (state.error) return <ErrorView message={state.error} onRetry={refresh} />;
118
+ if (!state.data.length) return <EmptyState />;
119
+ return <FlatList data={state.data} keyExtractor={item => item.id} renderItem={...} />;
120
+ }
121
+ ```
@@ -0,0 +1,117 @@
1
+ # Common Pitfalls — Problem → Symptoms → Solution
2
+
3
+ > Cross-platform mobile mistakes. Learn from production incidents.
4
+
5
+ ---
6
+
7
+ ## 1. setState After Unmount
8
+
9
+ | | |
10
+ |--|--|
11
+ | **Problem** | Async operation completes after screen is popped/unmounted |
12
+ | **Symptoms** | "Can't perform a React state update on an unmounted component" / crash |
13
+ | **Solution (RN)** | Track mounted state: `useRef` + cleanup in `useEffect` return |
14
+ | **Solution (Flutter)** | Check `mounted` before `setState`, cancel in `dispose()` |
15
+ | **Solution (iOS)** | Use `Task` with cancellation, `[weak self]` in closures |
16
+ | **Solution (Android)** | Use `viewModelScope` (auto-cancels), `Lifecycle`-aware coroutines |
17
+
18
+ ## 2. Token Refresh Race Condition
19
+
20
+ | | |
21
+ |--|--|
22
+ | **Problem** | Multiple 401 responses trigger multiple token refresh calls |
23
+ | **Symptoms** | Duplicate refresh requests, token corruption, logout loops |
24
+ | **Solution** | Queue all 401s, refresh once, replay queued requests with new token |
25
+
26
+ ## 3. List Performance (ScrollView Trap)
27
+
28
+ | | |
29
+ |--|--|
30
+ | **Problem** | Using ScrollView / Column for dynamic lists |
31
+ | **Symptoms** | Jank, high memory, slow render with 50+ items |
32
+ | **Solution (RN)** | `FlatList` with `keyExtractor`, `getItemLayout`, `removeClippedSubviews` |
33
+ | **Solution (Flutter)** | `ListView.builder` or `SliverList` (lazy rendering) |
34
+ | **Solution (Android)** | `LazyColumn` with stable `key` |
35
+
36
+ ## 4. Memory Leak — Listeners Not Cleaned
37
+
38
+ | | |
39
+ |--|--|
40
+ | **Problem** | Event listeners, subscriptions, timers created but never removed |
41
+ | **Symptoms** | Memory grows over time, app slows down, eventual crash |
42
+ | **Solution (RN)** | Always return cleanup in `useEffect`: `return () => listener.remove()` |
43
+ | **Solution (Flutter)** | `StreamSubscription.cancel()` and `controller.dispose()` in `dispose()` |
44
+ | **Solution (iOS)** | Remove `NotificationCenter` observers, cancel `Task`s |
45
+ | **Solution (Android)** | Unregister `BroadcastReceiver`, cancel coroutine scopes |
46
+
47
+ ## 5. Hardcoded Strings / Magic Numbers
48
+
49
+ | | |
50
+ |--|--|
51
+ | **Problem** | Colors, sizes, URLs, keys scattered as literals in code |
52
+ | **Symptoms** | Inconsistent UI, hard to maintain, hard to theme |
53
+ | **Solution** | Constants file for colors/spacing, env config for URLs/keys |
54
+
55
+ ## 6. Missing Error Boundaries
56
+
57
+ | | |
58
+ |--|--|
59
+ | **Problem** | Uncaught error in one component crashes the entire app |
60
+ | **Symptoms** | White screen of death, full app crash |
61
+ | **Solution (RN)** | Wrap with `ErrorBoundary` component at screen/feature level |
62
+ | **Solution (Flutter)** | `ErrorWidget.builder` + try/catch in async providers |
63
+ | **Solution (iOS)** | Graceful error states in every View (`.error` case in ViewModel) |
64
+ | **Solution (Android)** | Sealed `UiState` with `Error` case, never let exceptions propagate to UI |
65
+
66
+ ## 7. Deep Link Injection
67
+
68
+ | | |
69
+ |--|--|
70
+ | **Problem** | Deep link parameters used directly without validation |
71
+ | **Symptoms** | Navigation to unauthorized screens, data exposure |
72
+ | **Solution** | Validate all deep link params (type, format, authorization) before navigating |
73
+
74
+ ## 8. Button Double-Tap
75
+
76
+ | | |
77
+ |--|--|
78
+ | **Problem** | User taps submit button twice during async operation |
79
+ | **Symptoms** | Duplicate API calls, duplicate records, charge twice |
80
+ | **Solution** | `isSubmitting` flag — disable button during async operation |
81
+
82
+ ## 9. Large Images Unoptimized
83
+
84
+ | | |
85
+ |--|--|
86
+ | **Problem** | Loading full-resolution images from server |
87
+ | **Symptoms** | High memory, slow scroll, OOM crash on old devices |
88
+ | **Solution** | Request resized images from CDN, use `cached_network_image` / `FastImage`, progressive loading |
89
+
90
+ ## 10. Missing Offline Handling
91
+
92
+ | | |
93
+ |--|--|
94
+ | **Problem** | App assumes network is always available |
95
+ | **Symptoms** | Crash or infinite loading when offline, data loss |
96
+ | **Solution** | Cache critical data locally, show cached data + "offline" banner, queue operations for retry |
97
+
98
+ ## 11. Platform-Specific Ignoring
99
+
100
+ | | |
101
+ |--|--|
102
+ | **Problem** | Testing only on iOS, shipping broken Android (or vice versa) |
103
+ | **Symptoms** | Android back button doesn't work, keyboard covers input, notch/status bar overlap |
104
+ | **Solution** | Test on BOTH platforms. Handle: back button, safe area, keyboard avoidance, permissions |
105
+
106
+ ## 12. Wrong Package Manager
107
+
108
+ | | |
109
+ |--|--|
110
+ | **Problem** | Using `npm install` in a `yarn.lock` project |
111
+ | **Symptoms** | Conflicting lock files, dependency resolution differs, CI fails |
112
+ | **Solution** | Check lock file first. `yarn.lock` → yarn. `package-lock.json` → npm. Never mix. |
113
+
114
+ ---
115
+
116
+ > Every pitfall here has caused a production incident.
117
+ > Learn from others' mistakes.
@@ -0,0 +1,167 @@
1
+ # Document Analysis — Extract Requirements from Any File
2
+
3
+ > Parse design files, specs, and documents into actionable mobile implementation tasks.
4
+
5
+ ## Supported Formats
6
+
7
+ | Format | How to Read | Use Case |
8
+ |--------|------------|----------|
9
+ | **Images** (PNG, JPG, WebP) | Read tool (multimodal) | UI mockups, wireframes, screenshots |
10
+ | **PDF** | Read tool (pages param, max 20/request) | PRD, API docs, design specs |
11
+ | **DOCX** | Convert to text first | Requirements, user stories |
12
+ | **XML** | Read tool directly | Android layouts, config, API response |
13
+ | **JSON** | Read tool directly | API contracts, config, mock data |
14
+ | **YAML** | Read tool directly | CI/CD config, OpenAPI specs |
15
+ | **Figma** | URL → WebFetch | Design tokens, component specs |
16
+
17
+ ## Analysis Protocol
18
+
19
+ ### Step 1: Identify Document Type
20
+
21
+ ```
22
+ DOCUMENT TYPE:
23
+ Image (mockup/wireframe) → UI Analysis Protocol
24
+ PDF/DOCX (requirements) → Requirements Extraction Protocol
25
+ XML/JSON (API contract) → Data Model Protocol
26
+ Figma URL → Design Token Protocol
27
+ ```
28
+
29
+ ### Step 2: Extract by Type
30
+
31
+ #### UI Analysis (Images)
32
+
33
+ ```
34
+ FROM IMAGE, EXTRACT:
35
+ 1. LAYOUT
36
+ - Screen structure (header, body, footer, tabs)
37
+ - Component hierarchy (parent → child)
38
+ - Spacing pattern (uniform? 8px grid? 16px?)
39
+
40
+ 2. COMPONENTS
41
+ - List all visible UI elements
42
+ - Map to framework components:
43
+ Button, TextInput, FlatList, Image, Card, Modal, etc.
44
+ - Note interactive elements (tap, swipe, scroll)
45
+
46
+ 3. STYLING
47
+ - Colors (primary, secondary, background, text)
48
+ - Typography (heading size, body size, font weight)
49
+ - Border radius, shadows, elevation
50
+ - Dark mode indicators (if visible)
51
+
52
+ 4. STATES (infer from design)
53
+ - Loading: where to show skeleton/shimmer?
54
+ - Empty: what if list has no items?
55
+ - Error: where to show error message?
56
+
57
+ OUTPUT → Component tree + style constants + state handling plan
58
+ ```
59
+
60
+ #### Requirements Extraction (PDF/DOCX)
61
+
62
+ ```
63
+ FROM DOCUMENT, EXTRACT:
64
+ 1. USER STORIES
65
+ - "As a [user], I want [action], so that [benefit]"
66
+ - Priority: must-have / nice-to-have
67
+ - Acceptance criteria
68
+
69
+ 2. SCREENS / FLOWS
70
+ - List all screens mentioned
71
+ - Map navigation flow (Screen A → Screen B → Screen C)
72
+ - Identify entry points and exit points
73
+
74
+ 3. DATA REQUIREMENTS
75
+ - What data does each screen need?
76
+ - API endpoints mentioned
77
+ - Data relationships (user has many orders)
78
+
79
+ 4. BUSINESS RULES
80
+ - Validation rules (email format, password strength)
81
+ - Permission levels (admin, user, guest)
82
+ - Edge cases mentioned
83
+
84
+ 5. NON-FUNCTIONAL
85
+ - Performance requirements (load time, offline support)
86
+ - Platform requirements (iOS min version, Android min SDK)
87
+ - Accessibility requirements
88
+
89
+ OUTPUT → Feature list + screen map + data model + API contract
90
+ ```
91
+
92
+ #### Data Model Protocol (XML/JSON)
93
+
94
+ ```
95
+ FROM API CONTRACT, EXTRACT:
96
+ 1. ENDPOINTS
97
+ - Method + URL + description
98
+ - Request params / body
99
+ - Response shape
100
+
101
+ 2. MODELS / TYPES
102
+ - Generate TypeScript interfaces / Dart classes / Swift structs / Kotlin data classes
103
+ - Include optional fields, enums, nested objects
104
+ - Add serialization annotations if needed
105
+
106
+ 3. ERROR RESPONSES
107
+ - Error code mapping
108
+ - Error message display strategy
109
+
110
+ OUTPUT → Type definitions + API service layer + error handling
111
+ ```
112
+
113
+ ## Document → Code Pipeline
114
+
115
+ ```
116
+ STEP 1: READ DOCUMENT
117
+ - Image: Read tool (visual analysis)
118
+ - PDF: Read tool with pages param
119
+ - DOCX/XML/JSON: Read tool directly
120
+ - Large PDF (>20 pages): Read in chunks (pages: "1-20", "21-40", etc.)
121
+
122
+ STEP 2: EXTRACT REQUIREMENTS
123
+ - Run appropriate extraction protocol above
124
+ - Output structured summary
125
+
126
+ STEP 3: MAP TO FEATURES
127
+ - Group requirements into features
128
+ - Identify dependencies between features
129
+ - Prioritize: auth → core screens → secondary features
130
+
131
+ STEP 4: SCAFFOLD
132
+ - Use Feature Scaffold Protocol from SKILL.md
133
+ - Create features in dependency order
134
+ - Wire navigation between screens
135
+
136
+ STEP 5: VERIFY
137
+ - Cross-check: every requirement has matching code
138
+ - Cross-check: every screen in doc has matching screen file
139
+ - Cross-check: every API endpoint has matching service method
140
+ ```
141
+
142
+ ## Quick Commands
143
+
144
+ ```
145
+ "Read mockup.png and implement this screen"
146
+ → UI Analysis → Component tree → Generate code
147
+
148
+ "Read requirements.pdf pages 1-10 and list all features"
149
+ → Requirements Extraction → Feature list
150
+
151
+ "Read api.json and generate all models and services"
152
+ → Data Model Protocol → Types + Services
153
+
154
+ "Read wireframe.png and create navigation flow"
155
+ → UI Analysis (focus on navigation) → Router setup
156
+
157
+ "Read spec.docx and estimate feature scope"
158
+ → Requirements Extraction → Feature count + complexity
159
+ ```
160
+
161
+ ## Tips
162
+
163
+ - **Large PDFs**: Always specify page range. Read table of contents first (page 1-2) to find relevant sections.
164
+ - **Multiple mockups**: Read all screens first, identify shared components, create shared components first.
165
+ - **API docs**: Generate types/models first, then services, then UI. Types are the foundation.
166
+ - **Incomplete specs**: Flag missing information. Ask user before assuming.
167
+ - **Conflicting info**: Document wins over assumption. If doc says X but code says Y, ask user which is correct.