# SkillPatch skill: firebase-basics

This skill guides agents through setting up and using Firebase products and services for mobile or web apps. It includes mandatory prerequisite steps (verifying NPM, installing Firebase agent skills), a quick-start workflow for CLI login and project setup, and a reference directory for Firebase core concepts, CLI usage, security, and more.

You (the agent) were given this URL and asked to use this skill. This is a **public** skill — no SkillPatch account, API key, or prior setup is required. Two ways to use it:

**1. Use it right now** — the skill's complete file tree (SKILL.md + all reference files) is inlined below; read `SKILL.md` first, then follow it, consulting the other files as it directs.

**2. Install the exact package onto disk** (recommended if you can run a shell — this reproduces the skill byte-for-byte, including any binary assets that can't be inlined):

```bash
mkdir -p .claude/skills/firebase-basics
curl -sSL https://skillpatch.dev/install_skill/firebase-basics | tar -xz -C .claude/skills/
```

(`.claude/skills/` is Claude Code's convention; use whatever directory your agent loads skills from.)


---

## Skill files (8)

- `SKILL.md`
- `references/additional-skills.md`
- `references/cli-usage.md`
- `references/client-library-usage.md`
- `references/core-concepts.md`
- `references/iac-usage.md`
- `references/iam-security.md`
- `references/mcp-usage.md`


### `SKILL.md`

````markdown
---
name: firebase-basics
metadata:
  category: Serverless
description: Use this skill whenever you are working on a project that uses Firebase products or services, especially for mobile or web apps.
---

# Firebase Basics

### **CRITICAL** Mandatory prerequisites

Before attempting to fulfill any user request regarding Firebase, you **MUST**
follow these steps in order. Do not proceed to implementation until these are
completed. Failure to follow these instructions may result in using outdated
patterns and lack of access to essential reference materials.

1.  **Leverage the planning phase**

    If you use a planning mode (e.g., maintaining a `task.md` file), you
    **MUST** include a task to check and install `firebase/agent-skills` as your
    very first item.

2.  **Ensure NPM is installed.**

    ```bash
    ## Check if NPM is installed
    npm --version
    ```

    If NPM is not installed, guide the user to download and install the
    LTS version from https://nodejs.org/en/download.

    Then, request the user to manually install Node.js and to reply with a
    confirmation that the installation is finished. **Stop and wait** for the
    user's confirmation.

3.  **Verify and install Agent Skills for Firebase**

    You **MUST** ensure the full set of skills is installed to avoid using
    outdated patterns. Run this command:

    ```bash
    npx -y skills add firebase/agent-skills -y
    ```

    *If the skills are already installed, this command will ensure they are up
    to date. Do not skip this step.*

## Quick start

After completing the mandatory prerequisites above, proceed with these steps to
set up your environment:

1.  **Log in to the Firebase CLI.**

    Run this command:

    ```bash
    npx -y firebase-tools@latest login
    ```

    Then, ask the user to complete the login flow in the browser.

2.  **Set an active project for the CLI.**

    Most Firebase tasks require an active project context. Check the current
    project for the Firebase CLI by running this command:

    ```bash
    npx -y firebase-tools@latest use
    ```

    - If the command outputs `Active Project: <PROJECT_ID>`, you can proceed
      with your task.

    - If the command does *not* output an active project, ask the user if they
      have an existing Firebase project ID.

      - If yes: Set the ID as the active project and add a default alias by
        running:

        ```bash
        npx -y firebase-tools@latest use --add <PROJECT_ID>
        ```

      - If no: Create a new Firebase project by running:

        ```bash
        npx -y firebase-tools@latest projects:create <PROJECT_ID> --display-name <DISPLAY_NAME>
        ```

## Reference directory

- [Firebase core concepts](references/core-concepts.md)
- [Firebase CLI usage](references/cli-usage.md)
- [Firebase client library usage](references/client-library-usage.md)
- [Firebase CLI and MCP server](references/mcp-usage.md)
- [Firebase IaC usage](references/iac-usage.md)
- [Firebase security-related features](references/iam-security.md)
- [Additional Published Skills](references/additional-skills.md)

If you need product information that's not found in these references, check the
other skills for Firebase that you have installed, or use the `search_documents`
tool of the Developer Knowledge MCP server.
````


### `references/additional-skills.md`

```markdown
## Additional Published Skills

The following skills and reference files are published in the
[Firebase Agent Skills repository](https://github.com/firebase/agent-skills/tree/main/skills):

### `firebase-ai-logic-basics`

-   [`SKILL.md`](https://github.com/firebase/agent-skills/blob/main/skills/firebase-ai-logic-basics/SKILL.md)
-   [`references/usage_patterns_web.md`](https://github.com/firebase/agent-skills/blob/main/skills/firebase-ai-logic-basics/references/usage_patterns_web.md)

### `firebase-app-hosting-basics`

-   [`SKILL.md`](https://github.com/firebase/agent-skills/blob/main/skills/firebase-app-hosting-basics/SKILL.md)
-   [`references/cli_commands.md`](https://github.com/firebase/agent-skills/blob/main/skills/firebase-app-hosting-basics/references/cli_commands.md)
-   [`references/configuration.md`](https://github.com/firebase/agent-skills/blob/main/skills/firebase-app-hosting-basics/references/configuration.md)
-   [`references/emulation.md`](https://github.com/firebase/agent-skills/blob/main/skills/firebase-app-hosting-basics/references/emulation.md)

### `firebase-auth-basics`

-   [`SKILL.md`](https://github.com/firebase/agent-skills/blob/main/skills/firebase-auth-basics/SKILL.md)
-   [`references/client_sdk_web.md`](https://github.com/firebase/agent-skills/blob/main/skills/firebase-auth-basics/references/client_sdk_web.md)
-   [`references/security_rules.md`](https://github.com/firebase/agent-skills/blob/main/skills/firebase-auth-basics/references/security_rules.md)

### `firebase-basics`

-   [`SKILL.md`](https://github.com/firebase/agent-skills/blob/main/skills/firebase-basics/SKILL.md)
-   [`references/firebase-cli-guide.md`](https://github.com/firebase/agent-skills/blob/main/skills/firebase-basics/references/firebase-cli-guide.md)
-   [`references/firebase-service-init.md`](https://github.com/firebase/agent-skills/blob/main/skills/firebase-basics/references/firebase-service-init.md)
-   [`references/local-env-setup.md`](https://github.com/firebase/agent-skills/blob/main/skills/firebase-basics/references/local-env-setup.md)
-   [`references/web_setup.md`](https://github.com/firebase/agent-skills/blob/main/skills/firebase-basics/references/web_setup.md)
-   [`references/refresh/antigravity.md`](https://github.com/firebase/agent-skills/blob/main/skills/firebase-basics/references/refresh/antigravity.md)
-   [`references/refresh/claude.md`](https://github.com/firebase/agent-skills/blob/main/skills/firebase-basics/references/refresh/claude.md)
-   [`references/refresh/gemini-cli.md`](https://github.com/firebase/agent-skills/blob/main/skills/firebase-basics/references/refresh/gemini-cli.md)
-   [`references/refresh/other-agents.md`](https://github.com/firebase/agent-skills/blob/main/skills/firebase-basics/references/refresh/other-agents.md)
-   [`references/setup/antigravity.md`](https://github.com/firebase/agent-skills/blob/main/skills/firebase-basics/references/setup/antigravity.md)
-   [`references/setup/claude_code.md`](https://github.com/firebase/agent-skills/blob/main/skills/firebase-basics/references/setup/claude_code.md)
-   [`references/setup/cursor.md`](https://github.com/firebase/agent-skills/blob/main/skills/firebase-basics/references/setup/cursor.md)
-   [`references/setup/gemini_cli.md`](https://github.com/firebase/agent-skills/blob/main/skills/firebase-basics/references/setup/gemini_cli.md)
-   [`references/setup/github_copilot.md`](https://github.com/firebase/agent-skills/blob/main/skills/firebase-basics/references/setup/github_copilot.md)
-   [`references/setup/other_agents.md`](https://github.com/firebase/agent-skills/blob/main/skills/firebase-basics/references/setup/other_agents.md)

### `firebase-data-connect-basics`

-   [`SKILL.md`](https://github.com/firebase/agent-skills/blob/main/skills/firebase-data-connect-basics/SKILL.md)
-   [`examples.md`](https://github.com/firebase/agent-skills/blob/main/skills/firebase-data-connect-basics/examples.md)
-   [`templates.md`](https://github.com/firebase/agent-skills/blob/main/skills/firebase-data-connect-basics/templates.md)
-   [`reference/advanced.md`](https://github.com/firebase/agent-skills/blob/main/skills/firebase-data-connect-basics/reference/advanced.md)
-   [`reference/config.md`](https://github.com/firebase/agent-skills/blob/main/skills/firebase-data-connect-basics/reference/config.md)
-   [`reference/native_sql.md`](https://github.com/firebase/agent-skills/blob/main/skills/firebase-data-connect-basics/reference/native_sql.md)
-   [`reference/operations.md`](https://github.com/firebase/agent-skills/blob/main/skills/firebase-data-connect-basics/reference/operations.md)
-   [`reference/schema.md`](https://github.com/firebase/agent-skills/blob/main/skills/firebase-data-connect-basics/reference/schema.md)
-   [`reference/sdk_web.md`](https://github.com/firebase/agent-skills/blob/main/skills/firebase-data-connect-basics/reference/sdk_web.md)
-   [`reference/security.md`](https://github.com/firebase/agent-skills/blob/main/skills/firebase-data-connect-basics/reference/security.md)

### `firebase-firestore`

-   [`SKILL.md`](https://github.com/firebase/agent-skills/blob/main/skills/firebase-firestore/SKILL.md)

#### Enterprise Edition

-   [`references/enterprise/android_sdk_usage.md`](https://github.com/firebase/agent-skills/blob/main/skills/firebase-firestore/references/enterprise/android_sdk_usage.md)
-   [`references/enterprise/data_model.md`](https://github.com/firebase/agent-skills/blob/main/skills/firebase-firestore/references/enterprise/data_model.md)
-   [`references/enterprise/flutter_setup.md`](https://github.com/firebase/agent-skills/blob/main/skills/firebase-firestore/references/enterprise/flutter_setup.md)
-   [`references/enterprise/indexes.md`](https://github.com/firebase/agent-skills/blob/main/skills/firebase-firestore/references/enterprise/indexes.md)
-   [`references/enterprise/ios_setup.md`](https://github.com/firebase/agent-skills/blob/main/skills/firebase-firestore/references/enterprise/ios_setup.md)
-   [`references/enterprise/provisioning.md`](https://github.com/firebase/agent-skills/blob/main/skills/firebase-firestore/references/enterprise/provisioning.md)
-   [`references/enterprise/python_sdk_usage.md`](https://github.com/firebase/agent-skills/blob/main/skills/firebase-firestore/references/enterprise/python_sdk_usage.md)
-   [`references/enterprise/security_rules.md`](https://github.com/firebase/agent-skills/blob/main/skills/firebase-firestore/references/enterprise/security_rules.md)
-   [`references/enterprise/web_sdk_usage.md`](https://github.com/firebase/agent-skills/blob/main/skills/firebase-firestore/references/enterprise/web_sdk_usage.md)

#### Standard Edition

-   [`references/standard/android_sdk_usage.md`](https://github.com/firebase/agent-skills/blob/main/skills/firebase-firestore/references/standard/android_sdk_usage.md)
-   [`references/standard/flutter_setup.md`](https://github.com/firebase/agent-skills/blob/main/skills/firebase-firestore/references/standard/flutter_setup.md)
-   [`references/standard/indexes.md`](https://github.com/firebase/agent-skills/blob/main/skills/firebase-firestore/references/standard/indexes.md)
-   [`references/standard/ios_setup.md`](https://github.com/firebase/agent-skills/blob/main/skills/firebase-firestore/references/standard/ios_setup.md)
-   [`references/standard/provisioning.md`](https://github.com/firebase/agent-skills/blob/main/skills/firebase-firestore/references/standard/provisioning.md)
-   [`references/standard/security_rules.md`](https://github.com/firebase/agent-skills/blob/main/skills/firebase-firestore/references/standard/security_rules.md)
-   [`references/standard/web_sdk_usage.md`](https://github.com/firebase/agent-skills/blob/main/skills/firebase-firestore/references/standard/web_sdk_usage.md)

### `firebase-hosting-basics`

-   [`SKILL.md`](https://github.com/firebase/agent-skills/blob/main/skills/firebase-hosting-basics/SKILL.md)
-   [`references/configuration.md`](https://github.com/firebase/agent-skills/blob/main/skills/firebase-hosting-basics/references/configuration.md)
-   [`references/deploying.md`](https://github.com/firebase/agent-skills/blob/main/skills/firebase-hosting-basics/references/deploying.md)

### `firebase-security-rules-auditor`

-   [`SKILL.md`](https://github.com/firebase/agent-skills/blob/main/skills/firebase-security-rules-auditor/SKILL.md)

```


### `references/cli-usage.md`

````markdown
# Firebase CLI usage

The Firebase CLI (`firebase-tools`) is the primary tool for managing Firebase
projects and resources from the command line.

**Use npx for Firebase CLI commands**: To ensure you always use the latest
version of the Firebase CLI, always run commands with
`npx -y firebase-tools@latest` instead of just `firebase`. (e.g., use
`npx -y firebase-tools@latest --version` instead of `firebase --version`).

## Exploring commands

The Firebase CLI documents itself. Use help commands to discover functionality.

- **Global help**: List all available commands and categories:

  ```bash
  npx -y firebase-tools@latest --help
  ```

- **Command help**: Get detailed usage for a specific command:

  ```bash
  npx -y firebase-tools@latest [command] --help
  ```

  ```bash
  # Example:
  npx -y firebase-tools@latest deploy --help
  npx -y firebase-tools@latest firestore:indexes --help
  ```
````


### `references/client-library-usage.md`

````markdown
# Firebase client library usage

Firebase provides SDKs for both client-side application development and
server-side administrative tasks.

For a full list of Firebase client libraries and links to their documentation
and GitHub repositories, see https://firebase.google.com/docs/libraries

## Mobile and web client-side SDKs

The Firebase client-side SDKs allow direct interaction with Firebase services
from a mobile or web app. These SDKs are available for iOS (Swift and
Objective-C), Android (Kotlin and Java), Web (JavaScript), Flutter (Dart),
Unity, and C++.

-   For **web apps**, Agent Skills for Firebase provide guides to get started
    with the JavaScript client SDK. Install these skills by running:

    ```bash
    npx -y skills add firebase/agent-skills -y
    ```

-   For **native iOS or Android mobile apps**, see the documentation to get
    started:

    -   **iOS**: https://firebase.google.com/docs/ios/setup.md.txt
    -   **Android**: https://firebase.google.com/docs/android/setup.md.txt

-   For **Flutter apps**, see the documentation to get started:

    -   **Flutter**: https://firebase.google.com/docs/flutter/setup.md.txt

-   For **Unity and C++ mobile apps**, see the documentation to get started:

    -   **Unity**: https://firebase.google.com/docs/unity/setup.md.txt
    -   **C++**: https://firebase.google.com/docs/cpp/setup.md.txt

## Server-side Admin SDKs

The Firebase Admin SDKs provide privileged access to Firebase services from a
server environment. These SDKs are available for Node.js, Java, Python, and Go.

For details about Firebase Admin SDKs and getting started, see
https://firebase.google.com/docs/reference/admin.md.txt and
https://firebase.google.com/docs/admin/setup.md.txt

````


### `references/core-concepts.md`

```markdown
# Firebase core concepts

Firebase is a platform of services for mobile and web applications. It offers
products for managed backend infrastructure (BaaS), building AI-powered
experiences in apps, DevOps, and end-user engagement. Most services are
integrated into apps using mobile and web client SDKs.

## Key services

Here are some popular Firebase products:

- **Firebase Authentication**: Simplify end-user authentication and sign-in on a
  secure, all-in-one identity platform.
- **Firestore**: Store and sync data using a secure, scalable NoSQL cloud
  database with rich data models and queryability.
- **Firebase Data Connect**: Build and scale your apps using a fully-managed
  PostgreSQL relational database service.
- **Cloud Storage for Firebase**: Store and serve unstructured content like
  images, audio, video with a secure cloud-hosted solution.
- **Firebase App Hosting**: Deploy modern, full-stack web apps that require
  server-side rendering and automated secret management, CI/CD, and CDN caching.
- **Firebase Hosting**: Deploy static and single-page web apps to a global CDN
  with a single command.
- **Cloud Functions for Firebase**: Run backend code in response to events and
  HTTPS requests without provisioning or managing a server.
- **Firebase AI Logic**: Build secure AI-powered experiences in mobile and web
  apps using the Gemini API and without provisioning or managing a server.
- **Firebase Crashlytics**: Track, prioritize, and fix stability issues in
  mobile apps.
- **Firebase Cloud Messaging (FCM)**: Send push notifications and messages to
  end users.

## Regional availability

Firebase services are available globally, with several products supporting
specific regional configurations.

- **Firestore**: Each instance can be provisioned in a different location;
  supports multi-region (e.g., `nam5`) and regional (e.g., `us-east1`)
  locations.
- **Cloud Storage for Firebase**: Each bucket can be provisioned in a different
  location.
- **Firebase App Hosting**: Can be deployed to specific regions to minimize
  latency for operations and end users.
- **Firebase Hosting**: Content is delivered via a global CDN.
- **Cloud Functions for Firebase**: Can be deployed to specific regions to
  minimize latency for operations and end users.

## Pricing

Firebase offers two pricing plans:

- **Spark (no-cost) pricing plan**: Projects don't need a billing account to
  use only the no-cost Firebase services and to get started with generous
  no-cost usage quota.
- **Blaze (pay-as-you-go) pricing plan**: Link a billing account to the project
  to access more products and services and to get usage levels beyond the
  no-cost usage quota.

For up-to-date detailed pricing information, see the Firebase pricing
page: https://firebase.google.com/pricing
```


### `references/iac-usage.md`

````markdown
# Firebase IaC usage

Firebase resources can be provisioned using Infrastructure as Code (IaC) tools,
like Terraform.

## Terraform configuration

Use the `google` or `google-beta` providers to manage Firebase resources.

### Example: Firebase project setup

```hcl
resource "google_firebase_project" "default" {
 provider = google-beta
 project  = "user-defined-project-id"
}

resource "google_firebase_web_app" "default" {
 provider     = google-beta
 project      = google_firebase_project.default.project
 display_name = "user-defined-display-name"
}
```

### Supported Terraform resources

Here are some common Terraform resources for Firebase:

- `google_firebase_project`: Enable Firebase services on an existing
  Google Cloud project.
- `google_identity_platform_config`: Set up Firebase Authentication.
- `google_firestore_database`: Provision a Firestore database.
  Always set `type = "FIRESTORE_NATIVE"`.
- `google_firebaserules_ruleset`: Define Firebase Security Rules to protect
  Firestore data or Cloud Storage for Firebase data.
- `google_firebaserules_release`: Deploy Firebase Security Rules rulesets for
  Firestore or for Cloud Storage for Firebase.

For a complete list of Terraform resources, and details about Terraform and
Firebase, see: https://firebase.google.com/docs/projects/terraform/get-started
````


### `references/iam-security.md`

````markdown
# Firebase security-related features

Firebase offers several security-related features and services, including:

- **Identity and Access Management (IAM)**: Restrict a project member's
  administrative access for projects, resources, and data.
- **Firebase Security Rules**: Restrict client-side access for Firestore data
  and Cloud Storage for Firebase data to only authorized users.
- **Firebase App Check**: Restrict client-side access for APIs and backend
  resources to only an authentic client and an authentic, untampered device.

## Identity and Access Management (IAM)

Here are some common IAM roles:

| Role | Description |
|---|---|
| `roles/viewer` | Permissions for read-only actions, such as viewing (but not modifying) existing resources or data. |
| `roles/editor` | All the `roles/viewer` permissions, plus permissions for actions that modify state, such as changing existing resources. |
| `roles/owner` | All the `roles/editor` permissions, plus permissions for the following actions: manage IAM for a project, manage all resources within the project, set up and manage billing for a project, and delete or restore a project. |
| `roles/firebase.viewer` | Read-only access to Firebase resources and data. |
| `roles/firebase.admin` | Full access to all Firebase products and project management. |

For details about IAM and Firebase, see
https://firebase.google.com/docs/projects/iam/overview.md.txt

## Firebase Security Rules

Firebase Security Rules are CRITICAL to protecting Firestore data and
Cloud Storage for Firebase data from unauthorized mobile and web client-side
access. They are defined in the project directory (e.g., `firestore.rules`)
and deployed using the Firebase CLI.

Here is a basic example of Security Rules for Firestore that restricts access
to authenticated end-users only:

```
service cloud.firestore {
  match /databases/{database}/documents {
    match /some_collection/{document} {
      allow read, write: if request.auth != null;
    }
  }
}
```

**CRITICAL**: Agent Skills for Firebase provide tools to draft and test Firebase
Security Rules. Install these skills by running:

```bash
npx -y skills add firebase/agent-skills -y
```

## Firebase App Check

Firebase App Check is CRITICAL to protecting a project's enabled APIs and
backend resources from unauthorized clients and devices. For example, it can
help protect Firebase AI Logic, Firestore, Cloud Storage for Firebase,
Cloud Functions for Firebase, and Firebase Data Connect.

For details about Firebase App Check, see
https://firebase.google.com/docs/app-check.md.txt

## Security best practices

- **Principle of least privilege:** Assign specific product-level roles instead
  of `roles/owner` whenever possible.
- **Firebase App Check:** Use this service to protect a project's enabled APIs
  and backend resources from abuse by allowing only authentic clients and
  devices to access them.
- **Environment management:** Use separate Firebase projects for development,
  staging, and production.
- **Sensitive operations:** Always have a human user approve sensitive
  operations like granting permissive IAM roles or deleting a database.
````


### `references/mcp-usage.md`

````markdown
# Firebase CLI and MCP server

The Firebase CLI includes a built-in local MCP server that can help with common
tasks.

1.  **Locate MCP configuration**

    Find the configuration file for your agent
    (e.g., `~/.codeium/windsurf/mcp_config.json`, `cline_mcp_settings.json`, or
    `claude_desktop_config.json`).

    *Note: If the document or its containing directory does not exist, create
    them and initialize the file with `{ "mcpServers": {} }` before proceeding.*

2.  **Check existing configuration**

    Open the configuration file and check the `mcpServers` section for a
    `firebase` entry.

    - Firebase is already configured if the `command` is `"firebase"` OR if the
      `command` is `"npx"` with `"firebase-tools"` and `"mcp"` in the `args`.

    - **Important**: If a valid `firebase` entry is found, the MCP server is
      already configured. **Skip step 3** and proceed directly to step 4.

    **Example valid configurations**:
    ```json
    "firebase": {
      "command": "npx",
      "args": ["-y", "firebase-tools@latest", "mcp"]
    }
    ```
    OR
    ```json
    "firebase": {
      "command": "firebase",
      "args": ["mcp"]
    }
    ```

3.  **Add or update configuration**

    If the `firebase` entry is missing or incorrect, add it to the `mcpServers`
    object:

    ```json
    "firebase": {
      "command": "npx",
      "args": [
        "-y",
        "firebase-tools@latest",
        "mcp"
      ]
    }
    ```

    *CRITICAL: Merge this configuration into the existing file. You MUST
    preserve any other existing servers inside the `mcpServers` object.*

4.  **Verify configuration**

    Save the file and confirm the `firebase` block is present and is properly
    formatted JSON.
````
