Skilllibrary firebase
Configure and develop on Firebase — set up Authentication providers, write Firestore security rules, deploy Hosting sites, build Cloud Functions, manage Storage buckets, and test with the Emulator Suite. Use when working with firebase.json, Firestore rules, Firebase Auth flows, Cloud Functions triggers, or Firebase CLI commands. Do not use for raw GCP services outside the Firebase SDK surface or non-Firebase auth providers.
install
source · Clone the upstream repo
git clone https://github.com/merceralex397-collab/skilllibrary
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/merceralex397-collab/skilllibrary "$T" && mkdir -p ~/.claude/skills && cp -r "$T/14-cloud-platform-devops/firebase" ~/.claude/skills/merceralex397-collab-skilllibrary-firebase && rm -rf "$T"
manifest:
14-cloud-platform-devops/firebase/SKILL.mdsource content
Purpose
Configure and develop on the Firebase platform — set up Authentication providers, write and test Firestore security rules, deploy Firebase Hosting sites, build Cloud Functions with triggers, manage Cloud Storage buckets, and validate everything locally with the Firebase Emulator Suite.
When to use this skill
- Creating or editing
,firebase.json
, or.firebaserc
.firestore.rules - Writing Firestore security rules to control read/write access per collection and document.
- Configuring Firebase Authentication providers (Email/Password, Google, GitHub, anonymous).
- Building Cloud Functions triggered by Firestore writes, Auth events, HTTP requests, or Pub/Sub.
- Deploying a static site or SSR app to Firebase Hosting with rewrites and redirects.
- Configuring Cloud Storage security rules and bucket CORS policies.
- Running the Firebase Emulator Suite for local development and testing.
- Using the Firebase Admin SDK in server-side code for privileged operations.
Do not use this skill when
- The task involves raw GCP services (BigQuery, Cloud Run, Pub/Sub) outside the Firebase SDK — prefer
.gcp - The authentication system uses a non-Firebase provider (Auth0, Clerk, Supabase Auth) — prefer the relevant auth skill.
- The task is about generic serverless patterns not tied to Firebase Cloud Functions — prefer
.serverless-patterns - The focus is on Cloudflare or Vercel deployment — prefer those respective skills.
Operating procedure
- Locate the Firebase config. Find
in the repo root. If absent, runfirebase.json
and select the needed services (Firestore, Functions, Hosting, Storage, Emulators).firebase init - Verify the project binding. Check
for the correct project aliases (default, staging, production). Switch projects with.firebaserc
.firebase use <alias> - Write Firestore security rules. Edit
. Structure rules per collection path:firestore.rules
with conditions likematch /users/{userId}
. Userequest.auth.uid == userId
to validate incoming writes. Userequest.resource.data
to check existing document fields.resource.data - Test rules with the Emulator. Start the Firestore emulator:
. Write rule unit tests usingfirebase emulators:start --only firestore
— test allow and deny cases for each rule path.@firebase/rules-unit-testing - Configure Authentication. In the Firebase Console, enable the required sign-in providers. For Email/Password, enable email enumeration protection. For OAuth providers, set the OAuth client ID and secret. In code, initialize auth with
and usegetAuth(app)
,signInWithPopup()
, orsignInWithEmailAndPassword()
.signInAnonymously() - Build Cloud Functions. Write functions in
. Usefunctions/src/index.ts
,onDocumentCreated()
for Firestore triggers. UseonDocumentUpdated()
for HTTP triggers. UseonRequest()
for callable functions with automatic auth context. Set the runtime to Node.js 20 inonCall()
.functions/package.json - Configure function secrets and env vars. Use
for sensitive values. Access viafirebase functions:secrets:set MY_SECRET
in function code. Useprocess.env.MY_SECRET
files for non-sensitive environment config..env.<project> - Set up Firebase Hosting. Configure
hosting section: setfirebase.json
directory, addpublic
for SPA routing (rewrites
), and add API rewrites to Cloud Functions ({"source": "**", "destination": "/index.html"}
).{"source": "/api/**", "function": "api"} - Configure Cloud Storage rules. Edit
. Set max file size withstorage.rules
. Restrict uploads by content type:request.resource.size < 5 * 1024 * 1024
. Require authentication:request.resource.contentType.matches('image/.*')
.request.auth != null - Run the full Emulator Suite. Start all emulators:
. Connect your app to emulators usingfirebase emulators:start
,connectFirestoreEmulator()
, andconnectAuthEmulator()
. Run integration tests against the emulators.connectFunctionsEmulator() - Deploy incrementally. Deploy specific services:
,firebase deploy --only firestore:rules
,firebase deploy --only functions:myFunction
. Avoidfirebase deploy --only hosting
without flags — it deploys everything.firebase deploy - Verify the deployment. Check the Hosting URL for the deployed site. Test Cloud Functions via their HTTP endpoints. Verify Firestore rules by attempting reads/writes from the client. Check the Firebase Console for function logs and error rates.
Decision rules
- Always test Firestore rules with the Emulator before deploying — rule errors can lock out all users or expose all data.
- Use
functions overonCall
when the client is a Firebase app —onRequest
provides automatic auth context and input validation.onCall - Use the Admin SDK for server-side operations that bypass security rules (migrations, batch operations, admin dashboards).
- Deploy rules and functions separately from hosting — a hosting deploy should not accidentally change security rules.
- Use Firestore composite indexes only when queries require them — the emulator will log index creation URLs when a query needs one.
- Prefer Firestore real-time listeners (
) for live UI updates; useonSnapshot
/getDoc
for one-time reads.getDocs - Set Firestore security rules to deny-by-default — explicitly allow only the paths and operations needed.
Output requirements
- Firebase configuration —
with services, rewrites, and emulator ports configured.firebase.json - Security rules —
and/orfirestore.rules
with per-path access control.storage.rules - Cloud Functions — function code with trigger type, runtime config, and secret references.
- Rule tests — unit tests covering allow and deny cases for each rule path.
- Deploy commands — the specific
commands used.firebase deploy --only - Verification — confirmed the deployed resources are accessible and rules enforce correctly.
References
- Firebase CLI reference: https://firebase.google.com/docs/cli
- Firestore security rules: https://firebase.google.com/docs/firestore/security/get-started
- Cloud Functions for Firebase: https://firebase.google.com/docs/functions
- Firebase Emulator Suite: https://firebase.google.com/docs/emulator-suite
- Firebase Hosting configuration: https://firebase.google.com/docs/hosting/full-config
references/preflight-checklist.md
Related skills
— GCP services outside the Firebase SDK (Cloud Run, BigQuery, IAM).gcp
— generic serverless architecture design.serverless-patterns
— alternative hosting and serverless platform.vercel
Anti-patterns
- Deploying Firestore rules without testing them in the Emulator first — can lock out all users.
- Using
in production rules — exposes the entire database.allow read, write: if true; - Putting the Firebase Admin SDK private key in client-side code — it grants full access to all Firebase services.
- Running
withoutfirebase deploy
flags — accidentally deploys rules, functions, and hosting together.--only - Hardcoding the Firebase project config in source instead of using environment-based
aliases..firebaserc - Not connecting to emulators in test/dev environments — tests hit production data.
Failure handling
- If
fails with permission errors, verify the active project withfirebase deploy
and check that the CLI is authenticated withfirebase use
.firebase login - If Firestore rules deny a request that should be allowed, use the Rules Playground in the Firebase Console to simulate the request and inspect the evaluation path.
- If Cloud Functions fail to deploy, check the function runtime version matches the supported Node.js version and that
dependencies install cleanly.functions/package.json - If the Emulator Suite fails to start, check for port conflicts and ensure Java 11+ is installed (required for the Firestore emulator).
- If the task involves raw GCP services (BigQuery, Cloud Run, Pub/Sub) not exposed through the Firebase SDK, redirect to the
skill.gcp