AIPM
Theme

AIPM package

Extension To Functions Codebase

@firebase/extension-to-functions-codebase@1.0.0

Skill for converting an installed Firebase Extension (or extension source) into a standalone Cloud Functions for Firebase codebase or publishable npm package…

Scanned · no issues · Oct 24, 2026

GitHub stars: ★ 481

LinkedInPost

Install Skill

Pins this version in aipm.package.json and aipm-lock.json.

aipm add @firebase/extension-to-functions-codebase@1.0.0

Without project tracking

Writes the skill files only. Add --no-init to skip aipm.package.json and the lockfile.

aipm add @firebase/extension-to-functions-codebase@1.0.0 --no-init

How to use

Install the skill above, then run this in your AI tool:

/extension-to-functions-codebase <your description>

About

## Overview

Source

What gets added to your project

Preview every file this package writes on install before you run the command above.

Summary

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

Skill instructions

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).
  2. 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 "<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

  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).
  2. 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 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).
  2. Re-export snippet (export * from "<package-name>").
  3. Parameterized Configuration .env reference table.
  4. What Changed (Extension vs Package) comparison table.

Reminder: NEVER execute npm publish.

Loading package files…

Share this package

Add an Install with AIPM badge

Add this badge to a GitHub README so readers can open the package page and install the same version.

Install with AIPM
[![Install with AIPM](https://www.aipm-registry.com/install-with-aipm.svg)](https://www.aipm-registry.com/skills/firebase/extension-to-functions-codebase/1.0.0?utm_source=github&utm_medium=readme&utm_campaign=package_badge)

Publisher

Firebase

This imported publisher has not claimed its AIPM account. A connected account confirms account control, but it does not guarantee that a package is safe.

AI assistant context

What this skill is for

@firebase/extension-to-functions-codebase@1.0.0 is an AIPM skill package for All tools. Use it when a project needs the reusable AI behavior described as: 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
aipm add @firebase/extension-to-functions-codebase@1.0.0
Use after install
/extension-to-functions-codebase <your description>

Tool targets

Install command by target

Add --no-init to any of these when you want the skill files without aipm.package.json or aipm-lock.json.

cursor

Run this variant when you want to install the package into cursor.

aipm add @firebase/extension-to-functions-codebase@1.0.0 --target cursor --ci

claude

Run this variant when you want to install the package into claude.

aipm add @firebase/extension-to-functions-codebase@1.0.0 --target claude --ci

Discussion

Comments (0)

Loading comments…

Package FAQ

Install and compatibility

How to install
Run aipm add @firebase/extension-to-functions-codebase@1.0.0 in a project that has AIPM initialized.
Supported tools
@firebase/extension-to-functions-codebase@1.0.0 supports All tools.

Before installing

AIPM skills can add files to your project. Review the package name, target, description, license, and publisher before installing. Use a clean branch when trying a new skill.