Extension To Functions Codebase

TopTinker Aug 13, 2026 New v1.0.0 1,358 installs Sec S+ Verified source
Claude Code Cursor
Free
Open verification
AI OverviewGenerated from SKILL.md
Core usage
This skill converts a Firebase Extension (installed or source) into a standalone Cloud Functions for Firebase codebase under functions/src/ or into a publishable npm package exporting V2 functions. It guides users through inventorying extension.yaml resources, configuring package.json, upgrading 1st Gen triggers to 2nd Gen, converting lifecycle events to SDK hooks, and generating a README with installation and re-export instructions.
Key advantages
It leverages native Cloud Functions features such as declarative IAM, Parameterized Config, and SDK Lifecycle Hooks, reducing manual GCP setup. It modernizes legacy 1st Gen triggers to 2nd Gen using the Destructuring Compatibility Shim, and supports both local app integration and reusable package distribution.
Limitations
It imposes strict constraints, including never calling .value() at top-level module load scope, which requires careful initialization inside onInit() or lazy getters. V2 concurrency can alter pricing behavior unless cpu: "gcf_gen1" is explicitly set. The workflow explicitly warns to never execute npm publish, limiting direct publishing automation.
Target audience
This is for developers migrating existing Firebase Extensions into a local Cloud Functions codebase for their own application, or into a shareable npm package. It is also relevant for maintainers who need to modernize extension triggers to 2nd Gen and align with current Firebase Functions SDK patterns.
Risks & notes
Misusing global parameter access can cause runtime failures because SDK instances may be initialized before parameter values are resolved. Failing to preserve single-concurrency behavior under V2 may result in unexpected cost changes. Incorrect lifecycle event mapping or package exports configuration could break extension behavior or consumer re-exports, and running npm publish against the source is explicitly prohibited.
DescriptionWritten by the seller

# Extension to Functions Codebase & npm Package Migration

## Overview

Migrates a Firebase Extension into either:

1. **A local Cloud Functions codebase** (`functions/src/` for app integration).
1. **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.json` specifying `exports` map,
`engines: { "node": ">=22" }`, and
`peerDependencies: { "firebase-functions": ">=6.0.0" }`.
- Usage: Consumers install package and re-export functions in `index.ts`
(`export * from ""`).

______________________________________________________________________

## 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

1. **`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`).
1. **Files & Scripts**: Preserve devDependencies, test framework (`jest`), and
test scripts.

### Step 2: Configure `package.json`

- Set `name: ""`, `engines: { "node": ">=22" }`.
- Set `peerDependencies`:
```json
"peerDependencies": {
"firebase-admin": "^11.0.0 || ^12.0.0",
"firebase-functions": ">=6.0.0"
}
```
- Configure `exports` map targeting ESM/CommonJS and TypeScript declarations
(`lib/index.js`, `lib/index.d.ts`).

### Step 3: Upgrade Triggers from V1 to V2

- Firestore: Use `onDocumentWritten` from `firebase-functions/v2/firestore`.
- Tasks: Use `onTaskDispatched` from `firebase-functions/v2/tasks`. Remove
`EXT_INSTANCE_ID` when enqueueing tasks.
- HTTP: Use `onRequest` from `firebase-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:

1. Installation instructions (`npm install`).
1. Re-export snippet (`export * from ""`).
1. Parameterized Configuration `.env` reference table.
1. What Changed (Extension vs Package) comparison table.

_Reminder: NEVER execute `npm publish`._

Use caseInput → Output
Input
Migrates a Firebase Extension into either: 1. A local Cloud Functions codebase (functions/src/ for app integration). 1. A publishable npm package (reusable open-source p
Output
Verified guidance, commands and best practices for Extension To Functions Codebase, ready to paste into your agent
How it worksImport to your platform and run
Item details
Use case
AI Skills
Capability
Coding
Agents
Claude Code, Cursor
Version
1.0.0
First seen
Aug 13, 2026
Installs
1,358
License
Non-exclusive
Last update
Aug 13, 2026
InstallCompatible with agent skill ecosystem
npx skills add firebase/agent-skills --skill extension-to-functions-codebase
Source: firebase/agent-skills
What you get
SKILL.md skill definitionCommand referenceInstallation instructionsExtension To Functions Codebase reference
Verified sourceOriginal project page — inspect before install
Open the original source project
Check the upstream repository, license and changelog before install
Open source
Security ScanS+Score 100/100 · 0 findings · 2026-08-15 21:36:12
Static analysis100
Dynamic behavior100
Dependencies100
Network100
Privacy100
Threat intel100
✓ 未发现安全问题,六维检测全部通过。
Security scan generated by TopTinker automated engine from SKILL.md static analysis, for pre-install reference only. Third-party skills carry their own runtime risk.
WeChat
Qizhuwang Source Code Trading Platform
2021-12-28开店时间
284商品数
认证
Guarantees
Escrow paymentOn
Platform holds funds until delivery is confirmed
Install verified
Free download - install & run before you pay
Source transparency
Original GitHub repo linked & verified
No refunds after download
Digital product - disputes arbitrated on evidence only
Enhanced protection
Trusted seller - priority arbitration within 48h, backed by platform bond
Free

Report this listing

This content is locked. Buy it once and use it forever - instant delivery after purchase.

one-time
Unlock now
Escrow payment · 7-day refund support