learning_ai_common_plat/AI.dev/SKILLS/mobile-code-quality.md
saravanakumardb1 c3b869ceb9 feat: create AI.dev/SKILLS repository with reusable development skills
- Add 15 comprehensive skills extracted from Windsurf workflows
- Cover debugging, testing, releases, deployment, security, and documentation
- Each skill includes step-by-step instructions and copy-pasteable commands
- Skills organized by category with cross-references and difficulty levels
2026-02-12 17:13:16 -08:00

6.8 KiB

Mobile Code Quality Skill

Description: Comprehensive code quality checks for native mobile apps (iOS/Swift and Android/Kotlin).

When to Use

  • Before mobile app releases
  • During development sprints
  • In CI/CD pipelines for mobile
  • When onboarding new mobile developers

Prerequisites

iOS Development

# Install SwiftLint
brew install swiftlint

# Verify installation
swiftlint version

Android Development

# Ensure Android SDK is installed
echo $ANDROID_HOME  # Should point to Android SDK path

Phase 1: MindLyst Native (Kotlin Multiplatform)

cd /Users/sd9235/code/mygh/learning_multimodal_memory_agents/mindlyst-native

# 1. Full project build
./gradlew build
# If fails: fix, then git add . && git commit -m "fix(mindlyst): build fixes" && git push

# 2. Kotlin compilation checks
./gradlew compileKotlinMetadata
./gradlew :shared:compileKotlinIosSimulatorArm64
./gradlew :shared:compileKotlinAndroid
# If fails: fix, commit push

# 3. Kotlin Lint with ktlint
./gradlew ktlintCheck
# If fails: auto-fix with ./gradlew ktlintFormat, then git add . && git commit -m "style(mindlyst): ktlint fixes"

# 4. Static Analysis with Detekt
./gradlew detekt
# If fails: fix issues, then git add . && git commit -m "fix(mindlyst): detekt issues"

# 5. Unit tests
./gradlew test
./gradlew :shared:test
# If fails: fix, commit push

Android Specific Checks (if SDK available)

./gradlew :androidApp:lintDebug
./gradlew :androidApp:testDebugUnitTest
# If fails: fix, commit push

iOS Specific Checks

cd ../iosApp

# SwiftLint check
swiftlint
# If fails: auto-fix with swiftlint --fix, then git add . && git commit -m "style(mindlyst): swiftlint fixes"

# Swift format (if configured)
# swiftformat .

Phase 2: LysnrAI Mobile Components

cd /Users/sd9235/code/mygh/learning_voice_ai_agent/mobile_app

# 1. Android checks
cd android
./gradlew build
./gradlew lintDebug
./gradlew testDebugUnitTest
# If fails: fix, commit push

# 2. iOS checks
cd ../ios/LysnrAI
xcodebuild -project LysnrAI.xcodeproj -scheme LysnrAI -configuration Debug build
swiftlint
# If fails: fix, commit push

# 3. Common checks
cd ../common
# Python lint for shared scripts
python -m ruff check .
python -m ruff format .
# If fails: fix, commit push

Phase 3: Cross-Platform Consistency

Design Token Synchronization

cd /Users/sd9235/code/mygh/learning_multimodal_memory_agents

# Check if tokens are in sync
./scripts/sync-design-tokens.sh --check
# If fails: run ./scripts/sync-design-tokens.sh, then git add . && git commit

Feature Flag Consistency

# Verify feature flags are consistent across platforms
grep -r "FEATURE_" mindlyst-native/shared/src/commonMain/kotlin/
grep -r "FEATURE_" ../learning_voice_ai_agent/mobile_app/common/

API Contract Validation

# Compare shared API models across platforms
diff mindlyst-native/shared/src/commonMain/kotlin/api/ \
     ../learning_voice_ai_agent/mobile_app/common/api/ || echo "API differences found"

Phase 4: Performance and Security

Android Performance

cd /Users/sd9235/code/mygh/learning_multimodal_memory_agents/mindlyst-native

./gradlew :androidApp:assembleDebug

# Check APK size
ls -lh androidApp/build/outputs/apk/debug/

iOS Performance

cd ../iosApp

xcodebuild -project LysnrAI.xcodeproj -scheme LysnrAI -configuration Release \
  -destination 'platform=iOS Simulator,name=iPhone 15' clean build

Security Scan

# Android dependency check
./gradlew dependencyCheckAnalyze

# iOS (if using mob security)
# mob security check

Quality Gates and Metrics

Coverage Targets

Platform Unit Tests UI Tests Coverage
Kotlin Shared 80% N/A JaCoCo reports
Android App 70% 30% Espresso + JUnit
iOS App 70% 30% XCTest + XCUITest

Lint Rules

  • Kotlin: Official ktlint rules + custom Detekt rules
  • Swift: SwiftLint default + custom rules
  • Android: Android lint default rules

Performance Budgets

  • Android APK: < 50MB
  • iOS IPA: < 100MB
  • Build time: < 5 minutes

Automation Scripts

Setup Script (scripts/setup-mobile-quality.sh)

#!/bin/bash
# Install mobile code quality tools

# SwiftLint
if ! command -v swiftlint &> /dev/null; then
  brew install swiftlint
fi

# Kotlin formatting (add to gradle)
echo "Add ktlint plugin to build.gradle.kts"
echo "Add detekt plugin to build.gradle.kts"

Pre-commit Hook (.husky/pre-commit-mobile)

#!/bin/sh
# Mobile-specific pre-commit hooks

# Kotlin files
if git diff --cached --name-only | grep -E "\.kt$"; then
  cd mindlyst-native
  ./gradlew ktlintCheck
  ./gradlew detekt
fi

# Swift files
if git diff --cached --name-only | grep -E "\.swift$"; then
  cd iosApp
  swiftlint
fi

CI/CD Integration

GitHub Actions Example

name: Mobile Code Quality
on: [push, pull_request]

jobs:
  kotlin:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-java@v4
        with:
          distribution: temurin
          java-version: 17
      - run: ./gradlew ktlintCheck detekt test

  ios:
    runs-on: macos-latest
    steps:
      - uses: actions/checkout@v4
      - run: brew install swiftlint
      - run: cd iosApp && swiftlint
      - run: xcodebuild -project LysnrAI.xcodeproj -scheme LysnrAI build

Troubleshooting

Common Issues

  1. SwiftLint not found: Install via Homebrew
  2. Kotlin lint fails: Run ./gradlew ktlintFormat to auto-fix
  3. Detekt issues: Check detekt.yml configuration
  4. Android SDK missing: Set $ANDROID_HOME correctly

Performance Tips

  • Use --daemon for Gradle
  • Enable Gradle build cache
  • Use parallel execution where possible

Reporting

Generate Quality Report

# Combined report
./gradlew check jacocoTestReport
open shared/build/reports/jacoco/jacocoTestReport/html/index.html

# Android lint report
open androidApp/build/reports/lint-results-debug.html

# SwiftLint report (JSON)
swiftlint --reporter json > swiftlint-report.json

Commit Patterns

fix(mobile): ktlint fixes
style(ios): swiftlint fixes
fix(android): lint issues
test(mobile): add unit tests
perf(mobile): reduce APK size

Notes

  • Run before major releases: Always run full workflow
  • Incremental checks: Use pre-commit hooks for immediate feedback
  • Cross-platform consistency: Regular sync meetings recommended
  • Tool versions: Keep linting tools updated consistently across team