agentleFS
pabloirracionalpabloirracional/claude-skills/skills/setting-up-firebase-auth/SKILL.md

setting-up-firebase-auth

Skill0 starsChanged 4 months agoMITView on GitHub

Sets up Firebase Authentication using the modular v9+ SDK, with every method reference checked against the real installed package to catch API drift before it causes a runtime error. Use whenever the user wants to add login/signup to an app using Firebase, or mentions Firebase Auth, social login, or protected routes with Firebase.

The file

We split this skill into the rules it gives an agent

4 rules. About 0 are common, 2 are distinctive, and 2 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Auth state: use onAuthStateChanged as the source of truth for login status, not a manually tracked boolean.

    line 14
  2. Distinctive:

    Protected routes: check auth state with an explicit loading state while Firebase determines the session, to avoid a flash of logged-out …

    line 15
  3. Distinctive:

    Server-side verification: if there's a backend, verify the ID token server-side with the Admin SDK.

    line 16
  4. Very specific:

    Never store a service account key or Admin SDK credentials in client-side code - that's a server-only credential, unlike the public …

    line 53

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Setting up Firebase Auth

Configures Firebase Authentication using the modular (v9+) SDK - checked against the actual installed package, not written from memory of an API that may have shifted.

Workflow

  1. Confirm providers needed: email/password, Google, GitHub, phone, anonymous - each needs separate enablement in the Firebase console before code will work. This is the most common "why doesn't this work" issue and has nothing to do with the code itself.
  2. Use the modular SDK pattern (getAuth(app), tree-shakeable function imports) - not the older namespaced firebase.auth() pattern, which is legacy in current versions.
  3. Auth state: use onAuthStateChanged as the source of truth for login status, not a manually tracked boolean.
  4. Protected routes: check auth state with an explicit loading state while Firebase determines the session, to avoid a flash of logged-out content.
  5. Server-side verification: if there's a backend, verify the ID token server-side with the Admin SDK.

Tested: every SDK method used below actually exists

Installed the real firebase npm package and checked every method this skill's example code calls against the actual module exports - this catches the class of bug where an SDK method got renamed or moved between major versions and code written from memory silently references something that no longer exists.

const authMod = require('firebase/auth');
// Checked: getAuth, onAuthStateChanged, signInWithEmailAndPassword,
// createUserWithEmailAndPassword, GoogleAuthProvider, signInWithPopup,
// signOut, browserLocalPersistence, setPersistence

Confirmed: all 9 methods exist on the installed SDK version. Also confirmed initializeApp() doesn't throw even with a fake config object - it only fails on the first actual network-dependent call (sign-in, etc.), which matters when reviewing code: an app that "starts fine" hasn't proven its Firebase config is correct yet.

Reference pattern (methods above, used correctly)

import { initializeApp } from 'firebase/app';
import { getAuth, onAuthStateChanged, signInWithEmailAndPassword, GoogleAuthProvider, signInWithPopup, signOut } from 'firebase/auth';

const app = initializeApp(firebaseConfig);
const auth = getAuth(app);

onAuthStateChanged(auth, (user) => {
  // source of truth for logged-in state - handles token refresh internally
});

async function loginWithGoogle() {
  const provider = new GoogleAuthProvider();
  await signInWithPopup(auth, provider);
}

Notes

  • This confirms the shape of the API is correct - it doesn't confirm behavior against a real Firebase project (that needs a real firebaseConfig with a real apiKey/projectId, which this environment doesn't have). If sign-in fails against a real project, the cause is almost always provider enablement (Step 1) or config values, not the code pattern itself.
  • Firebase Auth persistence defaults differ between web and React Native - confirm the platform before advising on session persistence config (browserLocalPersistence is web-specific).
  • Never store a service account key or Admin SDK credentials in client-side code - that's a server-only credential, unlike the public firebaseConfig object used above.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.