@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.

Potentially problematic release.


This version of @buivietphi/skill-mobile-mt might be problematic. Click here for more details.

@@ -0,0 +1,677 @@
1
+ # Prompt Engineering — Intelligent Prompt Generation
2
+
3
+ > Learned from Anthropic, Cline, Roo Code, and Claude Code.
4
+ > How to generate prompts that AI agents execute correctly.
5
+
6
+ ---
7
+
8
+ ## Core Principles
9
+
10
+ ### 1. XML Tag Structure (Anthropic Best Practice)
11
+
12
+ **Why:** Clear structure prevents misinterpretation.
13
+
14
+ ```xml
15
+ <task>
16
+ <role>Senior React Native developer with 10+ years experience</role>
17
+
18
+ <context>
19
+ Project: E-commerce mobile app
20
+ Stack: React Native 0.73 + TypeScript + Redux Toolkit
21
+ Current: Product listing works
22
+ Need: Add cart functionality
23
+ </context>
24
+
25
+ <instructions>
26
+ 1. Clone pattern from ProductList screen
27
+ 2. Create cart slice with Redux Toolkit
28
+ 3. Add items to cart with optimistic updates
29
+ 4. Handle API errors with rollback
30
+ </instructions>
31
+
32
+ <constraints>
33
+ - Must work offline (cache in Redux Persist)
34
+ - Follow existing ProductList pattern
35
+ - Use existing Button/Card components
36
+ - NO new dependencies without approval
37
+ </constraints>
38
+
39
+ <examples>
40
+ <example>
41
+ <input>Add product to cart</input>
42
+ <output>
43
+ dispatch(addToCart(product));
44
+ // Optimistic update → API call → rollback on error
45
+ </output>
46
+ </example>
47
+ </examples>
48
+
49
+ <output_format>
50
+ 1. List files to create/modify
51
+ 2. Show code changes with before/after
52
+ 3. Specify test cases
53
+ 4. List manual verification steps
54
+ </output_format>
55
+ </task>
56
+ ```
57
+
58
+ ---
59
+
60
+ ## Auto-Think Templates (Enhanced)
61
+
62
+ ### Fix / Debug
63
+
64
+ ```xml
65
+ <think>
66
+ BUG: [description]
67
+ FILE: [path]
68
+
69
+ <context_needed>
70
+ - Read [file] to understand current implementation
71
+ - Grep for similar patterns: grep "[pattern]" src/
72
+ - Check imports and dependencies
73
+ </context_needed>
74
+
75
+ <root_cause>
76
+ [Analyze AFTER loading context - don't guess]
77
+ - What code is executed?
78
+ - What values are passed?
79
+ - What conditions are checked?
80
+ </root_cause>
81
+
82
+ <fix>
83
+ [Specific change with code snippet]
84
+
85
+ WHY IT WORKS:
86
+ [Explain the fix based on root cause]
87
+ </fix>
88
+
89
+ <side_effects>
90
+ - Files that import this: [list after grep]
91
+ - Tests affected: [list]
92
+ - Platform-specific: iOS [impact] / Android [impact]
93
+ </side_effects>
94
+
95
+ <test>
96
+ 1. Unit test: [specific test case]
97
+ 2. Manual: [steps to reproduce bug → verify fix]
98
+ 3. Regression: [what could this break]
99
+ </test>
100
+
101
+ <cleanup>
102
+ - Remove debug logs
103
+ - Update comments
104
+ - Check for unused imports
105
+ </cleanup>
106
+ </think>
107
+ ```
108
+
109
+ **Example:**
110
+ ```xml
111
+ <think>
112
+ BUG: App crashes when tapping product with no images
113
+
114
+ <context_needed>
115
+ - Read src/screens/ProductDetail.tsx
116
+ - Grep for image rendering: grep "Image source" src/
117
+ - Check Product type definition
118
+ </context_needed>
119
+
120
+ <root_cause>
121
+ Line 42: <Image source={{uri: product.images[0]}} />
122
+ Problem: product.images is undefined when API returns no images
123
+ TypeScript allows this because images is Product['images']?
124
+ </root_cause>
125
+
126
+ <fix>
127
+ {product.images?.length > 0 ? (
128
+ <Image source={{uri: product.images[0]}} />
129
+ ) : (
130
+ <Image source={require('@assets/placeholder.png')} />
131
+ )}
132
+
133
+ WHY IT WORKS:
134
+ Optional chaining prevents undefined access.
135
+ Fallback image provides default visual.
136
+ </fix>
137
+
138
+ <side_effects>
139
+ - ProductCard.tsx also renders images → apply same fix
140
+ - No tests affected (this is a UI safety check)
141
+ - Works same on both platforms
142
+ </side_effects>
143
+
144
+ <test>
145
+ 1. Unit: Mock product with images: undefined
146
+ 2. Manual: Find product without images in staging API
147
+ 3. Regression: Verify products WITH images still render
148
+ </test>
149
+
150
+ <cleanup>
151
+ - No debug code added
152
+ - Add comment: // Handle products without images
153
+ </cleanup>
154
+ </think>
155
+ ```
156
+
157
+ ---
158
+
159
+ ### Build / Create (Multi-Phase)
160
+
161
+ **Phase 1: Discovery**
162
+ ```xml
163
+ <think>
164
+ <discovery>
165
+ FEATURE: [description]
166
+ PLATFORM: [React Native / Flutter / iOS / Android]
167
+
168
+ STEP 1: SCAN PROJECT
169
+ - List screens: ls src/screens/
170
+ - Find similar features: grep -r "useState" src/screens/
171
+ - Identify pattern: feature-based or layer-based?
172
+
173
+ STEP 2: FIND REFERENCE
174
+ - Most similar feature: [name]
175
+ - Location: [path]
176
+ - Files in reference:
177
+ * Screen component
178
+ * Service/API layer
179
+ * State management (slice/store/bloc)
180
+ * Types/interfaces
181
+ * Tests
182
+
183
+ STEP 3: READ REFERENCE FILES
184
+ [List files to read - will load in next step]
185
+ </discovery>
186
+ </think>
187
+ ```
188
+
189
+ **Phase 2: Analysis**
190
+ ```xml
191
+ <think>
192
+ <analysis>
193
+ REFERENCE ANALYZED: src/features/product/
194
+
195
+ PATTERNS DETECTED:
196
+ - State: Redux Toolkit slice
197
+ - API: Axios with interceptor
198
+ - Data: API response → map to domain entity
199
+ - UI: Functional component + hooks
200
+ - Navigation: React Navigation v6
201
+ - Naming: camelCase for files, PascalCase for components
202
+
203
+ DATA FLOW:
204
+ ProductScreen
205
+ → useSelector(state.product.items)
206
+ → dispatch(fetchProducts())
207
+ → productSlice.ts (createAsyncThunk)
208
+ → productService.ts (axios.get)
209
+ → API response
210
+ → map to Product entity
211
+ → update Redux state
212
+ → re-render with new data
213
+
214
+ ERROR HANDLING:
215
+ - API errors: catch in thunk → set error state
216
+ - UI errors: ErrorBoundary wraps screen
217
+ - Network: Show offline banner
218
+
219
+ STATES: loading / success / error / empty
220
+ </analysis>
221
+ </think>
222
+ ```
223
+
224
+ **Phase 3: Clone Mapping**
225
+ ```xml
226
+ <think>
227
+ <clone_map>
228
+ REFERENCE → NEW FEATURE
229
+
230
+ product/ProductScreen.tsx → cart/CartScreen.tsx
231
+ product/useProducts.ts → cart/useCart.ts
232
+ product/productService.ts → cart/cartService.ts
233
+ product/productSlice.ts → cart/cartSlice.ts
234
+ product/product.types.ts → cart/cart.types.ts
235
+ product/ProductCard.tsx → cart/CartItem.tsx
236
+ product/ProductScreen.test.tsx → cart/CartScreen.test.tsx
237
+
238
+ MODIFICATIONS:
239
+ 1. Update API endpoints:
240
+ - GET /products → GET /cart
241
+ - POST /cart/add → add item to cart
242
+
243
+ 2. Adjust state shape:
244
+ - items: Product[] → items: CartItem[]
245
+ - Add: quantities, totals, discounts
246
+
247
+ 3. UI changes:
248
+ - ProductCard shows image + price
249
+ - CartItem shows image + price + quantity + remove button
250
+
251
+ 4. Navigation:
252
+ - ProductScreen → ProductDetail
253
+ - CartScreen → Checkout
254
+ </clone_map>
255
+ </think>
256
+ ```
257
+
258
+ **Phase 4: Implementation Plan**
259
+ ```xml
260
+ <think>
261
+ <implementation>
262
+ INCREMENTAL APPROACH (test after each step):
263
+
264
+ ITERATION 1: Type Definitions
265
+ - Create cart/cart.types.ts
266
+ - Define CartItem, Cart interfaces
267
+ - Export types
268
+ ✅ TEST: TypeScript compilation succeeds
269
+
270
+ ITERATION 2: API Service
271
+ - Create cart/cartService.ts
272
+ - Implement getCart(), addToCart(), removeFromCart()
273
+ - Use same axios instance as productService
274
+ ✅ TEST: Unit tests pass for API calls
275
+
276
+ ITERATION 3: Redux Slice
277
+ - Create cart/cartSlice.ts
278
+ - createAsyncThunk for async operations
279
+ - Add reducers for optimistic updates
280
+ ✅ TEST: Redux tests pass
281
+
282
+ ITERATION 4: Custom Hook
283
+ - Create cart/useCart.ts
284
+ - Wrap useSelector + useDispatch
285
+ - Export cart operations
286
+ ✅ TEST: Hook tests pass
287
+
288
+ ITERATION 5: UI Components
289
+ - Create cart/CartItem.tsx (clone ProductCard)
290
+ - Create cart/CartScreen.tsx (clone ProductScreen)
291
+ - Wire up with useCart hook
292
+ ✅ TEST: Component renders without errors
293
+
294
+ ITERATION 6: Navigation
295
+ - Add CartScreen to navigator
296
+ - Add "View Cart" button to header
297
+ - Test navigation flow
298
+ ✅ TEST: Navigation works on both platforms
299
+
300
+ DEPENDENCIES:
301
+ - No new packages needed (reuse existing stack)
302
+ </implementation>
303
+ </think>
304
+ ```
305
+
306
+ ---
307
+
308
+ ### Review / Audit
309
+
310
+ ```xml
311
+ <think>
312
+ <review>
313
+ SCOPE: [files/feature to review]
314
+
315
+ SCAN ORDER (by severity):
316
+ 1. 🔴 CRITICAL: Crash risks
317
+ - Force unwraps (! / !!)
318
+ - Array access without bounds check
319
+ - Unhandled null from API
320
+
321
+ 2. 🔴 CRITICAL: Security
322
+ - Hardcoded secrets
323
+ - Tokens in AsyncStorage (use SecureStore)
324
+ - SQL injection / XSS vulnerabilities
325
+
326
+ 3. 🟠 HIGH: Memory leaks
327
+ - useEffect without cleanup
328
+ - Listeners not removed
329
+ - Timers not cleared
330
+
331
+ 4. 🟡 MEDIUM: Performance
332
+ - Inline functions in render
333
+ - Missing React.memo
334
+ - ScrollView for long lists (use FlatList)
335
+
336
+ 5. 🟡 MEDIUM: Code quality
337
+ - Missing types (any)
338
+ - Duplicate code
339
+ - Magic numbers/strings
340
+
341
+ OUTPUT FORMAT:
342
+ file:line — severity — issue — fix
343
+ </review>
344
+ </think>
345
+ ```
346
+
347
+ ---
348
+
349
+ ### Refactor
350
+
351
+ ```xml
352
+ <think>
353
+ <refactor>
354
+ TARGET: [what to improve]
355
+
356
+ CONSTRAINTS:
357
+ ✅ NO behavior changes
358
+ ✅ NO new dependencies
359
+ ✅ Match existing conventions
360
+ ✅ All tests must still pass
361
+
362
+ STEP 1: IMPACT ANALYSIS
363
+ - Files affected: grep -r "[pattern]" src/
364
+ - Dependencies: [what imports this]
365
+ - Tests: find . -name "*.test.*" | grep [pattern]
366
+
367
+ STEP 2: REFACTOR PLAN
368
+ Priority 1 (Core Logic):
369
+ - [file]: [specific change]
370
+
371
+ Priority 2 (Dependents):
372
+ - [file]: [update imports/usage]
373
+
374
+ Priority 3 (Tests):
375
+ - [file]: [update test cases]
376
+
377
+ STEP 3: EXECUTION
378
+ [Execute Priority 1 → run tests → proceed to Priority 2]
379
+
380
+ STEP 4: VERIFICATION
381
+ ✅ All tests pass
382
+ ✅ TypeScript compiles
383
+ ✅ No new lint errors
384
+ ✅ Git diff review (no unintended changes)
385
+ </refactor>
386
+ </think>
387
+ ```
388
+
389
+ ---
390
+
391
+ ## Mobile-Specific Patterns
392
+
393
+ ### Platform-Specific Implementation
394
+
395
+ ```xml
396
+ <think>
397
+ <mobile_implementation>
398
+ FEATURE: [description]
399
+ PLATFORM: React Native
400
+
401
+ CROSS-PLATFORM STRATEGY:
402
+ 1. Identify platform differences:
403
+ iOS: [specific behaviors]
404
+ Android: [specific behaviors]
405
+
406
+ 2. Choose approach:
407
+ [ ] Shared component with Platform.select
408
+ [ ] Separate .ios.tsx and .android.tsx files
409
+ [ ] Native module (requires native code)
410
+
411
+ EXAMPLE:
412
+ // Shared component approach
413
+ import { Platform } from 'react-native';
414
+
415
+ export const DatePicker = () => {
416
+ const Picker = Platform.select({
417
+ ios: () => require('./DatePicker.ios').default,
418
+ android: () => require('./DatePicker.android').default,
419
+ })();
420
+
421
+ return <Picker />;
422
+ };
423
+
424
+ TESTING:
425
+ - Jest: Test shared logic
426
+ - Platform-specific: Manual on both devices
427
+ - Edge cases: Different OS versions, screen sizes
428
+
429
+ CONSIDERATIONS:
430
+ - iOS: Use native UIDatePicker
431
+ - Android: Use native DatePickerDialog
432
+ - Permissions: Different request flows
433
+ - UI: Respect platform design guidelines
434
+ </mobile_implementation>
435
+ </think>
436
+ ```
437
+
438
+ ---
439
+
440
+ ### Performance Optimization
441
+
442
+ ```xml
443
+ <think>
444
+ <optimization>
445
+ COMPONENT: [name]
446
+
447
+ STEP 1: PROFILE
448
+ - Tool: React DevTools Profiler
449
+ - Metric: Render time, re-render count
450
+ - Current: [value] ms per render
451
+
452
+ STEP 2: ANALYZE
453
+ Root causes:
454
+ - [ ] Expensive computation in render
455
+ - [ ] Inline functions causing re-renders
456
+ - [ ] Missing memoization
457
+ - [ ] Large list without virtualization
458
+
459
+ STEP 3: OPTIMIZE (priority order)
460
+ 1. [ ] React.memo for pure components
461
+ 2. [ ] useMemo for expensive computations
462
+ 3. [ ] useCallback for stable callbacks
463
+ 4. [ ] FlatList with getItemLayout
464
+ 5. [ ] Image optimization (resize, cache)
465
+
466
+ STEP 4: MEASURE
467
+ - Before: [ms] per render
468
+ - After: [ms] per render
469
+ - Improvement: [%]
470
+
471
+ TRADE-OFFS:
472
+ - Code complexity: [increased/decreased]
473
+ - Bundle size: [KB change]
474
+ - Maintainability: [impact]
475
+
476
+ DECISION: [proceed / revert / iterate]
477
+ </optimization>
478
+ </think>
479
+ ```
480
+
481
+ ---
482
+
483
+ ## Context Management
484
+
485
+ ### Progressive Loading (Don't load everything upfront)
486
+
487
+ ```
488
+ Level 1: Always Loaded
489
+ └── SKILL.md (project overview, tech stack)
490
+
491
+ Level 2: Task-Triggered
492
+ └── Identify reference pattern (don't read yet)
493
+
494
+ Level 3: File-Specific
495
+ └── Read ONLY files needed for current task
496
+
497
+ Level 4: Deep Dive
498
+ └── Load detailed docs if stuck
499
+
500
+ Level 5: Expert
501
+ └── Invoke specialized subagent
502
+
503
+ ⛔ DON'T jump to Level 5 immediately.
504
+ ✅ DO progress through levels as complexity requires.
505
+ ```
506
+
507
+ **Example:**
508
+ ```xml
509
+ <progressive_context>
510
+ User: "Add dark mode"
511
+
512
+ Level 1: Check SKILL.md
513
+ → React Native + TypeScript project
514
+ → Styled with StyleSheet
515
+
516
+ Level 2: Find pattern
517
+ → grep "theme" src/ --files-with-matches
518
+ → Found: src/theme/theme.ts
519
+
520
+ Level 3: Read reference
521
+ → Read src/theme/theme.ts
522
+ → Understand current theme structure
523
+
524
+ Level 4: Implement
525
+ → Clone pattern
526
+ → Add dark mode values
527
+ → No need for Level 5 (straightforward task)
528
+ </progressive_context>
529
+ ```
530
+
531
+ ---
532
+
533
+ ### Just-In-Time File Reading
534
+
535
+ ```xml
536
+ <jit_reading>
537
+ ❌ BAD: Read all files upfront
538
+ Read src/screens/HomeScreen.tsx
539
+ Read src/screens/ProductScreen.tsx
540
+ Read src/screens/CartScreen.tsx
541
+ Read src/screens/ProfileScreen.tsx
542
+ [Load 50+ files → context bloat]
543
+
544
+ ✅ GOOD: Search → Read only relevant
545
+ grep "useAuth" src/screens/ --files-with-matches
546
+ → Found: ProfileScreen.tsx
547
+
548
+ Read src/screens/ProfileScreen.tsx
549
+ [Load 1 file → use ~500 tokens instead of 25,000]
550
+ </jit_reading>
551
+ ```
552
+
553
+ ---
554
+
555
+ ### Reference Pattern System
556
+
557
+ ```markdown
558
+ BEFORE reading docs, check if a REFERENCE exists:
559
+
560
+ List Screen → src/screens/ProductList/
561
+ Form Screen → src/screens/UserProfile/EditProfile
562
+ API Integration → src/services/productService.ts
563
+ Redux Slice → src/store/slices/productSlice.ts
564
+ Navigation → src/navigation/RootNavigator.tsx
565
+
566
+ Clone the reference pattern → modify → test.
567
+ Faster than reading documentation.
568
+ ```
569
+
570
+ ---
571
+
572
+ ## Multi-AI Format
573
+
574
+ | AI | Think Format | Notes |
575
+ |----|-------------|-------|
576
+ | Claude | `<think>...</think>` | XML tags preferred |
577
+ | Gemini | `## Thinking:` block | Markdown headings |
578
+ | Kimi | `【思考】` or markdown | Supports Chinese |
579
+ | Cursor | Inline in Composer | Visible to user |
580
+ | Copilot | `// PLAN:` comments | Code comments |
581
+ | Windsurf | Inline reasoning | Similar to Cursor |
582
+
583
+ ---
584
+
585
+ ## Anti-Patterns (Don't Do This)
586
+
587
+ ```
588
+ ❌ Vague instructions
589
+ "Make this better"
590
+ "Optimize the app"
591
+ "Fix all bugs"
592
+
593
+ ✅ Specific instructions
594
+ "Reduce ProductList render time from 300ms to <100ms"
595
+ "Fix crash when product.images is undefined"
596
+ "Add pagination to ProductList with 20 items per page"
597
+
598
+ ❌ Over-loading context
599
+ Read all 50 component files upfront
600
+
601
+ ✅ Lazy loading
602
+ Grep → identify → read only relevant files
603
+
604
+ ❌ Skipping verification
605
+ Write code → mark as done
606
+
607
+ ✅ Quality gate
608
+ Write → test → verify → then mark done
609
+
610
+ ❌ Guessing root cause
611
+ "Probably a race condition"
612
+
613
+ ✅ Reading code first
614
+ Read file → analyze flow → identify cause → fix
615
+
616
+ ❌ Generic prompts
617
+ "Create login screen"
618
+
619
+ ✅ Contextual prompts
620
+ "Create login screen following pattern in src/screens/ProductScreen
621
+ using Redux slice from src/store/slices/authSlice
622
+ with email/password fields + remember me checkbox"
623
+ ```
624
+
625
+ ---
626
+
627
+ ## Quick Reference
628
+
629
+ ### Good Prompt Checklist
630
+
631
+ ```
632
+ ✅ Role defined (Senior React Native developer)
633
+ ✅ Context provided (tech stack, current state)
634
+ ✅ Task is specific (what to build, not "make better")
635
+ ✅ Constraints listed (platform, dependencies, patterns)
636
+ ✅ Reference pattern identified (clone from X)
637
+ ✅ Success criteria clear (passes tests + renders)
638
+ ✅ Output format specified (code + tests + verification)
639
+ ```
640
+
641
+ ### Before Writing Code
642
+
643
+ ```
644
+ 1. 🔍 READ existing code (don't guess patterns)
645
+ 2. 🗺️ IDENTIFY reference to clone
646
+ 3. 📋 PLAN files to create/modify
647
+ 4. 🧪 DEFINE how to test/verify
648
+ 5. ⚠️ CHECK side effects (what else could break)
649
+ 6. 💻 WRITE code incrementally (test each step)
650
+ 7. ✅ VERIFY all quality gates pass
651
+ ```
652
+
653
+ ### When Stuck
654
+
655
+ ```
656
+ Instead of: "I don't know how to do this"
657
+ Do this: grep -r "similar pattern" src/
658
+ Read reference files
659
+ Clone and modify
660
+
661
+ Instead of: Load all documentation
662
+ Do this: Start with SKILL.md overview
663
+ Find reference pattern
664
+ Read only needed files
665
+ Load docs only if stuck
666
+
667
+ Instead of: Try random fixes
668
+ Do this: Read code → understand flow
669
+ Analyze root cause
670
+ Apply targeted fix
671
+ Verify with tests
672
+ ```
673
+
674
+ ---
675
+
676
+ > **Golden Rule:** Think like a senior developer joining a new team.
677
+ > Read their code. Follow their patterns. Ask when unclear. Test before shipping.