firestore_patterns

Implements Firestore CRUD operations, real-time listeners, queries, and security rules.

Updated Jan 14, 2026
One-click install
npx skills add https://github.com/jvsandhu/agentic-skills --skill firestore-patterns-jvsandhu
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: firestore_patterns
Source: https://github.com/jvsandhu/agentic-skills/tree/main/skills/firestore_patterns
Command: npx skills add https://github.com/jvsandhu/agentic-skills --skill firestore-patterns-jvsandhu

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires firebase.

What problem does it solve? Designing a Firestore database without clear patterns leads to slow queries, oversized documents, and insecure data access. This Skill provides proven patterns for data modeling, real-time synchronization, and security rules so your Firebase backend stays performant and protected. ## Core Features & Use Cases - CRUD & Real-time Sync: Code patterns for reading, writing, updating, and deleting documents, plus onSnapshot listeners with proper cleanup. - Query & Index Guidance: Compound queries with where, orderBy, and limit, along with composite index and offline persistence advice. - Security Rules: Templates for authentication checks and data validation in Firestore security rules, with emulator-based testing guidance. - Use Case: When building a chat or social app backend, use this Skill to model subcollections correctly, enforce per-user write access, and avoid the 1MB document limit. ## Quick Start Use the firestore_patterns skill to design the data model and write security rules for my Firebase app.

Frequently Asked Questions about firestore_patterns

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I structure data in Firestore for a new app?

Model Firestore data based on your read patterns rather than normalizing like SQL. Use subcollections to stay under the 1MB document limit and denormalize data when it improves read performance.

How do I write Firestore security rules for user data?

Add request.auth != null checks to every rule and restrict writes with conditions like request.auth.uid == userId. Validate incoming data types and lengths inside the rules, then test them with the Firebase Emulator.

How do I listen to Firestore document changes in real time?

Use onSnapshot from firebase/firestore on a document or query reference to receive live updates. Always call the returned unsubscribe function during cleanup to avoid memory leaks.

Why does my Firestore query fail with an index error?

Compound queries combining multiple where clauses with orderBy require composite indexes. Create the index from the error link in the Firebase console, or simplify the query to match existing indexes.

When should I not use Firestore for my backend?

Firestore is a poor fit for highly relational data requiring complex joins or ad-hoc queries across many entities. In those cases a relational database like PostgreSQL is a better choice.