
Firebase Cli
- 211 installs
- 40 repo stars
- Updated August 4, 2026
- akillness/oh-my-skills
Initialize Firebase projects, deploy Hosting/Functions/Firestore rules, manage emulators, and wire CI deploys without memorizing firebase-tools flags.
About
Guides Claude through Firebase CLI workflows for bootstrapping apps, configuring services, running emulators, and shipping Hosting, Cloud Functions, and database rules safely across environments.
- Project init and multi-environment targets
- Hosting, Functions, and Firestore deploy flows
- Local emulator suite orchestration
- Auth and security rules management
- CI-friendly noninteractive deploy patterns
Firebase Cli by the numbers
- 211 all-time installs (skills.sh)
- Ranked #196 of 550 CLI & Terminal skills by installs in the Skillselion catalog
- Data as of Aug 5, 2026 (Skillselion catalog sync)
npx skills add https://github.com/akillness/oh-my-skills --skill firebase-cliAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 211 |
|---|---|
| repo stars | ★ 40 |
| Last updated | August 4, 2026 |
| Repository | akillness/oh-my-skills ↗ |
What it does
Initialize Firebase projects, deploy Hosting/Functions/Firestore rules, manage emulators, and wire CI deploys without memorizing firebase-tools flags.
Files
firebase-cli — Firebase platform operator
Keyword:firebase·firebase deploy·firebase init·firebase emulators
>
Use this skill when the center of gravity is Firebase platform/project operation through the CLI.
When to use this skill
- Install or update
firebase-tools, choose an auth path, and verify the CLI can operate the target project - Bootstrap Firebase config in a repo with
firebase init,.firebaserc, aliases, targets, and deploy surfaces - Run the Firebase Emulator Suite for local development, persistence, and test execution
- Deploy or promote Hosting, Functions, rules, Remote Config, Extensions, or App Hosting through the CLI
- Manage preview channels, project aliases, selective deploys, and CI/CD auth for Firebase operations
- Perform Firebase admin/data tasks such as auth import/export, App Distribution, Remote Config rollback, and extension management
When not to use this skill
- The main job is backend AI workflow orchestration, tools, flows, RAG, evals, or observability inside Firebase / Google AI products → use
genkit - The main job is direct app/client SDK integration for Gemini-powered in-app features → use
firebase-ai-logic - The main job is auth stack choice and product auth architecture rather than Firebase CLI execution → use
authentication-setup - The main job is schema/index design rather than Firebase CLI commands → use
database-schema-design - The main job is generic rollout strategy across providers instead of Firebase-specific operator commands → use
deployment-automation
Instructions
Step 1: Pick the operating mode
Start by routing the request into one of these modes:
| Mode | Use when | Primary support |
|---|---|---|
| Install / auth | CLI missing, outdated, or blocked on credentials | scripts/install.sh, references/install-auth-and-bootstrap.md |
| Bootstrap / config | Need firebase init, aliases, targets, or repo config layout | references/install-auth-and-bootstrap.md |
| Local emulators | Need local Firebase runtime, persistence, or test harness | scripts/emulators.sh, references/emulator-and-release-workflows.md |
| Deploy / release | Need scoped deploys, preview channels, App Hosting rollout, or CI execution | scripts/deploy.sh, references/emulator-and-release-workflows.md |
| Admin / data ops | Need auth import/export, Remote Config, App Distribution, Extensions, or Data Connect commands | references/admin-and-data-operations.md |
| Unsure / mixed job | Need help deciding whether this is Firebase CLI vs adjacent lane work | references/modes-and-routing.md |
Step 2: Verify prerequisites before changing anything
1. Confirm the CLI exists and capture the version: firebase --version 2. Confirm the runtime is new enough for current firebase-tools releases:
- npm install path requires Node.js 20+
- standalone installer is macOS/Linux only
3. Check authentication path:
- local interactive work →
firebase login - CI/non-interactive work → service account credentials via
GOOGLE_APPLICATION_CREDENTIALS
4. Inspect project config before deploys or emulator work:
firebase.json.firebaserc- any target-specific directories (
functions/, hosting output dir, rules/index files)
Step 3: Run the smallest workflow that answers the request
Mode A — Install / auth
- Install or update via
bash scripts/install.sh - Prefer npm install when Node.js 20+ is available:
npm install -g firebase-tools - Use browser OAuth locally with
firebase login - In CI, prefer service-account credentials over deprecated
--token/FIREBASE_TOKEN
Mode B — Bootstrap / config
- Use
firebase initfor the exact surfaces needed instead of turning on everything blindly - Set/inspect aliases with
firebase useandfirebase use --add - Use deploy targets when multiple Hosting sites, DB instances, or buckets exist
- Record which Firebase features belong in this repo and which belong in adjacent skills
Mode C — Local emulators
- Use
bash scripts/emulators.sh --persistentfor durable local data - Use
firebase emulators:exec "<test command>"for one-shot test runs - Start only the emulators you need with
--only auth,firestore,functions - Keep emulator config and seed-data expectations explicit in the repo
Mode D — Deploy / release
- Scope deploys with
--onlyor--except - Prefer preview channels for reviewable Hosting changes before production deploys
- For App Hosting, treat backend creation/rollouts as an operator workflow, not a generic web deploy shortcut
- In CI, use
--non-interactiveand explicit credentials - Verify what changed after deploy instead of assuming success from the command exit alone
Mode E — Admin / data ops
- Use the CLI for auth import/export, Remote Config versioning/rollback, App Distribution, Extensions, and targeted cleanup tasks
- Be explicit about destructive commands like
firestore:delete --recursive --force - For large/import-sensitive jobs, capture the exact hash/config/version parameters before execution
Step 4: Route out aggressively when the job changed shape
Use firebase-cli as the operator anchor, but hand off when the work is really about:
- app/client Gemini SDK feature wiring →
firebase-ai-logic - flow/tool/RAG/eval orchestration →
genkit - auth-model product decisions →
authentication-setup - schema/index modeling →
database-schema-design - provider-agnostic rollout strategy →
deployment-automation
Step 5: Verify the outcome
For every mode, verify the smallest truthful artifact:
- install/auth →
firebase --version,firebase login:list, or successful auth-bound command - bootstrap/config →
firebase.json,.firebaserc, target mappings - emulators → running ports, imported/exported data directory, successful test run
- deploy/release → deployed target list, preview URL, or post-deploy smoke check
- admin/data ops → exported/imported file, version rollback confirmation, tester/group update, or extension status
Examples
Example 1: Bootstrap a Firebase repo cleanly
Prompt: "Set up Firebase in this repo for Hosting + Functions + preview channels"
Mode:
- Bootstrap / config
Likely actions:
- bash scripts/install.sh
- firebase login
- firebase init hosting functions
- firebase use --add
- firebase target:apply ... # if multi-site is neededExample 2: Local emulator workflow with persistence
Prompt: "Run auth + firestore emulators locally and keep the data between runs"
Mode:
- Local emulators
Likely actions:
- bash scripts/emulators.sh --only auth,firestore --persistent
- or firebase emulators:start --only auth,firestore --import ./emulator-data --export-on-exitExample 3: Firebase release / preview flow
Prompt: "Deploy Hosting to a reviewable staging channel, then ship production after approval"
Mode:
- Deploy / release
Likely actions:
- bash scripts/deploy.sh --channel staging --expires 7d
- firebase hosting:channel:open staging
- firebase deploy --only hostingExample 4: Route AI workflow work away from this skill
Prompt: "Build a Firebase RAG flow with tools, evals, and observability"
Decision:
- Route to `genkit`
- Keep `firebase-cli` only for operator tasks like local setup or deploy wiring if neededBest practices
1. Prefer workflow selection over command dumping — choose the mode first, then the commands 2. Use service accounts in CI — treat --token / FIREBASE_TOKEN as deprecated escape hatches, not the default path 3. Scope deploys tightly — --only and preview channels reduce accidental blast radius 4. Keep repo config explicit — firebase.json, .firebaserc, and target mappings should match the repo’s real deploy surfaces 5. Use persistence intentionally in emulator work — import/export directories make local debugging and tests repeatable 6. Separate Firebase operator work from app/AI logic work — route to firebase-ai-logic or genkit when the CLI is no longer the main job 7. Treat destructive admin commands as high-risk — confirm paths, versions, and resource IDs before delete/rollback/import operations
References
- Mode selection and route-outs
- Install, auth, and bootstrap guide
- Emulator and release workflows
- Admin and data operations
- Full command reference
- Scripts —
install.sh,deploy.sh,emulators.sh - Firebase CLI reference
- firebase-tools GitHub
{
"skill": "firebase-cli",
"version": "1.1",
"evals": [
{
"id": "firebase-cli-mode-bootstrap",
"description": "Choose bootstrap/config mode for a new repo that needs Hosting and Functions wiring",
"input": "이 저장소에 Firebase Hosting이랑 Functions 붙이고 firebase.json / .firebaserc까지 정리해줘",
"expected_actions": [
"select bootstrap/config mode",
"bash scripts/install.sh",
"firebase login",
"firebase init hosting functions"
],
"expected_outputs": [
"firebase.json",
".firebaserc"
],
"tags": ["bootstrap", "config", "hosting", "functions"]
},
{
"id": "firebase-cli-mode-emulators",
"description": "Choose emulator mode and preserve local data",
"input": "Firestore랑 Auth 에뮬레이터만 띄우고 데이터는 다음 실행에도 유지되게 해줘",
"expected_actions": [
"select local emulators mode",
"bash scripts/emulators.sh --only auth,firestore --persistent"
],
"expected_outputs": [
"emulator-data directory",
"emulator startup command"
],
"tags": ["emulators", "persistence", "auth", "firestore"]
},
{
"id": "firebase-cli-mode-deploy",
"description": "Choose deploy/release mode for a reviewable Hosting rollout",
"input": "Hosting 변경사항을 먼저 스테이징 프리뷰 채널로 배포하고 확인 끝나면 프로덕션 배포하게 정리해줘",
"expected_actions": [
"select deploy/release mode",
"firebase hosting:channel:create staging --expires 7d",
"firebase hosting:channel:deploy staging",
"firebase deploy --only hosting"
],
"expected_outputs": [
"preview channel URL",
"scoped production deploy command"
],
"tags": ["hosting", "preview-channel", "deploy"]
},
{
"id": "firebase-cli-mode-admin",
"description": "Choose admin/data ops mode for auth migration",
"input": "기존 사용자 JSON을 Firebase Authentication으로 옮기되 SCRYPT 파라미터까지 정확히 챙겨줘",
"expected_actions": [
"select admin/data ops mode",
"firebase auth:import users.json --hash-algo=SCRYPT"
],
"expected_outputs": [
"hash parameter checklist",
"auth import command"
],
"tags": ["auth", "import", "migration"]
},
{
"id": "firebase-cli-mode-ci",
"description": "Prefer service-account auth for CI deploys",
"input": "GitHub Actions에서 Firebase Hosting 자동 배포 연결해줘. 토큰 말고 지금 권장 방식으로.",
"expected_actions": [
"select install/auth or deploy/release mode",
"recommend GOOGLE_APPLICATION_CREDENTIALS service-account auth",
"firebase deploy --only hosting --non-interactive"
],
"expected_outputs": [
"service-account credential guidance",
"non-interactive deploy command"
],
"tags": ["ci-cd", "service-account", "hosting"]
},
{
"id": "firebase-cli-route-out-genkit",
"description": "Route backend AI workflow work to genkit instead of keeping firebase-cli active",
"input": "Firebase 안에서 RAG랑 tool calling, eval까지 들어간 Genkit flow 만들어줘",
"expected_actions": [
"route to genkit"
],
"expected_outputs": [
"explicit route-out note to genkit"
],
"tags": ["routing", "genkit", "boundary"]
}
]
}
Admin and data operations
Auth import / export
Export users
firebase auth:export users.jsonImport users
firebase auth:import users.json --hash-algo=BCRYPTFor SCRYPT or other migrated hashes, capture all required hash parameters before running the import.
Remote Config
firebase remoteconfig:get --output config.json
firebase remoteconfig:versions:list --limit 20
firebase remoteconfig:rollback --version-number 5App Distribution
firebase appdistribution:distribute app-release.apk \
--app APP_ID \
--release-notes "Sprint build" \
--groups qa-teamExtensions
firebase ext:list
firebase ext:install firebase/delete-user-data
firebase ext:update delete-user-data
firebase ext:uninstall delete-user-dataData Connect / targeted admin commands
Use Firebase CLI for operational Data Connect actions when the request is still mainly CLI/platform work.
firebase dataconnect:services:list
firebase dataconnect:sdk:generateHigh-risk command reminders
firebase firestore:delete ... --recursive --forceis destructive- Remote Config rollback should capture the target version first
- Auth imports should preserve exact hash settings
- App Distribution commands should verify the correct app ID, tester group, and release notes
Firebase CLI — Complete Command Reference
Source: https://firebase.google.com/docs/cli | firebase-tools v15.15.0
Last updated: 2026-04-16
---
Global Flags
These flags apply to any Firebase CLI command.
| Flag | Description |
|---|---|
-P <id>, --project <id> | Specify the Firebase project ID |
--account <email> | Specify the account (email) to use |
--token <token> | (Deprecated) Long-lived user token |
--debug | Enable verbose debug output |
--json | Output results as JSON |
--non-interactive | Disable interactive prompts |
--interactive | Force interactive mode |
-h, --help | Display help for the command |
---
Authentication
firebase login
Authenticate to Firebase. Opens browser for OAuth.
firebase login
firebase login --no-localhost # Copy-paste flow
firebase login --reauth # Force re-authentication| Flag | Description |
|---|---|
--no-localhost | Use copy-paste instead of local server |
--reauth | Force re-authentication |
firebase logout
firebase logout
firebase logout --account user@example.comfirebase login:ci
Generate a CI token (deprecated — use service accounts instead).
firebase login:ci
firebase login:ci --no-localhostfirebase login:add
Add authorization for an additional Google account.
firebase login:addfirebase login:list
List all authorized CLI accounts.
firebase login:listfirebase login:use
Set default account for the current project directory.
firebase login:use user@example.comfirebase login:revoke
Revoke credentials for an account.
firebase login:revoke user@example.com---
CI/CD Authentication
Priority order: 1. GOOGLE_APPLICATION_CREDENTIALS env var → service account JSON (recommended) 2. Local user login 3. --token / FIREBASE_TOKEN (deprecated) 4. Application Default Credentials (gcloud auth application-default login)
export GOOGLE_APPLICATION_CREDENTIALS="/path/to/service-account-key.json"
firebase deploy --non-interactive---
Project Management
firebase init
Set up Firebase features in the current directory. Creates firebase.json.
firebase init
firebase init hosting
firebase init functions
firebase init firestore
firebase init database
firebase init storage
firebase init emulators
firebase init remoteconfig
firebase init hosting:github # Set up GitHub Actions
firebase init apphosting
firebase init genkitAvailable features: hosting, functions, firestore, database, storage, emulators, remoteconfig, extensions, apphosting, dataconnect, genkit
firebase use
Manage active Firebase project and aliases.
firebase use # Show active project + aliases
firebase use <project_id> # Set active project
firebase use <alias> # Switch to alias
firebase use --add # Add new alias interactively
firebase use --clear # Clear active project
firebase use --unalias <alias> # Remove an aliasAliases stored in .firebaserc.
firebase projects:list
firebase projects:listfirebase projects:create
firebase projects:create <project_id>
firebase projects:create --display-name "My App"| Flag | Description |
|---|---|
-n, --display-name <name> | Display name |
firebase projects:addfirebase
Add Firebase to an existing GCP project.
firebase projects:addfirebase <gcp_project_id>firebase open
Open Firebase console for a resource.
firebase open hosting:site
firebase open database
firebase open auth
firebase open storage
firebase open functions
firebase open firestore
firebase open analytics
firebase open crashlytics
firebase open messaging
firebase open remoteconfig---
Apps
firebase apps:create
firebase apps:create WEB "My Web App"
firebase apps:create ANDROID com.example.app
firebase apps:create IOS com.example.app| Flag | Description |
|---|---|
-a, --package-name <name> | Android package name |
-b, --bundle-id <id> | iOS bundle ID |
-s, --app-store-id <id> | iOS App Store ID |
firebase apps:list
firebase apps:list
firebase apps:list ANDROID
firebase apps:list IOS
firebase apps:list WEBfirebase apps:sdkconfig
Print app configuration (google-services.json, GoogleService-Info.plist, etc.).
firebase apps:sdkconfig
firebase apps:sdkconfig ANDROID <app_id>
firebase apps:sdkconfig WEB <app_id> --out config.js| Flag | Description |
|---|---|
-a, --app <app_id> | App ID |
-o, --out <filename> | Write to file |
---
Deploy Targets
Named aliases for specific resources (Hosting sites, DB instances, Storage buckets).
firebase target:apply
firebase target:apply hosting TARGET_NAME RESOURCE_ID
firebase target:apply storage TARGET_NAME BUCKET_NAME
firebase target:apply database TARGET_NAME INSTANCE_NAMEfirebase target:clear
firebase target:clear hosting TARGET_NAMEfirebase target:remove
firebase target:remove hosting TARGET_NAME RESOURCE_IDTargets stored in .firebaserc under targets.
---
Deployment
firebase deploy
Deploy to Firebase based on firebase.json.
firebase deploy
firebase deploy --only hosting
firebase deploy --only functions
firebase deploy --only firestore
firebase deploy --only database
firebase deploy --only storage
firebase deploy --only remoteconfig
firebase deploy --only extensions
firebase deploy --only apphosting
# Multiple targets (comma-separated)
firebase deploy --only hosting,functions
firebase deploy --only hosting,firestore,storage
# Sub-targets
firebase deploy --only functions:myFunction
firebase deploy --only functions:groupName
firebase deploy --only hosting:siteName
firebase deploy --only firestore:rules
firebase deploy --only firestore:indexes
firebase deploy --only database:rules
# Exclude targets
firebase deploy --except functions
firebase deploy --except hosting,storageAll `--only` targets:
| Target | What deploys |
|---|---|
hosting | Hosting content + config |
hosting:<site_id> | Specific site (multi-site) |
functions | All Cloud Functions |
functions:<name> | Specific function or group |
firestore | Firestore rules + indexes |
firestore:rules | Firestore rules only |
firestore:indexes | Firestore indexes only |
database | Realtime Database rules |
database:rules | Database rules only |
storage | Cloud Storage rules |
remoteconfig | Remote Config template |
extensions | All installed extensions |
apphosting | App Hosting backend |
All flags:
| Flag | Description |
|---|---|
--only <targets> | Comma-separated deploy targets |
--except <targets> | Comma-separated targets to skip |
-m, --message <msg> | Deploy message stored with the release |
--force | Delete Functions not in local source; bypass prompts |
--non-interactive | Disable interactive prompts |
--debug | Verbose debug output |
--dry-run | Preview without deploying |
firebase serve
Local development server for Hosting + HTTPS-triggered Functions.
firebase serve
firebase serve --only hosting
firebase serve --only functions
firebase serve --only hosting,functions
firebase serve --host 0.0.0.0
firebase serve --port 5000| Flag | Description |
|---|---|
--only <services> | Limit to hosting, functions |
--host <host> | Host to bind (default: localhost) |
-p, --port <port> | Port to listen on (default: 5000) |
---
Firebase Emulator Suite
firebase emulators:start
firebase emulators:start
firebase emulators:start --only hosting,functions,firestore
firebase emulators:start --import ./emulator-data
firebase emulators:start --import ./emulator-data --export-on-exit
firebase emulators:start --export-on-exit ./emulator-data
firebase emulators:start --inspect-functions
firebase emulators:start --inspect-functions 9229| Flag | Description |
|---|---|
--only <emulators> | Comma-separated emulators to start |
--import <dir> | Import emulator data on startup |
--export-on-exit [dir] | Export data on shutdown |
--inspect-functions [port] | Node.js debugger for Functions (default: 9229) |
--log-verbosity <level> | DEBUG, INFO, QUIET, SILENT |
--ui / --no-ui | Enable/disable Emulator UI |
Valid `--only` values: auth, functions, firestore, database, hosting, pubsub, storage, apphosting, eventarc, dataconnect
Default ports:
| Emulator | Port |
|---|---|
| Authentication | 9099 |
| Cloud Functions | 5001 |
| Firestore | 8080 |
| Realtime Database | 9000 |
| Hosting | 5000 |
| Pub/Sub | 8085 |
| Cloud Storage | 9199 |
| Emulator Suite UI | 4000 |
firebase emulators:exec
Start emulators, run a script, then shut down.
firebase emulators:exec "npm test"
firebase emulators:exec --only firestore,auth "npm test"
firebase emulators:exec --import ./emulator-data "npm test"
firebase emulators:exec --export-on-exit ./emulator-data "npm test"| Flag | Description |
|---|---|
--only <emulators> | Emulators to start |
--import <dir> | Import data before running |
--export-on-exit [dir] | Export data after script |
--inspect-functions [port] | Functions debugger |
--log-verbosity <level> | Log verbosity |
firebase emulators:export
Export data from running emulators.
firebase emulators:export ./emulator-data
firebase emulators:export ./emulator-data --forceSetup emulator binaries
firebase setup:emulators:database # Realtime Database emulator
firebase setup:emulators:firestore # Firestore emulator---
Firebase Hosting
firebase hosting:channel:create
firebase hosting:channel:create CHANNEL_ID
firebase hosting:channel:create staging --expires 7d| Flag | Description |
|---|---|
-e, --expires <duration> | Expiry duration: 12h, 7d, 2w; max 30d |
-s, --site <site_id> | Target a specific site |
firebase hosting:channel:deploy
firebase hosting:channel:deploy CHANNEL_ID
firebase hosting:channel:deploy staging --expires 7d
firebase hosting:channel:deploy new-feature --expires 24h --open
firebase hosting:channel:deploy staging --only my-site| Flag | Description |
|---|---|
-e, --expires <duration> | Channel expiry; default 7d; max 30d |
--only <targets> | Restrict to specific site targets |
--open | Open browser to channel URL after deploy |
--no-authorized-domains | Skip syncing with Auth authorized domains |
Channel URL format: https://PROJECT_ID--CHANNEL_ID-HASH.web.app
firebase hosting:channel:delete
firebase hosting:channel:delete CHANNEL_ID
firebase hosting:channel:delete staging --forcefirebase hosting:channel:list
firebase hosting:channel:list
firebase hosting:channel:list --site my-sitefirebase hosting:channel:open
firebase hosting:channel:open CHANNEL_ID
firebase hosting:channel:open livefirebase hosting:clone
Clone a Hosting version between sites/channels.
firebase hosting:clone SOURCE_SITE:SOURCE_CHANNEL TARGET_SITE:TARGET_CHANNEL
firebase hosting:clone my-app:live my-app-staging:stagingfirebase hosting:disable
firebase hosting:disable
firebase hosting:disable --force
firebase hosting:disable --site my-sitefirebase hosting:sites:create
firebase hosting:sites:create SITE_IDfirebase hosting:sites:list
firebase hosting:sites:listfirebase hosting:sites:delete
firebase hosting:sites:delete SITE_ID --force---
Cloud Functions
firebase functions:list
firebase functions:listfirebase functions:log
firebase functions:log
firebase functions:log --only myFunction
firebase functions:log --lines 50
firebase functions:log --open| Flag | Description |
|---|---|
--only <name> | Filter by function name |
-n, --lines <n> | Number of lines (default: 35) |
--open | Open console log viewer |
firebase functions:delete
firebase functions:delete myFunction
firebase functions:delete myFunction --region us-east1
firebase functions:delete myFunction --force| Flag | Description |
|---|---|
--region <region> | Function region (e.g., us-central1) |
--force | Skip confirmation |
firebase functions:shell
firebase functions:shell
firebase functions:shell --port 5001firebase functions:config:set (1st gen only)
firebase functions:config:set api.key="THE_API_KEY" api.url="https://api.example.com"firebase functions:config:get (1st gen only)
firebase functions:config:get
firebase functions:config:get api
firebase functions:config:get api.keyfirebase functions:config:unset (1st gen only)
firebase functions:config:unset api.keyfirebase functions:config:clone (1st gen only)
firebase functions:config:clone --from SOURCE_PROJECT_IDfirebase functions:secrets:set
firebase functions:secrets:set SECRET_NAMEfirebase functions:secrets:get
firebase functions:secrets:get SECRET_NAMEfirebase functions:secrets:access
firebase functions:secrets:access SECRET_NAME
firebase functions:secrets:access SECRET_NAME@VERSIONfirebase functions:secrets:prune
firebase functions:secrets:prune
firebase functions:secrets:prune --forcefirebase functions:secrets:destroy
firebase functions:secrets:destroy SECRET_NAME
firebase functions:secrets:destroy SECRET_NAME@VERSION --force---
Realtime Database
firebase database:get
firebase database:get /path
firebase database:get /messages --pretty
firebase database:get /messages --shallow
firebase database:get /messages --export
firebase database:get /messages -o messages.json
firebase database:get /messages --instance my-db
firebase database:get /messages --order-by-child score --limit-to-last 10| Flag | Description |
|---|---|
--pretty | Pretty-print JSON output |
--shallow | Top-level keys only |
--export | Include .priority values |
-o, --output <file> | Write to file |
-i, --instance <name> | Non-default DB instance |
--order-by-child <key> | Order by child key |
--order-by-key | Order by key |
--order-by-value | Order by value |
--limit-to-first <n> | First N results |
--limit-to-last <n> | Last N results |
--start-at <value> | Results starting at value |
--end-at <value> | Results ending at value |
--equal-to <value> | Exact match |
firebase database:set
firebase database:set /path data.json
firebase database:set /path --data '{"key":"value"}'
echo '{"foo":"bar"}' | firebase database:set /import --confirm| Flag | Description |
|---|---|
-d, --data <json> | Inline JSON data |
-y, --confirm | Skip confirmation |
-i, --instance <name> | Non-default DB instance |
firebase database:push
firebase database:push /messages data.json
firebase database:push /messages --data '{"name":"Doug","text":"Hello"}'firebase database:update
firebase database:update /users/uid --data '{"name":"New Name"}'
firebase database:update /path data.jsonfirebase database:remove
firebase database:remove /path
firebase database:remove / --confirm # WARNING: deletes entire databasefirebase database:profile
firebase database:profile
firebase database:profile --duration 30
firebase database:profile --output report.json
firebase database:profile --raw| Flag | Description |
|---|---|
-d, --duration <secs> | Profile duration (default: 120) |
-o, --output <file> | Write report to file |
--raw | Raw operation data |
-i, --instance <name> | Non-default DB instance |
firebase database:instances:create
firebase database:instances:create INSTANCE_NAME
firebase database:instances:create my-db --location us-central1firebase database:instances:list
firebase database:instances:listfirebase database:settings:get
firebase database:settings:get /settings/pathfirebase database:settings:set
firebase database:settings:set /settings/path VALUE---
Cloud Firestore
firebase firestore:delete
firebase firestore:delete COLLECTION_PATH
firebase firestore:delete COLLECTION_PATH/DOCUMENT_ID
firebase firestore:delete COLLECTION_PATH --recursive
firebase firestore:delete --all-collections --recursive --force| Flag | Description |
|---|---|
-r, --recursive | Recursively delete subcollections |
--all-collections | Delete all Firestore data |
-y, --force | Skip confirmation |
--database <id> | Target named database |
firebase firestore:indexes
firebase firestore:indexes
firebase firestore:indexes --database my-dbfirebase firestore:rules:get
firebase firestore:rules:getfirebase firestore:rules:stage
firebase firestore:rules:stage RULES_FILEfirebase firestore:rules:release
firebase firestore:rules:release
firebase firestore:rules:release RULES_FILE---
Firebase Authentication
firebase auth:import
firebase auth:import users.json
firebase auth:import users.csv
# SCRYPT (Firebase native)
firebase auth:import users.json \
--hash-algo=SCRYPT \
--hash-key=<base64-key> \
--salt-separator=<base64-separator> \
--rounds=8 \
--mem-cost=8
# BCRYPT
firebase auth:import users.json --hash-algo=BCRYPTSupported hash algorithms: SCRYPT, STANDARD_SCRYPT, HMAC_SHA256, HMAC_SHA512, HMAC_SHA1, HMAC_MD5, MD5, SHA1, SHA256, SHA512, BCRYPT, PBKDF_SHA1, PBKDF2_SHA256
| Flag | Description |
|---|---|
--hash-algo <algo> | Hash algorithm |
--hash-key <key> | Signer key (base64) |
--salt-separator <sep> | Salt separator (base64) |
--rounds <n> | Hash rounds |
--mem-cost <n> | Memory cost |
--parallelization <n> | Parallelization (STANDARD_SCRYPT) |
--block-size <n> | Block size (STANDARD_SCRYPT) |
--dk-len <n> | Derived key length (STANDARD_SCRYPT) |
firebase auth:export
firebase auth:export users.json
firebase auth:export users.csv --format CSV| Flag | Description |
|---|---|
--format <fmt> | JSON (default) or CSV |
---
Remote Config
firebase remoteconfig:get
firebase remoteconfig:get
firebase remoteconfig:get --v 5
firebase remoteconfig:get --output config.json| Flag | Description |
|---|---|
-v, --version-number <n> | Retrieve specific version |
-o, --output <file> | Write to file |
firebase remoteconfig:rollback
firebase remoteconfig:rollback --version-number 5
firebase remoteconfig:rollback -v 5 --force| Flag | Description |
|---|---|
-v, --version-number <n> | (Required) Version to roll back to |
--force | Skip confirmation |
firebase remoteconfig:versions:list
firebase remoteconfig:versions:list
firebase remoteconfig:versions:list --limit 10
firebase remoteconfig:versions:list --limit 0 # All versionsRemote Config Experiments / Rollouts
firebase remoteconfig:experiments:get EXPERIMENT_ID
firebase remoteconfig:experiments:list
firebase remoteconfig:experiments:delete EXPERIMENT_ID
firebase remoteconfig:rollouts:get ROLLOUT_ID
firebase remoteconfig:rollouts:list
firebase remoteconfig:rollouts:delete ROLLOUT_ID---
App Distribution
firebase appdistribution:distribute
# Android
firebase appdistribution:distribute app-release.apk \
--app "1:1234567890:android:abcd1234" \
--release-notes "Bug fixes" \
--testers "alice@example.com,bob@example.com" \
--groups "qa-team,beta-users"
# iOS
firebase appdistribution:distribute MyApp.ipa \
--app "1:1234567890:ios:abcd1234" \
--release-notes-file ./release-notes.txt \
--groups-file ./groups.txt
# With automated testing
firebase appdistribution:distribute app.apk \
--app APP_ID \
--test-devices "model=shiba,version=34,locale=en,orientation=portrait"| Flag | Description |
|---|---|
--app <app_id> | (Required) Firebase App ID |
--release-notes <notes> | Release notes text |
--release-notes-file <path> | Path to release notes file |
--testers <emails> | Comma-separated tester emails |
--testers-file <path> | File with tester emails |
--groups <aliases> | Comma-separated group aliases |
--groups-file <path> | File with group aliases |
--test-devices <spec> | Device specs for automated testing |
--test-devices-file <path> | File with device specifications |
--test-username <user> | Username for login during tests |
--test-password <pass> | Password for login |
--test-non-blocking | Run tests asynchronously |
--debug | Verbose debug output |
Tester Management
firebase appdistribution:testers:list
firebase appdistribution:testers:list --group-alias qa-team
firebase appdistribution:testers:add alice@example.com --group-alias qa-team
firebase appdistribution:testers:add --file testers.txt
firebase appdistribution:testers:remove alice@example.com
firebase appdistribution:groups:list
firebase appdistribution:groups:create "QA Team" qa-team
firebase appdistribution:groups:delete qa-team
firebase appdistribution:testcases:export --output test-cases.yaml
firebase appdistribution:testcases:import test-cases.yaml---
Extensions
firebase ext:info
firebase ext:info publisher/extension-id
firebase ext:info firebase/delete-user-data@0.1.12firebase ext:install
firebase ext:install publisher/extension-id
firebase ext:install firebase/delete-user-data
firebase ext:install firebase/delete-user-data@0.1.12
firebase ext:install ./local/extensionfirebase ext:list
firebase ext:listfirebase ext:configure
firebase ext:configure INSTANCE_ID
firebase ext:configure delete-user-data --params params.envfirebase ext:update
firebase ext:update INSTANCE_ID
firebase ext:update delete-user-data
firebase ext:update delete-user-data@0.2.0 --forcefirebase ext:uninstall
firebase ext:uninstall INSTANCE_ID
firebase ext:uninstall delete-user-data --forcefirebase ext:export
firebase ext:exportExtension Developer Commands
firebase ext:dev:upload publisher/extension-id
firebase ext:dev:list publisher
firebase ext:dev:deprecate publisher/extension-id@version "Reason"
firebase ext:dev:undeprecate publisher/extension-id@version
firebase ext:sdk:install publisher/extension-id---
App Hosting
firebase apphosting:backends:create
firebase apphosting:backends:create
firebase apphosting:backends:create --location us-central1
firebase apphosting:backends:create --backend-id my-backend
firebase apphosting:backends:create --app <web_app_id>firebase apphosting:backends:list
firebase apphosting:backends:listfirebase apphosting:backends:delete
firebase apphosting:backends:delete BACKEND_ID --location us-central1 --forcefirebase apphosting:rollouts:create
firebase apphosting:rollouts:create BACKEND_ID
firebase apphosting:rollouts:create BACKEND_ID --git-branch main
firebase apphosting:rollouts:create BACKEND_ID --git-commit <commit_sha>
firebase apphosting:rollouts:create BACKEND_ID --location us-central1App Hosting Secrets
firebase apphosting:secrets:set SECRET_NAME
firebase apphosting:secrets:grantaccess SECRET_NAME --backend BACKEND_ID---
Data Connect
firebase dataconnect:services:list
firebase dataconnect:sql:setup
firebase dataconnect:sdk:generate---
firebase.json Configuration Reference
{
"hosting": {
"public": "public",
"ignore": ["firebase.json", "**/.*", "**/node_modules/**"],
"rewrites": [
{ "source": "**", "destination": "/index.html" }
],
"headers": [
{
"source": "**/*.@(js|css)",
"headers": [{ "key": "Cache-Control", "value": "max-age=31536000" }]
}
],
"cleanUrls": true,
"trailingSlash": false
},
"functions": {
"source": "functions",
"runtime": "nodejs20"
},
"firestore": {
"rules": "firestore.rules",
"indexes": "firestore.indexes.json"
},
"database": {
"rules": "database.rules.json"
},
"storage": {
"rules": "storage.rules"
},
"emulators": {
"auth": { "port": 9099 },
"functions": { "port": 5001 },
"firestore": { "port": 8080 },
"hosting": { "port": 5000 },
"database": { "port": 9000 },
"storage": { "port": 9199 },
"ui": { "enabled": true, "port": 4000 },
"singleProjectMode": true
}
}---
Environment Variables
| Variable | Description |
|---|---|
FIREBASE_TOKEN | (Deprecated) Long-lived token from login:ci |
GOOGLE_APPLICATION_CREDENTIALS | Path to service account JSON key |
HTTPS_PROXY / HTTP_PROXY | Proxy URL |
FIREBASE_EMULATOR_HUB | Emulator Hub address (e.g., localhost:4400) |
FIREBASE_AUTH_EMULATOR_HOST | Auth emulator host:port |
FIRESTORE_EMULATOR_HOST | Firestore emulator host:port |
FIREBASE_DATABASE_EMULATOR_HOST | Database emulator host:port |
FIREBASE_STORAGE_EMULATOR_HOST | Storage emulator host:port |
GCLOUD_PROJECT / FIREBASE_PROJECT | Fallback project ID |
---
Programmatic API (Node.js)
const client = require("firebase-tools");
// List apps
client.apps.list("ANDROID", { project: "my-project" })
.then(data => console.log(data));
// Deploy
client.deploy({
project: "my-project",
only: "hosting",
token: process.env.FIREBASE_TOKEN // or use service account
}).then(() => console.log("Deployed!"));---
Version Notes
| Feature | Notes |
|---|---|
functions:config:* | Deprecated for 2nd gen; use functions:secrets:* |
--token / FIREBASE_TOKEN | Deprecated; migrate to service accounts |
ext:dev:publish | Deprecated; use ext:dev:upload |
firebase serve | Primarily for Hosting + 1st gen HTTPS Functions |
| App Hosting | GA as of late 2024; requires firebase init apphosting |
| Node.js requirement | Current firebase-tools releases require Node.js 20+ for the npm install path |
Emulator and release workflows
Emulator patterns
Persistent local development
bash scripts/emulators.sh --persistentEquivalent raw command:
firebase emulators:start --import ./emulator-data --export-on-exitFocused emulator startup
firebase emulators:start --only auth,firestore,functionsRun tests against emulators then exit
firebase emulators:exec "npm test" --only auth,firestorePorts worth checking
- Emulator UI: 4000
- Hosting: 5000
- Functions: 5001
- Firestore: 8080
- Database: 9000
- Auth: 9099
- Storage: 9199
Release / deploy patterns
Safe selective deploy
firebase deploy --only hosting
firebase deploy --only functions:myFunction
firebase deploy --only firestore:indexesPreview channel flow
firebase hosting:channel:create staging --expires 7d
firebase hosting:channel:deploy staging
firebase hosting:channel:open stagingApp Hosting operator flow
firebase init apphosting
firebase apphosting:backends:create --location us-central1
firebase deploy --only apphostingCI execution pattern
export GOOGLE_APPLICATION_CREDENTIALS=/absolute/path/to/service-account.json
firebase deploy --only hosting --non-interactiveVerification checklist
- Did the deploy scope match the intended surface?
- Was a preview/staging URL captured when relevant?
- Did emulator data import/export succeed?
- Are the repo config files (
firebase.json,.firebaserc) consistent with the deploy target?
Install, auth, and bootstrap guide
Installation paths
npm install (preferred when Node.js is available)
Current firebase-tools releases require Node.js 20+.
node --version
npm --version
npm install -g firebase-tools
firebase --versionStandalone installer (macOS/Linux)
Useful when Node.js is unavailable and you only need the CLI binary.
curl -sL https://firebase.tools | bash
firebase --versionAuthentication choices
Local interactive work
firebase login
firebase login:listNon-interactive / CI work
Prefer service-account credentials via GOOGLE_APPLICATION_CREDENTIALS.
export GOOGLE_APPLICATION_CREDENTIALS=/absolute/path/to/service-account.json
firebase projects:list --non-interactiveTreat firebase login:ci, --token, and FIREBASE_TOKEN as deprecated compatibility paths, not the default recommendation.
Bootstrap checklist
Minimal repo setup
firebase initCommon focused init flows
firebase init hosting
firebase init functions
firebase init firestore
firebase init emulators
firebase init apphosting
firebase init hosting:githubProject alias management
firebase use --add
firebase use <alias>
firebase use --clearFiles to inspect after bootstrap
firebase.json.firebaserc- target-specific directories such as
functions/, rules files, hosting output directory
Good bootstrap habits
1. Initialize only the Firebase surfaces the repo actually uses 2. Commit .firebaserc when aliases are part of team workflow 3. Keep secrets and service-account JSON files out of version control 4. If the repo mixes Firebase platform work with AI app logic, document the route-out to genkit / firebase-ai-logic
Firebase CLI modes and routing
What firebase-cli owns
Use firebase-cli when the request is primarily about operating Firebase from the terminal:
- install/update
firebase-tools - authenticate the CLI
- initialize
firebase.json/.firebaserc - run emulators
- deploy Hosting / Functions / rules / App Hosting
- manage preview channels, aliases, and deploy targets
- run Firebase admin/data commands (auth import/export, Remote Config, Extensions, App Distribution, Data Connect CLI commands)
Decision table
| If the user wants… | Use | Why |
|---|---|---|
| Firebase project setup, aliases, Hosting/App Hosting deploys, or emulator commands | firebase-cli | Firebase platform/operator work |
| Flow/tool/RAG/eval orchestration in the Firebase ecosystem | genkit | Backend AI workflow layer, not CLI operations |
| Direct Gemini feature wiring inside the app/client SDK | firebase-ai-logic | App/client integration layer |
| Auth architecture choice (hosted auth vs sessions/JWTs vs enterprise SSO) | authentication-setup | Product-auth design question |
| Schema/index design and staged data-model evolution | database-schema-design | Storage-modeling question |
| Generic preview/staging/prod rollout strategy across providers | deployment-automation | Provider-agnostic release design |
Mode selection inside this skill
1. Install / auth — missing CLI, stale CLI, local login, CI credentials 2. Bootstrap / config — firebase init, aliases, targets, repo config 3. Local emulators — local runtime, persistence, seed data, tests 4. Deploy / release — selective deploys, preview channels, App Hosting rollout, CI execution 5. Admin / data ops — auth import/export, Remote Config rollback, App Distribution, Extensions, targeted cleanup
Common route-out mistakes to avoid
- Do not keep
firebase-cliactive when the real request became “design a Genkit flow” - Do not turn Firebase CLI questions into generic security or auth architecture advice
- Do not let Hosting/App Hosting deploy work absorb broader provider-agnostic rollout planning
- Do not treat command reference lookup as a substitute for choosing the right operating mode first
#!/usr/bin/env bash
# firebase-cli/scripts/deploy.sh
# Smart Firebase deployment helper with target detection and validation
#
# Usage:
# bash scripts/deploy.sh # Deploy all configured targets
# bash scripts/deploy.sh --only hosting # Deploy specific target
# bash scripts/deploy.sh --only hosting,functions # Multiple targets
# bash scripts/deploy.sh --channel staging # Deploy to preview channel
# bash scripts/deploy.sh --except functions # Skip a target
# bash scripts/deploy.sh --dry-run # Preview without deploying
# bash scripts/deploy.sh --message "v2.3.1" # Add deploy message
set -euo pipefail
RED='\033[0;31m'; GREEN='\033[0;32m'; YELLOW='\033[1;33m'; BLUE='\033[0;34m'; NC='\033[0m'
log_info() { echo -e "${BLUE}[deploy]${NC} $*"; }
log_success() { echo -e "${GREEN}[deploy] ✅${NC} $*"; }
log_warn() { echo -e "${YELLOW}[deploy] ⚠️${NC} $*"; }
log_error() { echo -e "${RED}[deploy] ❌${NC} $*" >&2; }
# ─── Defaults ────────────────────────────────────────────────────────────────
ONLY_TARGET=""
EXCEPT_TARGET=""
CHANNEL=""
CHANNEL_EXPIRES="7d"
MESSAGE=""
DRY_RUN=false
FORCE=false
DEBUG=false
NON_INTERACTIVE=false
PROJECT=""
# ─── Parse arguments ─────────────────────────────────────────────────────────
while [[ $# -gt 0 ]]; do
case "$1" in
--only) ONLY_TARGET="$2"; shift 2 ;;
--except) EXCEPT_TARGET="$2"; shift 2 ;;
--channel) CHANNEL="$2"; shift 2 ;;
--expires) CHANNEL_EXPIRES="$2"; shift 2 ;;
--message|-m) MESSAGE="$2"; shift 2 ;;
--project|-P) PROJECT="$2"; shift 2 ;;
--dry-run) DRY_RUN=true; shift ;;
--force) FORCE=true; shift ;;
--debug) DEBUG=true; shift ;;
--non-interactive) NON_INTERACTIVE=true; shift ;;
-h|--help)
echo "Usage: bash deploy.sh [options]"
echo ""
echo "Options:"
echo " --only <targets> Comma-separated deploy targets"
echo " Values: hosting, functions, firestore, database, storage,"
echo " remoteconfig, extensions, apphosting"
echo " Sub-targets: hosting:site, functions:name, firestore:rules"
echo " --except <targets> Comma-separated targets to skip"
echo " --channel <id> Deploy to a Hosting preview channel"
echo " --expires <duration> Channel expiry: 1h, 7d, 30d (default: 7d)"
echo " --message <msg> Deploy message"
echo " --project <id> Firebase project ID"
echo " --dry-run Preview deployment without executing"
echo " --force Skip confirmation prompts"
echo " --debug Verbose debug output"
echo " --non-interactive Disable interactive prompts (for CI)"
exit 0
;;
*)
log_error "Unknown argument: $1"
exit 1
;;
esac
done
# ─── Pre-flight checks ────────────────────────────────────────────────────────
if ! command -v firebase &>/dev/null; then
log_error "Firebase CLI not found. Run: bash scripts/install.sh"
exit 1
fi
if [[ ! -f "firebase.json" ]]; then
log_warn "firebase.json not found in current directory: $(pwd)"
log_warn "Run 'firebase init' to set up Firebase in this project."
exit 1
fi
# ─── Build deploy command ─────────────────────────────────────────────────────
DEPLOY_CMD="firebase deploy"
[[ -n "$PROJECT" ]] && DEPLOY_CMD+=" --project ${PROJECT}"
[[ -n "$ONLY_TARGET" ]] && DEPLOY_CMD+=" --only ${ONLY_TARGET}"
[[ -n "$EXCEPT_TARGET" ]] && DEPLOY_CMD+=" --except ${EXCEPT_TARGET}"
[[ -n "$MESSAGE" ]] && DEPLOY_CMD+=" --message \"${MESSAGE}\""
[[ "$FORCE" == "true" ]] && DEPLOY_CMD+=" --force"
[[ "$DEBUG" == "true" ]] && DEPLOY_CMD+=" --debug"
[[ "$NON_INTERACTIVE" == "true" ]] && DEPLOY_CMD+=" --non-interactive"
# ─── Preview channel deploy ───────────────────────────────────────────────────
if [[ -n "$CHANNEL" ]]; then
log_info "Deploying to preview channel: ${CHANNEL}"
log_info "Channel expires: ${CHANNEL_EXPIRES}"
CHANNEL_CMD="firebase hosting:channel:deploy ${CHANNEL} --expires ${CHANNEL_EXPIRES}"
[[ -n "$PROJECT" ]] && CHANNEL_CMD+=" --project ${PROJECT}"
[[ "$DEBUG" == "true" ]] && CHANNEL_CMD+=" --debug"
if [[ "$DRY_RUN" == "true" ]]; then
log_info "[DRY RUN] Would execute: ${CHANNEL_CMD}"
exit 0
fi
# Create channel if it doesn't exist
log_info "Ensuring preview channel exists..."
firebase hosting:channel:create "${CHANNEL}" --expires "${CHANNEL_EXPIRES}" 2>/dev/null || true
log_info "Deploying to channel..."
eval "$CHANNEL_CMD"
CHANNEL_URL=$(firebase hosting:channel:open "${CHANNEL}" --json 2>/dev/null | python3 -c "import sys,json; print(json.load(sys.stdin).get('url',''))" 2>/dev/null || echo "")
log_success "Channel deploy complete!"
[[ -n "$CHANNEL_URL" ]] && log_success "Preview URL: ${CHANNEL_URL}"
exit 0
fi
# ─── Dry run ─────────────────────────────────────────────────────────────────
if [[ "$DRY_RUN" == "true" ]]; then
log_info "[DRY RUN] Would execute: ${DEPLOY_CMD}"
log_info ""
log_info "firebase.json targets configured:"
python3 -c "
import json, os
try:
cfg = json.load(open('firebase.json'))
targets = [k for k in cfg.keys() if k not in ('emulators',)]
for t in targets:
print(f' - {t}')
except Exception as e:
print(f' (could not parse firebase.json: {e})')
" 2>/dev/null || true
exit 0
fi
# ─── Deploy ───────────────────────────────────────────────────────────────────
log_info "Starting Firebase deploy..."
log_info "Command: ${DEPLOY_CMD}"
START_TIME=$(date +%s)
eval "$DEPLOY_CMD"
END_TIME=$(date +%s)
DURATION=$((END_TIME - START_TIME))
log_success "Deploy complete in ${DURATION}s"
#!/usr/bin/env bash
# firebase-cli/scripts/emulators.sh
# Firebase Emulator Suite management helper
#
# Usage:
# bash scripts/emulators.sh # Start all configured emulators
# bash scripts/emulators.sh --only auth,firestore # Start specific emulators
# bash scripts/emulators.sh --import ./emulator-data # Import data on start
# bash scripts/emulators.sh --persistent # Import + export-on-exit
# bash scripts/emulators.sh --test "npm test" # Run script with emulators
# bash scripts/emulators.sh --export ./data # Export from running emulators
# bash scripts/emulators.sh --inspect # Enable Functions debugger
set -euo pipefail
RED='\033[0;31m'; GREEN='\033[0;32m'; YELLOW='\033[1;33m'; BLUE='\033[0;34m'; NC='\033[0m'
log_info() { echo -e "${BLUE}[emulators]${NC} $*"; }
log_success() { echo -e "${GREEN}[emulators] ✅${NC} $*"; }
log_warn() { echo -e "${YELLOW}[emulators] ⚠️${NC} $*"; }
log_error() { echo -e "${RED}[emulators] ❌${NC} $*" >&2; }
# ─── Defaults ────────────────────────────────────────────────────────────────
ONLY=""
IMPORT_DIR=""
EXPORT_DIR=""
PERSISTENT=false
TEST_SCRIPT=""
EXPORT_ONLY=false
INSPECT=false
INSPECT_PORT=9229
NO_UI=false
LOG_VERBOSITY=""
PROJECT=""
# ─── Parse arguments ─────────────────────────────────────────────────────────
while [[ $# -gt 0 ]]; do
case "$1" in
--only) ONLY="$2"; shift 2 ;;
--import) IMPORT_DIR="$2"; shift 2 ;;
--export) EXPORT_DIR="$2"; EXPORT_ONLY=true; shift 2 ;;
--persistent) PERSISTENT=true; shift ;;
--test) TEST_SCRIPT="$2"; shift 2 ;;
--inspect) INSPECT=true; shift ;;
--inspect-port) INSPECT_PORT="$2"; shift 2 ;;
--no-ui) NO_UI=true; shift ;;
--log-verbosity) LOG_VERBOSITY="$2"; shift 2 ;;
--project|-P) PROJECT="$2"; shift 2 ;;
-h|--help)
echo "Usage: bash emulators.sh [options]"
echo ""
echo "Options:"
echo " --only <list> Comma-separated emulators to start"
echo " Values: auth, functions, firestore, database,"
echo " hosting, pubsub, storage, apphosting, eventarc"
echo " --import <dir> Import data from directory on start"
echo " --export <dir> Export data from running emulators (requires --export-only)"
echo " --persistent Import from ./emulator-data and export on exit"
echo " --test <script> Run script against emulators then shut down"
echo " --inspect Enable Node.js debugger for Cloud Functions (port 9229)"
echo " --inspect-port <port> Custom debugger port (default: 9229)"
echo " --no-ui Disable Emulator Suite UI"
echo " --log-verbosity <lv> DEBUG | INFO | QUIET | SILENT"
echo " --project <id> Firebase project ID"
exit 0
;;
*)
log_error "Unknown argument: $1"
exit 1
;;
esac
done
# ─── Pre-flight checks ────────────────────────────────────────────────────────
if ! command -v firebase &>/dev/null; then
log_error "Firebase CLI not found. Run: bash scripts/install.sh"
exit 1
fi
# Check if emulators are configured in firebase.json
if [[ ! -f "firebase.json" ]]; then
log_warn "firebase.json not found. Run 'firebase init emulators' first."
exit 1
fi
# ─── Export mode ─────────────────────────────────────────────────────────────
if [[ "$EXPORT_ONLY" == "true" ]]; then
EXPORT_TARGET="${EXPORT_DIR:-./emulator-data}"
log_info "Exporting emulator data to: ${EXPORT_TARGET}"
CMD="firebase emulators:export ${EXPORT_TARGET} --force"
[[ -n "$PROJECT" ]] && CMD+=" --project ${PROJECT}"
eval "$CMD"
log_success "Data exported to ${EXPORT_TARGET}"
exit 0
fi
# ─── Persistent mode setup ───────────────────────────────────────────────────
if [[ "$PERSISTENT" == "true" ]]; then
IMPORT_DIR="${IMPORT_DIR:-./emulator-data}"
EXPORT_DIR="${EXPORT_DIR:-./emulator-data}"
mkdir -p "$IMPORT_DIR"
log_info "Persistent mode: import from ${IMPORT_DIR}, export on exit to ${EXPORT_DIR}"
fi
# ─── Build command ────────────────────────────────────────────────────────────
if [[ -n "$TEST_SCRIPT" ]]; then
CMD="firebase emulators:exec"
else
CMD="firebase emulators:start"
fi
[[ -n "$PROJECT" ]] && CMD+=" --project ${PROJECT}"
[[ -n "$ONLY" ]] && CMD+=" --only ${ONLY}"
[[ -n "$IMPORT_DIR" ]] && CMD+=" --import ${IMPORT_DIR}"
[[ -n "$EXPORT_DIR" ]] && [[ -z "$TEST_SCRIPT" ]] && CMD+=" --export-on-exit ${EXPORT_DIR}"
[[ -n "$EXPORT_DIR" ]] && [[ -n "$TEST_SCRIPT" ]] && CMD+=" --export-on-exit ${EXPORT_DIR}"
[[ "$INSPECT" == "true" ]] && CMD+=" --inspect-functions ${INSPECT_PORT}"
[[ "$NO_UI" == "true" ]] && CMD+=" --no-ui"
[[ -n "$LOG_VERBOSITY" ]] && CMD+=" --log-verbosity ${LOG_VERBOSITY}"
[[ -n "$TEST_SCRIPT" ]] && CMD+=" \"${TEST_SCRIPT}\""
# ─── Default ports info ───────────────────────────────────────────────────────
log_info "Starting Firebase Emulator Suite..."
log_info ""
log_info "Default ports:"
log_info " Auth: http://localhost:9099"
log_info " Functions: http://localhost:5001"
log_info " Firestore: http://localhost:8080"
log_info " Database: http://localhost:9000"
log_info " Hosting: http://localhost:5000"
log_info " Storage: http://localhost:9199"
log_info " Pub/Sub: http://localhost:8085"
log_info " Emulator UI: http://localhost:4000"
log_info ""
log_info "Command: ${CMD}"
log_info ""
# ─── Execute ──────────────────────────────────────────────────────────────────
eval "$CMD"
#!/usr/bin/env bash
# firebase-cli/scripts/install.sh
# Install and configure the Firebase CLI (firebase-tools)
#
# Usage:
# bash scripts/install.sh # Auto-detect and install
# bash scripts/install.sh --method npm # Force npm install
# bash scripts/install.sh --method standalone # Standalone binary (no Node required)
# bash scripts/install.sh --method ci # CI setup with service account
# bash scripts/install.sh --version 13.5.0 # Install specific version
# bash scripts/install.sh --init hosting # Install + init a Firebase feature
set -euo pipefail
# ─── Color helpers ───────────────────────────────────────────────────────────
RED='\033[0;31m'; GREEN='\033[0;32m'; YELLOW='\033[1;33m'; BLUE='\033[0;34m'; NC='\033[0m'
log_info() { echo -e "${BLUE}[firebase-cli]${NC} $*"; }
log_success() { echo -e "${GREEN}[firebase-cli] ✅${NC} $*"; }
log_warn() { echo -e "${YELLOW}[firebase-cli] ⚠️${NC} $*"; }
log_error() { echo -e "${RED}[firebase-cli] ❌${NC} $*" >&2; }
# ─── Defaults ────────────────────────────────────────────────────────────────
METHOD="auto"
FIREBASE_VERSION=""
INIT_FEATURE=""
CI_MODE=false
# ─── Parse arguments ─────────────────────────────────────────────────────────
while [[ $# -gt 0 ]]; do
case "$1" in
--method) METHOD="$2"; shift 2 ;;
--version) FIREBASE_VERSION="$2"; shift 2 ;;
--init) INIT_FEATURE="$2"; shift 2 ;;
--ci) CI_MODE=true; shift ;;
-h|--help)
echo "Usage: bash install.sh [--method npm|standalone|ci] [--version X.Y.Z] [--init <feature>] [--ci]"
echo ""
echo "Options:"
echo " --method npm Install via npm install -g firebase-tools (default if Node.js found)"
echo " --method standalone Install via standalone binary (no Node.js required)"
echo " --method ci Configure CI/CD with service account credentials"
echo " --version X.Y.Z Install a specific firebase-tools version"
echo " --init <feature> Run firebase init <feature> after installing"
echo " Features: hosting, functions, firestore, database, storage,"
echo " emulators, remoteconfig, apphosting, genkit"
echo " --ci CI mode: non-interactive, no browser auth"
exit 0
;;
*)
log_error "Unknown argument: $1"
exit 1
;;
esac
done
# ─── Auto-detect method ──────────────────────────────────────────────────────
if [[ "$METHOD" == "auto" ]]; then
if command -v node &>/dev/null && command -v npm &>/dev/null; then
METHOD="npm"
log_info "Detected Node.js + npm → using npm install method"
else
METHOD="standalone"
log_warn "Node.js not found → using standalone binary install"
fi
fi
# ─── Check existing installation ─────────────────────────────────────────────
if command -v firebase &>/dev/null; then
CURRENT_VERSION=$(firebase --version 2>/dev/null || echo "unknown")
log_info "Firebase CLI already installed: v${CURRENT_VERSION}"
if [[ -z "$FIREBASE_VERSION" ]]; then
log_info "Upgrading to latest..."
fi
fi
# ─── Install ─────────────────────────────────────────────────────────────────
case "$METHOD" in
npm)
# Check Node.js version
NODE_VERSION=$(node --version 2>/dev/null | sed 's/v//' | cut -d. -f1 || echo "0")
if [[ "$NODE_VERSION" -lt 20 ]]; then
log_warn "Node.js v${NODE_VERSION} detected. Current firebase-tools releases require Node.js 20+."
log_warn "Consider upgrading before using the npm install path: https://nodejs.org"
fi
PACKAGE="firebase-tools"
if [[ -n "$FIREBASE_VERSION" ]]; then
PACKAGE="firebase-tools@${FIREBASE_VERSION}"
fi
log_info "Installing ${PACKAGE} via npm..."
npm install -g "$PACKAGE"
log_success "firebase-tools installed via npm"
;;
standalone)
if [[ "$(uname -s)" != "Darwin" && "$(uname -s)" != "Linux" ]]; then
log_error "Standalone binary is only supported on macOS and Linux."
log_info "On Windows, use: npm install -g firebase-tools"
exit 1
fi
log_info "Installing Firebase CLI via standalone binary (no Node.js required)..."
curl -sL https://firebase.tools | bash
log_success "Firebase CLI standalone binary installed"
;;
ci)
log_info "Setting up Firebase CLI for CI/CD environment..."
log_info ""
log_info "Recommended: Use service account credentials (not --token / FIREBASE_TOKEN)"
log_info ""
log_info "Steps:"
log_info " 1. Create a service account in Firebase console → Project Settings → Service accounts"
log_info " 2. Grant required IAM roles:"
log_info " - Firebase Admin SDK Service Agent"
log_info " - Cloud Functions Admin (if deploying functions)"
log_info " - Cloud Build Service Account (if using Cloud Build)"
log_info " 3. Download the JSON key file"
log_info " 4. Set environment variable:"
log_info " export GOOGLE_APPLICATION_CREDENTIALS=/absolute/path/to/service-account.json"
log_info "In CI (GitHub Actions example):"
log_info " - name: Deploy to Firebase"
log_info " env:"
log_info " GOOGLE_APPLICATION_CREDENTIALS: \${{ secrets.FIREBASE_SERVICE_ACCOUNT }}"
log_info " run: |"
log_info " npm install -g firebase-tools"
log_info " firebase deploy --only hosting --non-interactive"
# Still install the CLI
if command -v node &>/dev/null; then
PACKAGE="firebase-tools"
[[ -n "$FIREBASE_VERSION" ]] && PACKAGE="firebase-tools@${FIREBASE_VERSION}"
npm install -g "$PACKAGE"
log_success "firebase-tools installed for CI"
fi
exit 0
;;
*)
log_error "Unknown method: $METHOD. Use: npm, standalone, or ci"
exit 1
;;
esac
# ─── Verify installation ─────────────────────────────────────────────────────
if ! command -v firebase &>/dev/null; then
log_error "Installation failed: 'firebase' command not found in PATH"
log_info "Try adding npm global bin to PATH: export PATH=\"\$(npm bin -g):\$PATH\""
exit 1
fi
INSTALLED_VERSION=$(firebase --version 2>/dev/null || echo "unknown")
log_success "Firebase CLI installed: v${INSTALLED_VERSION}"
# ─── Authentication ───────────────────────────────────────────────────────────
if [[ "$CI_MODE" == "false" ]]; then
if [[ -z "${GOOGLE_APPLICATION_CREDENTIALS:-}" ]] && [[ -z "${FIREBASE_TOKEN:-}" ]]; then
log_info ""
log_info "Authenticating with Firebase..."
log_info "(If you're in CI, set GOOGLE_APPLICATION_CREDENTIALS instead)"
firebase login
else
log_info "Using existing credentials (GOOGLE_APPLICATION_CREDENTIALS or FIREBASE_TOKEN)"
fi
fi
# ─── Optional: firebase init ──────────────────────────────────────────────────
if [[ -n "$INIT_FEATURE" ]]; then
log_info ""
log_info "Initializing Firebase feature: ${INIT_FEATURE}"
firebase init "$INIT_FEATURE"
fi
# ─── Summary ─────────────────────────────────────────────────────────────────
log_success ""
log_success "Firebase CLI setup complete!"
log_success ""
log_success "Quick reference:"
log_success " firebase init # Set up Firebase in current directory"
log_success " firebase deploy # Deploy everything"
log_success " firebase emulators:start # Run local emulators"
log_success " firebase --help # Full command list"
log_success ""
log_success "Full command reference: .agent-skills/firebase-cli/references/commands.md"
N:firebase-cli
D:[firebase-cli] Firebase platform/operator anchor for `firebase-tools`: install/auth the CLI, bootstrap `firebase.json` + `.firebaserc`, run emulators, deploy Hosting / Functions / rules / App Hosting, manage preview channels, and handle admin tasks like auth import/export, Remote Config, App Distribution, Extensions, and Data Connect CLI commands. Route backend AI workflow orchestration to genkit and direct in-app SDK integration to firebase-ai-logic.
G:firebase firebase-cli firebase-tools deploy hosting functions firestore database emulators auth remote-config app-distribution extensions apphosting dataconnect ci-cd preview-channel service-account
U[8]:
Install or update firebase-tools and choose the right auth path
Bootstrap firebase.json, .firebaserc, aliases, and deploy targets
Run the Firebase Emulator Suite with persistence or one-shot test execution
Deploy Hosting, Functions, rules, or App Hosting with scoped commands
Manage preview/staging channels before production deploys
Handle auth import/export, Remote Config, App Distribution, and Extensions
Use Firebase CLI in CI/CD with service-account credentials
Route AI flow orchestration to genkit and app/client Gemini wiring to firebase-ai-logic
S[5]{n,action,details}:
1,Pick mode,install/auth | bootstrap/config | local emulators | deploy/release | admin/data ops
2,Verify prerequisites,check firebase --version plus Node.js 20+ for npm install path and inspect firebase.json/.firebaserc
3,Run smallest workflow,use scripts/install.sh deploy.sh emulators.sh or focused raw commands for the chosen mode
4,Route out,send backend AI workflow work to genkit and client SDK integration to firebase-ai-logic
5,Verify outcome,confirm version login config files emulator data preview URL or admin operation result
R[7]:
Choose the workflow mode first instead of dumping commands
Prefer service-account auth in CI over deprecated --token / FIREBASE_TOKEN
Scope deploys with --only and use preview channels when possible
Keep firebase.json, .firebaserc, and target mappings truthful to the repo
Use emulator import/export directories for repeatable local runs
Separate Firebase operator work from app/AI logic work
Treat delete/rollback/import commands as high-risk operations
E[5]{type,command}:
Bootstrap repo,bash scripts/install.sh && firebase login && firebase init hosting functions
Persistent emulators,bash scripts/emulators.sh --only auth,firestore --persistent
Preview deploy,firebase hosting:channel:create staging --expires 7d && firebase hosting:channel:deploy staging
Scoped prod deploy,firebase deploy --only hosting
Admin import,firebase auth:import users.json --hash-algo=BCRYPT