firebase-development
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseFirebase Development
Firebase开发
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:
- - Initialize new Firebase projects
firebase-development:project-setup - - Add functions/collections/endpoints
firebase-development:add-feature - - Troubleshoot emulator and runtime issues
firebase-development:debug - - Review Firebase code for security/patterns
firebase-development:validate
该技能系统借助生产项目中验证有效的模式,指导Firebase开发工作。它会根据检测到的意图,将任务路由到对应的专业子技能。
子技能:
- - 初始化新的Firebase项目
firebase-development:project-setup - - 添加函数/集合/端点
firebase-development:add-feature - - 排查模拟器和运行时问题
firebase-development:debug - - 审核Firebase代码的安全性与模式规范
firebase-development:validate
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)
- 启动新的Firebase项目
- 添加Cloud Functions或Firestore集合
- 调试模拟器问题或规则违规情况
- 审核Firebase代码的安全性与模式规范
- 配置多托管环境
- 实现认证功能(API密钥或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"
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
- 分析请求:检查是否包含路由关键词
- 匹配子技能:根据关键词密度确定最佳匹配项
- 告知用户:"我将使用firebase-development:[子技能]技能来执行[操作]"
- 路由任务:加载并执行对应的子技能
- 回退机制:若意图不明确,使用AskUserQuestion功能提供4个选项
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)当意图不清晰时,询问:
问题:"你正在处理哪项Firebase任务?"
选项:
- "项目搭建"(初始化新的Firebase项目)
- "添加功能"(添加函数、集合、端点)
- "调试问题"(排查错误或故障)
- "代码验证"(对照模式规范进行审核)Reference Projects
参考项目
Patterns are extracted from three production Firebase projects:
| Project | Path | Key Patterns |
|---|---|---|
| oneonone | | Express API, custom API keys, server-write-only |
| bot-socialmedia | | Domain-grouped functions, Firebase Auth + roles |
| meme-rodeo | | Individual function files, entitlements |
所有模式均提取自三个生产环境中的Firebase项目:
| 项目 | 路径 | 核心模式 |
|---|---|---|
| oneonone | | Express API、自定义API密钥、仅服务器可写入 |
| bot-socialmedia | | 按领域分组的函数、Firebase Auth + 角色权限 |
| meme-rodeo | | 独立函数文件、权限管理 |
Pattern Summaries
模式总结
Multi-Hosting Setup
多托管配置
Three options based on needs:
| Option | When to Use | Key Feature |
|---|---|---|
| Multiple independent URLs | Simple, no build coordination |
| Need predeploy hooks | Build scripts run automatically |
| Single + rewrites | Smaller projects | All under one domain |
Details: See
docs/examples/multi-hosting-setup.md根据需求提供三种选项:
| 选项 | 适用场景 | 核心特性 |
|---|---|---|
基于 | 多个独立URL | 配置简单,无需构建协调 |
基于 | 需要预部署钩子 | 构建脚本自动运行 |
| 单域名+重写 | 小型项目 | 所有内容统一在一个域名下 |
详情: 参见
docs/examples/multi-hosting-setup.mdAuthentication
认证模式
| 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| 模式 | 适用场景 | 示例项目 |
|---|---|---|
| 自定义API密钥 | MCP工具、服务器到服务器通信 | oneonone |
| Firebase Auth + 角色权限 | 面向用户的应用 | bot-socialmedia |
| 混合模式 | 同时需要上述两种模式 | Web UI + API访问 |
详情: 参见
docs/examples/api-key-authentication.mdCloud Functions Architecture
Cloud Functions架构
| Pattern | When to Use | Structure |
|---|---|---|
| Express app | API with middleware, routing | |
| Domain-grouped | Feature-rich apps | |
| Individual files | Maximum modularity | One function per file |
Details: See
docs/examples/express-function-architecture.md| 模式 | 适用场景 | 结构 |
|---|---|---|
| Express应用 | 带中间件、路由的API | |
| 按领域分组 | 功能丰富的应用 | |
| 独立文件模式 | 最大化模块化 | 每个函数对应一个文件 |
详情: 参见
docs/examples/express-function-architecture.mdSecurity 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| 模型 | 适用场景 | 复杂度 |
|---|---|---|
| 仅服务器可写入 | 低写入量应用、高安全性需求 | 规则简单 |
| 客户端可写入+验证 | 高写入量应用、实时需求 | 规则复杂 |
强烈推荐在低写入量应用中使用仅服务器可写入模型。
详情: 参见
docs/examples/firestore-rules-patterns.mdEmulator-First Development
优先使用模拟器开发
Always develop locally with emulators:
bash
firebase emulators:start始终在本地使用模拟器进行开发:
bash
firebase emulators:startAccess UI at http://127.0.0.1:4000
访问UI界面: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`
**firebase.json中的关键设置:**
- `singleProjectMode: true` - 模拟器协同工作的必要配置
- `ui.enabled: true` - 启用调试UI界面
**详情:** 参见`docs/examples/emulator-workflow.md`Modern Tooling Standards
现代工具标准
All Firebase projects follow these standards:
| Tool | Purpose | Config File |
|---|---|---|
| TypeScript | Type safety | |
| vitest | Testing | |
| biome | Linting + formatting | |
所有Firebase项目均遵循以下标准:
| 工具 | 用途 | 配置文件 |
|---|---|---|
| TypeScript | 类型安全 | |
| vitest | 测试 | |
| biome | 代码检查+格式化 | |
ABOUTME Comment Pattern
ABOUTME注释规范
Every TypeScript file starts with 2-line ABOUTME comment:
typescript
// ABOUTME: Brief description of what this file does
// ABOUTME: Second line with additional context每个TypeScript文件开头必须包含两行ABOUTME注释:
typescript
// ABOUTME: 简要描述该文件的功能
// ABOUTME: 第二行补充额外上下文信息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 | |
| 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 | |
| 问题 | 解决方案 |
|---|---|
| 模拟器端口被占用 | 执行 |
| Admin SDK与Client SDK的区别 | Admin SDK绕过规则限制,Client SDK遵循规则 |
| 冷启动延迟 | 首次调用耗时5-10秒,属于正常现象 |
| 数据持久化 | 使用Ctrl+C(而非kill命令)导出数据 |
| 函数中的CORS问题 | 添加 |
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:
- - Initialize new projects
firebase-development:project-setup - - Add functions/collections
firebase-development:add-feature - - Troubleshoot issues
firebase-development:debug - - Review code
firebase-development:validate
该协调器会将任务路由到对应的专业子技能:
- 通过关键词检测用户意图
- 路由到合适的子技能
- 子技能使用TodoWrite检查清单
- 所有内容均参考中的共享模式
docs/examples/
子技能:
- - 初始化新项目
firebase-development:project-setup - - 添加函数/集合
firebase-development:add-feature - - 排查问题
firebase-development:debug - - 审核代码
firebase-development:validate