agentleFS
launch52-ailaunch52-ai/flutter-template/.claude/skills/flavors/SKILL.md

flavors

Skill2 starsChanged 9 months agoMITView on GitHub

Configure environment flavors (dev, staging, prod) for Flutter apps. Sets up compile-time variables via --dart-define-from-file, Gradle productFlavors, Xcode schemes, and per-environment configuration. Use when adding multi-environment support or separating dev/staging/prod builds.

  • Reads credentials

We split this skill into the rules it gives an agent

10 rules. About 0 are common, 1 is distinctive, and 9 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 9

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    If your project uses /init's approach (await dotenv.load()), running /flavors will:

    line 29
  2. Very specific:

    Create FlavorConfig class using String.fromEnvironment()

    line 32
  3. Very specific:

    Keep feature flags in DebugConstants, flavor config in FlavorConfig.

    line 46
  4. Very specific:

    Create .env.{flavor} files.

    line 80
  5. Very specific:

    Update android/app/build.gradle.

    line 84
  6. Distinctive:

    Create xcconfig files and Xcode schemes.

    line 88
  7. Very specific:

    Remove flutter_dotenv, use FlavorConfig.

    line 96
  8. Very specific:

    Add .env.dev, .env.staging, .env.prod.

    line 100
  9. Very specific:

    Ensure flavor names match exactly in build.gradle, iOS schemes, and .env.{flavor} files.

    line 163
  10. Very specific:

    Ensure you're passing --dart-define-from-file=.env.{flavor} flag.

    line 171

≈ “Common” is an estimate: at least 1 in 5 of the 308,232 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Flavors - Environment Configuration

Configure dev, staging, and production environments with separate configurations, bundle IDs, and app names.

When to Use This Skill

  • Setting up multiple environments (dev, staging, prod)
  • Separating API endpoints per environment
  • Using different bundle IDs for each environment
  • Configuring environment-specific Firebase/Supabase projects
  • User asks "add flavors", "setup environments", "separate dev/prod"

When NOT to Use This Skill

  • Single environment projects - Use /init with single .env
  • CI/CD setup - Use /ci-cd after flavors are configured
  • Basic Firebase setup - Use /analytics first, then add per-flavor config

Important: Migration from flutter_dotenv

This skill REPLACES flutter_dotenv runtime loading with compile-time variables.

If your project uses /init's approach (await dotenv.load()), running /flavors will:

  1. Remove flutter_dotenv dependency
  2. Replace .env runtime loading with --dart-define-from-file build flags
  3. Create FlavorConfig class using String.fromEnvironment()

Why compile-time? Secrets are not bundled in the app binary - they're injected at build time.

Integration with /core

FlavorConfig handles:

  • Flavor identification (isDev, isProd, isStaging)
  • Per-flavor API URLs and service credentials

DebugConstants (from /core) handles:

  • Debug/mock flags (useMockAuth, useMockApi)
  • Logging and UI debug options

Keep feature flags in DebugConstants, flavor config in FlavorConfig.

Questions to Ask

  1. Flavor count: How many environments? (dev + prod, dev + staging + prod)
  2. Bundle ID pattern: How should bundle IDs differ? (suffix: .dev)
  3. App name pattern: How should app names differ? (suffix: " (Dev)")
  4. Firebase: Separate Firebase projects per flavor? (yes/no)
  5. Supabase: Separate Supabase projects per flavor? (yes/no)

Quick Reference

FlavorBundle ID SuffixApp Name SuffixPurpose
dev.dev (Dev)Local development
staging.staging (Staging)QA/testing
prod(none)(none)Production release

Key Commands

flutter run --flavor dev --dart-define-from-file=.env.dev
flutter run --flavor prod --dart-define-from-file=.env.prod
dart run .claude/skills/flavors/scripts/check.dart

Workflow

Phase 1: Gather Requirements

Confirm: flavor count, base bundle ID, base app name, Firebase/Supabase per flavor.

Phase 2: Create Environment Files

Create .env.{flavor} files. See templates/env-files/.

Phase 3: Configure Android

Update android/app/build.gradle. See android-guide.md.

Phase 4: Configure iOS

Create xcconfig files and Xcode schemes. See ios-guide.md.

Phase 5: Create FlavorConfig

Generate lib/core/config/flavor_config.dart from reference/flavor_config.dart.

Phase 6: Migrate main.dart

Remove flutter_dotenv, use FlavorConfig. See reference/main_flavored.dart.

Phase 7: Update .gitignore

Add .env.dev, .env.staging, .env.prod.

Phase 8: Verify Setup

dart run .claude/skills/flavors/scripts/check.dart
flutter build apk --flavor dev --dart-define-from-file=.env.dev

Guides

GuideContent
android-guide.mdGradle productFlavors, signing configs
ios-guide.mdXcode schemes, xcconfig files
firebase-guide.mdPer-flavor Firebase setup (see /analytics for basic setup)
checklist.mdVerification checklist

Templates

TemplatePurpose
templates/env-files/.env.dev, .env.staging, .env.prod
templates/android/build.gradle flavor config
templates/ios/xcconfig files
templates/vscode/launch.json configurations

Checklist

Environment Files:

  • .env.dev and .env.prod exist
  • All .env.* files in .gitignore
  • flutter_dotenv removed from pubspec.yaml (if migrating)

Android:

  • build.gradle has flavorDimensions and productFlavors
  • Each flavor has applicationIdSuffix and resValue app name

iOS:

  • Dev.xcconfig and Prod.xcconfig exist
  • Xcode schemes created for each flavor

Dart:

  • lib/core/config/flavor_config.dart exists
  • main.dart does NOT use dotenv.load()
  • main.dart uses FlavorConfig

Build:

  • flutter build apk --flavor dev succeeds
  • flutter build apk --flavor prod succeeds

Related Skills

  • /init - Creates project with single .env (flavors replaces this approach)
  • /core - DebugConstants for mock/debug flags (complementary to FlavorConfig)
  • /ci-cd - Add flavor-aware CI/CD pipelines after this skill
  • /analytics - Basic Firebase setup; use before per-flavor config
  • /release - Prepare production flavor for app stores

Common Issues

"Flavor not found" Error

Ensure flavor names match exactly in build.gradle, iOS schemes, and .env.{flavor} files.

Environment Variables Empty

Using dotenv.env['KEY']? Switch to String.fromEnvironment('KEY').

Build works but wrong config

Ensure you're passing --dart-define-from-file=.env.{flavor} flag.

Next Steps

  1. /ci-cd - Update GitHub Actions for multi-flavor builds
  2. /analytics - Configure per-flavor Firebase Analytics
  3. /release - Prepare production signing

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

Reviews can't be read right now.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.