Token导航 LogoToken导航TokenDH.com
研究检索需要联网github未标认证来源可访问许可证需确认审计通过

firebase-cloud-firestoreFirebase cloud firestore 搜索

Agent Skill

firebase-cloud-firestore 用于查找、检索和筛选相关信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要根据关键词、任务场景或来源线索快速定位候选结果时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

282

周安装

12

GitHub Stars

537

下载量

99
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:firebase-cloud-firestore(Firebase cloud firestore 搜索)
来源仓库:https://github.com/evanca/flutter-ai-rules
仓库路径:skills/firebase-cloud-firestore
安装命令:
npx skills add https://github.com/evanca/flutter-ai-rules --skill firebase-cloud-firestore
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/evanca/flutter-ai-rules --skill firebase-cloud-firestore

简介

firebase-cloud-firestore 用于查找、检索和筛选相关信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要根据关键词、任务场景或来源线索快速定位候选结果时使用。

  • 适用于 Firebase cloud firestore 搜索相关的资料搜索与内容筛选,可结合来源仓库和原始 README 进一步核验具体用法。
  • 通过 npx skills add 命令从 GitHub 仓库安装,支持主流 AI 宿主环境集成调用。
  • 安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写操作。
  • 适用宿主包括 Codex、Claude、Cursor、Gemini CLI,接入前应确认版本、权限和运行环境要求。

SKILL.md

Firebase Cloud Firestore Skill

This skill defines how to correctly implement Cloud Firestore in Flutter applications, covering data modeling, queries, real-time updates, security rules, and scale optimization.

When to Use

Use this skill when:

  • Setting up and configuring Cloud Firestore in a Flutter project.
  • Designing document and collection structure or planning subcollections.
  • Performing read, write, batch, or transaction operations.
  • Implementing real-time listeners or paginated queries.
  • Optimizing for scale and avoiding write hotspots.
  • Writing or debugging Firestore security rules.

1. Database Selection

Choose Cloud Firestore when the app needs:

  • Rich, hierarchical data models with subcollections.
  • Complex queries: chaining filters, combining filtering and sorting on a property.
  • Transactions that atomically read and write data from any part of the database.
  • High availability (typical uptime 99.999%) or critical-level reliability.
  • Automatic scaling to millions of concurrent users.

Use Realtime Database instead for simple data models requiring simple lookups and extremely low-latency synchronization (typical response times under 10ms).


2. Setup and Configuration

flutter pub add cloud_firestore
import 'package:cloud_firestore/cloud_firestore.dart';

final db = FirebaseFirestore.instance; // after Firebase.initializeApp()

Location:

  • Select the database location closest to users and compute resources.
  • Use multi-region locations for critical apps (maximum availability and durability).
  • Use regional locations for lower costs and lower write latency.

iOS/macOS: Consider pre-compiled frameworks to improve build times:

pod 'FirebaseFirestore',
  :git => 'https://github.com/invertase/firestore-ios-sdk-frameworks.git',
  :tag => 'IOS_SDK_VERSION'

Offline persistence is enabled by default on mobile. Configure cache size:

FirebaseFirestore.instance.settings = const Settings(
  persistenceEnabled: true,
  cacheSizeBytes: Settings.CACHE_SIZE_UNLIMITED,
);

3. Document Structure

  • Avoid document IDs . and .. (special meaning in Firestore paths).
  • Avoid forward slashes (/) in document IDs (path separators).
  • Do not use monotonically increasing document IDs (e.g., Customer1, Customer2) — causes write hotspots.
  • Use Firestore's automatic document IDs when possible:
