Agent skill

firebase-operations

Performs Firebase Firestore operations. Use when querying collections, creating/updating/deleting documents, using batch writes, or working with Timestamps. Includes pagination, transactions, and security rules patterns.

Stars 163
Forks 31

Install this agent skill to your Project

npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/data/firebase-operations

SKILL.md

Firebase Operations Skill

Instructions

  1. Import getAdminDb, COLLECTIONS from @/lib/firebase-admin
  2. Use Timestamp.now() for timestamps
  3. Convert to ISO string for API responses: createdAt.toDate().toISOString()
  4. Use batch writes for multiple operations (max 500)
  5. Use transactions for atomic operations

Quick Reference

typescript
import { getAdminDb, COLLECTIONS } from '@/lib/firebase-admin'
import { Timestamp, FieldValue } from 'firebase-admin/firestore'

// Get document
const doc = await db.collection(COLLECTIONS.PROJECTS).doc(id).get()

// Create with timestamps
const now = Timestamp.now()
await docRef.set({ ...data, createdAt: now, updatedAt: now })

// Update
await docRef.update({ field: value, updatedAt: Timestamp.now() })

// Increment counter
await docRef.update({ likes: FieldValue.increment(1) })

For complete operations (batch writes, transactions, pagination, queries), see reference.md.

Didn't find tool you were looking for?

Be as detailed as possible for better results