Android Jetpack Compose
Cursor-Regel für Android-Entwicklung mit Jetpack Compose — sorgt für idiomatischen, deklarativen Kotlin-UI-Code.
Cursor-Regel für Android-Entwicklung mit Jetpack Compose — sorgt für idiomatischen, deklarativen Kotlin-UI-Code.
Original-Beschreibung der Autoren: Cursor rules for Android development with Jetpack Compose integration.
Die Regel
---
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
`;
So nutzt du sie
Die Regel kopieren (Button oben) oder als Datei herunterladen und im Projekt unter .cursor/rules/ ablegen — Cursor lädt sie beim nächsten Start automatisch. Ältere Cursor-Versionen lesen alternativ eine einzelne .cursorrules-Datei im Projektstamm; dort einfach den Regel-Text ohne den Kopfblock zwischen den ----Zeilen einfügen.
Der Regel-Text ist englisch — Cursor versteht ihn unabhängig von der Sprache, in der Sie mit dem Editor chatten.
Im Detail
Diese Regel bringt Cursor bei, wie bei Android-Projekten mit Jetpack Compose (Googles modernem, deklarativem UI-Toolkit für Kotlin) programmiert werden soll — State-Handling, Composable-Struktur, Konventionen statt XML-Layouts. Sinnvoll für Android-Entwickler, die von klassischer View-basierter Entwicklung auf Compose umsteigen oder neue Compose-Projekte mit KI-Unterstützung starten. Die Regel ersetzt kein Compose-Wissen, hilft aber, dass generierter Code den gängigen Compose-Patterns folgt statt veralteten Android-Ansätzen. Wie alle Regeln der Sammlung: einfach nach .cursor/rules kopieren, Cursor wendet sie automatisch an.
Praxis-Tipp
Besonders hilfreich in einem bestehenden Compose-Projekt, damit Cursor Vorschläge im Stil des restlichen Codes macht statt generischer Android-Snippets.
Lizenz & Quelle
- Lizenz: CC0 1.0
- Quelle: PatrickJS/awesome-cursorrules (GitHub)
Inhalt ansehen (android-jetpack-compose.mdc)
Lade …
Erfahrungen & Kommentare.
Funktioniert der Regel bei Ihnen? Tipps, Stolperfallen, Varianten — teilen Sie es mit der Community.
Lade Kommentare …
Passt dazu.
AI Agent Specialist
Cursor-Regel, die den KI-Editor auf diszipliniertes, spezialisiertes Agenten-Verhalten trimmt.
Alpha Skills Quant Factor Research
Cursor-Regel für quantitative Faktor-Recherche im Trading/Finance-Bereich — leitet die KI zu methodisch sauberer Analyse an.
Angular Novo Elements
Cursor-Regel für Angular-Projekte mit der älteren Novo-Elements-Komponentenbibliothek.