final docRef = await db.collection("users").add({
  'name': 'Ada Lovelace',
  'email': 'ada@example.com',
  'created_at': FieldValue.serverTimestamp(),
});
print('Created document with ID: ${docRef.id}');
  • Avoid these characters in field names (require extra escaping): . [ ] * ` ``
  • Use subcollections within documents to organize complex, hierarchical data rather than deeply nested objects.

4. Indexing

  • Firestore queries are indexed by default; query performance is proportional to the result set size, not the dataset size.
  • Set collection-level index exemptions to reduce write latency and storage costs.
  • Disable Descending and Array indexing for fields that do not need them.
  • Exempt string fields with long values that are not used for querying.
  • Exempt fields with sequential values (e.g., timestamps) from indexing if not used in queries — avoids the 500 writes/second index limit.
  • Add single-field exemptions for TTL fields.
  • Exempt large array or map fields not used in queries — avoids the 40,000 index entries per document limit.

5. Read and Write Operations

Read All Documents in a Collection

final querySnapshot = await db.collection("users").get();
for (var doc in querySnapshot.docs) {
  print("${doc.id} => ${doc.data()}");
}

Query with Filters

final query = db.collection("users")
    .where("age", isGreaterThanOrEqualTo: 18)
    .orderBy("age")
    .limit(20);

final results = await query.get();

Cursor-Based Pagination

// First page
final first = db.collection("cities").orderBy("name").limit(25);
final firstSnapshot = await first.get();

// Next page using last document as cursor
final lastDoc = firstSnapshot.docs.last;
final next = db.collection("cities")
    .orderBy("name")
    .startAfterDocument(lastDoc)
    .limit(25);
  • Do not use offsets for pagination — use cursors to avoid retrieving and being billed for skipped documents.

Write with Server Timestamp

await db.collection("users").doc("user_1").set({
  'name': 'Grace Hopper',
  'updated_at': FieldValue.serverTimestamp(),
});

Batch Write (Atomic, Up to 500 Operations)

final batch = db.batch();
batch.set(db.collection("cities").doc("LA"), {'name': 'Los Angeles'});
batch.update(db.collection("cities").doc("SF"), {'population': 860000});
batch.delete(db.collection("cities").doc("OLD"));
await batch.commit();

Transaction

await db.runTransaction((transaction) async {
  final snapshot = await transaction.get(db.collection("counters").doc("visits"));
  final currentCount = snapshot.get("count") as int;
  transaction.update(snapshot.reference, {"count": currentCount + 1});
});
  • Execute independent operations (e.g., a document lookup and a query) in parallel, not sequentially.
  • Be aware of write rate limits: ~1 write per second per document.
  • For writing a large number of documents, use a bulk writer instead of the atomic batch writer.

6. Designing for Scale

  • Avoid high read or write rates to lexicographically close documents (hotspotting).
  • Avoid creating new documents with monotonically increasing fields (like timestamps) at a very high rate.
  • Avoid deleting documents in a collection at a high rate.
  • Gradually increase traffic when writing to the database at a high rate — ramp up over 5 minutes.
  • Avoid queries that skip over recently deleted data — use start_at to find the correct start point.
  • Distribute writes across different document paths to avoid contention.
  • Firestore scales automatically to ~1 million concurrent connections and 10,000 writes/second.

7. Real-time Updates

final subscription = db.collection("messages")
    .where("room", isEqualTo: "general")
    .orderBy("timestamp", descending: true)
    .limit(50)
    .snapshots()
    .listen((querySnapshot) {
      for (var change in querySnapshot.docChanges) {
        switch (change.type) {
          case DocumentChangeType.added:
            print("New message: ${change.doc.data()}");
            break;
          case DocumentChangeType.modified:
            print("Modified: ${change.doc.data()}");
            break;
          case DocumentChangeType.removed:
            print("Removed: ${change.doc.id}");
            break;
        }
      }
    });

// Detach when no longer needed:
subscription.cancel();
  • Limit the number of simultaneous real-time listeners.
  • Detach listeners when they are no longer needed to avoid memory leaks and unnecessary reads.
  • Use compound queries to filter data server-side rather than filtering on the client.
  • For large collections, use queries to limit the data being listened to — never listen to an entire large collection.

8. Security

  • Always use Firebase Security Rules to protect Firestore data.
  • Security rules do not cascade unless a wildcard is used.
  • If a query's results might contain data the user does not have access to, the entire query fails.

Example rules for user-owned documents:

rules_version = '2';
service cloud.firestore {
  match /databases/{database}/documents {
    match /users/{userId} {
      allow read, update, delete: if request.auth != null && request.auth.uid == userId;
      allow create: if request.auth != null;
    }
  }
}
  • Validate user input before submitting to Firestore to prevent injection attacks.
  • Use transactions for operations that require atomic updates to multiple documents.
  • Implement proper error handling for all Firestore operations.
  • Never store sensitive information in Firestore without proper access controls.

References

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

36.69%
按下载量换算36

Claude

32.04%
按下载量换算32

Cursor

19.85%
按下载量换算20

Gemini CLI

8.88%
按下载量换算9

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills