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
統一AI SDK for Dart,支援程式碼生成、結構化輸出、工具、流程與代理。提供核心API用於生成、工具定義、流程編排、嵌入與串流,並具備單一介面。包含8個以上外掛程式,支援LLM提供者(Google Gemini、Anthropic Claude、OpenAI GPT)、Firebase AI、模型上下文協定、Chrome瀏覽器整合,以及透過Shelf進行HTTP伺服器託管。內建CLI與本地開發UI,用於流程執行、追蹤、模型實驗等。
official
developing-genkit-go
firebase
使用 Genkit 在 Go 中開發 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);超過20 MB的檔案會透過Cloud Storage路由。包含自動記錄歷史的聊天會話、即時顯示的串流回應,以及強制結構化JSON輸出。透過Chrome中的Gemini Nano提供裝置端混合推論,並自動備援至雲端執行。正式環境需啟用App Check...
official
firebase-ai-logic-basics
firebase
用於將 Firebase AI Logic(Gemini API)整合至網頁應用程式的官方技能,涵蓋設定、多模態推論、結構化輸出及安全性。
official
firebase-app-hosting-basics
firebase
使用 Firebase App Hosting 搭配 Next.js、Angular 及其他支援的框架,部署與管理全端網頁應用程式。需使用 Blaze 計費方案的 Firebase 專案;支援伺服器端渲染(SSR)與增量靜態再生(ISR)工作流程。可透過 firebase.json 設定檔進行部署,並選擇性使用 apphosting.yaml 設定後端,或啟用 GitHub 整合的自動化「git push 部署」。包含透過 CLI 指令管理機密資訊,以安全存取敏感金鑰...
official