sickn33/agentic-awesome-skills / plugins/aasb-design-studio/skills/mobile-design
mobile-design
VerifiedDesign and review iOS, Android, React Native or Flutter interfaces for touch, accessibility, navigation, offline behavior and measured performance. Use for mobile app UI work; not a mobile compliance certification.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 9.0 KB |
| decision-trees.md | markdown | 17.1 KB |
| mobile-backend.md | markdown | 15.7 KB |
| mobile-color-system.md | markdown | 10.2 KB |
| mobile-debugging.md | markdown | 5.1 KB |
| mobile-design-thinking.md | markdown | 16.9 KB |
| mobile-navigation.md | markdown | 12.1 KB |
| mobile-performance.md | markdown | 20.5 KB |
| mobile-testing.md | markdown | 11.6 KB |
| mobile-typography.md | markdown | 11.2 KB |
| platform-android.md | markdown | 19.9 KB |
| platform-ios.md | markdown | 17.5 KB |
| scripts/mobile_audit.py | script | 6.0 KB |
| scripts/test_mobile_audit_review.py | script | 3.1 KB |
| touch-psychology.md | markdown | 17.3 KB |
mobile-backend.md
View on GitHub# Mobile Backend Patterns
> **This file covers backend/API patterns SPECIFIC to mobile clients.**
> Generic backend patterns are in `nodejs-best-practices` and `api-patterns`.
> **Mobile backend is NOT the same as web backend. Different constraints, different patterns.**
---
## π§ MOBILE BACKEND MINDSET
```
Mobile clients are DIFFERENT from web clients:
βββ Unreliable network (2G, subway, elevator)
βββ Battery constraints (minimize wake-ups)
βββ Limited storage (can't cache everything)
βββ Interrupted sessions (calls, notifications)
βββ Diverse devices (old phones to flagships)
βββ Binary updates are slow (App Store review)
```
**Your backend must compensate for ALL of these.**
---
## π« AI MOBILE BACKEND ANTI-PATTERNS
### These are common AI mistakes when building mobile backends:
| β AI Default | Why It's Wrong | β
Mobile-Correct |
|---------------|----------------|-------------------|
| Same API for web and mobile | Mobile needs compact responses | Separate mobile endpoints OR field selection |
| Full object responses | Wastes bandwidth, battery | Partial responses, pagination |
| No offline consideration | App crashes without network | Offline-first design, sync queues |
| WebSocket for everything | Battery drain | Push notifications + polling fallback |
| No app versioning | Can't force updates, breaking changes | Version headers, minimum version check |
| Generic error messages | Users can't fix issues | Mobile-specific error codes + recovery actions |
| Session-based auth | Mobile apps restart | Token-based with refresh |
| Ignore device info | Can't debug issues | Device ID, app version in headers |
---
## 1. Push Notifications
### Platform Architecture
```
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β YOUR BACKEND β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β β
β ββββββββββββ΄βββββββββββ β
β βΌ βΌ β
β βββββββββββββββββββ βββββββββββββββββββ β
β β FCM (Google) β β APNs (Apple) β β
β β Firebase β β Direct or FCM β β
β ββββββββββ¬βββββββββ ββββββββββ¬βββββββββ β
β β β β
β βΌ βΌ β
β βββββββββββββββββββ βββββββββββββββββββ β
β β Android Device β β iOS Device β β
β βββββββββββββββββββ βββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
```
### Push Types
| Type | Use Case | User Sees |
|------|----------|-----------|
| **Display** | New message, order update | Notification banner |
| **Silent** | Background sync, content update | Nothing (background) |
| **Data** | Custom handling by app | Depends on app logic |
### Anti-Patterns
| β NEVER | β
ALWAYS |
|----------|----------|
| Send sensitive data in push | Push says "New message", app fetches content |
| Overload with pushes | Batch, dedupe, respect quiet hours |
| Same message to all | Segment by user preference, timezone |
| Ignore failed tokens | Clean up invalid tokens regularly |
| Skip APNs for iOS | FCM alone doesn't guarantee iOS delivery |
### Token Management
```
TOKEN LIFECYCLE:
βββ App registers β Get token β Send to backend
βββ Token can change β App must re-register on start
βββ Provider reports token invalid/unregistered β remove or refresh its binding
βββ User uninstalls β Token becomes invalid (detect via error)
βββ Multiple devices β Store multiple tokens per user
```
---
## 2. Offline Sync & Conflict Resolution
### Sync Strategy Selection
```
WHAT TYPE OF DATA?
β
βββ Read-only (news, catalog)
β βββ Simple cache + TTL
β βββ ETag/Last-Modified for invalidation
β
βββ User-owned (notes, todos)
β βββ Last-write-wins (simple)
β βββ Or timestamp-based merge
β
βββ Collaborative (shared docs)
β βββ Choose CRDT, OT, locking or explicit merge according to collaboration semantics
β βββ Consider Firebase/Supabase
β
βββ Critical (payments, inventory)
βββ Server is source of truth
βββ Optimistic UI + server confirmation
```
### Conflict Resolution Strategies
| Strategy | How It Works | Best For |
|----------|--------------|----------|
| **Last-write-wins** | Latest timestamp overwrites | Simple data, single user |
| **Server-wins** | Server always authoritative | Critical transactions |
| **Client-wins** | Offline changes prioritized | Offline-heavy apps |
| **Merge** | Combine changes field-by-field | Documents, rich content |
| **CRDT** | Mathematically conflict-free | Real-time collaboration |
### Sync Queue Pattern
```
CLIENT SIDE:
βββ User makes change β Write to local DB
βββ Add to sync queue β { action, data, timestamp, retries }
βββ Network available β Process queue FIFO
βββ Success β Remove from queue
βββ Failure β Retry with backoff (max 5 retries)
βββ Conflict β Apply resolution strategy
SERVER SIDE:
βββ Accept change with client timestamp
βββ Compare with server version
βββ Apply conflict resolution
βββ Return merged state
βββ Client updates local with server response
```
---
## 3. Mobile API Optimization
### Response Size Reduction
| Technique | Savings | Implementation |
|-----------|---------|----------------|
| **Field selection** | 30-70% | `?fields=id,name,thumbnail` |
| **Compression** | 60-80% | gzip/brotli (automatic) |
| **Pagination** | Varies | Cursor-based for mobile |
| **Image variants** | 50-90% | `/image?w=200&q=80` |
| **Delta sync** | 80-95% | Only changed records since timestamp |
### Pagination: Cursor vs Offset
```
OFFSET (Bad for mobile):
βββ Page 1: OFFSET 0 LIMIT 20
βββ Page 2: OFFSET 20 LIMIT 20
βββ Problem: New item added β duplicates!
βββ Problem: Large offset = slow query
CURSOR (Good for mobile):
βββ First: ?limit=20
βββ Next: ?limit=20&after=cursor_abc123
βββ Cursor = encoded (id + sort values)
βββ Stable ordering and snapshot semantics still need design; cursor alone cannot guarantee no duplicates
βββ Consistent performance
```
### Batch Requests
```
Instead of:
GET /users/1
GET /users/2
GET /users/3
(3 round trips, 3x latency)
Use:
POST /batch
{ requests: [
{ method: "GET", path: "/users/1" },
{ method: "GET", path: "/users/2" },
{ method: "GET", path: "/users/3" }
]}
(1 round trip)
```
---
## 4. App Versioning
### Version Check Endpoint
```
GET /api/app-config
Headers:
X-App-Version: 2.1.0
X-Platform: ios
X-Device-ID: abc123
Response:
{
"minimum_version": "2.0.0",
"latest_version": "2.3.0",
"force_update": false,
"update_url": "https://apps.apple.com/...",
"feature_flags": {
"new_player": true,
"dark_mode": true
},
"maintenance": false,
"maintenance_message": null
}
```
### Version Comparison Logic
```
CLIENT VERSION vs MINIMUM VERSION:
βββ client >= minimum β Continue normally
βββ client < minimum β Show force update screen
β βββ Block app usage until updated
βββ client < latest β Show optional update prompt
FEATURE FLAGS:
βββ Enable/disable features without app update
βββ A/B testing by version/device
βββ Gradual rollout (10% β 50% β 100%)
```
---
## 5. Authentication for Mobile
### Token Strategy
```
ACCESS TOKEN:
βββ Short-lived (15 min - 1 hour)
βββ Stored in memory (not persistent)
βββ Used for API requests
βββ Refresh when expired
REFRESH TOKEN:
βββ Long-lived (30-90 days)
βββ Stored in SecureStore/Keychain
βββ Used only to get new access token
βββ Rotate on each use (security)
DEVICE TOKEN:
βββ Identifies this device
βββ Allows "log out all devices"
βββ Stored alongside refresh token
βββ Server tracks active devices
```
### Silent Re-authentication
```
REQUEST FLOW:
βββ Make request with access token
βββ 401 Unauthorized? (single-flight refresh; at most one retry)
β βββ Have refresh token?
β β βββ Yes β Call /auth/refresh
β β β βββ Success β Retry original request
β β β βββ Network failure β preserve recoverable session; invalid/revoked refresh β reauthenticate
β β βββ No β Force logout
β βββ Token just expired (not invalid)
β βββ Auto-refresh, user doesn't notice
βββ Success β Continue
```
---
## 6. Error Handling for Mobile
### Mobile-Specific Error Format
```json
{
"error": {
"code": "PAYMENT_DECLINED",
"message": "Your payment was declined",
"user_message": "Please check your card details or try another payment method",
"action": {
"type": "navigate",
"destination": "payment_methods"
},
"retry": {
"allowed": true,
"after_seconds": 5
}
}
}
```
### Error Categories
| Code Range | Category | Mobile Handling |
|------------|----------|-----------------|
| 400-499 | Client error | Show message, user action needed |
| 401 | Auth expired | Silent refresh or re-login |
| 403 | Forbidden | Explain denied access; do not assume a paid upgrade is appropriate |
| 404 | Not found | Apply endpoint-specific semantics; avoid destructive cache deletion on a transient/masked response |
| 409 | Conflict | Show sync conflict UI |
| 429 | Rate limit | Retry after header, backoff |
| 500-599 | Server error | Retry with backoff, show "try later" |
| Network | No connection | Use cached data, queue for sync |
---
## 7. Media & Binary Handling
### Image Optimization
```
CLIENT REQUEST:
GET /images/{id}?w=400&h=300&q=80&format=webp
SERVER RESPONSE:
βββ Resize on-the-fly OR use CDN
βββ WebP for Android (smaller)
βββ HEIC for iOS 14+ (if supported)
βββ JPEG fallback
βββ Cache-Control: max-age=31536000
```
### Chunked Upload (Large Files)
```
UPLOAD FLOW:
1. POST /uploads/init
{ filename, size, mime_type }
β { upload_id, chunk_size }
2. PUT /uploads/{upload_id}/chunks/{n}
β Upload each chunk (1-5 MB)
β Can resume if interrupted
3. POST /uploads/{upload_id}/complete
β Server assembles chunks
β Return final file URL
```
### Streaming Audio/Video
```
REQUIREMENTS:
βββ HLS (HTTP Live Streaming) for iOS
βββ DASH or HLS for Android
βββ Multiple quality levels (adaptive bitrate)
βββ Range request support (seeking)
βββ Offline download chunks
ENDPOINTS:
GET /media/{id}/manifest.m3u8 β HLS manifest
GET /media/{id}/segment_{n}.ts β Video segment
GET /media/{id}/download β Full file for offline
```
---
## 8. Security for Mobile
### Device Attestation
```
VERIFY REAL DEVICE (not emulator/bot):
βββ iOS: DeviceCheck API
β βββ Server verifies with Apple
βββ Android: Play Integrity API (replaces SafetyNet)
β βββ Server verifies with Google
βββ Define an explicit threat/availability policy; a missing verdict is not proof of compromise
```
### Request authenticity and replay
Do not embed a shared HMAC backend secret in a mobile binary or build-time env
variable: it can be extracted. Use platform TLS plus server-side user/session
validation. When a threat model needs request proof, use reviewed per-device
nonexportable key provisioning and server validation, including user binding,
method/path/body canonicalization, expiry and one-use nonce/replay controls.
A timestamp alone does not prevent replay inside its accepted window. Device
attestation is a risk signal, not proof a person/device is trustworthy or a
replacement for authorization. Availability failures need an explicit policy.
### Rate Limiting
```
MOBILE-SPECIFIC LIMITS:
βββ Per device (X-Device-ID)
βββ Per user (after auth)
βββ Per endpoint (stricter for sensitive)
βββ Sliding window preferred
HEADERS:
X-RateLimit-Limit: 100
X-RateLimit-Remaining: 95
X-RateLimit-Reset: 1609459200
Retry-After: 60 (when 429)
```
---
## 9. Monitoring & Analytics
### Minimal diagnostics metadata
Send app/platform version and per-request correlation ID only when needed. A
persistent device identifier, model, timezone or user ID can identify or profile
people; do not require or log them universally. Define consent/notice, purpose,
retention and access controls. Never log authorization, push tokens, payloads or
all request headers. Treat every client-supplied field as untrusted.
### What to Log
```
FOR EACH REQUEST:
βββ Explicitly allowlisted sanitized diagnostic fields only
βββ Endpoint, method, status
βββ Response time
βββ Error details (if any)
βββ User ID (if authenticated)
ALERTS:
βββ Error rate > 5% per version
βββ P95 latency > 2 seconds
βββ Specific version crash spike
βββ Auth failure spike (attack?)
βββ Push delivery failure spike
```
---
## π MOBILE BACKEND CHECKLIST
### Before API Design
- [ ] Identified mobile-specific requirements?
- [ ] Planned offline behavior?
- [ ] Designed sync strategy?
- [ ] Considered bandwidth constraints?
### For Every Endpoint
- [ ] Response as small as possible?
- [ ] Pagination cursor-based?
- [ ] Proper caching headers?
- [ ] Mobile error format with actions?
### Authentication
- [ ] Token refresh implemented?
- [ ] Silent re-auth flow?
- [ ] Multi-device logout?
- [ ] Secure token storage guidance?
### Push Notifications
- [ ] FCM + APNs configured?
- [ ] Token lifecycle managed?
- [ ] Silent vs display push defined?
- [ ] Sensitive data NOT in push payload?
### Release
- [ ] Version check endpoint ready?
- [ ] Feature flags configured?
- [ ] Force update mechanism?
- [ ] Monitoring headers required?
---
> **Remember:** Mobile backend must be resilient to bad networks, respect battery life, and handle interrupted sessions gracefully. The client cannot be trusted, but it also cannot be hung upβprovide offline capabilities and clear error recovery paths.
## Sync, retries and push limitations
Use server-controlled revisions/ETags for concurrency, not an untrusted client
clock as authority. Queue writes with a stable idempotency key and bounded retries;
a payment network error is an unknown outcome, not permission to repeat the charge.
Reconcile status before retrying. Realtime transport alone does not implement CRDT,
OT, conflict resolution or offline persistence. Push/silent background delivery is
best-effort and cannot be the sole synchronization or safety-critical mechanism.
Illustrative bandwidth savings and token lifetimes above are not measured guarantees.
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| brainstormingobra/superpowersYou MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation). | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| brand-guidelinesanthropics/skillsApplies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand colors or style guidelines, visual formatting, or company design standards apply. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| frontend-designanthropics/skillsGuidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making choices that don't read as templated defaults. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| mcp-builderanthropics/skillsGuide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK). | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |