Firebase Development
Overview
This skill system guides Firebase development using proven patterns from production projects. It routes to specialized sub-skills based on detected intent.
Sub-skills:
firebase-development:project-setup - Initialize new Firebase projects
firebase-development:add-feature - Add functions/collections/endpoints
firebase-development:debug - Troubleshoot emulator and runtime issues
firebase-development:validate - Review Firebase code for security/patterns
When This Skill Applies
- Starting new Firebase projects
- Adding Cloud Functions or Firestore collections
- Debugging emulator issues or rule violations
- Reviewing Firebase code for security and patterns
- Setting up multi-hosting configurations
- Implementing authentication (API keys or Firebase Auth)
Routing Logic
Keywords by Sub-Skill
project-setup:
- "new firebase project", "initialize firebase", "firebase init"
- "set up firebase", "create firebase app", "start firebase project"
add-feature:
- "add function", "create endpoint", "new tool", "add api"
- "new collection", "add feature", "build", "implement"
debug:
- "error", "not working", "debug", "emulator issue"
- "rules failing", "permission denied", "troubleshoot", "deployment failed"
validate:
- "review firebase", "check firebase", "validate", "audit firebase"
- "look at firebase code", "security review"
Routing Process
- Analyze Request: Check for routing keywords
- Match Sub-Skill: Identify best match based on keyword density
- Announce: "I'm using the firebase-development:[sub-skill] skill to [action]"
- Route: Load and execute the sub-skill
- Fallback: If ambiguous, use AskUserQuestion with 4 options
Fallback Example
If intent is unclear, ask:
Question: "What Firebase task are you working on?"
Options:
- "Project Setup" (Initialize new Firebase project)
- "Add Feature" (Add functions, collections, endpoints)
- "Debug Issue" (Troubleshoot errors or problems)
- "Validate Code" (Review against patterns)
Reference Projects
Patterns are extracted from three production Firebase projects:
| Project |
Path |
Key Patterns |
| oneonone |
/Users/dylanr/work/2389/oneonone |
Express API, custom API keys, server-write-only |
| bot-socialmedia |
/Users/dylanr/work/2389/bot-socialmedia-server |
Domain-grouped functions, Firebase Auth + roles |
| meme-rodeo |
/Users/dylanr/work/2389/meme-rodeo |
Individual function files, entitlements |
Pattern Summaries
Multi-Hosting Setup
Three options based on needs:
| Option |
When to Use |
Key Feature |
site: based |
Multiple independent URLs |
Simple, no build coordination |
target: based |
Need predeploy hooks |
Build scripts run automatically |
| Single + rewrites |
Smaller projects |
All under one domain |
Details: See docs/examples/multi-hosting-setup.md
Authentication
| Pattern |
When to Use |
Example |
| Custom API keys |
MCP tools, server-to-server |
oneonone |
| Firebase Auth + roles |
User-facing apps |
bot-socialmedia |
| Hybrid |
Both patterns needed |
Web UI + API access |
Details: See docs/examples/api-key-authentication.md
Cloud Functions Architecture
| Pattern |
When to Use |
Structure |
| Express app |
API with middleware, routing |
app.post('/mcp', handler) |
| Domain-grouped |
Feature-rich apps |
posts.ts, journal.ts |
| Individual files |
Maximum modularity |
One function per file |
Details: See docs/examples/express-function-architecture.md
Security Model
| Model |
When to Use |
Complexity |
| Server-write-only |
Light-write apps, high security |
Simple rules |
| Client-write + validation |
High-volume writes, real-time |
Complex rules |
Strongly prefer server-write-only for light-write applications.
Details: See docs/examples/firestore-rules-patterns.md
Emulator-First Development
Always develop locally with emulators:
firebase emulators:start
# Access UI at http://127.0.0.1:4000
Key settings in firebase.json:
singleProjectMode: true - Essential for emulators to work together
ui.enabled: true - Access debug UI
Details: See docs/examples/emulator-workflow.md
Modern Tooling Standards
All Firebase projects follow these standards:
| Tool |
Purpose |
Config File |
| TypeScript |
Type safety |
tsconfig.json |
| vitest |
Testing |
vitest.config.ts |
| biome |
Linting + formatting |
biome.json |
ABOUTME Comment Pattern
Every TypeScript file starts with 2-line ABOUTME comment:
// ABOUTME: Brief description of what this file does
// ABOUTME: Second line with additional context
Testing Requirements
- Unit tests: Test handlers/utilities in isolation
- Integration tests: Test with emulators running
- Both required for every feature
Common Gotchas
| Issue |
Solution |
| Emulator ports in use |
lsof -i :5001, kill process |
| Admin SDK vs Client SDK |
Admin bypasses rules, client respects rules |
| Cold start delays |
First call takes 5-10s, normal |
| Data persistence |
Use Ctrl+C (not kill) to export data |
| CORS in functions |
app.use(cors({ origin: true })) |
Summary
This orchestrator routes to specialized sub-skills:
- Detects intent via keywords
- Routes to appropriate sub-skill
- Sub-skills use TodoWrite checklists
- All reference shared patterns in
docs/examples/
Sub-Skills:
firebase-development:project-setup - Initialize new projects
firebase-development:add-feature - Add functions/collections
firebase-development:debug - Troubleshoot issues
firebase-development:validate - Review code
1---2name: firebase-development3description: This skill should be used when working with Firebase projects, including initializing projects, adding Cloud Functions or Firestore collections, debugging emulator issues, or reviewing Firebase code. Triggers on "firebase", "firestore", "cloud functions", "emulator", "firebase auth", "deploy to firebase", "firestore rules".4---56# Firebase Development78## Overview910This skill system guides Firebase development using proven patterns from production projects. It routes to specialized sub-skills based on detected intent.1112**Sub-skills:**13- `firebase-development:project-setup` - Initialize new Firebase projects14- `firebase-development:add-feature` - Add functions/collections/endpoints15- `firebase-development:debug` - Troubleshoot emulator and runtime issues16- `firebase-development:validate` - Review Firebase code for security/patterns1718## When This Skill Applies1920- Starting new Firebase projects21- Adding Cloud Functions or Firestore collections22- Debugging emulator issues or rule violations23- Reviewing Firebase code for security and patterns24- Setting up multi-hosting configurations25- Implementing authentication (API keys or Firebase Auth)2627## Routing Logic2829### Keywords by Sub-Skill3031**project-setup:**32- "new firebase project", "initialize firebase", "firebase init"33- "set up firebase", "create firebase app", "start firebase project"3435**add-feature:**36- "add function", "create endpoint", "new tool", "add api"37- "new collection", "add feature", "build", "implement"3839**debug:**40- "error", "not working", "debug", "emulator issue"41- "rules failing", "permission denied", "troubleshoot", "deployment failed"4243**validate:**44- "review firebase", "check firebase", "validate", "audit firebase"45- "look at firebase code", "security review"4647### Routing Process48491. **Analyze Request**: Check for routing keywords502. **Match Sub-Skill**: Identify best match based on keyword density513. **Announce**: "I'm using the firebase-development:[sub-skill] skill to [action]"524. **Route**: Load and execute the sub-skill535. **Fallback**: If ambiguous, use AskUserQuestion with 4 options5455### Fallback Example5657If intent is unclear, ask:5859```60Question: "What Firebase task are you working on?"61Options:62 - "Project Setup" (Initialize new Firebase project)63 - "Add Feature" (Add functions, collections, endpoints)64 - "Debug Issue" (Troubleshoot errors or problems)65 - "Validate Code" (Review against patterns)66```6768## Reference Projects6970Patterns are extracted from three production Firebase projects:7172| Project | Path | Key Patterns |73|---------|------|--------------|74| **oneonone** | `/Users/dylanr/work/2389/oneonone` | Express API, custom API keys, server-write-only |75| **bot-socialmedia** | `/Users/dylanr/work/2389/bot-socialmedia-server` | Domain-grouped functions, Firebase Auth + roles |76| **meme-rodeo** | `/Users/dylanr/work/2389/meme-rodeo` | Individual function files, entitlements |7778## Pattern Summaries7980### Multi-Hosting Setup8182Three options based on needs:8384| Option | When to Use | Key Feature |85|--------|-------------|-------------|86| `site:` based | Multiple independent URLs | Simple, no build coordination |87| `target:` based | Need predeploy hooks | Build scripts run automatically |88| Single + rewrites | Smaller projects | All under one domain |8990**Details:** See `docs/examples/multi-hosting-setup.md`9192### Authentication9394| Pattern | When to Use | Example |95|---------|-------------|---------|96| Custom API keys | MCP tools, server-to-server | oneonone |97| Firebase Auth + roles | User-facing apps | bot-socialmedia |98| Hybrid | Both patterns needed | Web UI + API access |99100**Details:** See `docs/examples/api-key-authentication.md`101102### Cloud Functions Architecture103104| Pattern | When to Use | Structure |105|---------|-------------|-----------|106| Express app | API with middleware, routing | `app.post('/mcp', handler)` |107| Domain-grouped | Feature-rich apps | `posts.ts`, `journal.ts` |108| Individual files | Maximum modularity | One function per file |109110**Details:** See `docs/examples/express-function-architecture.md`111112### Security Model113114| Model | When to Use | Complexity |115|-------|-------------|------------|116| Server-write-only | Light-write apps, high security | Simple rules |117| Client-write + validation | High-volume writes, real-time | Complex rules |118119**Strongly prefer server-write-only** for light-write applications.120121**Details:** See `docs/examples/firestore-rules-patterns.md`122123### Emulator-First Development124125Always develop locally with emulators:126127```bash128firebase emulators:start129# Access UI at http://127.0.0.1:4000130```131132**Key settings in firebase.json:**133- `singleProjectMode: true` - Essential for emulators to work together134- `ui.enabled: true` - Access debug UI135136**Details:** See `docs/examples/emulator-workflow.md`137138## Modern Tooling Standards139140All Firebase projects follow these standards:141142| Tool | Purpose | Config File |143|------|---------|-------------|144| TypeScript | Type safety | `tsconfig.json` |145| vitest | Testing | `vitest.config.ts` |146| biome | Linting + formatting | `biome.json` |147148### ABOUTME Comment Pattern149150Every TypeScript file starts with 2-line ABOUTME comment:151152```typescript153// ABOUTME: Brief description of what this file does154// ABOUTME: Second line with additional context155```156157### Testing Requirements158159- **Unit tests**: Test handlers/utilities in isolation160- **Integration tests**: Test with emulators running161- Both required for every feature162163## Common Gotchas164165| Issue | Solution |166|-------|----------|167| Emulator ports in use | `lsof -i :5001`, kill process |168| Admin SDK vs Client SDK | Admin bypasses rules, client respects rules |169| Cold start delays | First call takes 5-10s, normal |170| Data persistence | Use Ctrl+C (not kill) to export data |171| CORS in functions | `app.use(cors({ origin: true }))` |172173## Summary174175This orchestrator routes to specialized sub-skills:1761771. Detects intent via keywords1782. Routes to appropriate sub-skill1793. Sub-skills use TodoWrite checklists1804. All reference shared patterns in `docs/examples/`181182**Sub-Skills:**183- `firebase-development:project-setup` - Initialize new projects184- `firebase-development:add-feature` - Add functions/collections185- `firebase-development:debug` - Troubleshoot issues186- `firebase-development:validate` - Review code