Agent skill

Firebase Database

by evanca in evanca/flutter-ai-rules

A skill your agent uses when syncing real-time data, structuring JSON trees, reading/writing, creating listeners, enabling offline persistence, managing presence, sharding, or writing security rules.

MITAuto-check passedDatabases

Install Firebase Database

skills CLI
$ npx skills add evanca/flutter-ai-rules --skill firebase-database -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install evanca/flutter-ai-rules firebase-database --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/evanca/flutter-ai-rules.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/firebase-database .claude/skills/firebase-database && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
firebase-database
GitHub stars
647
Token cost
~2k tokens
SKILL.md length
546 words
Files
1
Skills in repo
37
Repo updated
First seen
Licence
MIT

At a glance

A skill your agent uses when syncing real-time data, structuring JSON trees, reading/writing, creating listeners, enabling offline persistence, managing presence, sharding, or writing security rules.

  • Works in 8 steps: Database Selection → Setup and Configuration → Data Structure → …
  • Syncing real-time data
  • SKILL.md covers When to Use, 1. Database Selection, 2. Setup and Configuration and 3. Data Structure, plus 6 more sections
  • Calls flutter

What it does

Firebase Database is an agent skill from evanca/flutter-ai-rules. Use when syncing real-time data, structuring JSON trees, reading/writing, creating listeners, enabling offline persistence, managing presence, sharding, or writing security rules.

Its SKILL.md is about 2k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in Databases, covering Database administration. It works with Firebase. The repository describes itself as: Flutter AI Skills and Rules for Claude, Codex, Cursor, and Other AI-Powered IDEs. The licence is MIT.

When your agent uses it

  • Syncing real-time data
  • Structuring JSON trees
  • Reading/writing
  • Creating listeners

Example prompts

  • “/firebase-database”

Workflow steps

8 steps, taken from the step headings in SKILL.md.

  1. Database Selection
  2. Setup and Configuration
  3. Data Structure
  4. Indexing and Querying
  5. Read and Write Operations
  6. Designing for Scale
  7. Offline Capabilities and Presence
  8. Security

What it can do on your machine

Read from SKILL.md and the folder at commit 7b9cce2. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • flutter

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    Links to these hosts (documentation or services it may open):

    • firebase.google.com

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Firebase Database loads about 2k tokens when it runs. Until then it costs about 49 tokens; SKILL.md has 546 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~49
When it runs · the whole SKILL.md, loaded when a task matches
~2k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from evanca/flutter-ai-rules at commit 7b9cce2, republished under its MIT licence (© evanca). 546 words, ~2,006 tokens.

