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
Written by Firebase and published in firebase/agent-skills under the Apache-2.0 license. Treq shows it unchanged except for heading levels and links to files on GitHub.
Migrates a Firebase Extension into either:
functions/src/ for app integration).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 A: Local Functions Codebase (End-User App Integration)
functions/src/. Config in .env.firebase deploy --only functions.Target B: Publishable npm Package / Shareable Package
package.json specifying exports map,
engines: { "node": ">=22" }, and
peerDependencies: { "firebase-functions": ">=6.0.0" }.index.ts
(export * from "<package-name>").Use native SDK declarations instead of manual gcloud scripts or console
instructions:
requiresRole("roles/...") for required GCP IAM permissions.requiresAPI("service.googleapis.com", "Description") for Google APIs..value() at top-level module load scope.onInit() or lazy getters:
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() });
});
V2 enables concurrency (up to 80 requests). To preserve V1 single-concurrency
pricing, set cpu: "gcf_gen1".
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).jest), and
test scripts.package.jsonname: "<package-name>", engines: { "node": ">=22" }.peerDependencies:
"peerDependencies": {
"firebase-admin": "^11.0.0 || ^12.0.0",
"firebase-functions": ">=6.0.0"
}
exports map targeting ESM/CommonJS and TypeScript declarations
(lib/index.js, lib/index.d.ts).onDocumentWritten from firebase-functions/v2/firestore.onTaskDispatched from firebase-functions/v2/tasks. Remove
EXT_INSTANCE_ID when enqueueing tasks.onRequest from firebase-functions/v2/https.{ change, context },
{ snapshot, context }) where legacy 1st Gen handlers expect
(change, context).Map extension lifecycle events to SDK lifecycle hooks in src/index.ts:
onInstall → afterFirstDeploy({ task: { function: "initTask" } })onUpdate / onConfigure →
afterRedeploy({ task: { function: "setupTask" } })Generate README.md containing:
npm install).export * from "<package-name>")..env reference table.Reminder: NEVER execute npm publish.
Claude Code and Codex keep each installed skill's name and description in context. When a request matches the description, the agent loads the full SKILL.md. You can also run it yourself: type /extension-to-functions-codebase in Claude Code or $extension-to-functions-codebase in Codex.
Copy the extension-to-functions-codebase folder into .claude/skills/ in your project. To use it in every project, copy it into ~/.claude/skills/ instead.
git clone --depth 1 https://github.com/firebase/agent-skills.git /tmp/firebase-agent-skills
mkdir -p .claude/skills
cp -r /tmp/firebase-agent-skills/skills/extension-to-functions-codebase .claude/skills/
Codex reads skills from .agents/skills/ in your repository, and from ~/.agents/skills/ for every repository. It detects new skills on its own. Restart Codex if extension-to-functions-codebase does not appear.
git clone --depth 1 https://github.com/firebase/agent-skills.git /tmp/firebase-agent-skills
mkdir -p .agents/skills
cp -r /tmp/firebase-agent-skills/skills/extension-to-functions-codebase .agents/skills/
Open Settings and select the Skills tab. The tab appears when Skills installation is on under Settings → Feature Preview. Search for extension-to-functions-codebase and choose Install….
Install for repository writes the skill under .treq/skills/ in the current repository. Install for application makes it available to every repository on this machine. Each new workspace gets a copy in .claude/skills/ and .agents/skills/, so Claude Code and Codex both find it. See Installing Skills from the Library.
extension-to-functions-codebase ships 4 files, 19.5 KB in total. Select a file to load it from GitHub.