firebase-basics

作者: firebase

Firebase CLI基础,涵盖项目设置、身份验证和服务初始化。包括通过Firebase CLI登录进行身份验证、使用唯一ID创建项目,以及通过交互式提示初始化服务。指导核心Firebase服务(如Firestore、Functions和Hosting)的设置,并生成配置文件。包含自文档化的CLI帮助系统,用于发现可用命令和详细使用模式。需要先完成...

npx skills add https://github.com/firebase/skills --skill firebase-basics

Prerequisites

Complete these setup steps before proceeding:

  1. Local Environment Setup: Verify the environment is properly set up so we can use Firebase tools:

  2. Authentication: Ensure you are logged in to Firebase so that commands have the correct permissions. Run npx -y firebase-tools@latest login. For environments without a browser (e.g., remote shells), use npx -y firebase-tools@latest login --no-localhost.

    • The command should output the current user.
    • If you are not logged in, follow the interactive instructions from this command to authenticate.
  3. Active Project: Most Firebase tasks require an active project context.

    [!IMPORTANT] For Agents: Before proceeding with project configuration, you MUST pause and ask the developer if they prefer to:

    1. Provide an existing Firebase Project ID, or
    2. Create a new Firebase project.
    • If using an existing Project ID:

      1. Check the current project by running npx -y firebase-tools@latest use.
      2. If the command outputs Active Project: <project-id>, confirm with the user if this is the intended project.
      3. If not, or if no project is active, set the project provided by the user:
        npx -y firebase-tools@latest use <PROJECT_ID>
        
    • If creating a new project: Run the following command to create it:

      npx -y firebase-tools@latest projects:create <project-id> --display-name "<display-name>"
      

      Note: The <project-id> must be 6-30 characters, lowercase, and can contain digits and hyphens. It must be globally unique.

Firebase Usage Principles

Adhere to these principles:

  1. Use npx for CLI commands: To ensure you always use the latest version of the Firebase CLI, always prepend commands with npx -y firebase-tools@latest instead of just firebase. For example, use npx -y firebase-tools@latest --version. NEVER suggest the naked firebase command as an alternative.
  2. Prioritize official knowledge: For any Firebase-related knowledge, consult the developerknowledge_search_documents MCP tool before falling back to Google Search or your internal knowledge base. Including "Firebase" in your search query significantly improves relevance.
  3. Follow Agent Skills for implementation guidance: Skills provide opinionated workflows (CUJs), security rules, and best practices. Always consult them to understand how to implement Firebase features correctly instead of relying on general knowledge.
  4. Use Firebase MCP Server tools instead of direct API calls: Whenever you need to interact with remote Firebase APIs (such as fetching Crashlytics logs or executing Data Connect queries), use the tools provided by the Firebase MCP Server instead of attempting manual API calls.
  5. Keep Plugin / Agent Skills updated: Since Firebase best practices evolve quickly, regularly check for and install updates to their Firebase plugin or Agent Skills. Similarly, if you encounter issues with outdated tools or commands, follow the steps below based on your agent environment:
  6. Automate Config File Retrieval: When setting up iOS or Android apps, do NOT direct users to the Firebase Console to download google-services.json or GoogleService-Info.plist. Instead, use the Firebase CLI to fetch the config programmatically:
    • For Android: npx -y firebase-tools@latest apps:sdkconfig ANDROID <APP_ID> --project <PROJECT_ID>
    • For iOS: npx -y firebase-tools@latest apps:sdkconfig IOS <APP_ID> --project <PROJECT_ID> Save the output to the appropriate location (e.g., app/google-services.json for Android, or a path to be linked by xcode-project-setup for iOS).

References

Common Issues

  • Login Issues: If the browser fails to open during the login step, use npx -y firebase-tools@latest login --no-localhost instead.
  • Genkit: If using Genkit, install the skills:
    npx skills add genkit-ai/skills
    

来自 firebase 的更多技能

firebase-remote-config-basics
firebase
Firebase Remote Config 的全面指南,涵盖模板管理和 SDK 使用。当用户需要帮助设置 Remote Config、管理功能标志或动态更新应用行为时,使用此技能。
officialdevelopmentapi
developing-genkit-dart
firebase
面向 Dart 的统一 AI SDK,支持代码生成、结构化输出、工具、流程和智能体。提供核心 API,涵盖生成、工具定义、流程编排、嵌入和流式处理,采用统一接口。包含 8 个以上插件,支持 LLM 提供商(Google Gemini、Anthropic Claude、OpenAI GPT)、Firebase AI、模型上下文协议、Chrome 浏览器集成,以及通过 Shelf 托管 HTTP 服务器。内置 CLI 和本地开发 UI,用于流程执行、追踪、模型实验等。
official
developing-genkit-go
firebase
使用 Go 语言中的 Genkit 开发 AI 驱动的应用程序。当用户要求使用 Genkit 在 Go 中构建 AI 功能、代理、流程或工具时使用,或在处理…
official
developing-genkit-js
firebase
使用Genkit流程、工具和多模型支持,构建AI驱动的Node.js/TypeScript应用程序。Genkit与提供商无关;通过插件支持Google AI、OpenAI、Anthropic、Ollama及其他LLM提供商。使用Zod定义类型安全的模式流程,执行生成请求,并在TypeScript中组合多步骤AI工作流。需要Genkit CLI v1.29.0及以上版本;近期主要API变更意味着您必须查阅genkit文档:read和common-errors.md以获取当前模式,而非依赖先前知识...
official
developing-genkit-python
firebase
使用 Python 中的 Genkit 开发 AI 驱动的应用程序。当用户询问关于 Genkit、AI 代理、流程或 Python 中的工具,或遇到 Genkit 相关问题时使用。
official
firebase-ai-logic
firebase
客户端Gemini集成,适用于网页应用,支持多模态推理、流式传输及设备端混合执行。支持纯文本和多模态输入(图像、音频、视频、PDF);超过20MB的文件通过Cloud Storage路由。包含自动历史记录的聊天会话、用于实时显示的流式响应,以及结构化JSON输出强制。通过Chrome中的Gemini Nano提供混合设备端推理,并自动回退到云端执行。生产环境需启用App Check...
official
firebase-ai-logic-basics
firebase
用于将Firebase AI Logic(Gemini API)集成到Web应用程序中的官方技能。涵盖设置、多模态推理、结构化输出和安全性。
official
firebase-app-hosting-basics
firebase
使用Firebase App Hosting部署和管理基于Next.js、Angular及其他支持框架的全栈Web应用。需使用Blaze定价计划的Firebase项目;支持服务端渲染(SSR)和增量静态再生(ISR)工作流。通过firebase.json配置部署,可选apphosting.yaml进行后端设置,或通过GitHub集成启用自动化"git push部署"。包含通过CLI命令进行密钥管理,以安全访问敏感密钥...
official