Download SKILL.mdSave it as .claude/skills/firebase-database/SKILL.md (or your agent's skills folder).
name
firebase-database
description
Use when syncing real-time data, structuring JSON trees, reading/writing, creating listeners, enabling offline persistence, managing presence, sharding, or writing security rules.
license
MIT

Firebase Realtime Database Skill

This skill defines how to correctly implement Firebase Realtime Database in Flutter applications, covering data modeling, queries, real-time sync, offline support, and security rules.

When to Use

Use this skill when working with Firebase Realtime Database for simple data models, low-latency sync, or presence functionality. For rich data models requiring complex queries and high scalability, use Cloud Firestore instead.


1. Database Selection

Choose Realtime Database when the app needs:

  • Simple data models with simple lookups.
  • Extremely low-latency synchronization (typical response times under 10ms).
  • Deep queries that return an entire subtree by default.
  • Access to data at any granularity, down to individual leaf-node values.
  • Frequent state-syncing with built-in presence functionality.

Choose Cloud Firestore instead for rich data models requiring queryability, scalability, and high availability.


2. Setup and Configuration

flutter pub add firebase_database
dart
import 'package:firebase_database/firebase_database.dart';

// After Firebase.initializeApp():
final DatabaseReference ref = FirebaseDatabase.instance.ref();
  • Select the database location closest to users.
  • Enable persistence for offline capabilities:
dart
FirebaseDatabase.instance.setPersistenceEnabled(true);
FirebaseDatabase.instance.setPersistenceCacheSizeBytes(10000000); // 10MB
Setup Checklist
  1. Confirm Firebase.initializeApp() completes before accessing FirebaseDatabase.instance.
  2. Set persistence before any read/write operations.
  3. Verify connectivity by writing a test value and reading it back.

3. Data Structure

  • Structure data as a flattened JSON tree — avoid deep nesting.
  • Maximum nesting depth is 32 levels.
  • Design the data structure to support the most common queries.
  • Use push IDs for unique identifiers in list-type data:
dart
final newPostKey = FirebaseDatabase.instance.ref().child('posts').push().key;
  • Denormalize data when necessary — Realtime Database does not support joins.
  • Custom keys must be UTF-8 encoded, max 768 bytes, and cannot contain . $ # [ ] / or ASCII control characters 0-31 or 127.
Flattened Structure Example
dart
// Instead of nesting chat messages inside rooms:
// rooms/roomId/messages/messageId/...

// Flatten into separate top-level paths:
// rooms/roomId: { name: "General", createdBy: "uid1" }
// room-members/roomId: { uid1: true, uid2: true }
// room-messages/roomId/messageId: { text: "Hello", sender: "uid1", timestamp: ... }

This pattern allows reading room metadata without downloading all messages.


4. Indexing and Querying

  • Queries can sort or filter on a property, but not both in the same query.
  • Use .indexOn in security rules to index frequently queried fields:
json
{
  "rules": {
    "dinosaurs": {
      ".indexOn": ["height", "length"]
    }
  }
}
  • Queries are deep by default and return the entire subtree.
  • Sort with orderByChild(), orderByKey(), or orderByValue():
dart
final query = FirebaseDatabase.instance.ref("dinosaurs").orderByChild("height");
  • Limit results with limitToFirst() or limitToLast():
dart
final query = ref.orderByChild("height").limitToFirst(10);
  • Range queries using startAt(), endAt(), and equalTo():
dart
// Find users whose name starts with "A"
final query = ref.child("users")
    .orderByChild("name")
    .startAt("A")
    .endAt("A\uf8ff");

Show full SKILL.md (237 more words)Show less

5. Read and Write Operations

Read once:

dart
final snapshot = await FirebaseDatabase.instance.ref('users/123').get();
if (snapshot.exists) {
  print(snapshot.value);
}

Real-time listener:

dart
final subscription = FirebaseDatabase.instance
    .ref('users/123')
    .onValue
    .listen((event) {
      final data = event.snapshot.value;
      print(data);
    });

// Cancel when no longer needed:
subscription.cancel();

A DatabaseEvent fires every time data changes at the reference, including changes to children.

Write (replace):

dart
await ref.set({
  "name": "John",
  "age": 18,
  "created_at": ServerValue.timestamp,
});

Update (partial):

dart
await ref.update({"age": 19});

Atomic transaction:

dart
final result = await FirebaseDatabase.instance
    .ref('posts/123/likes')
    .runTransaction((currentValue) {
      return Transaction.success((currentValue as int? ?? 0) + 1);
    });
print('Likes: ${result.snapshot.value}');

Multi-path atomic update:

dart
final updates = <String, dynamic>{
  'posts/$postId': postData,
  'user-posts/$uid/$postId': postData,
};
await FirebaseDatabase.instance.ref().update(updates);
  • Keep individual write operations under 256KB.
  • Use listeners for real-time updates rather than polling.

6. Designing for Scale

  • Realtime Database scales to ~200,000 concurrent connections and 1,000 writes/second per database. For higher scale, shard data across multiple database instances.
  • Avoid storing large blobs — use Firebase Storage for files.
  • Use server timestamps for consistent time tracking:
dart
await FirebaseDatabase.instance.ref('posts/123/timestamp').set(ServerValue.timestamp);
  • Implement fan-out patterns for data accessed from multiple paths.
  • Avoid deep nesting — it leads to performance issues when retrieving data.

7. Offline Capabilities and Presence

dart
FirebaseDatabase.instance.setPersistenceEnabled(true);

// Keep critical paths synced when offline
FirebaseDatabase.instance.ref('important-data').keepSynced(true);
Connection State and Presence
dart
// Detect connection state
FirebaseDatabase.instance.ref('.info/connected').onValue.listen((event) {
  final connected = event.snapshot.value as bool? ?? false;
  if (connected) {
    // Set online status and configure onDisconnect cleanup
    final presenceRef = FirebaseDatabase.instance.ref('status/${uid}');
    presenceRef.set({'online': true, 'last_seen': ServerValue.timestamp});
    presenceRef.onDisconnect().set({
      'online': false,
      'last_seen': ServerValue.timestamp,
    });
  }
});
  • Use value events (onValue) to read data and get notified of updates — optimized for online/offline transitions.
  • Use get() only when data is needed once; it probes local cache if the server is unavailable.
  • onDisconnect() operations are executed server-side, ensuring cleanup even if the app crashes.

8. Security

json
{
  "rules": {
    "users": {
      "$uid": {
        ".read": "$uid === auth.uid",
        ".write": "$uid === auth.uid"
      }
    }
  }
}
  • Use .read, .write, .validate, and .indexOn to control access and validate data.
  • Read and write rules cascade in Realtime Database — a parent rule granting access cannot be revoked by a child rule.
  • Use the auth variable to authenticate users in security rules.
Data Validation Example
json
{
  "rules": {
    "messages": {
      "$messageId": {
        ".validate": "newData.hasChildren(['text', 'sender', 'timestamp'])",
        "text": {
          ".validate": "newData.isString() && newData.val().length <= 500"
        }
      }
    }
  }
}
  • Test rules thoroughly using the Firebase console's rules simulator.
  • Use the Firebase Emulator Suite for local testing.

References

© evanca, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in skills/firebase-database of evanca/flutter-ai-rules.

Open the folder on GitHubat commit 7b9cce2

Compare with similar skills

Firebase Database next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Firebase Database compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Firebase Database this skillevanca/flutter-ai-rules647—~2kAutomated safety check: PassMIT
Hybrid Cloud Outboxesgetsentry/sentry45k—~4.8kAutomated safety check: PassCustom licence
Sea Orm 2FlyinPancake/yoink112—~2.9kAutomated safety check: PassApache-2.0
Redis Clusteringredis/agent-skills1651 repos~1kAutomated safety check: PassMIT
DB AdminEliasOulkadi/shokunin114—~2kAutomated safety check: NotesMIT
Redis Connectionsredis/agent-skills1651 repos~1.3kAutomated safety check: PassMIT

Similar skills

  • Hybrid Cloud Outboxes

    getsentry/sentry

    Official

    Guide for creating and maintaining outbox-based eventually consistent operations in Sentry.

    45k GitHub stars~4.8k tokensUpdated today
    DatabasesAuto-check passed
  • Sea Orm 2

    FlyinPancake/yoink

    Expert guidance for SeaORM 2.0, Rust's async ORM with strongly-typed columns, nested ActiveModels, Entity Loader API, and entity-first workflow.

    112 GitHub stars~2.9k tokensUpdated 2 days ago
    DatabasesAuto-check passed
  • Redis Clustering

    redis/agent-skills

    Official

    Redis Cluster and replication guidance covering hash tags for multi-key operations, avoiding CROSSSLOT errors, and reading from replicas to scale read-heavy workloads.

    165 GitHub starsUsed in 1 repo~1k tokens
    DatabasesAuto-check passed
  • DB Admin

    EliasOulkadi/shokunin

    PostgreSQL database administration — backup/restore (pgdump, PITR, WAL archiving), health monitoring (connections, bloat, cache hit ratio, dead tuples), connection pooling (PgBouncer), replication…

    114 GitHub stars~2k tokensUpdated 2 days ago
    DatabasesAuto-check: notes
  • Redis Connections

    redis/agent-skills

    Official

    Redis client and connection guidance covering connection pooling, multiplexing, pipelining, client-side caching with RESP3, avoiding slow commands (KEYS, SMEMBERS, HGETALL), and tuning socket…

    165 GitHub starsUsed in 1 repo~1.3k tokens
    DatabasesAuto-check passed
  • Bun Test Patterns

    shepherdjerred/monorepo

    Current Bun test runner guidance for discovery, isolation, parallelism, sharding, changed tests, mocks, timers, snapshots, coverage, DOM Testing Library, and integration teardown.

    112 GitHub stars~2k tokensUpdated today
    DatabasesAuto-check passed

More from evanca/flutter-ai-rules

All 37 skills in this repo
  • Code Review

    evanca/flutter-ai-rules

    A skill your agent uses when asked to review a PR, MR, branch, or diff, audit changed files, or check code quality.

    647 GitHub stars~2.4k tokensUpdated 23 days ago
    Auto-check passed
  • Developing Genkit Dart

    evanca/flutter-ai-rules

    A skill your agent uses when building AI agents in Dart, implementing Genkit flows or tools, integrating LLMs into Dart or Flutter applications, or using Genkit Dart plugins.

    647 GitHub stars~961 tokensUpdated 23 days ago
    Auto-check passed
  • Generate Images With Firebase AI

    evanca/flutter-ai-rules

    A skill your agent uses when generating or editing images from Flutter/Dart with Firebase AI Logic and a Gemini image model (Nano Banana), making the first call work, choosing Gemini Developer API…

    647 GitHub stars~2.3k tokensUpdated 23 days ago
    Auto-check passed
  • Flutter Use Column Row First

    evanca/flutter-ai-rules

    A skill your agent uses when building any Flutter screen or component to choose responsive Row, Column, Expanded, Flexible, and Spacer layouts before fixed-size or coordinate-based alternatives.

    647 GitHub stars~1.3k tokensUpdated 23 days ago
    Auto-check passed
  • Architecture Feature First

    evanca/flutter-ai-rules

    A skill your agent uses when creating a feature, designing folder structure, adding repositories/services/view models, wiring dependency injection, or deciding which layer owns logic.

    647 GitHub stars~1.9k tokensUpdated 23 days ago
    Auto-check passed
  • Bloc

    evanca/flutter-ai-rules

    A skill your agent uses when creating a Cubit or Bloc, modeling state with sealed classes or status enums, wiring BlocBuilder/BlocListener/BlocProvider, writing bloc tests, or choosing between Cubit…

    647 GitHub stars~2.8k tokensUpdated 23 days ago
    Auto-check passed

Works with

Categories

Questions about Firebase Database

What does Firebase Database do?

A skill your agent uses when syncing real-time data, structuring JSON trees, reading/writing, creating listeners, enabling offline persistence, managing presence, sharding, or writing security rules. Firebase Database is an agent skill from evanca/flutter-ai-rules. Use when syncing real-time data, structuring JSON trees, reading/writing, creating listeners, enabling offline persistence, managing presence, sharding, or writing security rules.

When should I use Firebase Database?

Firebase Database fits situations like: syncing real-time data; structuring JSON trees; reading/writing; creating listeners.

How do I install Firebase Database in Claude Code?

Run `npx skills add evanca/flutter-ai-rules --skill firebase-database -a claude-code`. Or copy the skill folder (skills/firebase-database in evanca/flutter-ai-rules) into .claude/skills/firebase-database in your project. Claude Code loads it when a task matches its description.

How do I install Firebase Database in Codex?

Run `npx skills add evanca/flutter-ai-rules --skill firebase-database -a codex`. Or copy the skill folder (skills/firebase-database in evanca/flutter-ai-rules) into .agents/skills/firebase-database in your project. Codex loads it when a task matches its description.

Can I use Firebase Database in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add evanca/flutter-ai-rules --skill firebase-database -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/firebase-database, .gemini/skills/firebase-database, .github/skills/firebase-database and .opencode/skills/firebase-database in your project.

What does Firebase Database need to run?

Going by SKILL.md and its folder, Firebase Database needs the command-line tools its instructions call (flutter).

Does Firebase Database access the network?

SKILL.md names 1 domain. As links in the text: firebase.google.com. This is read from the text; nothing was executed.

Is Firebase Database safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Firebase Database use?

Firebase Database is published under the MIT licence (declared in SKILL.md). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Firebase Database use?

About 2k tokens (SKILL.md is roughly 8k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Firebase Database?

Skills that share tags, products or a category with Firebase Database: Hybrid Cloud Outboxes (getsentry/sentry, 45k stars), Sea Orm 2 (FlyinPancake/yoink, 112 stars), Redis Clustering (redis/agent-skills, 165 stars) and DB Admin (EliasOulkadi/shokunin, 114 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Firebase Database?

evanca (a GitHub user) maintains it in evanca/flutter-ai-rules, which has 647 GitHub stars. The repository holds 37 skills in this directory. The repository was last updated on September 14, 2026.

Source: evanca/flutter-ai-rules on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.