@intentsolutionsio/jeremy-firestore 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/plugin.json +26 -0
- package/LICENSE +21 -0
- package/README.md +615 -0
- package/agents/firebase-operations-agent.md +411 -0
- package/agents/firestore-security-agent.md +478 -0
- package/commands/firestore-setup.md +543 -0
- package/package.json +48 -0
- package/skills/firestore-operations-manager/ARD.md +215 -0
- package/skills/firestore-operations-manager/PRD.md +106 -0
- package/skills/firestore-operations-manager/SKILL.md +67 -0
- package/skills/firestore-operations-manager/references/errors.md +85 -0
- package/skills/firestore-operations-manager/references/examples.md +211 -0
- package/skills/firestore-operations-manager/references/implementation.md +214 -0
- package/skills/firestore-operations-manager/scripts/setup-firestore.sh +63 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "jeremy-firestore",
|
|
3
|
+
"version": "2.0.0",
|
|
4
|
+
"description": "Firestore database specialist for schema design, queries, and real-time sync",
|
|
5
|
+
"author": {
|
|
6
|
+
"name": "Jeremy Longshore",
|
|
7
|
+
"email": "[email protected]",
|
|
8
|
+
"url": "https://intentsolutions.io"
|
|
9
|
+
},
|
|
10
|
+
"repository": "https://github.com/jeremylongshore/claude-code-plugins",
|
|
11
|
+
"license": "MIT",
|
|
12
|
+
"keywords": [
|
|
13
|
+
"firebase",
|
|
14
|
+
"firestore",
|
|
15
|
+
"database",
|
|
16
|
+
"crud",
|
|
17
|
+
"security-rules",
|
|
18
|
+
"cloud-functions",
|
|
19
|
+
"batch-operations",
|
|
20
|
+
"data-migration",
|
|
21
|
+
"performance",
|
|
22
|
+
"cost-optimization",
|
|
23
|
+
"nosql",
|
|
24
|
+
"google-cloud"
|
|
25
|
+
]
|
|
26
|
+
}
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Claude Code Plugin Hub
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,615 @@
|
|
|
1
|
+
# Jeremy Firestore Plugin
|
|
2
|
+
|
|
3
|
+
**Production-ready Firebase/Firestore operations for Claude Code**
|
|
4
|
+
|
|
5
|
+
Build, manage, and optimize Firebase/Firestore databases with AI-powered agents that handle CRUD operations, security rules, batch processing, migrations, and performance monitoring.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Features
|
|
10
|
+
|
|
11
|
+
### Core Capabilities
|
|
12
|
+
- **CRUD Operations** - Create, read, update, delete with batch support
|
|
13
|
+
- **Security Rules** - Generate, validate, and deploy Firestore security rules
|
|
14
|
+
- **Data Migration** - Migrate data between collections, projects, or environments
|
|
15
|
+
- **Batch Operations** - Process thousands of documents efficiently
|
|
16
|
+
- **Cost Optimization** - Analyze and reduce Firebase costs
|
|
17
|
+
- **Performance Monitoring** - Track queries, indexes, and bottlenecks
|
|
18
|
+
- **Cloud Functions Integration** - Trigger and manage Cloud Functions
|
|
19
|
+
- **Collection Management** - Schema validation, indexing, and organization
|
|
20
|
+
|
|
21
|
+
### AI Agents
|
|
22
|
+
- **firebase-operations-agent** - CRUD, queries, batch operations
|
|
23
|
+
- **firestore-security-agent** - Security rules generation and validation
|
|
24
|
+
- **firestore-migration-agent** - Data migration and transformation
|
|
25
|
+
- **firestore-optimizer-agent** - Performance and cost optimization
|
|
26
|
+
|
|
27
|
+
### Commands
|
|
28
|
+
- `/firestore-setup` - Initialize Firebase SDK and credentials
|
|
29
|
+
- `/firestore-query` - Interactive query builder
|
|
30
|
+
- `/firestore-migrate` - Guided migration workflow
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## Quick Start
|
|
35
|
+
|
|
36
|
+
### Installation
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
# Install the plugin
|
|
40
|
+
/plugin install jeremy-firestore@claude-code-plugins-plus
|
|
41
|
+
|
|
42
|
+
# Initialize Firebase in your project
|
|
43
|
+
/firestore-setup
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### Prerequisites
|
|
47
|
+
|
|
48
|
+
1. **Firebase Project** - Create at https://console.firebase.google.com
|
|
49
|
+
2. **Service Account** - Download JSON key from Project Settings > Service Accounts
|
|
50
|
+
3. **Node.js** - Version 18+ with npm/pnpm/yarn
|
|
51
|
+
|
|
52
|
+
### First-Time Setup
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
# 1. Install Firebase Admin SDK
|
|
56
|
+
npm install firebase-admin
|
|
57
|
+
|
|
58
|
+
# 2. Set environment variable
|
|
59
|
+
export GOOGLE_APPLICATION_CREDENTIALS="/path/to/serviceAccountKey.json"
|
|
60
|
+
|
|
61
|
+
# 3. Run setup command
|
|
62
|
+
/firestore-setup
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
---
|
|
66
|
+
|
|
67
|
+
## Usage Examples
|
|
68
|
+
|
|
69
|
+
### Example 1: CRUD Operations
|
|
70
|
+
|
|
71
|
+
```javascript
|
|
72
|
+
// Create documents
|
|
73
|
+
"Create a new user document in the 'users' collection"
|
|
74
|
+
|
|
75
|
+
Agent creates:
|
|
76
|
+
{
|
|
77
|
+
uid: "user123",
|
|
78
|
+
email: "[email protected]",
|
|
79
|
+
createdAt: Timestamp.now(),
|
|
80
|
+
role: "user"
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// Read with queries
|
|
84
|
+
"Get all users created in the last 7 days"
|
|
85
|
+
|
|
86
|
+
Agent executes:
|
|
87
|
+
db.collection('users')
|
|
88
|
+
.where('createdAt', '>=', sevenDaysAgo)
|
|
89
|
+
.orderBy('createdAt', 'desc')
|
|
90
|
+
.get()
|
|
91
|
+
|
|
92
|
+
// Update documents
|
|
93
|
+
"Update user123's role to 'admin'"
|
|
94
|
+
|
|
95
|
+
Agent updates:
|
|
96
|
+
db.collection('users').doc('user123').update({
|
|
97
|
+
role: 'admin',
|
|
98
|
+
updatedAt: Timestamp.now()
|
|
99
|
+
})
|
|
100
|
+
|
|
101
|
+
// Delete with safety checks
|
|
102
|
+
"Delete all test users but keep production data"
|
|
103
|
+
|
|
104
|
+
Agent:
|
|
105
|
+
1. Validates query won't delete production data
|
|
106
|
+
2. Shows preview of documents to delete
|
|
107
|
+
3. Asks for confirmation
|
|
108
|
+
4. Executes batch delete
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### Example 2: Security Rules
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
# Generate security rules for a users collection
|
|
115
|
+
"Create security rules for the users collection where:
|
|
116
|
+
- Users can read their own document
|
|
117
|
+
- Only admins can write
|
|
118
|
+
- Email field is required and must be a valid email"
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
Agent generates:
|
|
122
|
+
```javascript
|
|
123
|
+
rules_version = '2';
|
|
124
|
+
service cloud.firestore {
|
|
125
|
+
match /databases/{database}/documents {
|
|
126
|
+
match /users/{userId} {
|
|
127
|
+
// Users can read their own document
|
|
128
|
+
allow read: if request.auth != null && request.auth.uid == userId;
|
|
129
|
+
|
|
130
|
+
// Only admins can write
|
|
131
|
+
allow write: if request.auth != null &&
|
|
132
|
+
get(/databases/$(database)/documents/users/$(request.auth.uid)).data.role == 'admin';
|
|
133
|
+
|
|
134
|
+
// Validation
|
|
135
|
+
allow create, update: if request.resource.data.email is string &&
|
|
136
|
+
request.resource.data.email.matches('^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$');
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
### Example 3: Data Migration
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
# Migrate data between environments
|
|
146
|
+
"Migrate all users from staging to production, but anonymize email addresses"
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
Agent workflow:
|
|
150
|
+
1. **Connects to staging** - Reads source collection
|
|
151
|
+
2. **Transforms data** - Anonymizes PII fields
|
|
152
|
+
3. **Validates** - Checks schema compatibility
|
|
153
|
+
4. **Batch writes** - Writes to production in chunks of 500
|
|
154
|
+
5. **Verifies** - Confirms document counts match
|
|
155
|
+
6. **Reports** - Shows migration summary
|
|
156
|
+
|
|
157
|
+
### Example 4: Batch Operations
|
|
158
|
+
|
|
159
|
+
```bash
|
|
160
|
+
# Update 10,000 documents efficiently
|
|
161
|
+
"Add a 'verified: false' field to all users who registered before 2024"
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
Agent executes:
|
|
165
|
+
- Queries in batches of 500 documents
|
|
166
|
+
- Uses batch writes for efficiency (reduces costs 10x)
|
|
167
|
+
- Handles rate limits automatically
|
|
168
|
+
- Shows progress updates
|
|
169
|
+
- Reports total documents updated
|
|
170
|
+
|
|
171
|
+
### Example 5: Performance Optimization
|
|
172
|
+
|
|
173
|
+
```bash
|
|
174
|
+
# Analyze slow queries
|
|
175
|
+
"Analyze the performance of my Firestore queries and suggest optimizations"
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
Agent analyzes:
|
|
179
|
+
- **Missing indexes** - Identifies composite indexes needed
|
|
180
|
+
- **Query patterns** - Finds inefficient queries
|
|
181
|
+
- **Collection structure** - Suggests denormalization opportunities
|
|
182
|
+
- **Read/write costs** - Calculates monthly costs
|
|
183
|
+
- **Recommendations** - Provides actionable improvements
|
|
184
|
+
|
|
185
|
+
---
|
|
186
|
+
|
|
187
|
+
## Agent Reference
|
|
188
|
+
|
|
189
|
+
### firebase-operations-agent
|
|
190
|
+
|
|
191
|
+
**Purpose:** Handle all Firestore CRUD operations, queries, and batch processing
|
|
192
|
+
|
|
193
|
+
**Use when:**
|
|
194
|
+
- Creating, reading, updating, or deleting documents
|
|
195
|
+
- Running complex queries with filters and ordering
|
|
196
|
+
- Batch operations on multiple documents
|
|
197
|
+
- Collection management
|
|
198
|
+
|
|
199
|
+
**Trigger phrases:**
|
|
200
|
+
- "create a document in..."
|
|
201
|
+
- "query the users collection..."
|
|
202
|
+
- "batch update all documents where..."
|
|
203
|
+
- "delete documents matching..."
|
|
204
|
+
|
|
205
|
+
**Example:**
|
|
206
|
+
```
|
|
207
|
+
User: "Get the 10 most recent orders for user123"
|
|
208
|
+
|
|
209
|
+
Agent:
|
|
210
|
+
1. Validates collection exists
|
|
211
|
+
2. Builds query: orders.where('userId', '==', 'user123').orderBy('createdAt', 'desc').limit(10)
|
|
212
|
+
3. Executes query
|
|
213
|
+
4. Returns formatted results
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
### firestore-security-agent
|
|
217
|
+
|
|
218
|
+
**Purpose:** Generate, validate, and deploy Firestore security rules
|
|
219
|
+
|
|
220
|
+
**Use when:**
|
|
221
|
+
- Creating new security rules
|
|
222
|
+
- Validating existing rules
|
|
223
|
+
- Troubleshooting permission errors
|
|
224
|
+
- Implementing authentication patterns
|
|
225
|
+
|
|
226
|
+
**Trigger phrases:**
|
|
227
|
+
- "create security rules for..."
|
|
228
|
+
- "validate my firestore rules..."
|
|
229
|
+
- "fix permission denied error..."
|
|
230
|
+
- "implement role-based access..."
|
|
231
|
+
|
|
232
|
+
**Example:**
|
|
233
|
+
```
|
|
234
|
+
User: "Create rules for a chat app with public rooms and private messages"
|
|
235
|
+
|
|
236
|
+
Agent:
|
|
237
|
+
1. Analyzes data model (rooms, messages collections)
|
|
238
|
+
2. Generates rules with:
|
|
239
|
+
- Public read for rooms
|
|
240
|
+
- Authenticated write for rooms
|
|
241
|
+
- Private message access (sender/recipient only)
|
|
242
|
+
3. Adds validation (message length, required fields)
|
|
243
|
+
4. Tests rules with sample scenarios
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
### firestore-migration-agent
|
|
247
|
+
|
|
248
|
+
**Purpose:** Migrate data between collections, projects, or environments
|
|
249
|
+
|
|
250
|
+
**Use when:**
|
|
251
|
+
- Moving data between environments (staging → production)
|
|
252
|
+
- Restructuring collections
|
|
253
|
+
- Backfilling data
|
|
254
|
+
- Importing/exporting data
|
|
255
|
+
|
|
256
|
+
**Trigger phrases:**
|
|
257
|
+
- "migrate data from..."
|
|
258
|
+
- "copy collection to..."
|
|
259
|
+
- "restructure the users collection..."
|
|
260
|
+
- "backfill missing fields..."
|
|
261
|
+
|
|
262
|
+
**Example:**
|
|
263
|
+
```
|
|
264
|
+
User: "Migrate users collection to a new structure with nested addresses"
|
|
265
|
+
|
|
266
|
+
Agent:
|
|
267
|
+
1. Reads existing user documents
|
|
268
|
+
2. Transforms: { address: "123 Main St" } → { address: { street: "123 Main St", city: "", zip: "" } }
|
|
269
|
+
3. Validates transformation
|
|
270
|
+
4. Writes to new collection
|
|
271
|
+
5. Verifies data integrity
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
### firestore-optimizer-agent
|
|
275
|
+
|
|
276
|
+
**Purpose:** Optimize Firestore performance and reduce costs
|
|
277
|
+
|
|
278
|
+
**Use when:**
|
|
279
|
+
- Slow queries need optimization
|
|
280
|
+
- Monthly costs are too high
|
|
281
|
+
- Need index recommendations
|
|
282
|
+
- Want to analyze usage patterns
|
|
283
|
+
|
|
284
|
+
**Trigger phrases:**
|
|
285
|
+
- "optimize my firestore performance..."
|
|
286
|
+
- "reduce firebase costs..."
|
|
287
|
+
- "why is this query slow..."
|
|
288
|
+
- "analyze my firestore usage..."
|
|
289
|
+
|
|
290
|
+
**Example:**
|
|
291
|
+
```
|
|
292
|
+
User: "Why is my users query so slow?"
|
|
293
|
+
|
|
294
|
+
Agent analyzes:
|
|
295
|
+
1. Query structure: .where('status', '==', 'active').where('createdAt', '>', date).orderBy('name')
|
|
296
|
+
2. Identifies: Missing composite index for (status, createdAt, name)
|
|
297
|
+
3. Calculates: 15,000 documents scanned for 100 results = 150x overhead
|
|
298
|
+
4. Recommends: Create index or denormalize data
|
|
299
|
+
5. Estimates: 50% cost reduction with index
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
---
|
|
303
|
+
|
|
304
|
+
## Configuration
|
|
305
|
+
|
|
306
|
+
### Environment Variables
|
|
307
|
+
|
|
308
|
+
```bash
|
|
309
|
+
# Required
|
|
310
|
+
GOOGLE_APPLICATION_CREDENTIALS="/path/to/serviceAccountKey.json"
|
|
311
|
+
|
|
312
|
+
# Optional
|
|
313
|
+
FIREBASE_PROJECT_ID="your-project-id" # Auto-detected from credentials
|
|
314
|
+
FIRESTORE_EMULATOR_HOST="localhost:8080" # For local development
|
|
315
|
+
FIREBASE_DATABASE_URL="https://your-db.firebaseio.com" # For Realtime Database
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
### firestore.config.js
|
|
319
|
+
|
|
320
|
+
```javascript
|
|
321
|
+
module.exports = {
|
|
322
|
+
// Project configuration
|
|
323
|
+
projectId: 'your-project-id',
|
|
324
|
+
|
|
325
|
+
// Batch operation settings
|
|
326
|
+
batchSize: 500, // Documents per batch write
|
|
327
|
+
maxConcurrentBatches: 3, // Parallel batch operations
|
|
328
|
+
|
|
329
|
+
// Query settings
|
|
330
|
+
defaultLimit: 100, // Default query limit
|
|
331
|
+
maxLimit: 1000, // Maximum allowed limit
|
|
332
|
+
|
|
333
|
+
// Cost optimization
|
|
334
|
+
enableCaching: true, // Cache frequently read documents
|
|
335
|
+
cacheTTL: 300, // Cache time-to-live (seconds)
|
|
336
|
+
|
|
337
|
+
// Migration settings
|
|
338
|
+
migrationBatchSize: 500, // Documents per migration batch
|
|
339
|
+
validateBeforeMigration: true, // Validate data before migrating
|
|
340
|
+
|
|
341
|
+
// Security
|
|
342
|
+
allowDangerousOperations: false, // Require confirmation for deletes
|
|
343
|
+
dryRun: false // Preview changes without executing
|
|
344
|
+
};
|
|
345
|
+
```
|
|
346
|
+
|
|
347
|
+
---
|
|
348
|
+
|
|
349
|
+
## Best Practices
|
|
350
|
+
|
|
351
|
+
### Security Rules
|
|
352
|
+
- **Never allow open access** - Always require authentication
|
|
353
|
+
- **Validate all writes** - Check field types and values
|
|
354
|
+
- **Limit read scope** - Only allow reading necessary data
|
|
355
|
+
- **Test rules thoroughly** - Use Firebase Emulator Suite
|
|
356
|
+
|
|
357
|
+
### Performance
|
|
358
|
+
- **Use indexes** - Create composite indexes for complex queries
|
|
359
|
+
- **Batch operations** - Use batch writes for multiple documents
|
|
360
|
+
- **Denormalize data** - Duplicate data to avoid joins
|
|
361
|
+
- **Paginate results** - Use cursor-based pagination for large datasets
|
|
362
|
+
|
|
363
|
+
### Cost Optimization
|
|
364
|
+
- **Cache frequently read data** - Use in-memory caching
|
|
365
|
+
- **Minimize document reads** - Use `select()` to read specific fields
|
|
366
|
+
- **Archive old data** - Move historical data to Cloud Storage
|
|
367
|
+
- **Monitor usage** - Set up billing alerts
|
|
368
|
+
|
|
369
|
+
### Data Modeling
|
|
370
|
+
- **Keep documents small** - Max 1MB per document
|
|
371
|
+
- **Use subcollections** - For nested data hierarchies
|
|
372
|
+
- **Plan for scale** - Design for millions of documents
|
|
373
|
+
- **Avoid hot documents** - Distribute writes across documents
|
|
374
|
+
|
|
375
|
+
---
|
|
376
|
+
|
|
377
|
+
## Common Patterns
|
|
378
|
+
|
|
379
|
+
### Pattern 1: User Profiles with Privacy
|
|
380
|
+
|
|
381
|
+
```javascript
|
|
382
|
+
// Collection structure
|
|
383
|
+
users/{userId}
|
|
384
|
+
- public: { name, avatar, bio } // Anyone can read
|
|
385
|
+
- private: { email, phone, address } // Only user can read
|
|
386
|
+
- settings: { notifications, privacy } // Only user can read/write
|
|
387
|
+
```
|
|
388
|
+
|
|
389
|
+
### Pattern 2: Real-time Chat
|
|
390
|
+
|
|
391
|
+
```javascript
|
|
392
|
+
// Collection structure
|
|
393
|
+
rooms/{roomId}
|
|
394
|
+
- metadata: { name, createdAt, memberCount }
|
|
395
|
+
- members/{userId}: { joinedAt, role }
|
|
396
|
+
|
|
397
|
+
messages/{messageId}
|
|
398
|
+
- roomId, userId, text, createdAt
|
|
399
|
+
|
|
400
|
+
// Query optimization
|
|
401
|
+
- Index: (roomId, createdAt) for fetching messages
|
|
402
|
+
- Denormalize: Store last message in room metadata
|
|
403
|
+
```
|
|
404
|
+
|
|
405
|
+
### Pattern 3: E-commerce Orders
|
|
406
|
+
|
|
407
|
+
```javascript
|
|
408
|
+
// Collection structure
|
|
409
|
+
orders/{orderId}
|
|
410
|
+
- userId, status, total, createdAt
|
|
411
|
+
- items: [ { productId, quantity, price } ] // Embedded array
|
|
412
|
+
|
|
413
|
+
// Status workflow
|
|
414
|
+
pending → processing → shipped → delivered
|
|
415
|
+
|
|
416
|
+
// Indexes
|
|
417
|
+
- (userId, createdAt) - User order history
|
|
418
|
+
- (status, createdAt) - Admin order management
|
|
419
|
+
```
|
|
420
|
+
|
|
421
|
+
---
|
|
422
|
+
|
|
423
|
+
## Troubleshooting
|
|
424
|
+
|
|
425
|
+
### Error: Permission Denied
|
|
426
|
+
|
|
427
|
+
```bash
|
|
428
|
+
# Check security rules
|
|
429
|
+
firebase firestore:rules:get
|
|
430
|
+
|
|
431
|
+
# Test rules locally
|
|
432
|
+
firebase emulators:start --only firestore
|
|
433
|
+
|
|
434
|
+
# Ask agent for help
|
|
435
|
+
"Why am I getting permission denied when reading /users/user123?"
|
|
436
|
+
```
|
|
437
|
+
|
|
438
|
+
### Error: Missing Index
|
|
439
|
+
|
|
440
|
+
```bash
|
|
441
|
+
# Agent will detect and create index automatically
|
|
442
|
+
"Create an index for querying users by (status, createdAt)"
|
|
443
|
+
|
|
444
|
+
# Or manually
|
|
445
|
+
firebase firestore:indexes
|
|
446
|
+
|
|
447
|
+
# Deploy
|
|
448
|
+
firebase deploy --only firestore:indexes
|
|
449
|
+
```
|
|
450
|
+
|
|
451
|
+
### Error: Rate Limits
|
|
452
|
+
|
|
453
|
+
```bash
|
|
454
|
+
# Agent handles rate limits automatically with exponential backoff
|
|
455
|
+
# For custom handling:
|
|
456
|
+
"Batch update 50,000 users with rate limit handling"
|
|
457
|
+
```
|
|
458
|
+
|
|
459
|
+
### Error: Invalid Credentials
|
|
460
|
+
|
|
461
|
+
```bash
|
|
462
|
+
# Verify service account
|
|
463
|
+
gcloud auth application-default login
|
|
464
|
+
|
|
465
|
+
# Or set environment variable
|
|
466
|
+
export GOOGLE_APPLICATION_CREDENTIALS="/path/to/serviceAccountKey.json"
|
|
467
|
+
|
|
468
|
+
# Verify
|
|
469
|
+
firebase projects:list
|
|
470
|
+
```
|
|
471
|
+
|
|
472
|
+
---
|
|
473
|
+
|
|
474
|
+
## Advanced Features
|
|
475
|
+
|
|
476
|
+
### Cloud Functions Integration
|
|
477
|
+
|
|
478
|
+
```javascript
|
|
479
|
+
// Trigger Cloud Functions from Firestore
|
|
480
|
+
"Create a function that sends an email when a new user signs up"
|
|
481
|
+
|
|
482
|
+
Agent creates:
|
|
483
|
+
exports.sendWelcomeEmail = functions.firestore
|
|
484
|
+
.document('users/{userId}')
|
|
485
|
+
.onCreate(async (snap, context) => {
|
|
486
|
+
const user = snap.data();
|
|
487
|
+
await sendEmail(user.email, 'Welcome!');
|
|
488
|
+
});
|
|
489
|
+
```
|
|
490
|
+
|
|
491
|
+
### Backup and Restore
|
|
492
|
+
|
|
493
|
+
```bash
|
|
494
|
+
# Export collection
|
|
495
|
+
"Export the users collection to JSON"
|
|
496
|
+
|
|
497
|
+
# Import data
|
|
498
|
+
"Import users from backup.json to the staging environment"
|
|
499
|
+
|
|
500
|
+
# Schedule backups
|
|
501
|
+
"Set up daily backups of all collections to Cloud Storage"
|
|
502
|
+
```
|
|
503
|
+
|
|
504
|
+
### Multi-Project Management
|
|
505
|
+
|
|
506
|
+
```bash
|
|
507
|
+
# Switch between projects
|
|
508
|
+
"Use the staging Firebase project"
|
|
509
|
+
"Switch back to production"
|
|
510
|
+
|
|
511
|
+
# Copy data between projects
|
|
512
|
+
"Copy the test users from staging to production"
|
|
513
|
+
```
|
|
514
|
+
|
|
515
|
+
---
|
|
516
|
+
|
|
517
|
+
## Performance Benchmarks
|
|
518
|
+
|
|
519
|
+
| Operation | Without Plugin | With Plugin | Improvement |
|
|
520
|
+
|-----------|----------------|-------------|-------------|
|
|
521
|
+
| Single document write | 50ms | 45ms | 1.1x |
|
|
522
|
+
| Batch write (500 docs) | 25s | 2.5s | 10x |
|
|
523
|
+
| Complex query | 5s | 500ms | 10x (with index) |
|
|
524
|
+
| Migration (10k docs) | Manual 2hrs | 5 minutes | 24x |
|
|
525
|
+
| Security rule generation | Manual 30min | 2 minutes | 15x |
|
|
526
|
+
|
|
527
|
+
---
|
|
528
|
+
|
|
529
|
+
## Integration Examples
|
|
530
|
+
|
|
531
|
+
### Next.js App
|
|
532
|
+
|
|
533
|
+
```javascript
|
|
534
|
+
// pages/api/users.js
|
|
535
|
+
import admin from 'firebase-admin';
|
|
536
|
+
|
|
537
|
+
// Agent sets up admin SDK automatically
|
|
538
|
+
export default async function handler(req, res) {
|
|
539
|
+
const users = await admin.firestore()
|
|
540
|
+
.collection('users')
|
|
541
|
+
.limit(10)
|
|
542
|
+
.get();
|
|
543
|
+
|
|
544
|
+
res.json(users.docs.map(doc => doc.data()));
|
|
545
|
+
}
|
|
546
|
+
```
|
|
547
|
+
|
|
548
|
+
### React App
|
|
549
|
+
|
|
550
|
+
```javascript
|
|
551
|
+
// hooks/useFirestore.js
|
|
552
|
+
import { getFirestore, collection, query, where } from 'firebase/firestore';
|
|
553
|
+
|
|
554
|
+
// Agent generates custom hooks
|
|
555
|
+
export function useUserOrders(userId) {
|
|
556
|
+
const [orders, setOrders] = useState([]);
|
|
557
|
+
|
|
558
|
+
useEffect(() => {
|
|
559
|
+
const q = query(
|
|
560
|
+
collection(db, 'orders'),
|
|
561
|
+
where('userId', '==', userId)
|
|
562
|
+
);
|
|
563
|
+
// ... subscribe to query
|
|
564
|
+
}, [userId]);
|
|
565
|
+
|
|
566
|
+
return orders;
|
|
567
|
+
}
|
|
568
|
+
```
|
|
569
|
+
|
|
570
|
+
### Cloud Functions
|
|
571
|
+
|
|
572
|
+
```javascript
|
|
573
|
+
// functions/index.js
|
|
574
|
+
const admin = require('firebase-admin');
|
|
575
|
+
admin.initializeApp();
|
|
576
|
+
|
|
577
|
+
// Agent creates Cloud Functions
|
|
578
|
+
exports.onUserCreate = functions.firestore
|
|
579
|
+
.document('users/{userId}')
|
|
580
|
+
.onCreate(async (snap) => {
|
|
581
|
+
// Send welcome email, create profile, etc.
|
|
582
|
+
});
|
|
583
|
+
```
|
|
584
|
+
|
|
585
|
+
---
|
|
586
|
+
|
|
587
|
+
## Resources
|
|
588
|
+
|
|
589
|
+
### Firebase Documentation
|
|
590
|
+
- [Firestore Documentation](https://firebase.google.com/docs/firestore)
|
|
591
|
+
- [Security Rules](https://firebase.google.com/docs/firestore/security/get-started)
|
|
592
|
+
- [Best Practices](https://firebase.google.com/docs/firestore/best-practices)
|
|
593
|
+
|
|
594
|
+
### Plugin Resources
|
|
595
|
+
- [GitHub Repository](https://github.com/jeremylongshore/claude-code-plugins)
|
|
596
|
+
- [Issue Tracker](https://github.com/jeremylongshore/claude-code-plugins/issues)
|
|
597
|
+
- [Marketplace](https://claudecodeplugins.io/)
|
|
598
|
+
|
|
599
|
+
### Community
|
|
600
|
+
- [Discord](https://discord.com/invite/6PPFFzqPDZ) (#claude-code channel)
|
|
601
|
+
- [GitHub Discussions](https://github.com/jeremylongshore/claude-code-plugins/discussions)
|
|
602
|
+
|
|
603
|
+
---
|
|
604
|
+
|
|
605
|
+
## License
|
|
606
|
+
|
|
607
|
+
MIT License - see [LICENSE](LICENSE) file for details
|
|
608
|
+
|
|
609
|
+
---
|
|
610
|
+
|
|
611
|
+
## Support
|
|
612
|
+
|
|
613
|
+
Need help? Open an issue on GitHub or ask in Discord!
|
|
614
|
+
|
|
615
|
+
**Made with** by [Jeremy Longshore](https://intentsolutions.io)
|