Firebase
Overview
This skill preserves the upstream Firebase skill identity while curating it into an execution-focused operator guide.
Firebase is fast to start but easy to misapply. Most production issues come from a small set of repeat mistakes:
- choosing Firestore for a workload that is actually relational
- designing collections before confirming query shapes and index requirements
- treating Security Rules, IAM, and App Check as if they solve the same problem
- deploying Functions, indexes, or Rules without emulator-backed testing
- underestimating listener cost, read amplification, and index side effects
Use this skill to plan, review, implement, or troubleshoot systems involving:
- Firebase Authentication
- Cloud Firestore
- Realtime Database
- Cloud Storage for Firebase
- Cloud Functions for Firebase, especially 2nd gen behavior
- Firebase Hosting
- App Check
- emulator-based local testing
When to Use
Use this skill when the user needs to:
- design a Firebase-backed application from scratch
- review an existing Firebase architecture for security, cost, or scaling risk
- decide between Firestore, Realtime Database, or a relational alternative
- debug Security Rules failures, missing indexes, auth integration issues, or Functions deployment/runtime behavior
- add emulator-backed testing before deploying rules or backend changes
- evaluate whether App Check, IAM, and Security Rules are applied at the right boundaries
Do not default to this skill when the workload is clearly relational, requires complex joins, or needs heavy ad hoc querying. In those cases, evaluate Firebase SQL Connect or Data Connect, or a non-Firebase relational service, before forcing the data model into Firestore.
Workflow
Clarify the product surface and trust boundaries
- List the exact Firebase products in scope: Auth, Firestore, Storage, Functions, Hosting, Messaging, App Check.
- Separate client-side access from server-side access.
- Identify who reads or writes data: end user, privileged backend, scheduled job, admin operator, or third-party integration.
Choose the right data and backend model before implementation
- Use Firestore when access patterns are document-oriented, read-heavy, and denormalized.
- Use Realtime Database only when its sync model is specifically beneficial.
- If the user needs relational constraints, joins, or SQL-style querying, stop and assess Firebase SQL Connect or Data Connect instead of reshaping everything into Firestore.
- Design around query patterns first; in Firestore, schema follows queries more than relationships.
Define request, auth, and authorization paths explicitly
- For client SDK access, define the authenticated principal, expected claims, and the Security Rules decision path.
- For Admin SDK or server access, note that IAM/service account permissions apply and Security Rules do not protect those reads and writes.
- Decide whether App Check is needed to reduce abuse from scripted or unauthorized app traffic.
- If using email-link authentication, verify the current supported flow and do not rely on Firebase Dynamic Links, which shut down on 2025-08-25.
Model Firestore collections, documents, and indexes from concrete queries
- Write the intended query shapes before creating collections.
- Check whether each query requires composite indexes, array membership behavior, or ordering constraints.
- Estimate cardinality, document growth, and whether listeners or fan-out writes will multiply reads.
- Avoid hotspot patterns such as monotonically increasing write targets or narrow key distribution in high-write workloads.
Test rules and backend behavior locally before deployment
- Use the Local Emulator Suite for rules and integration tests.
- Verify allowed and denied cases for Firestore, Storage, and Auth-dependent behavior.
- For Functions, test callable or HTTP handlers with representative auth context and payloads.
- Keep tests focused on realistic user roles and bad-path scenarios, not only happy paths.
Set production runtime controls deliberately
- For Functions 2nd gen, decide region, concurrency, memory, timeout, min instances, and secret handling intentionally.
- Keep data and compute in compatible regions to reduce latency and egress surprises.
- Use least-privilege service accounts where possible.
- Plan deployment order when rules, indexes, functions, and app code change together.
Review cost, observability, and rollback paths before launch
- Check read amplification from listeners, pagination, and rule-evaluation side effects.
- Confirm logging and error reporting paths for Functions and app clients.
- Ensure there is a rollback path for rules, function releases, and index-dependent application changes.
- Record which failures should be solved by Rules, IAM, App Check, or code fixes.
Examples
Example 1: Firestore query-first planning
Input requirement
Users can view their own orders, sorted by createdAt descending.
Support staff can view orders for a specific store and status.
The dashboard updates live for new orders.
Recommended interpretation
collections:
orders:
fields:
userId: string
storeId: string
status: string
createdAt: timestamp
total: number
queries:
- name: user_orders
where:
userId: == auth.uid
order_by:
createdAt: desc
- name: store_status_orders
where:
storeId: == $storeId
status: == $status
order_by:
createdAt: desc
risks:
- live listeners on broad store queries can create sustained read cost
- support-staff access must be role-gated in rules or moved behind privileged backend APIs
likely_followups:
- composite index for storeId + status + createdAt
- rules tests for user vs support role access
Expected operator decision
- keep user-specific live queries narrow
- define support role claims before writing rules
- create indexes from known query shapes, not after production errors
Example 2: Security boundary review
Scenario
A mobile app writes profile data directly to Firestore.
A backend job updates billing state using the Admin SDK.
The team enabled App Check and assumes billing writes are now protected by rules.
Correct boundary model
Mobile app -> Auth + Security Rules + optional App Check
Backend Admin SDK job -> IAM/service account permissions
Security Rules do not constrain Admin SDK writes
App Check does not replace Auth or IAM
Expected operator action
- review Firestore rules for client writes
- review service account IAM for backend jobs
- treat App Check as abuse resistance for app-origin traffic, not authorization for privileged systems
Example 3: Emulator-backed rules test workflow
Open examples/emulator-rules-test-workflow.md when you need a concrete before/deploy validation loop for Firestore rules.
Best Practices
Do design Firestore from required queries, sort orders, and access paths.
Do treat Security Rules, IAM, and App Check as separate layers with different enforcement points.
Do use the emulator for rule and integration testing before production deploys.
Do keep listeners as narrow as possible and measure how often they reconnect or refetch.
Do select Functions 2nd gen region and concurrency intentionally; defaults are not always cost-safe or latency-safe.
Do use custom claims or backend-mediated access for administrative roles rather than broad client-side permissions.
Do consider Firebase SQL Connect or Data Connect when the user is asking for relational behavior.
Do not assume Security Rules filter arbitrary query results; Firestore rules are not a substitute for query design.
Do not use the Admin SDK from semi-trusted environments.
Do not assume App Check proves user identity or authorization.
Do not ship functions, indexes, or rules together without checking migration and rollback order.
Do not ignore composite index creation prompts and then treat the resulting failures as transient bugs.
Do not rely on deprecated email-link flows that depended on Firebase Dynamic Links.
Troubleshooting
Symptoms: Firestore query fails with a missing index error.
Solution: Capture the exact query shape, create the required index, and verify the query matches your intended data model. If index demands keep growing unexpectedly, revisit the schema and query design rather than layering indexes indefinitely.
Symptoms: A client can read or write data that should be blocked.
Solution: Check whether the access is happening through a client SDK or the Admin SDK. For client SDK access, review Security Rules and auth claims. For Admin SDK access, review IAM and service account usage; Rules do not enforce those requests.
Symptoms: Queries are denied even though documents seem like they should match the rules.
Solution: Re-check the query against Firestore rules semantics. Rules are evaluated against the potential result set, not used as row-level post-filters. Align the query constraints with what the rules allow.
Symptoms: Costs rise sharply after enabling real-time listeners.
Solution: Inspect listener scope, reconnect behavior, and document churn. Reduce broad listeners, paginate where possible, and confirm whether the application is re-subscribing more often than expected.
Symptoms: A Cloud Function works locally but behaves poorly in production.
Solution: Review 2nd gen runtime settings: region, concurrency, memory, timeout, min instances, networking, and secrets. Also verify service account permissions and whether the function is too close to Firestore hot paths.
Symptoms: Email-link authentication stopped working or behaves inconsistently across links.
Solution: Check whether the flow depended on Firebase Dynamic Links. That service shut down on 2025-08-25, so older integration guidance may be invalid. Confirm the current supported email-link auth implementation before patching symptoms.
Symptoms: The team keeps building join-heavy workarounds in Firestore.
Solution: Stop and reassess the product fit. The workload may belong in Firebase SQL Connect, Data Connect, or another relational backend instead of a denormalized Firestore model.
Additional Resources
references/firestore-security-and-cost-reference.md — open this for a compact operator reference on security boundaries, read-cost drivers, App Check scope, and common Firestore production traps.
examples/emulator-rules-test-workflow.md — open this when you need a concrete local test loop for Firestore rules before deployment.
Related Skills
No related local skills were provided in the source context.
1---2name: firebase-v2-23description: Use this skill when designing, reviewing, or operating Firebase systems across Auth, Firestore, Realtime Database, Storage, Functions, Hosting, App Check, and related security boundaries.4license: Unknown5---67# Firebase89## Overview1011This skill preserves the upstream Firebase skill identity while curating it into an execution-focused operator guide.1213Firebase is fast to start but easy to misapply. Most production issues come from a small set of repeat mistakes:14- choosing Firestore for a workload that is actually relational15- designing collections before confirming query shapes and index requirements16- treating Security Rules, IAM, and App Check as if they solve the same problem17- deploying Functions, indexes, or Rules without emulator-backed testing18- underestimating listener cost, read amplification, and index side effects1920Use this skill to plan, review, implement, or troubleshoot systems involving:21- Firebase Authentication22- Cloud Firestore23- Realtime Database24- Cloud Storage for Firebase25- Cloud Functions for Firebase, especially 2nd gen behavior26- Firebase Hosting27- App Check28- emulator-based local testing2930## When to Use3132Use this skill when the user needs to:33- design a Firebase-backed application from scratch34- review an existing Firebase architecture for security, cost, or scaling risk35- decide between Firestore, Realtime Database, or a relational alternative36- debug Security Rules failures, missing indexes, auth integration issues, or Functions deployment/runtime behavior37- add emulator-backed testing before deploying rules or backend changes38- evaluate whether App Check, IAM, and Security Rules are applied at the right boundaries3940Do **not** default to this skill when the workload is clearly relational, requires complex joins, or needs heavy ad hoc querying. In those cases, evaluate Firebase SQL Connect or Data Connect, or a non-Firebase relational service, before forcing the data model into Firestore.4142## Workflow43441. **Clarify the product surface and trust boundaries**45 - List the exact Firebase products in scope: Auth, Firestore, Storage, Functions, Hosting, Messaging, App Check.46 - Separate client-side access from server-side access.47 - Identify who reads or writes data: end user, privileged backend, scheduled job, admin operator, or third-party integration.48492. **Choose the right data and backend model before implementation**50 - Use Firestore when access patterns are document-oriented, read-heavy, and denormalized.51 - Use Realtime Database only when its sync model is specifically beneficial.52 - If the user needs relational constraints, joins, or SQL-style querying, stop and assess Firebase SQL Connect or Data Connect instead of reshaping everything into Firestore.53 - Design around query patterns first; in Firestore, schema follows queries more than relationships.54553. **Define request, auth, and authorization paths explicitly**56 - For client SDK access, define the authenticated principal, expected claims, and the Security Rules decision path.57 - For Admin SDK or server access, note that IAM/service account permissions apply and Security Rules do not protect those reads and writes.58 - Decide whether App Check is needed to reduce abuse from scripted or unauthorized app traffic.59 - If using email-link authentication, verify the current supported flow and do not rely on Firebase Dynamic Links, which shut down on 2025-08-25.60614. **Model Firestore collections, documents, and indexes from concrete queries**62 - Write the intended query shapes before creating collections.63 - Check whether each query requires composite indexes, array membership behavior, or ordering constraints.64 - Estimate cardinality, document growth, and whether listeners or fan-out writes will multiply reads.65 - Avoid hotspot patterns such as monotonically increasing write targets or narrow key distribution in high-write workloads.66675. **Test rules and backend behavior locally before deployment**68 - Use the Local Emulator Suite for rules and integration tests.69 - Verify allowed and denied cases for Firestore, Storage, and Auth-dependent behavior.70 - For Functions, test callable or HTTP handlers with representative auth context and payloads.71 - Keep tests focused on realistic user roles and bad-path scenarios, not only happy paths.72736. **Set production runtime controls deliberately**74 - For Functions 2nd gen, decide region, concurrency, memory, timeout, min instances, and secret handling intentionally.75 - Keep data and compute in compatible regions to reduce latency and egress surprises.76 - Use least-privilege service accounts where possible.77 - Plan deployment order when rules, indexes, functions, and app code change together.78797. **Review cost, observability, and rollback paths before launch**80 - Check read amplification from listeners, pagination, and rule-evaluation side effects.81 - Confirm logging and error reporting paths for Functions and app clients.82 - Ensure there is a rollback path for rules, function releases, and index-dependent application changes.83 - Record which failures should be solved by Rules, IAM, App Check, or code fixes.8485## Examples8687### Example 1: Firestore query-first planning8889**Input requirement**9091```text92Users can view their own orders, sorted by createdAt descending.93Support staff can view orders for a specific store and status.94The dashboard updates live for new orders.95```9697**Recommended interpretation**9899```yaml100collections:101 orders:102 fields:103 userId: string104 storeId: string105 status: string106 createdAt: timestamp107 total: number108queries:109 - name: user_orders110 where:111 userId: == auth.uid112 order_by:113 createdAt: desc114 - name: store_status_orders115 where:116 storeId: == $storeId117 status: == $status118 order_by:119 createdAt: desc120risks:121 - live listeners on broad store queries can create sustained read cost122 - support-staff access must be role-gated in rules or moved behind privileged backend APIs123likely_followups:124 - composite index for storeId + status + createdAt125 - rules tests for user vs support role access126```127128**Expected operator decision**129- keep user-specific live queries narrow130- define support role claims before writing rules131- create indexes from known query shapes, not after production errors132133### Example 2: Security boundary review134135**Scenario**136137```text138A mobile app writes profile data directly to Firestore.139A backend job updates billing state using the Admin SDK.140The team enabled App Check and assumes billing writes are now protected by rules.141```142143**Correct boundary model**144145```text146Mobile app -> Auth + Security Rules + optional App Check147Backend Admin SDK job -> IAM/service account permissions148Security Rules do not constrain Admin SDK writes149App Check does not replace Auth or IAM150```151152**Expected operator action**153- review Firestore rules for client writes154- review service account IAM for backend jobs155- treat App Check as abuse resistance for app-origin traffic, not authorization for privileged systems156157### Example 3: Emulator-backed rules test workflow158159Open [`examples/emulator-rules-test-workflow.md`](examples/emulator-rules-test-workflow.md) when you need a concrete before/deploy validation loop for Firestore rules.160161## Best Practices162163- **Do** design Firestore from required queries, sort orders, and access paths.164- **Do** treat Security Rules, IAM, and App Check as separate layers with different enforcement points.165- **Do** use the emulator for rule and integration testing before production deploys.166- **Do** keep listeners as narrow as possible and measure how often they reconnect or refetch.167- **Do** select Functions 2nd gen region and concurrency intentionally; defaults are not always cost-safe or latency-safe.168- **Do** use custom claims or backend-mediated access for administrative roles rather than broad client-side permissions.169- **Do** consider Firebase SQL Connect or Data Connect when the user is asking for relational behavior.170171- **Do not** assume Security Rules filter arbitrary query results; Firestore rules are not a substitute for query design.172- **Do not** use the Admin SDK from semi-trusted environments.173- **Do not** assume App Check proves user identity or authorization.174- **Do not** ship functions, indexes, or rules together without checking migration and rollback order.175- **Do not** ignore composite index creation prompts and then treat the resulting failures as transient bugs.176- **Do not** rely on deprecated email-link flows that depended on Firebase Dynamic Links.177178## Troubleshooting179180**Symptoms:** Firestore query fails with a missing index error.181182**Solution:** Capture the exact query shape, create the required index, and verify the query matches your intended data model. If index demands keep growing unexpectedly, revisit the schema and query design rather than layering indexes indefinitely.183184**Symptoms:** A client can read or write data that should be blocked.185186**Solution:** Check whether the access is happening through a client SDK or the Admin SDK. For client SDK access, review Security Rules and auth claims. For Admin SDK access, review IAM and service account usage; Rules do not enforce those requests.187188**Symptoms:** Queries are denied even though documents seem like they should match the rules.189190**Solution:** Re-check the query against Firestore rules semantics. Rules are evaluated against the potential result set, not used as row-level post-filters. Align the query constraints with what the rules allow.191192**Symptoms:** Costs rise sharply after enabling real-time listeners.193194**Solution:** Inspect listener scope, reconnect behavior, and document churn. Reduce broad listeners, paginate where possible, and confirm whether the application is re-subscribing more often than expected.195196**Symptoms:** A Cloud Function works locally but behaves poorly in production.197198**Solution:** Review 2nd gen runtime settings: region, concurrency, memory, timeout, min instances, networking, and secrets. Also verify service account permissions and whether the function is too close to Firestore hot paths.199200**Symptoms:** Email-link authentication stopped working or behaves inconsistently across links.201202**Solution:** Check whether the flow depended on Firebase Dynamic Links. That service shut down on 2025-08-25, so older integration guidance may be invalid. Confirm the current supported email-link auth implementation before patching symptoms.203204**Symptoms:** The team keeps building join-heavy workarounds in Firestore.205206**Solution:** Stop and reassess the product fit. The workload may belong in Firebase SQL Connect, Data Connect, or another relational backend instead of a denormalized Firestore model.207208## Additional Resources209210- [`references/firestore-security-and-cost-reference.md`](references/firestore-security-and-cost-reference.md) — open this for a compact operator reference on security boundaries, read-cost drivers, App Check scope, and common Firestore production traps.211- [`examples/emulator-rules-test-workflow.md`](examples/emulator-rules-test-workflow.md) — open this when you need a concrete local test loop for Firestore rules before deployment.212213## Related Skills214215No related local skills were provided in the source context.