firebase/agent-skills/extension-to-functions-codebase
Claude Code and agent skill by firebase/agent-skills
- community
- ext:[{"type":"hook","description":"Pre/post lifecycle hooks"}]
Checking that the SKILL.md file is still in the repository.
Skill for converting an installed Firebase Extension (or extension source) into a standalone Cloud Functions for Firebase codebase or publishable npm package, including V1 to V2 trigger upgrades, lifecycle hooks, and declarative security
Install
npx vskill@latest install firebase/agent-skills/extension-to-functions-codebaseSemi-extensibleMentions customization, but needs skill-specific knowledge. Read the extensible skills standard
SKILL.md
The same SKILL.md was published earlier as firebase/agent-skills/extension-to-functions-codebase.
Extension to Functions Codebase & npm Package Migration
Overview
Migrates a Firebase Extension into either:
- A local Cloud Functions codebase (
functions/src/for app integration). - A publishable npm package (reusable open-source package exporting V2
functions).
Leverages native Cloud Functions features (declarative IAM, Parameterized Config, SDK Lifecycle Hooks) and modernizes 1st Gen triggers to 2nd Gen using the Destructuring Compatibility Shim.
Target Migration Workflows
- Target A: Local Functions Codebase (End-User App Integration)
- Output: Code under
functions/src/. Config in.env. - Deployment:
firebase deploy --only functions.
- Target B: Publishable npm Package / Shareable Package
- Output: Reusable npm package exporting V2 functions.
- Configuration:
package.jsonspecifyingexportsmap,
engines: { "node": ">=22" }, and peerDependencies: { "firebase-functions": ">=6.0.0" }.
- Usage: Consumers install package and re-export functions in
index.ts
(export * from "<package-name>").
Core Rules & Constraints
1. Declarative IAM & APIs (Zero-Local-Overhead)
Use native SDK declarations instead of manual gcloud scripts or console instructions:
- Use
requiresRole("roles/...")for required GCP IAM permissions. - Use
requiresAPI("service.googleapis.com", "Description")for Google APIs.
2. Global Parameter Access Restriction
- Never call `.value()` at top-level module load scope.
- Initialize global SDK instances inside
onInit()or lazy getters:
```typescript import { defineString } from "firebase-functions/params"; import { onInit } from "firebase-functions/v2";
const dataset = defineString("DATASET_ID"); let client: BigQuery;
onInit(() => { client = new BigQuery({ datasetId: dataset.value() }); }); ```
3. V2 Concurrency & Cost Parity
V2 enables concurrency (up to 80 requests). To preserve V1 single-concurrency pricing, set cpu: "gcf_gen1".
Step-by-Step Migration Execution
Step 1: Inventory Extension Resources
- `extension.yaml`:
params→defineString,defineInt,defineBoolean,defineSecret.apis→requiresAPI(...).roles→requiresRole(...).lifecycleEvents→afterFirstDeploy&afterRedeploy.resources→ Upgrade 1st Gen triggers to 2nd Gen (onDocumentWritten,
onTaskDispatched, onRequest).
- Files & Scripts: Preserve devDependencies, test framework (
jest), and
test scripts.
Step 2: Configure package.json
- Set
name: "<package-name>",engines: { "node": ">=22" }. - Set
peerDependencies:
``json "peerDependencies": { "firebase-admin": "^11.0.0 || ^12.0.0", "firebase-functions": ">=6.0.0" } ``
- Configure
exportsmap targeting ESM/CommonJS and TypeScript declarations
(lib/index.js, lib/index.d.ts).
Step 3: Upgrade Triggers from V1 to V2
- Firestore: Use
onDocumentWrittenfromfirebase-functions/v2/firestore. - Tasks: Use
onTaskDispatchedfromfirebase-functions/v2/tasks. Remove
EXT_INSTANCE_ID when enqueueing tasks.
- HTTP: Use
onRequestfromfirebase-functions/v2/https. - Apply Destructuring Compatibility Shim (
{ change, context },
{ snapshot, context }) where legacy 1st Gen handlers expect (change, context).
Step 4: Convert Lifecycle Events
Map extension lifecycle events to SDK lifecycle hooks in src/index.ts:
onInstall→afterFirstDeploy({ task: { function: "initTask" } })onUpdate/onConfigure→
afterRedeploy({ task: { function: "setupTask" } })
Step 5: Package README & Export Instructions
Generate README.md containing:
- Installation instructions (
npm install). - Re-export snippet (
export * from "<package-name>"). - Parameterized Configuration
.envreference table. - What Changed (Extension vs Package) comparison table.
_Reminder: NEVER execute npm publish._
Security
- Security scanPassed, 90 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/extension-to-functions-codebase/SKILL.md
Popularity
- Repository stars
- 468
- Repository forks
- 103
- 7-day trend score
- 30
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Extension points
hookPre/post lifecycle hooks
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/firebase/agent-skills/extension-to-functions-codebase)