1
---
2
name: firebase-basics
3
metadata:
4
version: "1.0.1"
5
category: Serverless
6
description: >-
7
Provides foundational Firebase CLI setup, CLI installation, version checks (`firebase-tools@latest --version`), CLI login (including --no-localhost), project creation, project selection (`firebase use`), and app config file downloads (`google-services.json`, `GoogleService-Info.plist`). Use ONLY for CLI login, project creation/switching, or downloading app config files. Don't use for Firebase Hosting deploy, Firestore, Auth, App Hosting, Data Connect, Crashlytics, or Remote Config.
8
---
9
10
# Firebase Basics
11
12
## Usage Attribution
13
14
**MUST READ**: Before executing any `gcloud`, REST API, or MCP command, you
15
MUST read and follow the instructions in
16
[Usage Attribution](references/attribution.md).
17
18
## Prerequisites
19
20
Complete these setup steps before proceeding:
21
22
1. **Local Environment Setup:** Verify the environment is properly set up so we
23
can use Firebase tools:
24
25
- Run `npx -y firebase-tools@latest --version` to check if the Firebase
26
CLI is installed.
27
- Verify if the Firebase MCP server is installed using your existing
28
tools.
29
- **CRITICAL**: Before configuring any extensions or agent environments
30
below, you MUST read
31
[references/local-env-setup.md](references/local-env-setup.md).
32
- **DO NOT SKIP** this step: if 'firebase-basics' is the only Firebase
33
skill available to you, you must follow the reference for your agent
34
environment to set up the full suite of Firebase skills:
35
- **Gemini CLI**: Review
36
[references/setup/gemini_cli.md](references/setup/gemini_cli.md)
37
- **Antigravity**: Review
38
[references/setup/antigravity.md](references/setup/antigravity.md)
39
- **Android Studio**: Review
40
[references/setup/android_studio.md](references/setup/android_studio.md)
41
- **Claude Code**: Review
42
[references/setup/claude_code.md](references/setup/claude_code.md)
43
- **Cursor**: Review
44
[references/setup/cursor.md](references/setup/cursor.md)
45
- **GitHub Copilot**: Review
46
[references/setup/github_copilot.md](references/setup/github_copilot.md)
47
- **Other Agents**: Review
48
[references/setup/other_agents.md](references/setup/other_agents.md)
49
50
1. **Authentication:** Ensure you are logged in to Firebase so that commands
51
have the correct permissions. Run `npx -y firebase-tools@latest login`. For
52
environments without a browser (e.g., remote shells), use `npx -y
53
firebase-tools@latest login --no-localhost`.
54
55
- The command should output the current user.
56
- If you are not logged in, follow the interactive instructions from this
57
command to authenticate.
58
59
1. **Active Project:** Most Firebase tasks require an active project context.
60
61
> [!IMPORTANT] **For Agents:** Before proceeding with project configuration,
62
> you MUST pause and ask the developer if they prefer to:
63
>
64
> 1. **Provide an existing Firebase Project ID**, or
65
> 1. **Create a new Firebase project**.
66
67
- **If using an existing Project ID:**
68
69
1. Check the current project by running `npx -y firebase-tools@latest
70
use`.
71
1. If the command outputs `Active Project: <project-id>`, confirm with
72
the user if this is the intended project.
73
1. If not, or if no project is active, set the project provided by the
74
user:
75
76
```bash
77
npx -y firebase-tools@latest use <PROJECT_ID>
78
```
79
80
- **If creating a new project:** Run the following command to create it:
81
82
```bash
83
npx -y firebase-tools@latest projects:create <project-id> --display-name "<display-name>"
84
```
85
86
*Note: The `<project-id>` must be 6-30 characters, lowercase, and can
87
contain digits and hyphens. It must be globally unique.*
88
89
## Firebase Usage Principles
90
91
Adhere to these principles:
92
93
1. **Use npx for CLI commands:** To ensure you always use the latest version of
94
the Firebase CLI, always prepend commands with `npx -y
95
firebase-tools@latest` instead of just `firebase`. For example, use `npx -y
96
firebase-tools@latest --version`. NEVER suggest the naked `firebase` command
97
as an alternative.
98
1. **Prioritize official knowledge:** For any Firebase-related knowledge,
99
consult the `developerknowledge_search_documents` MCP tool before falling
100
back to Google Search or your internal knowledge base. Including "Firebase"
101
in your search query significantly improves relevance.
102
1. **Follow Agent Skills for implementation guidance:** Skills provide
103
opinionated workflows (CUJs), security rules, and best practices. Always
104
consult them to understand *how* to implement Firebase features correctly
105
instead of relying on general knowledge.
106
1. **Use Firebase MCP Server tools instead of direct API calls:** Whenever you
107
need to interact with remote Firebase APIs (such as fetching Crashlytics
108
logs or executing Data Connect queries), use the tools provided by the
109
Firebase MCP Server instead of attempting manual API calls.
110
1. **Keep Plugin / Agent Skills updated:** Since Firebase best practices evolve
111
quickly, regularly check for and install updates to their Firebase plugin or
112
Agent Skills. Similarly, if you encounter issues with outdated tools or
113
commands, follow the steps below based on your agent environment:
114
- **Antigravity**: Follow
115
[references/refresh/antigravity.md](references/refresh/antigravity.md)
116
- **Gemini CLI**: Follow
117
[references/refresh/gemini-cli.md](references/refresh/gemini-cli.md)
118
- **Claude Code**: Follow
119
[references/refresh/claude.md](references/refresh/claude.md)
120
- **Cursor**: Follow
121
[references/refresh/other-agents.md](references/refresh/other-agents.md)
122
- **Android Studio**: Follow
123
[references/refresh/android_studio.md](references/refresh/android_studio.md)
124
- **Others**: Follow
125
[references/refresh/other-agents.md](references/refresh/other-agents.md)
126
1. **Automate Config File Retrieval:** When setting up iOS or Android apps, do
127
NOT direct users to the Firebase Console to download `google-services.json`
128
or `GoogleService-Info.plist`. Instead, use the Firebase CLI to fetch the
129
config programmatically:
130
- For Android: `npx -y firebase-tools@latest apps:sdkconfig ANDROID
131
<APP_ID> --project <PROJECT_ID>`
132
- For iOS: `npx -y firebase-tools@latest apps:sdkconfig IOS <APP_ID>
133
--project <PROJECT_ID>` Save the output to the appropriate location
134
(e.g., `app/google-services.json` for Android, or a path to be linked by
135
`xcode-project-setup` for iOS).
136
137
## References
138
139
- **Initialize Firebase:** See
140
[references/firebase-service-init.md](references/firebase-service-init.md)
141
when you need to initialize new Firebase services using the CLI.
142
- **Exploring Commands:** See
143
[references/firebase-cli-guide.md](references/firebase-cli-guide.md) to
144
discover and understand CLI functionality.
145
- **SDK Setup:** For detailed guides on adding Firebase to your app:
146
- **Web**: See [references/web_setup.md](references/web_setup.md)
147
- **Android**: See
148
[references/android_setup.md](references/android_setup.md)
149
- **iOS**: See [references/ios_setup.md](references/ios_setup.md)
150
151
## Common Issues
152
153
- **Login Issues:** If the browser fails to open during the login step, use
154
`npx -y firebase-tools@latest login --no-localhost` instead.
155
- **Genkit:** If using Genkit, install the skills:
156
157
```bash
158
npx skills add genkit-ai/skills
159
```
160