<< All versions

Skill v1.0.0

currentLLM-judged scan90/100
robertdewilde-dev/ai-workflow-rules/tech-firebase
──Details
PublishedOctober 24, 2026 at 04:27 AM
Content Hashsha256:64dcfc7b59c33941...
Git SHA529d49baa1ce
──Files
Files (1 file, 3.6 KB)
SKILL.md3.6 KBactive
SKILL.md · 77 lines · 3.6 KB

version: "1.0.0" name: tech-firebase description: Firebase integration patterns and best practices for AI-assisted development. user-invocable: false


Firebase Integration Patterns

Tech-stack skill for Firebase services in mobile and web applications. Covers Firestore, Cloud Functions, security rules, authentication, storage, and multi-environment management.

Supporting Files

FilePurpose
firestore-patterns.mdQuery optimization, pagination, batch writes, listeners, offline persistence
security-rules.mdLeast privilege, document validation, RBAC with custom claims, testing
cloud-functions.mdCold starts, memory sizing, connection pooling, triggers, timeouts
environment-management.mdMulti-environment setup, region consistency, Terraform IaC, index management

Services Overview

ServiceKey Considerations
FirestorePagination, batch writes (500 max), compound indexes, listener cleanup
AuthenticationToken refresh via auth state stream, App Check enforcement, multi-provider
Cloud FunctionsCold starts, memory sizing, region consistency, conditional triggers
StorageImage compression before upload, CDN caching, thumbnails via resize function
AnalyticsEvent tracking, user properties, conversion funnels
CrashlyticsError reporting, custom keys, non-fatal exceptions
PerformanceCustom traces, screen load tracking, network monitoring
MessagingFCM tokens, topic subscriptions, background handlers
App CheckPlay Integrity (Android), App Attest (iOS), debug tokens for dev

Key Principles

  1. Region consistency -- all services in the same region for lowest latency
  2. Offline-first -- leverage Firestore offline persistence and cache-first reads
  3. Pagination everywhere -- never load unbounded collections
  4. Listener hygiene -- always cancel StreamSubscriptions in dispose()
  5. Least privilege -- security rules deny by default, grant specific access
  6. Index management -- create composite indexes in all environments
  7. Cost awareness -- every listener, query, and function invocation has a cost

Cost Model (Key Metrics)

ServiceFree TierCost After Free
Firestore Reads50K/day$0.06/100K
Firestore Writes20K/day$0.18/100K
Storage5 GB$0.026/GB/month
Cloud Functions2M invocations/month$0.40/M
Phone Auth10K/month$0.06/verification

Authentication Patterns

  • Single auth state listener -- not per-screen, centralized in a service
  • Token refresh handled reactively via authStateChanges() stream
  • Anonymous upgrade -- allow anonymous users to link permanent credentials
  • Sign-out cleanup -- clear all local state, cancel listeners, reset providers
  • No auth tokens in logs -- sanitize error messages

Storage Patterns

  • Compress images before upload (quality reduction, resize)
  • Generate thumbnails via Cloud Function on upload
  • CDN caching -- Firebase Storage uses Google CDN by default
  • Progressive loading -- show thumbnail first, load full resolution on demand
  • User-scoped paths -- store files under users/{uid}/ for security rules

Performance Monitoring

  • Custom traces for business-critical operations
  • Screen load tracking via mixin on screen widgets
  • Route observer for navigation performance
  • Network monitoring for API call latency
All versions