Real-time detection of Jetpack Compose best practices and rule violations directly in Android Studio.
ComposeGuard is an IntelliJ/Android Studio plugin that provides real-time detection of Compose best practices violations as you write code. It analyzes your composable functions and highlights issues based on the Compose Rules documentation.
Instead of waiting for build-time lint checks or runtime issues, you get instant feedback right in your IDE with visual indicators, quick fixes, and detailed explanations.
ComposeGuard implements comprehensive rules across 7 categories:
| Category | Rules |
|---|---|
| Naming | Composable naming (PascalCase/camelCase), modifier naming, CompositionLocal naming, preview naming, multipreview naming, event parameter naming |
| Modifiers | Required modifier parameter, modifier default value, modifier naming, modifier at top-most layout, modifier reuse, modifier order, avoid composed |
| State | Remember state, type-specific mutableStateOf, state hoisting, mutable state as parameter |
| Parameters | Parameter ordering, trailing lambda for content, mutable types as parameters, explicit dependencies |
| Composables | Content emission rules, multiple content slots, effect keys, movable content, preview visibility |
| Stricter | Material 2 usage detection, unstable collections (enabled by default) |
| Experimental | LazyList missing key, LazyList contentType, derivedStateOf candidate, lifecycle-aware collection (opt-in) |
- Real-time Highlighting: See violations as you type with colored underlines
- Gutter Icons: Color-coded dots showing violation status per composable function
- π΄ Red: Error severity violations
- π Orange: Warning severity violations
- β« Gray: Weak warning violations
- π’ Green: Info level violations
- Inline Hints: Small badges next to function names showing rule violations
- Hover Tooltips: Detailed explanations when hovering over violations
- Quick Fixes: One-click fixes for common issues (Alt+Enter)
- Open Android Studio/IntelliJ IDEA
- Go to Settings β Plugins β Marketplace
- Search for "ComposeGuard"
- Click Install
Or install directly from: JetBrains Marketplace - ComposeGuard
Once installed, ComposeGuard automatically analyzes your Kotlin files containing @Composable functions.
// β Naming violation: Should be PascalCase
@Composable
fun userCard(user: User) { } // Warning: Should be "UserCard"
// β Missing modifier parameter
@Composable
fun ProductCard(product: Product) { } // Warning: Add modifier parameter
// β State not remembered
@Composable
fun Counter() {
val count = mutableStateOf(0) // Error: Wrap in remember { }
}
// β Unstable collection parameter
@Composable
fun ItemList(items: List<Item>) { } // Warning: Use ImmutableList- Rename composable to follow naming conventions
- Add modifier parameter with default value
- Wrap in remember { } for state
- Replace with type-specific state (mutableIntStateOf, etc.)
- Make preview private
- Use immutable collection
- Suppress rule for intentional violations
| Rule | Description |
|---|---|
| ComposableNaming | Unit-returning composables should use PascalCase, value-returning should use camelCase |
| ModifierNaming | Modifier parameters should be named modifier or follow xModifier pattern |
| CompositionLocalNaming | CompositionLocal properties should be prefixed with Local |
| PreviewNaming | Preview functions should follow naming conventions |
| EventParameterNaming | Event callbacks should follow onX naming pattern |
| Rule | Description |
|---|---|
| ModifierRequired | Public composables emitting UI should have a modifier parameter |
| ModifierDefaultValue | Modifier parameters should have = Modifier default value |
| ModifierTopMost | Modifier should be applied to the top-most layout |
| ModifierReuse | Don't reuse the same modifier across multiple layouts |
| ModifierOrder | Modifier chain order matters for behavior |
| AvoidComposed | Prefer Modifier.Node over composed { } |
| Rule | Description |
|---|---|
| RememberState | State builders (mutableStateOf, etc.) should be wrapped in remember { } |
| TypeSpecificState | Use mutableIntStateOf, mutableFloatStateOf, etc. for primitives |
| HoistState | State should be hoisted to appropriate level |
| MutableStateParameter | Don't pass MutableState as parameter, use value + callback |
| Rule | Description |
|---|---|
| Material2Usage | Detects Material 2 imports, suggests migration to Material 3 |
| UnstableCollections | Flags List, Set, Map parameters, suggests ImmutableList, etc. |
Enable in Settings β Tools β ComposeGuard β Experimental Rules
| Rule | Description |
|---|---|
| LazyListMissingKey | LazyColumn/LazyRow items() should have a key parameter for efficient recomposition |
| LazyListContentType | Heterogeneous LazyLists should use contentType for composition reuse |
| DerivedStateOfCandidate | Computed values should use remember(keys) to avoid recalculation |
| FrequentRecomposition | Suggests collectAsStateWithLifecycle instead of collectAsState |
ComposeGuard includes a Statistics Dashboard to track rule violations across your project.
- Real-time Statistics: View violation counts as you code
- Category Breakdown: See violations grouped by rule category
- Rule-level Details: Drill down into specific rule violations
- Project Overview: Track overall code quality trends
Access the dashboard from View β Tool Windows β ComposeGuard Statistics
ComposeGuard settings can be configured per-category. Access settings at:
Settings β Tools β ComposeGuard
If you're adding ComposeGuard to an existing project with legacy code, you may want to disable certain rules to avoid overwhelming violations. Here's how:
-
Go to Settings β Tools β ComposeGuard
-
You'll see all rule categories with checkboxes:
- Enable ComposeGuard: Master toggle to enable/disable the entire plugin
- Display Options: Toggle gutter icons and inlay hints
- Rule Configuration: Enable/disable individual rules or entire categories
-
Recommended approach for legacy codebases:
- Start by disabling stricter rules (Material 2 Usage, Unstable Collections)
- Gradually enable rules as you refactor code
- Use the category checkboxes to quickly toggle entire rule groups
- Individual rules can be fine-tuned within each category
-
Per-file suppression: You can also suppress specific rules in code using:
@Suppress("ComposeGuard:RuleName") @Composable fun MyComposable() { }
Toggle individual rules or entire categories on/off based on your project's needs.
- IntelliJ IDEA 2024.2+ or Android Studio Ladybug+
- Kotlin plugin installed
| ComposeGuard | IDE Version |
|---|---|
| 1.0.6 | 2024.2 - 2025.3 |
Contributions are welcome! Please feel free to submit issues and pull requests.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This plugin is based on the excellent Compose Rules documentation by Mrmans0n.
Designed and developed by 2025 androidpoet (Ranbir Singh)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Made with β€οΈ by androidpoet


