inehemiasm/AiAssistant / .agents/skills/firebase-firestore
firebase-firestore
VerifiedSets up, manages, and executes queries against Cloud Firestore database instances. You MUST unconditionally activate this skill if you plan to use Firestore in any way. Use when listing or creating Firestore databases, configuring security rules, designing data models, writing client SDK queries, or checking indexes.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 3.4 KB |
| references/enterprise/android_sdk_usage.md | markdown | 3.6 KB |
| references/enterprise/data_model.md | markdown | 2.8 KB |
| references/enterprise/flutter_setup.md | markdown | 4.5 KB |
| references/enterprise/indexes.md | markdown | 4.5 KB |
| references/enterprise/ios_setup.md | markdown | 5.8 KB |
| references/enterprise/provisioning.md | markdown | 3.2 KB |
| references/enterprise/python_sdk_usage.md | markdown | 2.9 KB |
| references/enterprise/security_rules.md | markdown | 26.5 KB |
| references/enterprise/web_sdk_usage.md | markdown | 4.2 KB |
| references/standard/android_sdk_usage.md | markdown | 4.7 KB |
| references/standard/flutter_setup.md | markdown | 4.3 KB |
| references/standard/indexes.md | markdown | 4.0 KB |
| references/standard/ios_setup.md | markdown | 5.2 KB |
| references/standard/provisioning.md | markdown | 2.8 KB |
| references/standard/security_rules.md | markdown | 26.5 KB |
| references/standard/web_sdk_usage.md | markdown | 4.4 KB |
references/standard/indexes.md
View on GitHub# Firestore Indexes Reference
Indexes allow Firestore to ensure that query performance depends on the size of
the result set, not the size of the database.
## Index Types
### Single-Field Indexes
In Standard Edition, Firestore **automatically creates** a single-field index
for every field in a document (and subfields in maps). * **Support**: Simple
equality queries (`==`) and single-field range/sort queries (`<`, `<=`,
`orderBy`). * **Behavior**: You generally don't need to manage these unless you
want to *exempt* a field.
### Composite Indexes
A composite index stores a sorted mapping of all documents based on an ordered
list of fields. * **Support**: Complex queries that filter or sort by **multiple
fields**. * **Creation**: These are **NOT** automatically created. You must
define them manually or via the console/CLI.
## Automatic vs. Manual Management
### What is Automatic?
* Indexes for simple queries.
* Merging of single-field indexes for multiple equality filters (e.g.,
`where("state", "==", "CA").where("country", "==", "USA")`).
### When Do I Need to Act?
If you attempt a query that requires a composite index, the SDK will throw an
error containing a **direct link** to the Firebase Console to create that
specific index.
**Example Error:**
> "The query requires an index. You can create it here:
> https://console.firebase.google.com/project/..."
## Query Support Examples
| Query Type | Index Required |
| :----------------------------------- | :----------------------------------- |
| **Simple Equality**<br>`where("a", | Automatic (Single-Field) |
: "==", 1)` : :
| **Simple Range/Sort**<br>`where("a", | Automatic (Single-Field) |
: ">", 1).orderBy("a")` : :
| **Multiple Equality**<br>`where("a", | Automatic (Merged Single-Field) |
: "==", 1).where("b", "==", 2)` : :
| **Equality + | **Composite Index** |
: Range/Sort**<br>`where("a", "==", : :
: 1).where("b", ">", 2)` : :
| **Multiple Ranges**<br>`where("a", | **Composite Index** (and technically |
: ">", 1).where("b", ">", 2)` : limited query support) :
| **Array Contains + | **Composite Index** |
: Equality**<br>`where("tags", : :
: "array-contains", : :
: "news").where("active", "==", true)` : :
## Best Practices & Exemptions
You can **exempt** fields from automatic indexing to save storage or strictly
enforce write limits.
### 1. High Write Rates (Sequential Values)
* **Problem**: Indexing fields that increase sequentially (like `timestamp`)
limits the write rate to ~500 writes/second per collection.
* **Solution**: If you don't query on this field, **exempt** it from simple
indexing.
### 2. Large String/Map/Array Fields
* **Problem**: Indexing limits (40k entries per doc). Indexing large blobs
wastes storage.
* **Solution**: Exempt large text blobs or huge arrays if they aren't used for
filtering.
### 3. TTL Fields
* **Problem**: TTL (Time-To-Live) deletion can cause index churn.
* **Solution**: Exempt the TTL timestamp field from indexing if you don't
query it.
## Management
### Config files
Your indexes should be defined in `firestore.indexes.json` (pointed to by
`firebase.json`).
```json
{
"indexes": [
{
"collectionGroup": "cities",
"queryScope": "COLLECTION",
"fields": [
{ "fieldPath": "country", "order": "ASCENDING" },
{ "fieldPath": "population", "order": "DESCENDING" }
]
}
],
"fieldOverrides": []
}
```
### CLI Commands
Deploy indexes only: `bash npx -y firebase-tools@latest deploy --only
firestore:indexes`
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| rea-analysis-optimizationmorluto/reaOptimize REA providers and shared analysis workflows for agent context, latency, CPU, and memory while preserving correctness and Evidence. Use for analysis bottlenecks and cache or query design; CI/test-suite optimization belongs to rea-ci-tests-audit. | Stars: 472k | Updated | Claude CodeCodex | Verified | Install |
| rea-ci-tests-auditmorluto/reaAudit REA CI and test suites for correctness, fixture drift, false passes, and measured performance; use for suite or workflow investigations and efficiency changes, rather than ordinary feature testing or a single test failure. | Stars: 472k | Updated | Claude CodeCodex | Verified | Install |
| rea-tool-designmorluto/reaAudit, investigate, design, or change REA investigation tools, CLI/MCP contracts, provider capabilities, and Evidence semantics. | Stars: 472k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-auditDietrichGebert/ponytailQuality audit of the whole repo: bugs, security, real load, missing tests, speed, and what to delete. Most important first. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |