Skip to main content
skill Claude Code CX Codex Cursor GitHub Copilot

extension-to-functions-codebase — Claude Code skill: install & usage

Converts a Firebase Extension into a standalone Cloud Functions codebase or an npm package. Upgrades triggers from V1 to V2 and introduces declarative IAM rules.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add firebase/agent-skills --skill extension-to-functions-codebase -a claude-code
Open on GitHub

What extension-to-functions-codebase does

The skill parses extension.yaml and maps resources to a local functions/src/ folder or a shareable npm package. Extension parameters convert to defineString, defineSecret, and other definitions from firebase-functions/params. Permissions translate into native declarations via requiresRole and requiresAPI. Manual gcloud commands are dropped completely.

Functions upgrade from 1st Gen to 2nd Gen triggers. Handlers switch to onDocumentWritten, onTaskDispatched, and onRequest. For existing event payloads, a destructuring compatibility shim preserves call signatures. Lifecycle events convert to SDK lifecycle hooks, mapping onInstall to afterFirstDeploy and updates to afterRedeploy.

Parameter values are never evaluated at module load scope. Client setup runs inside onInit() or lazy getters. Because 2nd Gen functions allow up to 80 concurrent requests, the skill adds cpu: "gcf_gen1" when preserving 1st Gen single-request billing behavior is required.

What it helps with

  • Convert an installed Firebase Extension into a standalone functions/src/ codebase
  • Package extension logic into an npm library with Node 22 support
  • Upgrade 1st Gen triggers to Cloud Functions 2nd Gen handlers
  • Replace manual GCP IAM setup with declarative requiresRole and requiresAPI calls

Example prompts for the agent

  • Migrate our installed Firebase extension into a local Cloud Functions V2 codebase
  • Convert this Firebase extension source into a shareable npm package for Node 22
  • Upgrade the extension triggers to V2 and set up afterFirstDeploy hooks

How to install extension-to-functions-codebase

1Skills CLI (Vercel)

npx skills add firebase/agent-skills --skill extension-to-functions-codebase -a claude-code

2Manually: put the files in place

~/.claude/skills/extension-to-functions-codebase/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/extension-to-functions-codebase/

From the same set10

The whole set →
firebase-hosting-basics Google LLC Deploys static sites and SPAs to Firebase Hosting CDN with SSL, preview channels, and custom domains. Claude Code CX Codex Cursor +1 169,800installs firebase-app-hosting-basics Google LLC Deploy and manage SSR web apps built with Next.js or Angular on Firebase App Hosting. Use it for configuration, secrets, and deployment workflows. Claude Code CX Codex Cursor +1 169,200installs firebase-data-connect Google LLC Builds and configures Firebase SQL Connect backends on PostgreSQL with GraphQL schemas and generated SDKs. Useful when adding relational data to Firebase projects. Claude Code CX Codex Cursor +1 168,300installs firebase-security-rules-auditor Google LLC Audits Firebase rules for data leaks, privilege escalation, and validation gaps. Use it when reviewing Firestore or Cloud Storage access. Claude Code CX Codex Cursor +1 138,200installs firebase-ai-logic-basics Google LLC Integrates Firebase AI Logic into Android, iOS, Web, and Flutter client apps. Helps configure direct Gemini API calls, streaming, and multimodal inputs. Claude Code CX Codex Cursor +1 135,300installs firebase-firestore Google LLC This skill helps configure Cloud Firestore, plan data models, and write SDK queries. Use it when creating a database or adding Firestore to an app. Claude Code CX Codex Cursor +1 134,900installs firebase-crashlytics Google LLC A skill for Firebase Crashlytics in Claude Code, Cursor, and other AI coding platforms. Collects crash reports from Android and iOS apps, lets you read data through the Firebase CLI MCP server. Claude Code CX Codex Cursor +1 131,200installs xcode-project-setup Google LLC This skill adds Swift Packages and links files in Xcode projects. Use it when an iOS app needs dependencies such as Firebase or Alamofire. Claude Code CX Codex Cursor +1 130,300installs

Similar

basin cloudflare Skill for building and troubleshooting Cloudflare Basin analytics. Stream data into R2 Iceberg tables, manage catalogs, and run distributed SQL queries from your IDE. Claude Code CX Codex Cursor +1 20,000installs eas-hosting expo Skill for deploying Expo web apps and API routes to EAS Hosting (Cloudflare Workers). Exports the web bundle, runs eas deploy for production and PR previews, manages environment variables and custom domains. Claude Code CX Codex Cursor +1 19,000installs architecture-diagram Cocoon-AI Generates architecture diagrams for systems, cloud infrastructure, microservices, and network topology as self-contained HTML files with a dark theme. Claude Code CX Codex Cursor +1 2,100installs architecture-diagram Cocoon AI ([email protected]), ported by Hermes Agent Generates SVG architecture and cloud infrastructure diagrams as a standalone HTML file with a dark theme. No API keys or external dependencies needed — just a browser. Claude Code CX Codex Cursor +1 491installs omni-providers cheaper-inference Manages connections to 375 AI providers via REST API: adds keys, tests connections, syncs models. Claude Code CX Codex Cursor +1 1,100installs omni-sync-cloud cheaper-inference Syncs OmniRoute configuration, provider connections, and settings to and from cloud storage. Manages cloud worker authentication and remote backup targets. Claude Code CX Codex Cursor +1 958installs workers-best-practices cloudflare Guides coding agents on production Cloudflare Workers standards, Wrangler typing, observability setup, and runtime anti-pattern checks. Claude Code CX Codex Cursor +1 124,900installs cloudflare-email-service cloudflare A skill for Cloudflare Email Sending and Email Routing: it walks the agent through sending and receiving mail in Workers. Claude Code CX Codex Cursor +1 101,400installs

Questions about extension-to-functions-codebase

How to install extension-to-functions-codebase in Claude Code?

Run npx skills add firebase/agent-skills --skill extension-to-functions-codebase -a claude-code in your terminal.

What targets does extension-to-functions-codebase support?

It targets two setups: a local Cloud Functions codebase under functions/src/ deployed via Firebase CLI, or a reusable npm package exporting V2 functions.

How does the skill handle concurrency pricing differences in V2?

Cloud Functions V2 allows concurrency up to 80 requests. To match V1 single-concurrency pricing, the skill sets cpu: "gcf_gen1" on migrated triggers.

Source text

SKILL.md · Apache-2.0
---
name: extension-to-functions-codebase
description: 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
metadata:
  author: Google LLC
  category: Serverless
---

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

_Reminder: NEVER execute `npm publish`._

© Google LLC · Apache-2.0 · firebase/agent-skills

See also

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor