dentvega/firebase-agent-skills/firebase-firestore
Claude Code and agent skill by dentvega/firebase-agent-skills
- community
Checking that the SKILL.md file is still in the repository.
Provisions and uses Cloud Firestore — creating databases, designing collections and documents, writing security rules, defining composite indexes, and writing client SDK reads/writes. Use whenever the user needs persistent structured storage that syncs in real time across clients.
Install
npx vskill@latest install dentvega/firebase-agent-skills/firebase-firestoreSKILL.md
The same SKILL.md was published earlier as dentvega/firebase-agent-skills/firebase-firestore.
Cloud Firestore
Minimum viable example
That's the canonical pattern. serverTimestamp() instead of client time, onSnapshot instead of polling, return the unsubscribe.
1. Identify or create the database
List existing databases:
If none exists, create one. Default to Enterprise (native mode) unless the user has a specific reason to use Standard edition:
Pick the same region as the rest of the user's Firebase resources (Functions, Storage) to avoid cross-region latency and egress charges.
2. Data modeling
Firestore is document-oriented with collections of documents. Documents can hold subcollections. The right shape depends on access patterns, not on what feels normalized.
Rules of thumb
- Read what you display. If you list 50 todos, store enough on each todo to render the list without N+1 fetches. Denormalize liberally.
- Subcollections for ownership.
users/{uid}/posts/{postId}is better than a top-levelpostsfiltered byownerIdif posts are only ever shown in that user's context — rules become trivial. - Top-level collections for cross-cutting queries. If you ever need "all posts site-wide, newest first", use a top-level collection.
- Avoid documents that grow unboundedly. A document max is 1 MiB. A chat with 100k messages must be a subcollection, not an array.
- Use auto-generated IDs unless you have a strong external key (e.g. an order number).
See references/data-modeling.md for full patterns.
3. Security rules
Default to deny everything, then open up the minimum needed. Edit firestore.rules:
For a default-deny starter that follows this pattern, invoke the scaffold:
Deploy:
CRITICAL: never write a rule like allow read, write: if request.auth != null; and ship it. It lets any signed-in user read or overwrite any document. Anchor every rule to ownership or membership.
See references/security-rules.md for advanced patterns: role-based access via custom claims, member-of-group checks, write validation, rate limiting.
4. Indexes
Single-field indexes are automatic. Composite indexes (more than one where + orderBy) must be declared in firestore.indexes.json:
Deploy:
The first time a query needs a missing composite index, Firestore throws an error with a console link that creates it for you. In dev, click the link; in CI / prod, commit the entry to firestore.indexes.json.
5. Client SDK usage
- Web → references/web-sdk.md
- Expo / React Native → references/react-native.md (use
@react-native-firebase/firestorefor native; the web SDK also works for managed Expo apps with reduced features)
Always-true patterns
- Use `onSnapshot` for any UI that should react to changes. Polling with
getDocsis almost always wrong. - Cleanup snapshot listeners in
useEffectcleanup, otherwise they leak and the SDK keeps the document hydrated forever. - Batch writes ≤ 500 ops. For more, chunk and run them sequentially or in parallel batches.
- Never put secrets in documents. Rules can be probed; if a field shouldn't be readable, don't store it client-side at all.
6. Common mistakes
- `allow read, write: if request.auth != null;` — leaks every doc to every signed-in user. Always anchor rules to ownership (
request.auth.uid == resource.data.ownerId) or membership. - Polling with `getDocs` for UI that should react to changes. Use
onSnapshotand return its unsubscribe fromuseEffect. Otherwise listeners leak. - Trusting client timestamps. Use
serverTimestamp()on write andrequest.timein rules — neverDate.now(). - Unbounded documents. 1 MiB hard cap. A chat with 100k messages must be a subcollection, not an
array. - Querying object properties inside arrays. Firestore can only
array-containswhole values. Restructure to a subcollection if you need to filter by inner fields. - Forgetting composite indexes in production. Dev gets a console link to create them; CI hits the missing-index error. Commit
firestore.indexes.json. - Calling `setDoc(ref, data, { merge: true })` and expecting `create` rules to fire. Merged writes evaluate
updaterules — write both.
7. Local emulator
For development, run the emulator suite so you don't burn quota and can iterate on rules safely:
Connect from the client:
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-firestore/SKILL.md
Popularity
- 7-day trend score
- 0
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/dentvega/firebase-agent-skills/firebase-firestore)