home / skills / jeremylongshore / claude-code-plugins-plus-skills / firestore-operations-manager

This skill helps you design and execute safe Firestore operations with schema-aware CRUD, batch processing, index guidance, and cost-aware validation.

npx playbooks add skill jeremylongshore/claude-code-plugins-plus-skills --skill firestore-operations-manager

Review the files below or copy the command above to add this skill to your agents.

Files (3)
SKILL.md
2.7 KB
---
name: firestore-operations-manager
description: |
  Manage Firebase/Firestore operations including CRUD, queries, batch processing, and index/rule guidance.
  Use when you need to create/update/query Firestore documents, run batch writes, troubleshoot missing indexes, or plan migrations.
  Trigger with phrases like "firestore operations", "create firestore document", "batch write", "missing index", or "fix firestore query".
allowed-tools: Read, Write, Edit, Grep, Glob, Bash(cmd:*)
version: 1.0.0
author: Jeremy Longshore <[email protected]>
license: MIT
---
# Firestore Operations Manager

Operate Firestore safely in production: schema-aware CRUD, query/index tuning, batch processing, and guardrails for permissions and cost.

## Overview

Use this skill to design Firestore data access patterns and implement changes with the right indexes, security rules, and operational checks (emulator tests, monitoring, and rollback plans).

## Prerequisites

- A Firebase project with Firestore enabled (or a local emulator setup)
- A clear collection/document schema (or permission to propose one)
- Credentials for the target environment (service account / ADC) and a plan for secrets

## Instructions

1. Identify the operation: create/update/delete/query/batch/migration.
2. Confirm schema expectations and security rules constraints.
3. Implement the change (or propose a patch) using safe patterns:
   - prefer batched writes/transactions where consistency matters
   - add pagination for large queries
4. Check indexes:
   - detect required composite indexes and provide `firestore.indexes.json` updates
5. Validate:
   - run emulator tests or a minimal smoke query
   - confirm cost/perf implications for the query pattern

## Output

- Code changes or snippets for the requested Firestore operation
- Index recommendations (and config updates when needed)
- A validation checklist (emulator commands and production smoke tests)

## Error Handling

- Permission denied: identify the rule/role blocking the operation and propose least-privilege changes.
- Missing index: provide the exact composite index needed for the query.
- Hotspot/latency issues: propose sharding, pagination, or query redesign.

## Examples

**Example: Fix a failing query**
- Request: “This query needs a composite index—what do I add?”
- Result: the exact index definition and a safer query pattern if needed.

**Example: Batch migration**
- Request: “Backfill a new field across 100k docs.”
- Result: batched write strategy, checkpoints, and rollback guidance.

## Resources

- Full detailed guide (kept for reference): `{baseDir}/references/SKILL.full.md`
- Firestore docs: https://firebase.google.com/docs/firestore
- Firestore indexes: https://firebase.google.com/docs/firestore/query-data/indexing

Overview

This skill helps manage Firestore operations safely in production and development. It covers schema-aware CRUD, query tuning, batch processing, index recommendations, and rule/permission guidance. Use it to implement changes, produce code snippets, and validate operations with emulator or smoke tests.

How this skill works

The skill inspects the requested operation (create, update, delete, query, batch, migration) and checks schema expectations, security rules, and performance/cost implications. It outputs code snippets or patches, exact composite index definitions when needed, and a validation checklist including emulator commands and minimal production smoke tests. For errors it diagnoses permission issues, missing indexes, and hotspot/latency problems and recommends concrete fixes.

When to use it

  • Creating or updating Firestore documents with a required schema or security constraints
  • Designing or optimizing queries that trigger missing composite index errors
  • Running bulk writes, migrations, or large backfills that need batching and checkpoints
  • Troubleshooting permission denied errors or unexpected rule rejections
  • Planning changes that might affect costs, hotspots, or latency

Best practices

  • Prefer batched writes or transactions for consistency and to respect Firestore limits
  • Add pagination and limit queries to avoid hotspots and reduce read costs
  • Run changes against the emulator or a small staging slice before production
  • Provide exact composite index config when a query requires it and keep index files under source control
  • Propose least-privilege rule changes and document rollback and monitoring steps

Example use cases

  • Provide the exact composite index JSON for a failing query and a safer query refactor
  • Generate a batched migration plan to backfill a new field across 100k documents with checkpoints
  • Create a code snippet for a transactional read-modify-write operation with retry logic
  • Diagnose a permission denied error by mapping the rule condition to required roles and suggesting minimal rule edits
  • Recommend sharding or key redesign when a single collection causes write hotspots

FAQ

How do you handle a missing composite index?

I produce the exact composite index definition suitable for firestore.indexes.json and suggest a query pattern change if the index would be costly.

What is the recommended approach for large migrations?

Use batched writes with small batch sizes, include checkpoints, test on the emulator, and run gradual production rollouts with monitoring and rollback plans.