BillDog CLI
Command-line tool (@billdog.io/cli) that detects your project platform and framework, installs and configures the matching BillDog SDK, runs end-to-end project diagnostics, scaffolds starter paywall components, and migrates competitor SDK call sites.
Integrating an SDK directly? Follow the guide for your platform: iOS, Android, Flutter, React Native, Expo or Web, or start with the Quick Start.
Installation
Run it with npx, or install it once (requires Node.js >= 18)
# In your project directory, no install needed:
npx @billdog.io/cli init
# Or install the billdog command globally:
npm install -g @billdog.io/cli
billdog --helpinit reads your project and installs the matching package with your project's own package manager (npm, pnpm, yarn or bun): billdogeng-next, -nuxt, -svelte, -angular, -astro, -vue, -react or -node for those frameworks, @billdog.io/web for other browser apps, and the React Native, Expo, iOS, Android and Flutter SDKs for mobile projects. Capacitor is detected but not supported yet.
Core Workflow
Initialize, diagnose, and scaffold paywall components
Initialize BillDog
billdog initWhat billdog init does:
- Auto-detects your project platform (Expo, React Native, Flutter, iOS, Android, Web; defaults to Web if no manifest matches)
- Validates your API key against
POST /validate-api-key - Installs the SDK automatically (Web, React Native, Expo, Flutter) or prints SPM/Gradle instructions (iOS, Android)
- Writes platform SDK setup code (
src/lib/billdog.ts,billdog.config.js,BillDogSetup.swift,BillDogSetup.kt, orlib/billdog_config.dart) and saves.billdog.json - Optionally scaffolds a starter
basicpaywall component
Non-interactive mode:
billdog init -y -k bd_public_test_YOUR_API_KEY --placement onboarding --with-sampleDiagnose Integration
billdog doctorRuns 9 checks (6 hard errors, 3 warnings) with actionable remediations:
- Platform recognition & CLI installer support (
platform,installer-support) - Project config (
.billdog.json) & SDK package presence (config,sdk-installed) - Credential presence, API key validity & cached session freshness (
credential-present,credential-valid,session-fresh) - API reachability (
/health-check) & recorded placement identifier (api-reachable,placement)
Generate Paywall
billdog generate paywallScaffolds starter paywall code tailored to your platform:
- Web (
src/components/Paywall.tsx) — React component importingBillDogfrom../lib/billdogand callingBillDog.presentPaywall('premium') - React Native / Expo (
src/components/Paywall.tsx) — Component importing{ BillDog }from@billdog.io/react-nativeand callingBillDog.purchase({ productId: 'premium_monthly' }) - iOS (
Sources/Paywalls/PaywallView.swift) — SwiftUIPaywallViewimportingBillDogFulland callingBillDog.shared.purchase(productId: "premium_monthly") - Android (
app/src/main/java/com/example/paywalls/PaywallView.kt) — Jetpack ComposePaywallViewwithio.billdog.core.BillDogandPurchaseResult - Flutter (
lib/widgets/paywall.dart) —PaywallWidgetwithpackage:billdog_flutter/billdog_flutter.dartcallingBillDog.shared.purchase(kPremiumProductId)
Command Reference
All 11 commands and options in @billdog.io/cli
billdog init
Initialize the BillDog SDK in your project, write the platform setup file (src/lib/billdog.ts, billdog.config.js, BillDogSetup.swift, BillDogSetup.kt, or lib/billdog_config.dart) and save .billdog.json. Note: init reads the API key from -k or interactive prompt (pass -k $BILLDOG_API_KEY in non-interactive scripts).
OPTIONS:
-p, --platform <platform> # Specify platform: web, react, next, nuxt, svelte, astro, vue, angular, node, react-native, expo, ios, android, flutter -k, --api-key <key> # Your BillDog API key (bd_public_test_... or bd_public_live_...) --project-id <id> # Project id for the framework wrappers (looked up from the API key if omitted) --placement <identifier> # Record the placement identifier in .billdog.json (checked by doctor and test) --with-sample # Generate sample paywall (basic template) --skip-install # Skip package manager installation step -y, --yes # Skip all prompts and use defaults
EXAMPLES:
billdog init # Interactive billdog init -y -k bd_public_test_1234567890123456 # Non-interactive billdog init -p web --placement onboarding --with-sample # Specific platform + placement
billdog doctor
Diagnose the project end-to-end across 9 checks: platform (ERROR), installer-support (WARN — warns on ios that SPM setup is manual and skips sdk-installed), config (ERROR — checks .billdog.json), credential-present (ERROR — checks .billdog.json apiKey, then BILLDOG_API_KEY env var, then ~/.billdog/credentials.json), credential-valid (ERROR — POST /validate-api-key), session-fresh (WARN — checks if cached login session expired), sdk-installed (ERROR), api-reachable (ERROR — GET /health-check), and placement (WARN — checks placement in .billdog.json). Prints a remediation for every failed check; exits 1 only if an ERROR check fails (warnings exit 0). Never prompts for a secret.
OPTIONS:
-p, --platform <platform> # Override the detected platform
billdog doctor billdog doctor -p web
billdog test
Connectivity subset of billdog doctor: runs config, credential-present, credential-valid, api-reachable, and placement. Takes no options.
billdog test
billdog validate
Configuration subset of billdog doctor: runs platform, config, credential-present, credential-valid, and sdk-installed.
OPTIONS:
-p, --platform <platform> # Specify platform to validate
billdog validate # Current setup billdog validate -p android # Specific platform
billdog update
Checks the installed SDK version against the latest published version (npm, pub.dev, GitHub tags on billdog-ios-spm, or Maven Central maven-metadata.xml). Automatically upgrades Web, React Native (including npx pod-install ios), Expo (@billdog.io/expo@latest and @billdog.io/react-native@latest), and Flutter (flutter pub upgrade billdog_flutter); prints manual update steps and changelog links for iOS and Android.
OPTIONS:
-p, --platform <platform> # Specify platform to update
billdog update # Current platform (from .billdog.json or auto-detected) billdog update -p web # Specific platform
billdog generate <type>
Generate starter paywall components (paywall) or standalone configuration files (config: writes billdog.config.ts on Web, billdog.config.js on RN/Expo, BillDog.plist on iOS, app/src/main/res/values/billdog.xml on Android, or lib/billdog_config.dart on Flutter). Requires .billdog.json or -p <platform> (does not auto-detect platform).
OPTIONS:
-p, --platform <platform> # Specify platform: web, react-native, expo, ios, android, flutter -t, --template <template> # Paywall template: basic, premium, offer, trial, family -o, --output <path> # Custom output file path
EXAMPLES:
billdog generate paywall # Pick a template interactively billdog generate paywall -p ios -t trial # Template: basic, premium, offer, trial, family billdog generate paywall -p web -o src/Paywall.tsx billdog generate config -p android # Generate standalone config template
billdog login
Authenticate the CLI with your own BillDog operator account (used by billdog migrate and billdog audit to obtain a BillDog-managed Anthropic key) and cache session credentials at ~/.billdog/credentials.json (mode 0600). This is operator access to the dashboard, not BillDog Auth, which signs in your app’s end users.
OPTIONS:
-e, --email <email> # Email address (prompted if omitted) -p, --password <password> # Password (prompted if omitted)
billdog login billdog login -e you@company.com
billdog logout
Remove cached credentials at ~/.billdog/credentials.json.
billdog logout
billdog detect
Scan dependency manifests (package.json, Podfile, build.gradle, build.gradle.kts, pubspec.yaml) for known competitor SDKs (RevenueCat, Superwall, Adapty, Mixpanel, Amplitude, OneSignal, Braze, Typeform, SurveyMonkey), detect cross-SDK chains (e.g. Superwall + RevenueCat, Adapty + Mixpanel), and present an interactive migration picker with chain-aware ordering. (Note: iOS projects using Swift Package Manager without a Podfile should run billdog migrate --from <provider> directly.)
OPTIONS:
--project-path <path> # Path to the app repo to scan (defaults to cwd) -y, --yes # Skip the consent picker; emit the detected list
billdog detect billdog detect --project-path ./my-app -y
billdog migrate
Rewrite a competitor SDK's call sites (RevenueCat, Superwall, Adapty, Mixpanel, Amplitude, OneSignal, Braze, Typeform, SurveyMonkey) to BillDog and write a unified-diff patch (git apply). Supported across iOS, Android, and React Native for all 9 providers, Flutter for RevenueCat, Superwall, Adapty, Mixpanel, Amplitude, and OneSignal, and Expo for RevenueCat and Superwall (pass -p react-native for other providers on Expo). Data migration is separate — use the dashboard importer (/dashboard/import). Live runs use Claude Sonnet (claude-sonnet-4-6) directly from your machine: run billdog login first (BillDog issues a rate-limited key: 1 mint per 5 minutes within your monthly CLI budget), or pass --anthropic-key / ANTHROPIC_API_KEY. --dry-run runs deterministically offline with no login or API call.
OPTIONS:
--from <provider> # Source provider (default: revenuecat): revenuecat | superwall | adapty | mixpanel | amplitude | onesignal | braze | typeform | surveymonkey --project-path <path> # Path to the app repo to scan (defaults to cwd) --output <path> # Where to write the patch file (default: ./billdog-migration.patch) --dry-run # Report call sites and mappability only; no API call, no patch written --anthropic-key <key> # Anthropic API key (optional — defaults to BillDog-issued via billdog login) -p, --platform <platform> # Override auto-detected platform -y, --yes # Skip confirmation prompts
EXAMPLES:
billdog migrate --from revenuecat --dry-run # Deterministic report: no login, no API call, no patch billdog migrate --from revenuecat # Writes ./billdog-migration.patch (trace in .billdog-migration-runs/) billdog migrate --from superwall --project-path ./ios-app --output ./sw.patch -y
billdog audit <module> Internal
For BillDog maintainers only. Crawls BillDog's own monorepo paths (dashboard pages, edge functions, and native SDK directories) for a module (paywalls, analytics, messaging, surveys, journeys, virtual-currency), two-pass verifies cross-SDK parity findings, and writes a Markdown audit report plus a git apply remediation patch.
OPTIONS:
--aspect <aspect> # Narrow the crawl to one aspect (e.g. "dynamic-values", "tap-actions") --platforms <list> # Comma-separated SDKs to include (default: "ios,android") --repo-root <path> # Monorepo root to audit (defaults to cwd) --output <path> # Where to write the proposed-fix patch (default: ./billdog-audit.patch) --report <path> # Where to write the findings report (default: docs/audits/<date>-<module>-audit.md) --anthropic-key <key> # Anthropic API key (optional — defaults to BillDog-issued via billdog login) --dry-run # Skip live confirmation prompts -y, --yes # Skip all confirmation prompts
billdog audit paywalls billdog audit analytics --aspect event-properties --platforms ios,android,react-native
Platform Support & Installer Behavior
How billdog init, update, and doctor handle each SDK platform
Web (React/Vite)
npm (@billdog.io/web)
Automated npm install + writes src/lib/billdog.ts
React Native
npm (@billdog.io/react-native) + pod-install
Automated npm & pod install + writes billdog.config.js
Expo
npx expo install (@billdog.io/expo + RN peers)
Automated expo install + writes billdog.config.js
iOS (Swift)
SPM (BillDogFull / BillDogEng)
Prints Xcode SPM steps + writes BillDogSetup.swift
Android (Kotlin)
Gradle (io.billdog:billdog-core)
Prints Maven Central Gradle coordinate + writes BillDogSetup.kt
Flutter
pub.dev (billdog_flutter)
Automated flutter pub add + writes lib/billdog_config.dart
Troubleshooting
Wrong platform detected (defaults to Web)
If no platform manifest matches in the current directory, auto-detection falls back to web. Pass -p explicitly:
billdog init -p iosbilldog generate says "No BillDog configuration found"
billdog generate reads the platform from .billdog.json rather than auto-detecting. Either run billdog init first or pass -p <platform>:
billdog generate paywall -p react-native -t trialAPI key rejected
Verify or re-issue your public key (bd_public_test_... or bd_public_live_...) under Integration & Data → API Keys in the dashboard.
Configuration or connectivity check failed
Run billdog doctor to see which check failed and its exact remediation command:
billdog doctorBest Practices
Record your placement and run doctor after init
billdog init --placement onboarding && billdog doctorPreview migrations with --dry-run first
billdog migrate --from revenuecat --dry-runValidate configuration in CI before deployment
billdog validateUse non-interactive flags in scripts and CI/CD
billdog init -y -k $BILLDOG_API_KEY --skip-install
CI/CD Integration
GitHub Actions & GitLab CI examples
Run billdog doctor / billdog test through npx with BILLDOG_API_KEY set in the environment.
GitHub Actions
- name: Validate BillDog Integration
env:
BILLDOG_API_KEY: ${{ secrets.BILLDOG_API_KEY }}
run: |
npx -y @billdog.io/cli init -y -k "$BILLDOG_API_KEY" --skip-install
npx -y @billdog.io/cli doctorGitLab CI
validate_billdog:
script:
- npx -y @billdog.io/cli init -y -k "$BILLDOG_API_KEY" --skip-install
- npx -y @billdog.io/cli doctorWas this page helpful?
Or rate this page: