firebase-ai — Claude Code skill: what it does, how to install
This skill gives the agent working patterns for wiring up Firebase AI Logic in a Flutter app and writing Gemini text and chat calls.
MIT ★ 674 updated 2026-10-29
/plugin marketplace add evanca/flutter-ai-rules
/plugin install flutter-ai-skills@flutter-ai-rulesWhat firebase-ai does
The skill covers the core firebase_ai setup in Flutter: calling Firebase.initializeApp, creating a model with FirebaseAI.googleAI().generativeModel, running single-turn generation, keeping a multi-turn conversation through model.startChat(), and streaming output via generateContentStream so the UI updates as text arrives. It also shows how to send a combined text-and-image prompt using Content.multi and InlineDataPart.
A separate section walks through catching FirebaseAIException, detecting quota errors, and applying exponential backoff, plus configuring safetySettings with HarmCategory values and turning on App Check to guard the AI endpoints. Windows isn't supported at all, and macOS and other Apple platforms are marked beta.
The agent uses these patterns when touching Dart code, but the project still needs Firebase AI Logic enabled in the Firebase console before any of this runs.
What it helps with
- wire up
firebase_aiin a Flutter project - generate a text response with Gemini
- build a multi-turn chat that keeps conversation history
- stream a Gemini response into the UI as it's generated
- send a Gemini prompt that mixes text and an image
Example prompts for the agent
- Set up firebase_ai in this project and initialize a Gemini model
- Stream the Gemini response into the UI as chunks arrive
- Add quota error handling around the generateContent call
How to install firebase-ai
1Plugin marketplace
/plugin marketplace add evanca/flutter-ai-rules/plugin install flutter-ai-skills@flutter-ai-rulesThis installs the whole flutter-ai-skills plugin with all its skills
2Skills CLI (Vercel)
npx skills add evanca/flutter-ai-rules --skill firebase-ai -a claude-code3Manually: put the files in place
~/.claude/skills/firebase-ai/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/firebase-ai/
1Skills CLI (Vercel)
npx skills add evanca/flutter-ai-rules --skill firebase-ai -a codex2Manually: put the files in place
.agents/skills/firebase-ai/SKILL.mdFor all projects use ~/.agents/skills/
1Skills CLI (Vercel)
npx skills add evanca/flutter-ai-rules --skill firebase-ai -a cursor2Manually: put the files in place
.cursor/skills/firebase-ai/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install evanca/flutter-ai-rules skills/firebase-ai2Manually: put the files in place
.github/skills/firebase-ai/SKILL.md1Skills CLI (Vercel)
npx skills add evanca/flutter-ai-rules --skill firebase-ai -a gemini-cli2Platform CLI
gemini skills install https://github.com/evanca/flutter-ai-rules --path skills/firebase-aiManually: put the files in place
.devin/skills/firebase-ai/SKILL.mdThe legacy .windsurf/skills/ path still works
Claude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
Step by step, with commands for each platform: How to install skills in Claude Code: five ways
Questions about firebase-ai
How do I install firebase-ai in Claude Code?
Run /plugin marketplace add evanca/flutter-ai-rules, then /plugin install flutter-ai-skills@flutter-ai-rules.
What does the firebase-ai skill do?
It gives the agent correct code patterns for Firebase AI Logic in Flutter: setup, Gemini text and chat generation, streaming output, multimodal prompts, and error handling.
Which platforms does Firebase AI Logic support?
iOS, Android and Web are fully supported, macOS and other Apple platforms are in beta, and Windows isn't supported.
Source text
SKILL.md · MIT
---
name: firebase-ai
description: "Use when setting up firebase_ai, generating text/chat with Gemini, streaming AI output, building multimodal prompts, or handling AI errors."
license: MIT
---
# Firebase AI Skill
This skill defines how to correctly use Firebase AI Logic in Flutter applications.
## When to Use
Use this skill when:
* Setting up and configuring Firebase AI in a Flutter project.
* Generating text content or chat responses with Gemini models.
* Implementing streaming AI responses for real-time UI updates.
* Sending multimodal prompts (text + images) to Gemini.
* Handling errors, offline scenarios, and rate limits for AI operations.
* Applying security and privacy considerations for AI features.
---
## 1. Setup and Configuration
```
flutter pub add firebase_ai
```
```dart
import 'package:firebase_ai/firebase_ai.dart';
import 'package:firebase_core/firebase_core.dart';
import 'firebase_options.dart';
// Initialize FirebaseApp
await Firebase.initializeApp(
options: DefaultFirebaseOptions.currentPlatform,
);
// Initialize the Gemini Developer API backend service
final model =
FirebaseAI.googleAI().generativeModel(model: 'gemini-2.5-flash');
```
- Ensure the Firebase project is configured for AI services via the Firebase AI Logic page in the Firebase Console.
- Initialize Firebase before using any Firebase AI features.
- Use `FirebaseAI.googleAI()` for the **Gemini Developer API** backend (recommended starting point).
- Implement **App Check** to prevent abuse of Firebase AI endpoints.
**Platform support:**
| Platform | Support |
|---|---|
| iOS | Full |
| Android | Full |
| Web | Full |
| macOS / other Apple | Beta |
| Windows | Not supported |
---
## 2. Generating Content
### Single-turn text generation
```dart
final response = await model.generateContent([
Content.text('Summarize the benefits of Flutter for mobile development'),
]);
final text = response.text; // The generated summary string
```
### Multi-turn chat
```dart
final chat = model.startChat();
final response = await chat.sendMessage(
Content.text('What is the difference between StatelessWidget and StatefulWidget?'),
);
print(response.text);
// Follow-up in the same conversation
final followUp = await chat.sendMessage(
Content.text('When should I use StatefulWidget?'),
);
print(followUp.text);
```
### Streaming responses
Use streaming to display partial results as they arrive:
```dart
final stream = model.generateContentStream([
Content.text('Write a step-by-step guide to implementing dark mode in Flutter'),
]);
await for (final chunk in stream) {
// Append chunk.text to the UI progressively
setState(() => _output += chunk.text ?? '');
}
```
### Multimodal prompts (text + image)
```dart
final imageBytes = await File('photo.jpg').readAsBytes();
final response = await model.generateContent([
Content.multi([
TextPart('Describe what you see in this image'),
InlineDataPart('image/jpeg', imageBytes),
]),
]);
```
---
## 3. Error Handling
Wrap AI calls in structured error handling:
```dart
try {
final response = await model.generateContent([Content.text(prompt)]);
return response.text;
} on FirebaseAIException catch (e) {
if (e.message?.contains('quota') ?? false) {
// Handle rate limiting — show retry message or queue the request
return 'Service is busy. Please try again shortly.';
}
return 'AI service error: ${e.message}';
} catch (e) {
return 'Unexpected error: $e';
}
```
- Provide meaningful error messages to users when AI operations fail.
- Handle **offline scenarios** with appropriate fallback behavior (e.g., cached responses).
- Implement **exponential backoff** for rate-limited or transient errors.
---
## 4. Security and Privacy
- Follow Firebase Security Rules best practices when using AI services alongside other Firebase products.
- Ensure proper **authentication and authorization** for AI feature access.
- Sanitize user input before sending it to the model to prevent prompt injection.
- Be mindful of **data privacy requirements** when processing user content with AI services.
- Implement appropriate **content filtering and moderation** using safety settings:
```dart
final model = FirebaseAI.googleAI().generativeModel(
model: 'gemini-2.5-flash',
safetySettings: [
SafetySetting(HarmCategory.harassment, HarmBlockThreshold.medium),
SafetySetting(HarmCategory.dangerousContent, HarmBlockThreshold.high),
],
);
```
---
## References
- [Firebase AI Logic Flutter documentation](https://firebase.google.com/docs/ai-logic/get-started?platform=flutter)
© Ivanna Kaceviča · MIT · evanca/flutter-ai-rules