Skip to content

add firebase-functions-basics#15

Open
jhuleatt wants to merge 6 commits intofirebase:mainfrom
jhuleatt:jhuleatt-functions
Open

add firebase-functions-basics#15
jhuleatt wants to merge 6 commits intofirebase:mainfrom
jhuleatt:jhuleatt-functions

Conversation

@jhuleatt
Copy link

@jhuleatt jhuleatt commented Feb 20, 2026

Add skills for Cloud Functions for Firebase

Fixes #9

@inlined
Copy link
Member

inlined commented Feb 24, 2026

I have an entirely different skill on migrating from configs to params. Maybe we should not even mention config except as instructions to always use params instead? Can you ping me tomorrow about this?

@jhuleatt
Copy link
Author

I have an entirely different skill on migrating from configs to params. Maybe we should not even mention config except as instructions to always use params instead? Can you ping me tomorrow about this?

@inlined, in the interest of getting this out in the hands of developers, want to either (1) keep upgrade.md for now, and then overwrite it with your own PR or update it to reference a new separate skill, or (2) delete upgrade.md and merge the rest of the skill?

@jhuleatt
Copy link
Author

@inlined I've removed upgrade.md and all references to functions.config, and renamed the skill to firebase-functions-basic. LGTY?

@jhuleatt jhuleatt changed the title Add Cloud Functions for Firebase add firebase-functions-basics Feb 26, 2026
Copy link

@egilmorez egilmorez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some thoughts for you Jeff, thanks!

@@ -0,0 +1,69 @@
# Cloud Functions for Firebase setup guide

This guide provides a step-by-step process for setting up Cloud Functions, tailored for coding agents.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we specify "with the Node.js runtime," and also add a "(Node.js)" to the title line?


## 1. Create a 2nd-gen HTTP function

Replace the contents of `src/index.ts` (or `index.js`) with the following code to create a simple, modern v2 HTTP endpoint.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the clarification below in the Python page: "along with a Firestore-triggered function."

This section only applies to Node.js, since all Python functions are 2nd gen.

- Always use 2nd-gen functions for new development. They are powered by Cloud Run and offer better performance and configurability.
- Use 1st-gen functions *only* for Analytics and basic Auth triggers, since those aren't supported by 2nd gen.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Auth triggers are on the near horizon, right? Is there a way to comment or flag this for update when we get them?


Functions can be initialized using the CLI or manually. Ensure you have initialized the Firebase Admin SDK to interact with other Firebase services.

1. Install the Admin SDK:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this Node.js-specific? If so, it probably belongs in the lower-level references file.

I'm no coding genius, but I'm thinking this file is leaning Node and possibly neglecting Python and other runtimes-to-be. If we can make it language agnostic, that would be a win I think.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This may be redundant with what's in the node setup. We're also being inconsistent with initializeApp. I like using it in onInit tbh

- Use `defineString`, `defineInt`, `defineSecret` for environment configuration.
- Recommend a `maxInstances` setting of 1 for all functions until correct behavior can be verified.

## 2. Build TypeScript

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we missing a dependencies step? Or do we assume they installed with Node.js dependencies?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we mention that building isn't necessary before deploying?

Copy link
Member

@inlined inlined left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we teach the model that --functions is used when only emulating functions? A lot of functions depend on event sources and I almost never run only --functions.

We might also want to add the genkit UI in the npx concurrently call

const scaleLimit = defineInt("MAX_INSTANCES", { default: 1 });
const greeting = defineString("GREETING", { default: "Hello" });

export const helloWorld = onRequest({ maxInstances: scaleLimit }, async (request, response) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: If you're going to use scaleLimit repeatedly, should it be in setGlobalOptions?

- Use `defineString`, `defineInt`, `defineSecret` for environment configuration.
- Recommend a `maxInstances` setting of 1 for all functions until correct behavior can be verified.

## 2. Build TypeScript
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we mention that building isn't necessary before deploying?


```bash
# Start the functions emulator
firebase emulators:start --only functions
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we expand this to say you should be running tsc --watch concurrently if running typescript?

TIL you can run:

npx concurrently "tsc --watch" "firebase emulators:start"

We should even consider making this the dev script?

@@ -0,0 +1,69 @@
# Cloud Functions for Firebase setup guide
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The thing people hate about params is that they can't use it at global scope. I wonder if we should update the skill to show a use of onInit?

This section only applies to Node.js, since all Python functions are 2nd gen.

- Always use 2nd-gen functions for new development. They are powered by Cloud Run and offer better performance and configurability.
- Use 1st-gen functions *only* for Analytics and basic Auth triggers, since those aren't supported by 2nd gen.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I might modify this. Maybe "discourage analytics functions because they will not be supported in 2nd gen." and something around the idea that auth functions may not be released yet, use them if they are but use 1st gen otherwise. They are coming imminently (though they have been for ages).


Functions can be initialized using the CLI or manually. Ensure you have initialized the Firebase Admin SDK to interact with other Firebase services.

1. Install the Admin SDK:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This may be redundant with what's in the node setup. We're also being inconsistent with initializeApp. I like using it in onInit tbh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Skills for Cloud Functions

5 participants