Coding & Developmentโจ๏ธcursor๐universal
๐ Level Up Your Android Code with Cursor AI IDE: Top Rules You Need
๐ Discover how to supercharge your Android projects by applying clear, powerful coding rules within Cursor AI IDE. This guide helps you write cleaner, more maintainable code while harnessing AI to maximize your productivity.
Quick Start
Install this Skill
npx skills add nphausg/cursor.rules# ๐ Level Up Your Android Code with Cursor AI IDE: Top Rules You Need <img src="./docs/banner.png"> For every Kotlin Android code you generate or refactor: 1. **Architecture:** - Follow **MVVM pattern** strictly. - Business logic must go into `ViewModel`, not in `View` (Activity/Fragment/Composable). - Views should only observe `StateFlow`/`LiveData` from ViewModel. 2. **Kotlin Best Practices:** - Use `StateFlow` instead of `LiveData` unless explicitly required. - Use Kotlin Coroutines (structured concurrency, `viewModelScope`, `SupervisorJob`). - Prefer `val` over `var` where possible. - Use extension functions and sealed classes when appropriate. - No memory leaks (avoid context leaks in ViewModel). - Use Dependency Injection (Hilt) if necessary. 3. **Android Performance:** - Avoid heavy work on the main thread. - Use `Dispatchers.IO` or background coroutines for I/O, disk, and network tasks. - Use `lazy` initialization where suitable. - For RecyclerView/List: use `ListAdapter` + `DiffUtil`. - Avoid unnecessary recomposition in Jetpack Compose. - Apply LRU caching for repeated data/images if needed. 4. **Testing:** - Generated ViewModel and Repository code must be testable (no static singletons). - Show sample unit test if introducing new logic. 5. **Code Quality:** - Minimize code duplication. - Clear function separation (Single Responsibility Principle). - Provide brief inline comments for complex sections. 6. **Output Requirement:** - Provide **full code samples** (including imports) unless specified otherwise. - Brief explanation of key design decisions made. # โ How to Use this Rule in Cursor: ๐ก When you prompt Cursor, prepend your request with this: Please follow this rule strictly when answering: [Insert the above "Universal Cursor Rule" block here] Now, hereโs my request: How to implement a memory-safe, MVVM-compliant ViewModel to fetch data from a repository using Coroutines and StateFlow? ## Optional: Automate this in Cursor (or similar tools) Save as a global Prompt Template / System Instruction (if your tool allows). Use Prompt Library / Custom Template features if Cursor supports it (coming in future versions). Or just copy-paste the above rule as part of each important prompt when setting up complex tasks. # Rule Review Checklist for Reviewers | Checklist Item | Details/Examples | | ------------------------------- | ---------------------------------------------- | | โ Naming and File Organization | File name descriptive? Proper folder location? | | โ Metadata and Scope | `globs` correctly match target files? | | โ Rule Clarity | Rules are easy to understand and actionable? | | โ Conciseness | Avoid redundant or overly verbose rules | | โ Consistency | Rules donโt conflict with existing ones | | โ Token Efficiency | Rule size is reasonable (<100 lines suggested) | | โ Alignment with Team Standards | Matches projectโs coding style and practices | | โ Documentation Update | README or docs updated if necessary | | โ Validation Performed | Syntax checked, optionally tested with AI tool | # Step-by-step plan ## Step 1: Collect Current Rules Gather all your existing .mdc rule files into a central folder. Make sure each file is named and categorized by purpose (e.g., android-clean-architecture.mdc, general-best-practices.mdc, unit-testing.mdc). ## Step 2: Categorize Rules Split rules into two categories: Project-Specific Rules โ Architecture choices, naming conventions, team coding styles, folder structure, DI patterns, etc. General Best Practices โ Common industry guidelines like โwrite clear functionsโ, โavoid memory leaksโ, โtest coverageโ, etc. ## Step 3: Audit AI Compliance (Sample Testing) Run sample AI prompts (or simulate conversations) with and without your general rules loaded. Check if AI suggestions comply with your project-specific rules and general best practices without explicit reminders. Note any general best practices the AI frequently misses or misapplies. ## Step 4: Rule Optimization Recommendations Keep all project-specific rules active at all times. For general rules: If AI consistently follows them: Archive or remove those rules to reduce token load. If AI misses or misapplies them: Keep these rules active or consider rewriting for clarity and emphasis. Consider grouping general rules into an optional โGeneral Best Practicesโ rule file that can be enabled or disabled based on context or user preference. ## Step 5: Maintain and Iterate Periodically (e.g., quarterly), rerun audits as AI capabilities or your project evolves. Collect team feedback on AI outputs to identify new rule needs or redundant rules. Keep documentation updated with the final optimized rule set. ## โจ Contributing Please feel f ... (truncated)
Related Skills
More coding & development skills you might like
Reticle
Coding & DevelopmentAI agents can generate code, but still struggle to understand what they build. Reticle brings Jev-style machine-native runtime perception to web & desktop applications.
๐คclaude๐universal
1.2k
190
View
agentscope-java
Coding & DevelopmentExpert Java developer skill for AgentScope Java framework - a reactive, message-driven multi-agent system built on Project Reactor. Use when working with reactive programming, LLM integration, agent orchestration, multi-agent systems, or when the user mentions AgentScope, ReActAgent, Mono/Flux, Project Reactor, or Java agent development. Specializes in non-blocking code, tool integration, hooks, pipelines, and production-ready agent applications.
๐universal
6.0k
1.5k
View
ospec
Coding & DevelopmentDocument-driven OSpec workflow for initialization, change/goal routing, validation, archiving, and durable project knowledge.
โจgemini๐คclaude๐ฌgpt๐universal
524
34
View
misakanet-failure-memory
Coding & Development๐ A zero-dependency, git-backed micro-lesson library for AI Agents to asynchronously share and search verified debugging experience. Python stdlib only. | https://misakanet.org
๐คclaudeโจ๏ธcursor๐universal
424
158
View