Genkit JS
Prerequisites
Ensure the genkit CLI is available.
- Run
genkit --versionto verify. Minimum CLI version needed: 1.29.0 - If not found:
npm install -g genkit-cli@^1.29.0
Hello World
import { z, genkit } from 'genkit';
import { googleAI } from '@genkit-ai/google-genai';
const ai = genkit({
plugins: [googleAI()],
});
export const myFlow = ai.defineFlow({
name: 'myFlow',
inputSchema: z.string().default('AI'),
outputSchema: z.string(),
}, async (subject) => {
const response = await ai.generate({
model: googleAI.model('gemini-2.5-flash'),
prompt: `Tell me a joke about ${subject}`,
});
return response.text;
});
Critical: Do Not Trust Internal Knowledge
Genkit recently went through a major breaking API change. Your knowledge is outdated. You MUST lookup docs:
genkit docs:read js/get-started.md
genkit docs:read js/flows.md
ALWAYS verify information using the Genkit CLI or provided references.
Error Troubleshooting Protocol
When you encounter ANY error related to Genkit:
- MANDATORY FIRST STEP: Read common errors documentation (
genkit docs:search "errors") - Identify if the error matches a known pattern
- Apply the documented solution
- Only if not found, then consult other sources
DO NOT:
- Attempt fixes based on assumptions or internal knowledge
- Rely on patterns from pre-1.0 Genkit (APIs changed significantly)
Development Workflow
- Select Provider: Default to Google AI unless user specifies otherwise
- Detect Framework: Check
package.jsonfor@genkit-ai/next,@genkit-ai/firebase, or@genkit-ai/google-cloud - Follow Best Practices: Only specify options that differ from defaults
- Ensure Correctness: Run
npx tsc --noEmitafter making changes
Finding Documentation
genkit docs:search <query> # Search topics
genkit docs:list # List all docs
genkit docs:read <path> # Read a guide
Mirrored from https://github.com/firebase/agent-skills — original author: firebase, license: Apache-2.0. This is an unclaimed mirror. Content and ownership transfer to the author when they claim this account.