firebase — Cursor rule: what it does, how to install
Enforces Firebase security patterns in Cursor. Focuses on setting up App Check and relying on Security Rules rather than client logic.
.cursor/rules/firebase.mdcWhat firebase does
This rule applies across the repository via the **/* glob. It instructs the assistant to treat all client-side code as compromised. Because of this, access control belongs strictly in Firebase Security Rules and App Check.
The guide mandates App Check across Firestore, Realtime Database, Storage, and Functions. Initialization happens early on the client using initializeAppCheck with providers like ReCaptchaV3Provider for web apps or native providers for mobile setups. Without registering the application inside the Firebase Console, App Check verifications will fail.
What it helps with
- configure Firebase App Check for incoming client requests
- initialize ReCaptchaV3Provider in client bootstrap files
- enforce access boundaries on Firestore, Storage, and Functions
Example prompts for the agent
- Initialize Firebase App Check inside
firebase.ts - Configure ReCaptchaV3Provider for client verification
- Set up Firebase initialization for web with App Check
How to install firebase
Manually: put the files in place
.cursor/rules/firebase.mdcFrontmatter: description, globs, alwaysApply
Manually: put the files in place
.claude/rules/firebase.mdThe paths frontmatter field limits the files: move globs from the source into paths
AGENTS.md
Codex reads AGENTS.md: paste the rule text there
Manually: put the files in place
.github/instructions/firebase.instructions.mdThe applyTo field sets which files it applies to: move globs from the source into applyTo
Manually: put the files in place
.devin/rules/firebase.mdManually: put the files in place
.clinerules/firebase.mdStep by step, with commands for each platform: Cursor rules: .mdc files, four modes and what replaced .cursorrules
Questions about firebase
How do I install the firebase rule in Cursor?
Save the rule content into .cursor/rules/firebase.mdc in your repository root. Cursor will automatically apply these instructions across the workspace.
What does the firebase rule do?
It directs Cursor to follow strict Firebase security practices, emphasizing client verification via App Check and server-enforced security rules.
Which Firebase services require App Check?
The guide specifies enabling App Check for Firestore, Realtime Database, Storage, and Functions.
Source text
firebase.mdc · CC0-1.0
---
description: This guide provides definitive, opinionated best practices for building secure, performant, and maintainable applications with Firebase, focusing on modern patterns and avoiding common pitfalls.
globs: **/*
---
# firebase Best Practices
Firebase is a powerful Backend-as-a-Service (BaaS) that accelerates development. To leverage it effectively, you must adhere to strict best practices for security, performance, and maintainability. This guide outlines the definitive approach for our team.
## 1. Security Best Practices
Security is paramount. Assume all client-side code is compromised and enforce access control exclusively through Firebase Security Rules and App Check.
### 1.1 Enable Firebase App Check
Always enable App Check for all supported Firebase services. This verifies that requests originate from your authentic app and an untampered device, preventing unauthorized clients from accessing your backend.
**✅ GOOD: Enable App Check**
Configure App Check in the Firebase Console for Firestore, Realtime Database, Storage, and Functions. On the client, initialize it early.
```typescript
// client/src/firebase.ts
import { initializeApp } from 'firebase/app';
import { initializeAppCheck, ReCaptchaV3Provider } from 'firebase/app-check';
// For mobile, use platform-specific providers (e.g., ReactNativeFirebaseAppCheckProvider)
const firebaseConfig = {
apiKey: "YOUR_API_KEY",
authDomain: "YOUR_AUTH_DOMAIN",
projectId: "YOUR_PROJECT_
© sanjeed5 · CC0-1.0 · sanjeed5/awesome-cursor-rules-mdc