android-jetpack-compose-cursorrules-prompt-file — Cursor rule
A Cursor rule that steers the agent through Android development with Jetpack Compose: architecture, state, tests.
.cursor/rules/android-jetpack-compose-cursorrules-prompt-file.mdcWhat android-jetpack-compose-cursorrules-prompt-file does
The file tells the agent how to behave in an Android project built on Jetpack Compose. It lists practices: domain, data and presentation layers, coroutines and Flow for async work, dependency injection with Hilt, unidirectional data flow through ViewModel and UI State, Compose navigation for screens. A separate block covers UI: remember and derivedStateOf, modifier ordering, preview annotations, theming with MaterialTheme, loading and error states.
Testing and performance get their own sections. Tests mean unit tests for ViewModels and UseCases, UI tests on the Compose testing framework, fake repositories. Performance means fewer recompositions via proper keys, lazy lists with LazyColumn and LazyRow, lifecycle awareness.
The folder layout is marked as a reference. The author asks not to enforce it when a project already has its own organisation, and to stay consistent with the existing architecture. Worth knowing before you drop the rule in: the agent may drift your code toward that layout unless you say otherwise. Install is a single file under .cursor/rules/.
Nothing here is tied to a Compose or Kotlin version, so you check freshness yourself on a new project.
What it helps with
- keep domain, data and presentation layers consistent
- move screens to unidirectional data flow
- wire up Hilt without modules drifting apart
- spot unnecessary recompositions
- write UI tests with the Compose testing framework
Example prompts for the agent
- add a new screen with a ViewModel and UI State following the project rules
- refactor this composable to cut down recompositions
- write a unit test for the UseCase with a fake repository
How to install android-jetpack-compose-cursorrules-prompt-file
Manually: put the files in place
.cursor/rules/android-jetpack-compose-cursorrules-prompt-file.mdcFrontmatter: description, globs, alwaysApply
Manually: put the files in place
.claude/rules/android-jetpack-compose-cursorrules-prompt-file.mdThe paths frontmatter field limits the files: move globs from the source into paths
AGENTS.md
Codex reads AGENTS.md: paste the rule text there
Manually: put the files in place
.github/instructions/android-jetpack-compose-cursorrules-prompt-file.instructions.mdThe applyTo field sets which files it applies to: move globs from the source into applyTo
Manually: put the files in place
.devin/rules/android-jetpack-compose-cursorrules-prompt-file.mdManually: put the files in place
.clinerules/android-jetpack-compose-cursorrules-prompt-file.mdStep by step, with commands for each platform: Cursor rules: .mdc files, four modes and what replaced .cursorrules
Questions about android-jetpack-compose-cursorrules-prompt-file
How do I install android-jetpack-compose-cursorrules-prompt-file in Cursor?
Copy the file to .cursor/rules/android-jetpack-compose-cursorrules-prompt-file.mdc. That is the whole step — Cursor picks up rules from that folder.
What does this rule do?
It gives the agent guidance for Android development with Jetpack Compose: architecture, state, navigation, tests and performance.
Will it restructure my project folders?
The layout in the file is a reference. The author asks the agent to adapt to your existing project organisation instead of enforcing it.
Source text
android-jetpack-compose-cursorrules-prompt-file.mdc · CC0-1.0
---
description: "Cursor rules for Android development with Jetpack Compose integration."
globs: **/*
alwaysApply: false
---
// 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 = `
1. Use remember and derivedStateOf appropriately
2. Implement proper recomposition optimization
3. Use proper Compose modifiers ordering
4. Follow composable function naming conventions
5. Implement proper preview annotations
6. Use proper state management with MutableState
7. Implement proper error handling and loading states
8. Use proper theming with MaterialTheme
9. Follow accessibility guidelines
10. Implement proper animation patterns
`;
// Testing Guidelines
const testingGuidelines = `
1. Write unit tests for ViewModels and UseCases
2. Implement UI tests using Compose testing framework
3. Use fake repositories for testing
4. Implement proper test coverage
5. Use proper testing coroutine dispatchers
`;
// Performance Guidelines
const performanceGuidelines = `
1. Minimize recomposition using proper keys
2. Use 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
`;
© PatrickJS · CC0-1.0 · PatrickJS/awesome-cursorrules