agent-security-hardening
AFaffaan-m/ECC315k4,381 new stars in the last 7 days
Builds, secures and reviews Firebase apps with the modular JS SDK (firebase 13), firebase-admin 14 and Cloud Functions 2nd gen: Firestore data modeling, queries, indexes, transactions and offline cache, Firestore and Storage Security Rules with emulator tests, Firebase Authentication and Identity Platform (custom claims, session cookies, blocking functions), callable and event-triggered functions with secrets, App Check, Firebase Hosting and App Hosting deploys, and Firestore cost control. Use when code imports from firebase/*, firebase-admin or firebase-functions, when editing firestore.rules, storage.rules, firestore.indexes.json, firebase.json or apphosting.yaml, when choosing between Firestore, Realtime Database and SQL Connect, or when diagnosing permission-denied errors, missing-index errors, runaway read costs or functions that loop on their own writes. Not for Supabase, AWS Amplify or plain Google Cloud projects with no Firebase.
Senior Firebase engineer for the modular JS SDK 13, firebase-admin 14 (Node 22+), firebase-functions 7 on Cloud Functions 2nd gen and firebase-tools 15: data shaped for the queries the app runs, Security Rules that enforce every invariant the client could fake, and every change proven against the Emulator Suite before deploy.
firestore.rules and storage.rules, and testing them with @firebase/rules-unit-testingpackage.json pins, firebase.json, .firebaserc, the rules and index files; note the Firestore edition, the plan (Blaze is required for Functions, App Hosting and Cloud Storage) and whether the code is modular or compatrequest.auth.uid, validated fields, server-only fields; privileged work goes to functions using the Admin SDKdefineSecret/defineString, idempotent triggers, App Check on clients and enforced on callablesfirebase emulators:exec, fix failures and re-run until green, then firebase deploy --only the changed targets and check the console for index builds and errors| Topic | Reference | Load When |
|---|---|---|
| Firestore | references/firestore.md | Data modeling, converters, queries, indexes, pagination, aggregation, transactions, batches, listeners, offline cache, read costs, RTDB and SQL Connect choice |
| Security Rules | references/security-rules.md | firestore.rules, storage.rules, validation helpers, role claims, rules-vs-queries, rules unit tests |
| Authentication | references/authentication.md | Client sign-in, Admin token verification, custom claims, session cookies for SSR, blocking functions, Identity Platform |
| Cloud Functions | references/cloud-functions.md | 2nd gen triggers, callable functions, params and secrets, idempotency, retries, concurrency, regions |
| Storage, App Check & AI Logic | references/storage-app-check.md | Uploads, Storage paths and metadata, App Check providers and enforcement, Firebase AI Logic client calls |
| Emulators & testing | references/emulators-testing.md | firebase.json emulators, connecting SDKs, seeding, function integration tests, CI with emulators:exec |
| Hosting & deployment | references/hosting-deployment.md | Hosting vs App Hosting, apphosting.yaml, environments and project aliases, CI auth without keys, index and rules deploys |
Client init that talks to the emulators in development and caches offline:
// src/lib/firebase.ts
import { initializeApp } from 'firebase/app';
import { connectAuthEmulator, getAuth } from 'firebase/auth';
import {
connectFirestoreEmulator,
initializeFirestore,
persistentLocalCache,
persistentMultipleTabManager,
} from 'firebase/firestore';
export const app = initializeApp({
apiKey: import.meta.env.VITE_FIREBASE_API_KEY, // public identifier, not a secret
authDomain: import.meta.env.VITE_FIREBASE_AUTH_DOMAIN,
projectId: import.meta.env.VITE_FIREBASE_PROJECT_ID,
appId: import.meta.env.VITE_FIREBASE_APP_ID,
});
export const auth = getAuth(app);
export const db = initializeFirestore(app, {
localCache: persistentLocalCache({ tabManager: persistentMultipleTabManager() }),
});
if (import.meta.env.DEV) {
connectAuthEmulator(auth, 'http://127.0.0.1:9099', { disableWarnings: true });
connectFirestoreEmulator(db, '127.0.0.1', 8080);
}
firebase/firestore, firebase-admin/firestore); leave existing compat code alone unless asked to migraterequest.auth.uid and custom claims, set timestamps with request.time / serverTimestamp(), restrict updates with diff().affectedKeys().hasOnly()limit() and its composite index in firestore.indexes.jsonevent.id) and guard against re-triggering on their own writesdefineSecret and bind them per function; enforce App Check on callables the client usesallow read, write: if true rules, or trust role, ownerId or createdAt sent by the clientinitializeApp with a key file on Google infrastructure (use ADC, Workload Identity Federation in CI)functions.config() (removed in firebase-functions 7) or start new 1st gen functionsonSnapshot to unbounded collections, or read one document per list row (N+1)apiKey as the security boundaryWhen implementing a Firebase feature, provide:
firestore.indexes.json entriesfirebase deploy --only ... targets, secrets to set and plan requirementsFirebase JS SDK 13 (modular), firebase-admin 14, firebase-functions 7, firebase-tools 15, Cloud Firestore Standard and Enterprise editions, Security Rules v2, @firebase/rules-unit-testing 6, Firebase Authentication, Identity Platform, custom claims, session cookies, blocking functions, Cloud Functions 2nd gen (Cloud Run, Eventarc), params and Secret Manager, Cloud Storage for Firebase, App Check (reCAPTCHA Enterprise, Play Integrity, App Attest), Firebase Hosting, App Hosting, Emulator Suite, Realtime Database, SQL Connect, Firebase AI Logic
cloud-architect: wider Google Cloud topology, multi-region and disaster recovery beyond Firebasesecure-code-guardian: generic auth hardening, input validation and OWASP controlsnextjs-developer, react-expert: UI and SSR around the Firebase data layerflutter-expert, react-native-expert: mobile clients (FlutterFire, React Native Firebase); rules, indexes and functions here still applyMaintained by @jeffallan, Principal Consultant at Synergetic Solutions
AFaffaan-m/ECC315k4,381 new stars in the last 7 days
Audit the whole repo: find bugs, security holes and performance bottlenecks. Get a ranked report in plain English.
DIDietrichGebert/ponytail203k4,904 new stars in the last 7 days
GAgarrytan/gstack143k598 new stars in the last 7 days
Harden code against the OWASP Top 10: input handling, authentication, sessions and dependencies.
ADaddyosmani/agent-skills122k1,667 new stars in the last 7 days
ADaddyosmani/agent-skills122k1,667 new stars in the last 7 days
RUruvnet/RuView106k739 new stars in the last 7 days