| name | using-firebase | |||||||
|---|---|---|---|---|---|---|---|---|
| description | Comprehensive Firebase development guidance for GCP-hosted applications. Covers Firestore database operations (CRUD, queries, transactions, data modeling), Cloud Functions (1st and 2nd generation, TypeScript and Python, all trigger types), Firebase CLI operations, emulator setup and data persistence, security rules (Firestore and Storage), authentication integration, hosting configuration, and GCP service integration. Use when working with Firebase projects, deploying Cloud Functions, querying Firestore, setting up triggers (Firestore, Auth, Storage, HTTP, Callable, Scheduled, Pub/Sub), managing security rules, configuring hosting rewrites/headers, managing secrets, or integrating with GCP services like BigQuery and Cloud Tasks. Triggers include firebase, firestore, cloud functions, firebase functions, firebase hosting, firebase auth, firebase storage, firebase emulator, firebase deploy, firebase init, firebase rules, callable function, scheduled function, onDocumentCreated, onRequest, onCall, onSchedule. | |||||||
| allowed-tools |
|
|||||||
| metadata |
|
- New project: Run
scripts/init_project.sh [project-id] - Local development: Run
scripts/start_emulators.sh - Deploy: Run
scripts/deploy.sh
| Task | Action |
|---|---|
| Initialize Firebase project | scripts/init_project.sh |
| Start local emulators | scripts/start_emulators.sh |
| Deploy to production | scripts/deploy.sh |
| Deploy functions only | scripts/deploy_functions.sh |
| Set up Python functions | python scripts/setup_python_functions.py |
| Manage secrets | scripts/manage_secrets.sh |
| Export Firestore data | scripts/export_firestore.sh |
| Import Firestore data | scripts/import_firestore.sh |
| Topic | Reference |
|---|---|
| CLI commands | references/cli-commands.md |
| Firestore CRUD, queries, modeling | references/firestore.md |
| Cloud Functions triggers | references/functions-triggers.md |
| Error handling, optimization | references/functions-patterns.md |
| Security rules | references/security-rules.md |
| Authentication | references/auth-integration.md |
| Hosting configuration | references/hosting-config.md |
| GCP integration | references/gcp-integration.md |
| Command | Purpose |
|---|---|
firebase login |
Authenticate with Firebase |
firebase use <project> |
Switch active project |
firebase emulators:start |
Start local emulators |
firebase deploy |
Deploy all resources |
firebase deploy --only functions |
Deploy functions only |
firebase deploy --only firestore:rules |
Deploy security rules |
firebase functions:log |
View function logs |
firebase firestore:delete --all-collections |
Clear all Firestore data |
Initialize Firebase project with Firestore, Functions, Hosting, Storage, Emulators.
./scripts/init_project.sh # Interactive
./scripts/init_project.sh my-project # Specific projectStart emulator suite with data persistence.
./scripts/start_emulators.sh # Auto-persistence
./scripts/start_emulators.sh --debug # Enable debugging
./scripts/start_emulators.sh --import ./backup # Import data
./scripts/start_emulators.sh --only functions,firestoreDeploy with safety confirmations.
./scripts/deploy.sh # Full deploy
./scripts/deploy.sh --dry-run # Preview only
./scripts/deploy.sh --only hosting # Specific target
./scripts/deploy.sh --force # Skip confirmationDeploy Cloud Functions with granular control.
./scripts/deploy_functions.sh # All functions
./scripts/deploy_functions.sh myFunction # Single function
./scripts/deploy_functions.sh --codebase python # Specific codebaseManage Cloud Functions secrets (2nd gen).
./scripts/manage_secrets.sh set API_KEY # Set secret
./scripts/manage_secrets.sh get API_KEY # View metadata
./scripts/manage_secrets.sh list # List all
./scripts/manage_secrets.sh delete API_KEY # DeleteBackup and restore Firestore data.
./scripts/export_firestore.sh --emulator # From emulator
./scripts/export_firestore.sh --output gs://bucket # Production to GCS
./scripts/import_firestore.sh --input ./data --emulatorCreate Python Cloud Functions project.
python scripts/setup_python_functions.py --path python-functions --codebase pythonUse 2nd generation (recommended):
- HTTP, Firestore, Storage, Scheduled, Pub/Sub triggers
- Higher concurrency, longer timeouts
Use 1st generation only for:
- Auth
onCreate/onDeletetriggers (not available in 2nd gen)
import { onDocumentCreated } from "firebase-functions/v2/firestore";
import { onRequest } from "firebase-functions/v2/https";
export const onUserCreated = onDocumentCreated("users/{userId}", (event) => {
console.log("New user:", event.params.userId, event.data?.data());
});
export const api = onRequest({ cors: true }, (req, res) => {
res.json({ status: "ok" });
});import * as functions from "firebase-functions/v1";
export const onUserCreate = functions.auth.user().onCreate((user) => {
console.log("New user:", user.uid);
return null;
});See references/functions-triggers.md for all trigger types with TypeScript and Python examples.
| File | Use |
|---|---|
assets/firebase.json.template |
Copy to firebase.json and customize |
assets/firestore.rules.template |
Copy to firestore.rules |
assets/storage.rules.template |
Copy to storage.rules |
assets/tsconfig.functions.json |
Copy to functions/tsconfig.json |
- Run
scripts/init_project.sh - Copy templates from
assets/directory - Start emulators:
scripts/start_emulators.sh
- Run
python scripts/setup_python_functions.py - Update
firebase.jsonwith provided config - Deploy:
scripts/deploy_functions.sh --codebase python
- Start with
assets/firestore.rules.template - Test with emulator
- Deploy:
firebase deploy --only firestore:rules
See references/security-rules.md for patterns.
- Set secrets:
scripts/manage_secrets.sh set API_KEY - Dry run:
scripts/deploy.sh --dry-run - Deploy:
scripts/deploy.sh
Before deploying to production, verify:
- Security Rules: Tested rules in emulator, no open access patterns
- Secrets: All required secrets configured via
scripts/manage_secrets.sh list - Environment: Correct project selected (
firebase use) - Functions: All functions tested locally with emulator
- Indexes: Firestore indexes deployed (
firebase deploy --only firestore:indexes) - Dry Run:
scripts/deploy.sh --dry-runshows expected changes - App Check: Enabled for production apps (prevents abuse)
- Billing: Budget alerts configured in GCP Console
- Monitoring: Cloud Logging and Error Reporting enabled
| Service | Port |
|---|---|
| Auth | 9099 |
| Functions | 5001 |
| Firestore | 8080 |
| Storage | 9199 |
| Hosting | 5000 |
| UI | 4000 |
- Embed data read together that rarely changes
- Reference data that changes frequently or is shared
- Subcollections for parent-child relationships
- Root collections for cross-document queries
See references/firestore.md for patterns.
- TypeScript: JavaScript teams, Firebase client SDK integration
- Python: ML/data science, Python ecosystem
Both can coexist via multiple codebases in firebase.json.
This skill focuses on Firebase development. Do not use for:
- Pure GCP without Firebase: Use GCP-specific documentation instead
- AWS or Azure services: This skill is Firebase/GCP-only
- Non-serverless architectures: Firebase is serverless-first
- Self-hosted solutions: Firebase is a managed platform
- Complex relational queries: Firestore is a NoSQL document database; consider Cloud SQL for relational needs