Feature Flags Android
PostHogOfficialCreated by PostHog
- Skill
- Tool integration
- Data and AI
- MIT
- No issues found
AutoGineer summary
Written by AutoGineer from the skill’s own files, not by the author
This skill provides guidance and best practices for implementing PostHog feature flags within Android applications. It covers the necessary SDK installation, configuration in the Application class, and methods for evaluating both boolean and multivariate flags. The skill emphasizes secure practices, such as using environment variables for API keys, and provides patterns for initializing the PostHog client to ensure efficient flag management.
What it does
- Guides the installation of the PostHog Android SDK via Gradle.
- Provides patterns for initializing PostHog in the Application class.
- Demonstrates how to evaluate boolean feature flags in Kotlin.
- Shows how to implement multivariate feature flags for specific user variants.
- Offers best practices for flag management and environment variable usage.
- Integrates with PostHog MCP tools for direct flag management.
When to use it
- When you need to perform phased rollouts of new features in an Android app.
- When you want to run A/B tests or experiments on specific user segments.
- When you need to toggle features on or off remotely without a new app release.
- When you are setting up a new Android project and want to include feature flagging capabilities.
Advantages
- Enables safer feature releases through gradual rollouts.
- Allows for remote configuration of app behavior.
- Supports data-driven decision making via experiments.
- Promotes clean code by separating feature logic from deployment.
Usage examples
- “How do I check if a feature flag is enabled in my Android app?”
- The agent will provide the Kotlin code snippet using PostHog.isFeatureEnabled('flag-key') and explain how to handle the boolean result.
- “Show me how to initialize PostHog in my Android Application class.”
- The agent will provide a sample implementation of the Application class, demonstrating the correct use of PostHogAndroid.setup() within the onCreate() method.
Install
Download the skill as a ZIP:
https://mp-staging.autogineer.com/agent-skills/posthog/feature-flags-android/downloadUnzip it into the cross-client skills folder of your project:
mkdir -p .agents/skills && unzip feature-flags-android.zip -d .agents/skills
Documentation by PostHog
PostHog feature flags for Android
This skill helps you add PostHog feature flags to Android applications.
Reference files
references/android.md- Android feature flags installation - docsreferences/adding-feature-flag-code.md- Adding feature flag code - docsreferences/best-practices.md- Feature flag best practices - docs
Consult the documentation for API details and framework-specific patterns.
Key principles
Environment variables: Always use environment variables for PostHog keys. Never hardcode them.
Minimal changes: Add feature flag code alongside existing logic. Don't replace or restructure existing code.
Boolean flags first: Default to boolean flag checks unless the user specifically asks for multivariate flags.
Server-side when possible: Prefer server-side flag evaluation to avoid UI flicker.
PostHog MCP tools
Check if a PostHog MCP server is connected. If available, look for tools related to feature flag management (creating, listing, updating, deleting flags). Use these tools to manage flags directly in PostHog rather than requiring the user to do it manually in the dashboard.
Framework guidelines
Adapt dependency configuration to the appropriate build.gradle(.kts) file according to the project gradle version
Call
PostHogAndroid.setup()only once in the Application class'sonCreate()method, so it's initialized as early as possible and only once.Initialize PostHog in the Application class's
onCreate()methodEnsure every activity has a
android:labelto accurately track screen views.
Files
- ATTRIBUTION.mdAdded by AutoGineer963 B
- LICENSELicence file added by AutoGineer1.0 KiB
- SKILL.md1.7 KiB
- references/adding-feature-flag-code.md108.7 KiB
- references/android.md3.5 KiB
- references/best-practices.md7.9 KiB
Requirements and compatibility
Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta
“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.
Needs: Needs an MCP server
Security
No issues found by our static scan· No issues found
A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.
Attribution and licence
- Created by
- PostHog
- Publisher
- PostHog (Official)
- Source
- PostHog/skills · skills/posthog/feature-flags/skills/android · commit a5d30e7
- Licence
- MIT License (redistribution allowed)
- LICENSE (added by AutoGineer from LICENSE)
- ATTRIBUTION.md (written by AutoGineer)
- Synced
- Also distributed in
- PostHog/skills
AutoGineer is not affiliated with or endorsed by PostHog.
Download ZIP
The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download feature-flags-android.zip