android jetpack compose
via PatrickJS/awesome-cursorrules
Android development with Jetpack Compose, Material Design 3, and clean architecture patterns.
What is android jetpack compose?
This rule provides best practices for Android development using Jetpack Compose, including project structure, UI guidelines, testing, and performance optimization. Use it when building Android apps with Compose to maintain clean architecture, proper state management, and Material Design 3 compliance.
- Guides clean architecture setup with domain, data, and presentation layers using Hilt dependency injection
- Establishes Compose UI patterns including state hoisting, recomposition optimization, and proper modifier ordering
- Provides testing strategies for ViewModels, UseCases, and UI using Compose testing framework
- Recommends performance optimizations including lazy loading, efficient recomposition, and memory management
- Enforces Material Design 3 guidelines and accessibility standards in Compose components
- Structures unidirectional data flow with ViewModel, Flow, and Kotlin coroutines
Applies to
File patterns this rule matches.
Rule definition (reference)
Source of truth, from the repository.
// Android Jetpack Compose .cursorrules
// Flexibility Notice
// Note: This is a recommended project structure, but be flexible and adapt to existing project structures. // Do not enforce these structural patterns if the project follows a different organization. // Focus on maintaining consistency with the existing project architecture while applying Jetpack Compose best practices.
// Project Architecture and Best Practices
const androidJetpackComposeBestPractices = [ "Adapt to 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", "Implement dependency injection using Hilt", "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. Adapt to the project's existing 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 = `
- Use remember and derivedStateOf appropriately
- Implement proper recomposition optimization
- Use proper Compose modifiers ordering
- Follow composable function naming conventions
- Implement proper preview annotations
- Use proper state management with MutableState
- Implement proper error handling and loading states
- Use proper theming with MaterialTheme
- Follow accessibility guidelines
- Implement proper animation patterns `;
// Testing Guidelines
const testingGuidelines = `
- Write unit tests for ViewModels and UseCases
- Implement UI tests using Compose testing framework
- Use fake repositories for testing
- Implement proper test coverage
- Use proper testing coroutine dispatchers `;
// Performance Guidelines
const performanceGuidelines = `
- Minimize recomposition using proper keys
- Use proper lazy loading with LazyColumn and LazyRow
- Implement efficient image loading
- Use proper state management to prevent unnecessary updates
- Follow proper lifecycle awareness
- Implement proper memory management
- Use proper background processing `;
Related rules
Senior full-stack TypeScript/React/Node.js guidance with clean architecture, testing, and WHY-oriented reasoning.
Quantitative factor research skills for discovering, evaluating, and backtesting alpha factors through natural language.
Cursor rules for Angular development with Novo Elements UI library.
Cursor rules for Angular development with TypeScript integration.