firebase-cloud-functions — скилл для Claude Code: вызов функций
Помогает агенту писать код для вызова Firebase Cloud Functions во Flutter: обработка ошибок, таймауты и работа с эмулятором.
MIT ★ 674 обновлён 2026-10-29
/plugin marketplace add evanca/flutter-ai-rules
/plugin install flutter-ai-skills@flutter-ai-rulesЧто делает firebase-cloud-functions
Скилл регламентирует интеграцию пакета cloud_functions во Flutter-проекты. Он учит агента использовать httpsCallable, передавать аргументы через Map и разбирать возвращаемый result.data. Правила запрещают передавать токены авторизации в параметрах вызова, потому что клиентский SDK добавляет их автоматически.
Шаблон охватывает перехват FirebaseFunctionsException с проверкой кодов вроде unavailable или permission-denied. В код закладываются таймауты через HttpsCallableOptions и выбор региона развёртывания с помощью FirebaseFunctions.instanceFor.
Для отладки без боевого окружения скилл перенаправляет запросы в Firebase Emulator Suite через useFunctionsEmulator('localhost', 5001).
Какие задачи решает
- настроить вызов callable-функций Firebase из Flutter
- обработать ошибки сети и FirebaseFunctionsException
- переключить вызовы на локальный Firebase Emulator Suite
- задать регион развёртывания и таймаут выполнения
Примеры запросов агенту
- Напиши вызов httpsCallable функции addMessage во Flutter с обработкой ошибок
- Подключи локальный эмулятор Firebase Functions на localhost:5001
- Настрой таймаут на 30 секунд для callable-функции в europe-west1
Как установить firebase-cloud-functions
1Через маркетплейс плагинов
/plugin marketplace add evanca/flutter-ai-rules/plugin install flutter-ai-skills@flutter-ai-rulesКоманда ставит плагин flutter-ai-skills целиком, со всеми его скиллами
2Через Skills CLI (Vercel)
npx skills add evanca/flutter-ai-rules --skill firebase-cloud-functions -a claude-code3Вручную: положить файлы
~/.claude/skills/firebase-cloud-functions/SKILL.mdПапка скилла целиком; для одного проекта — .claude/skills/firebase-cloud-functions/
1Через Skills CLI (Vercel)
npx skills add evanca/flutter-ai-rules --skill firebase-cloud-functions -a codex2Вручную: положить файлы
.agents/skills/firebase-cloud-functions/SKILL.mdДля всех проектов — ~/.agents/skills/
1Через Skills CLI (Vercel)
npx skills add evanca/flutter-ai-rules --skill firebase-cloud-functions -a cursor2Вручную: положить файлы
.cursor/skills/firebase-cloud-functions/SKILL.mdCursor читает и .agents/skills/, и .claude/skills/
1GitHub CLI
gh skill install evanca/flutter-ai-rules skills/firebase-cloud-functions2Вручную: положить файлы
.github/skills/firebase-cloud-functions/SKILL.md1Через Skills CLI (Vercel)
npx skills add evanca/flutter-ai-rules --skill firebase-cloud-functions -a gemini-cli2Командой платформы
gemini skills install https://github.com/evanca/flutter-ai-rules --path skills/firebase-cloud-functionsВручную: положить файлы
.devin/skills/firebase-cloud-functions/SKILL.mdСтарый путь .windsurf/skills/ тоже читается
Claude.ai
Упакуйте папку в zip и загрузите в Settings → Capabilities → Skills
По шагам, с командами для каждой платформы: Как установить скилл в Claude Code: пять способов
Вопросы о firebase-cloud-functions
Как установить firebase-cloud-functions в Claude Code?
Выполните команду /plugin marketplace add evanca/flutter-ai-rules, а затем /plugin install flutter-ai-skills@flutter-ai-rules. Также можно использовать команду npx skills add evanca/flutter-ai-rules --skill firebase-cloud-functions -a claude-code.
Что делает скилл firebase-cloud-functions?
Он задаёт правила генерации Dart-кода для Cloud Functions: вызов httpsCallable, сериализацию параметров, перехват исключений и настройку эмулятора.
Нужно ли вручную передавать токен авторизации в аргументах?
Нет. SDK Firebase передаёт токены аутентификации автоматически, поэтому передавать их внутри параметров функции нельзя.
Исходный текст
SKILL.md · MIT
---
name: firebase-cloud-functions
description: "Use when calling callable functions (httpsCallable), passing data to server-side logic, handling function errors/timeouts, configuring regions, or testing with the Emulator Suite."
license: MIT
---
# Firebase Cloud Functions Skill
This skill defines how to correctly call Firebase Cloud Functions from Flutter applications.
## When to Use
Use this skill when:
* Implementing callable Cloud Functions in a Flutter project.
* Passing structured data to server-side functions and processing results.
* Handling errors, timeouts, and retries for function calls.
* Configuring region-specific function deployments.
* Testing Cloud Functions locally with the Firebase Emulator Suite.
---
## 1. Setup and Configuration
```
flutter pub add cloud_functions
```
```dart
import 'package:cloud_functions/cloud_functions.dart';
// After Firebase.initializeApp():
final functions = FirebaseFunctions.instance;
```
- Initialize Firebase before using any Cloud Functions features.
- For region-specific deployments, specify the region:
```dart
final functions = FirebaseFunctions.instanceFor(region: 'europe-west1');
```
- Deploy callable functions to Firebase **before** attempting to call them from the Flutter app.
- Consider implementing **App Check** to prevent abuse of Cloud Functions.
---
## 2. Calling Functions
Use `httpsCallable` to reference a function, then `call` to invoke it:
```dart
final result = await FirebaseFunctions.instance
.httpsCallable('functionName')
.call(data);
```
- Pass data as a `Map` — it is automatically serialized to JSON:
```dart
final result = await FirebaseFunctions.instance
.httpsCallable('addMessage')
.call({
"text": messageText,
"push": true,
});
```
- Access the result via the `data` property — it is automatically deserialized from JSON:
```dart
final responseData = result.data;
// Cast to expected type if needed:
final message = result.data as Map<String, dynamic>;
final status = message['status'] as String;
```
- **Do not** pass authentication tokens in function parameters — they are automatically included by the SDK.
- Keep function names consistent between client code and server-side implementations.
---
## 3. Error Handling
Always wrap function calls in `try-catch` and check for `FirebaseFunctionsException`:
```dart
try {
final result = await FirebaseFunctions.instance
.httpsCallable('functionName')
.call(data);
// Handle successful result
} on FirebaseFunctionsException catch (e) {
switch (e.code) {
case 'not-found':
// Function does not exist
break;
case 'permission-denied':
// User lacks permission
break;
case 'unavailable':
// Service temporarily unavailable — retry
break;
default:
debugPrint('Function error [${e.code}]: ${e.message}');
}
} catch (e) {
debugPrint('Unexpected error: $e');
}
```
- Handle network connectivity issues and timeouts appropriately.
- Provide meaningful error messages to users when function calls fail.
- Implement retry logic with exponential backoff for transient errors (`unavailable`, `deadline-exceeded`).
---
## 4. Performance Optimization
Set a timeout appropriate to the expected execution time:
```dart
final callable = FirebaseFunctions.instance.httpsCallable(
'functionName',
options: HttpsCallableOptions(
timeout: const Duration(seconds: 30),
),
);
```
- Minimize the amount of data passed to and from functions to reduce latency.
- Use batch operations when possible to reduce the number of function calls.
- Consider client-side caching for frequently used function results.
- Account for **cold starts** for infrequently used functions.
- Implement proper loading states in the UI while waiting for function responses.
---
## 5. Testing and Development
Use the Firebase Emulator Suite for local development and testing:
```dart
FirebaseFunctions.instance.useFunctionsEmulator('localhost', 5001);
```
- Test functions with both valid and invalid inputs to ensure proper validation.
- Verify that functions handle authentication correctly.
- Test with different user roles and permissions to ensure proper access control.
- Implement unit tests for client-side function calling logic.
---
## References
- [Cloud Functions for Firebase Flutter documentation](https://firebase.google.com/docs/functions/callable?platform=flutter)
- [Firebase Emulator Suite](https://firebase.google.com/docs/emulator-suite)
© Ivanna Kaceviča · MIT · evanca/flutter-ai-rules