cmp-firebase-connect
Skill0 starsChanged 47 days agoMITView on GitHub
Add Firebase to a create-cmp app and wire it to its OWN real Firebase project. Use this when the user wants Firebase in their app, or asks "add firebase", "connect my app to firebase", "set up google-services.json", "wire firebase", "create a firebase project for this app", "replace the mock firebase config", "get a real GoogleService-Info.plist", "my app still has the REPLACE_ME firebase config". The stamp carries no Firebase: this runs `create-cmp add firebase` (the deterministic step that adds the GitLive SDK, the emulator wiring and a mock config that says it is one), then drives the Firebase CLI end-to-end — login, project create/reuse, Android app registration, the real google-services.json in place of the mock — every cloud-mutating command consent-gated, then proves it with a green assembleDebug. Android-first; iOS branch optional/deferred.
- Installs packages
In this repository17 other files it gives its agents.
- AGENTS.mdAGENTS.md
- template/AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- template/CLAUDE.mdCLAUDE.md
- llms.txtllms.txt
- npm-publishSkill
- plugin-refreshSkill
- cmp-auditSkill
- cmp-dev-clientSkill
- cmp-doctorSkill
- cmp-inspectSkill
- cmp-newSkill
- cmp-previewSkill
- cmp-qa-prepSkill
- cmp-testSkill
- cmp-upgradeSkill
- grill-meSkill
The file
We split this skill into the rules it gives an agent
11 rules. About 0 are common, 6 are distinctive, and 5 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈6
Distinctive · estimate
This author's own choices. Worth a look.
5
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 42
Run these checks before touching anything.
- Distinctive: line 58
Absent: run the add step. It edits only this repo's files, writes nothing until its whole plan is made, and changes nothing on a second run …
- Very specific: line 69
When iosApp/ exists it applies the iOS half too and says it is unproven.
- Distinctive: line 72
A config that already looks real: stop and ask whether they want to re-point the app at a different project (same flow, but be explicit …
- Distinctive: line 99
Run without a positional id and the CLI prompts interactively — fine if the user is driving, but prefer the explicit form so the consent …
- Very specific: line 115
If the output scrolled away: firebase apps:list ANDROID --project <project-id> re-shows it.
- Very specific: line 136
If the project has exactly one Android app you may omit <appId>.
- Very specific: line 162
If create-cmp.json records phone auth (firebase.auth is phone or both), flag the SHA row as
- Distinctive: line 168
Only on explicit request — iOS is deferred product-wide right now.
- Very specific: line 180
Verify: plutil -lint iosApp/iosApp/GoogleService-Info.plist and check BUNDLE_ID matches.
- Distinctive: line 200
If the toolchain or device setup isn't ready, hand off to cmp-doctor / cmp-qa-prep rather than debugging the environment here.
≈ “Common” is an estimate: at least 1 in 5 of the 364,980 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
cmp-firebase-connect — add Firebase to a stamped CMP app and wire it to its own project
Your job: take a CMP app create-cmp stamped — which carries no Firebase — add Firebase with
create-cmp add firebase, and connect it to a real Firebase project on the user's account,
using the Firebase CLI — no console clicking for anything the CLI can do. You finish by proving
the wiring with a green build.
The code edits are a program's, not yours.
create-cmp add firebaseadds the GitLive SDK, the google-services plugin, the debug-build emulator redirect and the config file, and refuses by name when the app's shape is one it does not recognise. Never hand-edit Gradle, the catalog or the entry points to wire Firebase; if the step refuses, report its message to the user.
Consent is a program in the stamped app; this skill does not restate it.
create-cmp add firebase(§1 step 4) shipsqa/hooks/firebase-consent.mjsand registers it in the app's.claude/settings.jsonas a PreToolUse hook: when a command would runprojects:create,apps:create,firestore:databases:createorapps:android:sha:create, Claude Code asks the user first, naming the mutation. The hook asks and never allows. Run the add step before any cloud command, so the hook is there when one runs.
Cost honesty. A fresh Firebase project starts on the Spark (free) plan. Nothing in this flow enables billing, attaches a card, or upgrades to Blaze — and the CLI cannot silently do so. Auth (email/phone within free quota), Firestore, and the free-tier services all work on Spark. Say this to the user up front so "create a cloud project" doesn't read as "spend money".
1. Preflight
Run these checks before touching anything; fix in order.
- CLI present —
firebase --version. If missing, offer (consent-gated — it's a global install on their machine):npm i -g firebase-tools, then re-check. - Logged in —
firebase login:list. If it reports no accounts, runfirebase login. Tell the user first: this opens an interactive browser OAuth flow they must complete themselves; you cannot do it for them. On a headless/remote box usefirebase login --no-localhost. Do not proceed untillogin:listshows an account. - Read the app's identity from the stamped project (never ask the user to retype what the
repo already knows):
- Android
applicationId— fromcomposeApp/build.gradle.kts(theapplicationId = "..."line insideandroid { defaultConfig { … } }). - iOS bundle id — from
iosApp/project.yml(PRODUCT_BUNDLE_IDENTIFIER/bundleIdPrefix). iOS is optional and currently deferred product-wide — do the Android wiring first and only take the iOS branch (§5) if the user explicitly wants it now.
- Android
- Add Firebase, if the app has none yet — read
create-cmp.json'sfirebaserecord.Absent: run the add step. It edits only this repo's files, writes nothing until its whole plan is made, and changes nothing on a second run — tell the user what it does, then:
npx create-cmp-cli add firebase --no-verify [--region <r>] [--auth <email|phone|both|none>]--regionis the Cloud Functions region (defaultus-central1);--authand--no-firestore/--no-storage/--no-functions/--no-fcmare recorded increate-cmp.jsonfor §4 below — every GitLive module is wired either way. It writes a mock config (projectdemo-mock-not-real, a key that says it is not one) so the app builds before any cloud work. WheniosApp/exists it applies the iOS half too and says it is unproven."config": "mock", or aREPLACE_ME_PROJECT_IDplaceholder (an app stamped with Firebase by create-cmp 0.27 or earlier): proceed to §2.- A config that already looks real: stop and ask whether they want to re-point the app at a different project (same flow, but be explicit that you're replacing a live config).
2. Choose or create the Firebase project
First show what they already have:
firebase projects:listOffer both paths and let the user pick:
- Reuse an existing project → take its Project ID, skip to §3.
- Create a new one. Show the exact command and get consent — this creates a real Google Cloud project on their account:
firebase projects:create <project-id> --display-name "<App Name>"Notes (from the CLI's --help; on a CLI that disagrees, its --help wins):
<project-id>is globally unique, lowercase, digits and hyphens (e.g.acme-app-dev). If the id is taken the command fails cleanly — pick another (suffix-dev,-2026, etc.); nothing was created.- The flag is
-n, --display-name <displayName>(optional).--organization/--folderexist for org-managed accounts; don't pass them unless the user asks. - Run without a positional id and the CLI prompts interactively — fine if the user is driving, but prefer the explicit form so the consent you showed matches what runs.
3. Register the Android app and install the real config
Three steps: create the app record, pull its SDK config, put it where Gradle looks.
3a. Create the Android app (consent-gated — cloud mutation):
firebase apps:create ANDROID "<App Name>" --package-name <applicationId> --project <project-id>--package-name(alias-a) must be the exactapplicationIdfrom preflight — a mismatch is the classic silent-failure later.- The output prints the new App ID (
1:<number>:android:<hex>). Capture it; you need it next. If the output scrolled away:firebase apps:list ANDROID --project <project-id>re-shows it.
3b. Pull the real config (read-only) to a temp file, and hand it to the add step, which checks
its package_name against the app's applicationId and replaces its own mock with it (it refuses,
and writes nothing, if the file there is not its mock):
firebase apps:sdkconfig ANDROID <appId> --project <project-id> --out /tmp/google-services.json
npx create-cmp-cli add firebase --google-services /tmp/google-services.json --no-verifyFor an app stamped with Firebase by create-cmp 0.27 or earlier (a REPLACE_ME placeholder, not
the mock), back up the placeholder and write straight to the Gradle location instead:
cp composeApp/google-services.json composeApp/google-services.json.placeholder.bak
firebase apps:sdkconfig ANDROID <appId> --project <project-id> --out composeApp/google-services.json-o, --out [file]writes the config to the file (verified inapps:sdkconfig --help); prefer it over redirecting stdout, which can pick up CLI progress lines.- If the project has exactly one Android app you may omit
<appId>; with several the CLI prompts (or errors under--non-interactive) — pass the id explicitly.
3c. Verify before building — both checks, mechanically:
python3 -c "import json;d=json.load(open('composeApp/google-services.json'));print(d['project_info']['project_id']);print(d['client'][0]['client_info']['android_client_info']['package_name'])"Assert: JSON parses, project_id is the real project (not REPLACE_ME… or demo-mock…), and package_name
equals the applicationId from preflight. Fix mismatches now (see troubleshooting), not at
build time.
4. Console-only steps — be honest about what the CLI can't do
The CLI registers apps and delivers config; it does not enable most services. Tell the user exactly which switches still need a human in the Firebase console:
| Service | CLI? | What to do |
| Auth sign-in providers (email/password, phone, Google, …) | No — auth:* only exports/imports users | Console → Authentication → Sign-in method → enable each provider. Auth calls fail with CONFIGURATION_NOT_FOUND / OPERATION_NOT_ALLOWED until done. |
| Firestore database | Yes (current CLIs — confirm with firebase firestore:databases:create --help) | firebase firestore:databases:create "(default)" --location <loc> --project <project-id> — consent-gated. Run firebase firestore:locations first to pick <loc> (e.g. nam5, eur3, or the region matching firebase.region in the app's create-cmp.json). Console fallback: Firestore → Create database. |
| Storage default bucket | No — no provisioning command in the CLI | Console → Storage → Get started. (Deploying storage.rules via firebase deploy also requires the bucket to exist first.) |
| FCM | Auto | Enabled by app registration; nothing to toggle for basic push. |
| SHA-1/SHA-256 fingerprints (needed for phone auth & Google Sign-In on Android) | Yes | ./gradlew :composeApp:signingReport → copy the debug SHA-1 → consent-gated: firebase apps:android:sha:create <appId> <shaHash>. Then re-download the config (§3b) — adding a SHA changes google-services.json (oauth_client / certificate_hash). |
If create-cmp.json records phone auth (firebase.auth is phone or both), flag the SHA row as
required, not optional, and say that iOS phone auth needs more than this skill covers (the
REVERSED_CLIENT_ID URL scheme and APNs, §5) — it is a minefield.
5. Optional iOS branch (deferred by default)
Only on explicit request — iOS is deferred product-wide right now. Same shape as §3:
firebase apps:create IOS "<App Name>" --bundle-id <bundleId> --project <project-id> # consent-gated
firebase apps:sdkconfig IOS <iosAppId> --project <project-id> --out iosApp/iosApp/GoogleService-Info.plist--bundle-id(alias-b) is the required flag for IOS (verified inapps:create --help);--app-store-idexists but is optional.create-cmp add firebasewrote a mock plist there wheniosApp/existed; back it up (or the 0.27-era placeholder) first, same as Android (iosApp/iosApp/GoogleService-Info.plist.mock.bak). The iOS half of the add step is unproven — say so when reporting.- Verify:
plutil -lint iosApp/iosApp/GoogleService-Info.plistand checkBUNDLE_IDmatches. - Remind the user: iOS phone auth additionally needs the
REVERSED_CLIENT_IDURL scheme and APNs setup — out of scope for this skill, and no create-cmp skill covers it yet.
6. Prove it — the build IS the verification
The google-services Gradle plugin parses the config at build time and fails the build if the
JSON is malformed or no client entry matches the module's applicationId. So:
./gradlew :composeApp:assembleDebug- GREEN → the real config is structurally valid and matched to the app. Report success.
- FAIL with
No matching client found for package name '<pkg>'→ the registered package and theapplicationIddiffer; see troubleshooting.
Optional runtime smoke (recommended when Auth/Firestore are already enabled in console): install
and launch (./gradlew :composeApp:installDebug), exercise one real call (e.g. an email sign-up),
and confirm it hits this project — a small, fixed, bounded number of live ops, never a loop.
If the toolchain or device setup isn't ready, hand off to cmp-doctor / cmp-qa-prep rather
than debugging the environment here.
7. Troubleshooting
| Symptom | Cause | Fix |
Error: Authentication Error / Command requires authentication | Login expired or never done | firebase login --reauth (browser flow — user must complete it). Headless: --no-localhost. Re-check with firebase login:list. |
projects:create fails: id unavailable/taken | Project IDs are globally unique | Pick a new id (-dev, -app, year suffix). Nothing was created on failure. |
apps:create fails: package name already exists | That package is registered in this (or another of their) project | firebase apps:list ANDROID --project <id> — if the app already exists, skip to §3b with its appId. |
Build: No matching client found for package name '…' | google-services.json package ≠ applicationId | Recheck the applicationId in composeApp/build.gradle.kts; re-register with the correct --package-name (or fix the Gradle id), re-pull config. |
Build: File google-services.json is missing | Config written to the wrong path | It must sit at composeApp/google-services.json (module root, next to build.gradle.kts), not the repo root or src/. |
| Build: JSON parse error in google-services task | stdout redirect captured CLI noise, or truncated file | Re-pull with --out (§3b); run the §3c parse check. |
Auth runtime error CONFIGURATION_NOT_FOUND | Sign-in provider not enabled | Console → Authentication → Sign-in method (§4 — CLI can't do this). |
Firestore runtime NOT_FOUND / permission error | No database created yet, or default locked-mode rules | firestore:databases:create (§4), then deploy/adjust rules. |
| Phone auth fails on a real Android device | Missing SHA fingerprint | §4 SHA row: signingReport → apps:android:sha:create → re-download the config. |
Rollback (undo the local change any time): the add step's edits are ordinary file changes —
git diff shows them and git checkout -- . (plus deleting the files it created, which it listed)
reverts them. A config you backed up by hand goes back the same way it came:
mv composeApp/google-services.json.placeholder.bak composeApp/google-services.json
# iOS, if taken: mv iosApp/iosApp/GoogleService-Info.plist.mock.bak iosApp/iosApp/GoogleService-Info.plistThe cloud side needs no rollback for a mistake here — an unused Firebase project/app record on Spark costs nothing; the user can delete it in console → Project settings if they want it gone.
8. Report
Tell the user: whether create-cmp add firebase ran (and that its iOS half is unproven, if it
applied one), the project id (created or reused), the Android App ID registered, that the mock
(or placeholder) was replaced, the GREEN/FAIL build verdict, which console toggles
remain (§4 list, tailored to the services their scaffold enabled), and — if they're heading to a
device run — point them at cmp-qa-prep (or cmp-doctor if the toolchain is suspect).
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

