ericrisco/rsc-harness/firebase
Claude Code and agent skill by ericrisco/rsc-harness
- community
Checking that the SKILL.md file is still in the repository.
Use when building on Firebase — Firestore data modeling, Security Rules, Auth and custom claims, Cloud Functions, Storage, modular Web/Admin SDK imports — including symptoms like a database open to the internet, a query rejected by rules, or a doc stuck at ~1 write/sec. NOT managed-Postgres BaaS with SQL and RLS (that is supabase).
Install
npx vskill@latest install ericrisco/rsc-harness/firebaseSKILL.md
The same SKILL.md was published earlier as ericrisco/rsc-harness/firebase.
Firebase — Firestore, Rules, Auth, Functions, Storage
The Firebase product surface that sits on top of GCP, on the modular Web SDK (v12) and the Admin SDK. The whole skill exists to stop two failure modes: dragging relational/SQL habits into a NoSQL document store, and leaving the database open to the internet.
Two facts drive everything below:
- It is a NoSQL document store, shaped for the read path. No joins, no server-side
ORacross
different fields without a composite index, no SELECT * across collections. Denormalize and fan-out so a screen is one cheap query — reads are what you pay for and what users wait on.
- Rules ARE the access control. Firestore is reachable directly from untrusted clients. There is
no app server in the trust path by default — firestore.rules (CEL) is the only thing between a browser and your data. App Check attests the request even came from your app before Rules evaluate.
Not this skill:
| Instead of Firebase | Go to | |
|---|---|---|
| Relational schema, SQL, EXPLAIN, indexing a SQL engine | ../postgresdb/SKILL.md | |
| Managed Postgres BaaS (SQL + Postgres RLS + PostgREST) — the most-confused sibling: same "backend-as-a-service" shape, completely different data model and rules language | supabase | |
| AWS document/key-value store with its own capacity model | dynamodb | |
| Self-hosted Mongo document modeling | mongodb | |
| Generic GCP project/IAM/billing not specific to a Firebase product | gcp-essentials | |
| React/Next.js component or rendering work that merely calls Firebase | react / ../nextjs/SKILL.md |
Data modeling
Firestore charges and waits on reads. Model so the common screen is one query against one collection.
Collection vs subcollection vs root + denormalized field — decide by access pattern:
| Shape | Use when | Why | |
|---|---|---|---|
Subcollection (rooms/{id}/messages) | Child list is only ever read inside its parent, can grow unbounded | Subcollections don't bloat the parent doc; deleting a parent does NOT delete them (handle that) | |
| Separate root collection + foreign id | Child must be queried across all parents (collection-group query) | A collectionGroup('messages') query needs the docs in same-named subcollections OR a root collection | |
| Denormalized field on the parent | A few values are shown alongside the parent and rarely change | Avoids a second read; you accept writing the copy on every change |
Hard limits — design around them, don't discover them in prod:
- A document maxes out at 1 MiB (1,048,576 bytes). Don't accumulate an unbounded array (chat
messages, audit log) inside one doc — it will hit the wall and every read pays for the whole blob. Use a subcollection.
- A single document tolerates only ~1 sustained write/sec. Monotonic IDs and indexed sequential
timestamps create a hotspot on one index range. Use scattered auto-IDs (doc(collection(db,'x'))), and for high-frequency counters use a sharded counter (N shard docs, sum on read).
Query reality: no joins; range/inequality filters on a field plus an orderBy on another field require a composite index; in / array-contains-any are capped (~30 values). If a query needs an index, declare it in firestore.indexes.json — see the emulator gotcha below.
Denormalization recipes, counter sharding, cursor pagination, getCountFromServer, collection-group queries, and composite-index design live in references/data-modeling.md.
Security Rules — the load-bearing section
Rules are NOT filters. A query is rejected outright unless the rules can guarantee every matched document is readable — Firestore will not silently drop the docs you can't see. So a list rule and the query that runs against it must agree: if the rule allows reading only your own docs, the query must itself be constrained (where("ownerId","==",uid)), or the whole query fails.
Rules to internalize:
- Default-deny. No matching
allow= denied. Never add a/{document=**}catch-all with
if true. That single line is the "open to the internet" headline risk.
- `request.auth` is the authenticated identity (null when signed out);
request.auth.token
carries custom claims for RBAC (e.g. request.auth.token.admin == true).
- `resource.data` is the existing doc; `request.resource.data` is the incoming write. Validate
the incoming write on create/update (types, immutable ownerId, no privilege escalation).
- `get()` / `exists()` read another doc for cross-document checks (e.g. role lookup) — each costs
a billed read and counts against rule-evaluation limits, so keep them shallow.
- `get` vs `list` are distinct: a single-doc read vs a query.
read= both; split them so a
query can't leak documents a single get would also have blocked.
Set custom claims with the Admin SDK, never from the client. Add App Check in production so Rules only run for requests that provably came from your real app.
Full CEL patterns — RBAC via claims, ownership, validation functions, time-based throttling, and the complete @firebase/rules-unit-testing recipe — are in references/security-rules.md.
Auth
- Client sign-in with
getAuth()+ a provider; the SDK manages the refresh of the ID token. - Server-side, verify the ID token with
getAuth(adminApp).verifyIdToken(idToken)before trusting
any caller. A raw UID from the client is not proof of anything.
- Custom claims for RBAC:
getAuth(adminApp).setCustomUserClaims(uid, { admin: true }). Claims
land in request.auth.token in Rules and in the decoded token on the server. They refresh on the client's next token refresh, not instantly — force a refresh if you need it immediately.
- Session cookies (
createSessionCookie) suit SSR / server-rendered apps where you want an
httpOnly cookie instead of shipping the ID token to every request — pairs with ../nextjs/SKILL.md.
Cloud Functions (2nd gen)
2nd gen is the default and the only generation that runs Node.js 22. Use firebase-functions v7 modular triggers and firebase-admin.
- Callable (
onCall) gives yourequest.authalready verified; raw `onRequest` HTTPS does not
— you must verify the ID token yourself.
- Idempotency is mandatory for background triggers (
onDocumentWrittenetc.): events can fire more
than once, so guard side effects with the event id.
- Pin region, set secrets with
defineSecret(not env literals), and tune concurrency for cost. - Functions require the Blaze plan; outbound networking from a function also requires Blaze.
Trigger catalogue, callable-vs-HTTPS auth, idempotency keys, cold-start/cost, Auth blocking functions, and region pinning are in references/cloud-functions.md.
Cloud Storage
Storage paths are gated by their own Rules; clients can hit them directly.
For server-issued time-limited access (private downloads), generate a signed URL from the Admin SDK rather than loosening the Rules.
SDK & project mechanics
Use the modular SDK so the bundler tree-shakes unused Firebase code. The old namespaced firebase.firestore() API is gone in v9+.
firebase.jsonconfigures emulators, rules/index file paths, and hosting;firestore.indexes.json
declares composite indexes.
- Run the Local Emulator Suite (
firebase emulators:start) for local dev and tests. - Emulator gotcha: the Firestore emulator does NOT enforce composite indexes — it runs any valid
query. So "works in the emulator, fails in prod with requires an index" is expected. Verify index coverage separately by keeping firestore.indexes.json in sync and deploying it.
- The Firebase API key in client config is not a secret (it identifies the project, not authorizes
access — Rules + App Check do that). Service-account JSON keys ARE secrets; keep them server-side.
Anti-patterns
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/firebase/SKILL.md
Popularity
- Repository stars
- 141
- Repository forks
- 11
- 7-day trend score
- 30
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/ericrisco/rsc-harness/firebase)