shekhar23/claude-zero-to-hero-android-kmp/android-feature-flags
Claude Code and agent skill by shekhar23/claude-zero-to-hero-android-kmp
- community
Checking that the SKILL.md file is still in the repository.
Feature flag patterns for Android - typed local flags with DataStore persistence, Firebase Remote Config fetch/activate lifecycle, wrapping remote config behind a FeatureFlagRepository interface, flag-gated navigation, environment-specific defaults, A/B testing user bucketing with exposure logging, and flag lifecycle naming conventions to prevent sprawl. Use this skill whenever adding feature toggles, kill switches, remote experiments, or A/B tests. Trigger on phrases like "feature flag", "remote config", "Firebase Remote Config", "A/B test", "feature toggle", "kill switch", "flag-gated", or "experiment".
Install
npx vskill@latest install shekhar23/claude-zero-to-hero-android-kmp/android-feature-flagsSKILL.md
Android Feature Flags
Core Principles
- Flags are temporary by default — every flag should have a defined retirement path.
- The domain layer knows about flag values but never about Remote Config, Firebase, or DataStore.
- Local flags are the floor; remote flags override them.
- Never gate safety-critical behavior behind a remote flag with no safe default.
- Exposure events must be logged at the moment the user is bucketed, not when they convert.
Flag Types
| Type | Source | Typical use | |
|---|---|---|---|
| Local static | Hardcoded constant | Dev builds, test seams | |
| Local persisted | DataStore | Sideloaded overrides, offline defaults | |
| Remote | Firebase Remote Config | Server-controlled rollouts, A/B tests |
All three should conform to the same FeatureFlagRepository interface.
Typed Flag Model
Use a sealed interface or enum so flags are always exhaustive and refactor-safe:
Avoid stringly-typed flag name lookups outside the data layer — callers should reference FeatureFlag.NewCheckoutFlow, not the string "new_checkout_flow".
FeatureFlagRepository Interface
The domain and presentation layers depend only on this interface. The data layer provides the implementation backed by Remote Config, DataStore, or both.
Local Feature Flags with DataStore
Use DataStore for local flag overrides (useful for QA, debug menus, and offline defaults). See android-datastore-preferences for general DataStore patterns.
Local overrides take precedence over remote values. Use them to unblock QA testing of features not yet fully rolled out remotely.
Firebase Remote Config: Defaults XML
Always declare defaults in res/xml/remote_config_defaults.xml:
The defaults file ensures flags work correctly even before the first successful fetch. Never ship a flag without a default.
Firebase Remote Config: Fetch and Activate
Minimum Fetch Interval
Set interval to 0 in debug builds so QA can test flag changes immediately. Production default is 12 hours but 1 hour is appropriate for active rollouts.
Do not call fetchAndActivate on every screen entry — it is rate-limited and adds startup latency.
Composing Local + Remote Config
A production FeatureFlagRepository checks local overrides first, falls back to remote:
Environment-Specific Defaults
Define defaults per build type to avoid accidentally enabling in-progress features in production:
Use a BuildConfig constant or a Gradle-generated value — not a hardcoded if (debug) check scattered through feature code.
Flag-Gated Navigation
Check flag values before navigating to a destination. Keep flag checks in the ViewModel, not inside composables:
Do not gate routes directly inside NavHost blocks — keep navigation logic in the ViewModel and emit typed events. See android-navigation for typed destination patterns.
A/B Testing: Bucketing and Exposure Events
A/B bucketing happens on the server (Remote Config or your own experiment service). The client's job is:
- Read the assigned variant.
- Log an exposure event immediately when the user is shown the variant.
- Log conversion events separately.
Log the exposure exactly once per session per experiment — not on every recomposition. See android-analytics-logging for event design and tracker patterns.
Debug Flag Override Screen
Expose a debug menu in non-production builds for QA to flip flags without code changes:
Gate the debug screen with if (BuildConfig.DEBUG) at the nav graph level.
Flag Lifecycle and Naming Conventions
Naming
Use the pattern <area>_<feature>_<state>:
checkout_new_flow_enabledhome_feed_layout(enum variant)auth_biometric_prompt_enabled
Avoid generic names like feature_1, experiment_a, new_thing.
Lifecycle Stages
- add: flag created, default off, under development.
- active: flag enabled for some or all users via rollout.
- mature: flag fully rolled out; all users on new behavior.
- retired: old code path deleted, flag removed from code and Remote Config.
When a flag reaches mature, file a ticket to remove the old code path within one sprint. Flag sprawl makes code unreadable and tests expensive.
Anti-Patterns
- Reading flags directly in composables with
LaunchedEffect— keep flag reads in theViewModel. - Creating a
RemoteConfigsingleton not wrapped byFeatureFlagRepository— other layers take on Firebase coupling. - Using Remote Config to store sensitive data (API keys, secrets) — Remote Config values are client-readable.
- Never retiring flags — code accumulates dead branches that are never exercised.
- Logging exposure events on conversion (purchase, signup) instead of on first view — skews experiment results by excluding non-converting users.
- Defaulting all flags to
truein debug andfalsein release — some flags should default tofalseeverywhere until specifically enabled. - Calling
fetchAndActivateinside aViewModelon every creation — rate-limited and adds cold start latency; call it once during app startup.
Testing Guidance
Use a FakeFeatureFlagRepository in all unit and integration tests:
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/android-feature-flags/SKILL.md
Popularity
- Repository stars
- 9
- Repository forks
- 5
- 7-day trend score
- 12
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/shekhar23/claude-zero-to-hero-android-kmp/android-feature-flags)