Android Development

Preface, you might find this prompt somewhat abstract, please have some patience, knowledge always needs to be memorized first, then understood. A few people have exceptional comprehension skills and don’t need practice to understand. But for most people, some practice is needed, to generalize from the concrete, for knowledge to become their own flesh and blood. It’s better to temporarily remember this prompt first, it can also guide general work, slowly experience its concentrated experience in the work. If you have ideas, feel free to speak freely.

Cursor Rule

// Android Jetpack Compose .cursorrules

// Flexibility Notice

// Note: This is a recommended project structure, but please maintain flexibility and adapt to existing project structures.
// If a project follows a different organizational approach, do not force these structural patterns.
// While applying Jetpack Compose best practices, focus on maintaining consistency with the existing project architecture.

// Project Architecture and Best Practices

const androidJetpackComposeBestPractices = [
"Adapt existing project architecture while maintaining clean code principles",
"Follow Material Design 3 guidelines and components",
"Implement clean architecture with domain, data, and presentation layers",
"Use Kotlin coroutines and Flow for asynchronous operations",
"Use Hilt for dependency injection",
"Follow unidirectional data flow with ViewModel and UI state",
"Use Compose Navigation for screen management",
"Implement proper state hoisting and composition",
];

// Folder Structure

// Note: This is a reference structure. Please adapt to your existing project organization

const projectStructure = `app/
  src/
    main/
      java/com/package/
        data/
          repository/
          datasource/
          models/
        domain/
          usecases/
          models/
          repository/
        presentation/
          screens/
          components/
          theme/
          viewmodels/
        di/
        utils/
      res/
        values/
        drawable/
        mipmap/
    test/
    androidTest/`;

// Compose UI Guidelines

const composeGuidelines = `

1. Proper use of remember and derivedStateOf
2. Implement proper recomposition optimization
3. Use correct Compose modifier order
4. Follow naming conventions for composable functions
5. Implement proper preview annotations
6. Use MutableState for proper state management
7. Implement proper error handling and loading states
8. Use MaterialTheme for proper theming
9. Follow accessibility guidelines
10. Implement proper animation patterns
    `;

// Testing Guidelines

const testingGuidelines = `

1. Write unit tests for ViewModels and UseCases
2. Use Compose testing framework for UI tests
3. Use fake repositories for testing
4. Implement proper test coverage
5. Use proper test coroutine dispatchers
   `;

// Performance Guidelines

const performanceGuidelines = `

1. Minimize recomposition using proper keys
2. Implement proper lazy loading with LazyColumn and LazyRow
3. Implement efficient image loading
4. Use proper state management to prevent unnecessary updates
5. Follow proper lifecycle awareness
6. Implement proper memory management
7. Use proper background processing
   `;