Skip to main content
rule

android-jetpack-compose-cursorrules-prompt-file — Cursor rule

A Cursor rule that steers the agent through Android development with Jetpack Compose: architecture, state, tests.

Install into Cursor · Manually: put the files in place All methods and platforms ↓
.cursor/rules/android-jetpack-compose-cursorrules-prompt-file.mdc
Open on GitHub

What 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.mdc

Frontmatter: description, globs, alwaysApply

Step 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

Similar IDE rules

Everything for Mobile →

From the same set68

cypress-defect-tracking-cursorrules-prompt-file A Cursor rule that turns the agent into a QA engineer: writes Cypress tests tagged by team, category and case ID, and builds reports through qa-shadow-report. ★ 41,011repo stars cursorrules-cursor-ai-wordpress-draft-macos-prompt A Cursor rule that describes the PressThat project: a system tray app that connects to WordPress and creates draft posts. Useful if you work on that app in Cursor. ★ 41,011repo stars cursor-ai-react-typescript-shadcn-ui-cursorrules-p A Cursor rule that pushes the agent toward React and TypeScript code written the way shadcn/ui and Tailwind CSS projects expect. ★ 41,011repo stars code-style-consistency-cursorrules-prompt-file A Cursor rule that makes the agent study your codebase conventions first and write new code to match them. Useful in repos with an established style. ★ 41,011repo stars cloudflare-workers-hono-angular-saas-cursorrules-prompt-file A Cursor rule that pins the stack and conventions for SaaS on Cloudflare Workers: Hono API, Angular, Drizzle, Clerk, Stripe. ★ 41,011repo stars chrome-extension-dev-js-typescript-cursorrules-pro A Cursor rule that points the agent at one set of conventions for building Chrome extensions in JavaScript and TypeScript. ★ 41,011repo stars ascii-simulation-game-cursorrules-prompt-file A Cursor rule that frames an observer-only ASCII simulation: 10x10 grid, turn-based play, logs for nearly everything. Useful if you are building something in the spirit of Conway's Game of Life. ★ 41,011repo stars ankra-cli A Cursor rule that tells the agent how to drive the Ankra CLI: clusters, stacks, Helm releases and tokens. ★ 41,011repo stars

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor