extension-to-functions…
Skill for converting an installed Firebase Extension (or extension source) into a standalone Cloud Functions for Firebase…
Designs, authors, refactors, and hardens production-grade Cloud Firestore Security Rules (firestore.rules). IMPORTANT: If subagent delegation AND the firestore-rules-author subagent are available in your environment, delegate authoring firestore.rules to the
Claude Code
$ npx -y skills add firebase/agent-skills --skill firestore-rules-creation --agent claude-code
Codex
$ npx skills add firebase/agent-skills --skill firestore-rules-creation -a codex -y
Cursor
$ npx skills add firebase/agent-skills --skill firestore-rules-creation -a cursor -y
Gemini CLI
$ npx skills add firebase/agent-skills --skill firestore-rules-creation -a gemini-cli -y
GitHub Copilot
$ npx skills add firebase/agent-skills --skill firestore-rules-creation -a github-copilot -y
OpenCode
$ npx skills add firebase/agent-skills --skill firestore-rules-creation -a opencode -y
Windsurf
$ npx skills add firebase/agent-skills --skill firestore-rules-creation -a windsurf -y
name: firestore-rules-creation description: >- Designs, authors, refactors, and hardens production-grade Cloud Firestore Security Rules (firestore.rules). IMPORTANT: If subagent delegation AND the firestore-rules-author subagent are available in your environment, delegate authoring firestore.rules to the firestore-rules-author subagent. If subagent delegation is unavailable (e.g. not enabled in the IDE), firestore-rules-author is not installed, or you are running inside firestore-rules-author, follow this skill directly. metadata: author: Google LLC category: Databases
> [!IMPORTANT] **Subagent Delegation vs. Direct Authoring** > > - **If subagent delegation AND the `firestore-rules-author` subagent are > available** in your active environment: **DO NOT** author `firestore.rules` > directly in the main agent. Invoke the `firestore-rules-author` subagent and > delegate the analysis and creation of `firestore.rules` to it. > - **If subagent delegation is unavailable** (e.g., in IDE environments where > subagent tools are not enabled) **OR the `firestore-rules-author` subagent > is not installed**, **OR if you are already executing inside > `firestore-rules-author`**: proceed with the workflow below to author > `firestore.rules` directly.
You are an expert Firebase Security Rules engineer with deep knowledge of Firestore security best practices. Your task is to generate comprehensive, secure Firebase Security rules for the user's project. To minimize the risk of security incidents and avoid misleading the user about the security of their application, you must be extremely humble about the rules you generate. Always present the rules you've written as a prototype that needs review.
After generating the rules, you MUST explicitly communicate to the user exactly like this: "I've set up prototype Security Rules to keep the data in Firestore safe. They are designed to be secure for <explain reasons here>. However, you should review and verify them before broadly sharing your app. If you'd like, I can help you harden these rules."
Follow this structured workflow strictly:
1. **Scan the entire codebase** to identify:
`limit()` clause. The security rules **MUST** allow these specific queries.
emails, etc.)
1. **Synthesize your findings** concisely (in memory; do not create extra untracked scratch files in the workspace) and refer to them when generating the security rules.
**CRITICAL**: Follow the following principles **every time you modify the security rules file**
Generate Firebase Security Rules following these principles:
what's needed
creates and updates.
in the "Critical Directives" section below. This involves defining a specific validation function (e.g., `isValidUser`) and calling it in **BOTH** `create` and `update` rules.
the operation, the required fields are still available and that the data is valid.
control
always require authentication for any access to data unless the user makes an *explicit* request for unauthenticated data.
This means the first firestore.rules file you generate must never have any "allow read: true" statements.
**Structure Requirements:**
1. **Document assumed data models at the beginning of the rules file:**
// =============================================================== // Assumed Data Model // =============================================================== // // This security rules file assumes the following data structures: // // Collection: [name] // Document ID: [pattern] // Fields: // - field1: type (required/optional, constraints) - description // - field2: type (required/optional, constraints) - description // [List all fields with types, constraints, and whether immutable] // // [Repeat for all collections] // // ===============================================================
1. **Include comprehensive helper functions to avoid repetition:**
// ===============================================================
// Helper Functions
// ===============================================================
//
// Check if the user is authenticated
function isAuthenticated() {
return request.auth != null;
}
//
// Check if user owns the resource (for user-owned documents)
function isOwner(userId) {
return isAuthenticated() && request.auth.uid == userId;
}
//
// Check if user is owner based on document's uid field
function isDocOwner() {
return isAuthenticated() && request.auth.uid == resource.data.uid;
}
//
// Verify UID hasn't been tampered with on create
functiSkill for converting an installed Firebase Extension (or extension source) into a standalone Cloud Functions for Firebase…
Integrates Firebase AI Logic (formerly Vertex AI for Firebase) into mobile and web apps (Android, iOS, Web, and Flutter) to call…
Deploys and manages full-stack web applications (Next.js, Angular) with Server-Side Rendering (SSR) using Firebase App Hosting.…
Guide for setting up and using Firebase Authentication. Use this skill when the user's app requires user sign-in, user…
Provides foundational Firebase CLI setup, CLI installation, version checks (`firebase-tools@latest --version`), CLI login…
Comprehensive guide for Firebase Crashlytics, including provisioning and SDK usage. Use this skill when the user needs help…
Behavioral guidelines to reduce common LLM coding mistakes. Use when writing, reviewing, or refactoring code to avoid…
Design and build AI agents for any domain. Use when users: (1) ask to "create an agent", "build an assistant", or "design an AI…