
developing-genkit-js
Develop AI-powered applications using Genkit in Node.js/TypeScript. Use when the user asks about Genkit, AI agents, flows, or tools in JavaScript/TypeScript, or when encountering Genkit errors, validation issues, type errors, or API problems.
Develop AI-powered applications using Genkit in Node.js/TypeScript. Use when the user asks about Genkit, AI agents, flows, or tools in JavaScript/TypeScript, or when encountering Genkit errors, validation issues, type errors, or API problems.
Genkit JS
Prerequisites
Ensure the genkit CLI is available.
- Run
genkit --versionto verify. Minimum CLI version needed: 1.29.0 - If not found or if an older version (1.x < 1.29.0) is present, install/upgrade it:
npm install -g genkit-cli@^1.29.0.
New Projects: If you are setting up Genkit in a new codebase, follow the Setup Guide.
Hello World
import { z, genkit } from 'genkit';
import { googleAI } from '@genkit-ai/google-genai';
// Initialize Genkit with the Google AI plugin
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-flash-latest'),
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. Recommended:
genkit docs:read js/get-started.md
genkit docs:read js/flows.md
See Common Errors for a list of deprecated APIs (e.g., configureGenkit, response.text(), defineFlow import) and their v1.x replacements.
ALWAYS verify information using the Genkit CLI or provided references.
Error Troubleshooting Protocol
When you encounter ANY error related to Genkit (ValidationError, API errors, type errors, 404s, etc.):
- MANDATORY FIRST STEP: Read Common Errors
- Identify if the error matches a known pattern
- Apply the documented solution
- Only if not found in common-errors.md, then consult other sources (e.g.
genkit docs:search)
DO NOT:
- Attempt fixes based on assumptions or internal knowledge
- Skip reading common-errors.md "because you think you know the fix"
- Rely on patterns from pre-1.0 Genkit
This protocol is non-negotiable for error handling.
Development Workflow
- Select Provider: Genkit is provider-agnostic (Google AI, OpenAI, Anthropic, Ollama, etc.).
- If the user does not specify a provider, default to Google AI.
- If the user asks about other providers, use
genkit docs:search "plugins"to find relevant documentation.
- Detect Framework: Check
package.jsonto identify the runtime (Next.js, Firebase, Express).- Look for
@genkit-ai/next,@genkit-ai/firebase, or@genkit-ai/google-cloud. - Adapt implementation to the specific framework's patterns.
- Look for
- Follow Best Practices:
- See Best Practices for guidance on project structure, schema definitions, and tool design.
- Be Minimal: Only specify options that differ from defaults. When unsure, check docs/source.
- Ensure Correctness:
- Run type checks (e.g.,
npx tsc --noEmit) after making changes. - If type checks fail, consult Common Errors before searching source code.
- Run type checks (e.g.,
- Handle Errors:
- On ANY error: First action is to read Common Errors
- Match error to documented patterns
- Apply documented fixes before attempting alternatives
Finding Documentation
Use the Genkit CLI to find authoritative documentation:
- Search topics:
genkit docs:search <query>- Example:
genkit docs:search "streaming"
- Example:
- List all docs:
genkit docs:list - Read a guide:
genkit docs:read <path>- Example:
genkit docs:read js/flows.md
- Example:
CLI Usage
The genkit CLI is your primary tool for development and documentation.
- See CLI Reference for common tasks, workflows, and command usage.
- Use
genkit --helpfor a full list of commands.
References
- Best Practices: Recommended patterns for schema definition, flow design, and structure.
- Docs & CLI Reference: Documentation search, CLI tasks, and workflows.
- Common Errors: Critical "gotchas", migration guide, and troubleshooting.
- Setup Guide: Manual setup instructions for new projects.
- Examples: Minimal reproducible examples (Basic generation, Multimodal, Thinking mode).
You Might Also Like
Related Skills

writing-skills
Use when creating new skills, editing existing skills, or verifying skills work before deployment
obra
doc-coauthoring
Guide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision docs, or similar structured content. This workflow helps users efficiently transfer context, refine content through iteration, and verify the doc works for readers. Trigger when user mentions writing docs, creating proposals, drafting specs, or similar documentation tasks.
anthropics
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK).
anthropics
xlsx
Use this skill any time a spreadsheet file is the primary input or output. This means any task where the user wants to: open, read, edit, or fix an existing .xlsx, .xlsm, .csv, or .tsv file (e.g., adding columns, computing formulas, formatting, charting, cleaning messy data); create a new spreadsheet from scratch or from other data sources; or convert between tabular file formats. Trigger especially when the user references a spreadsheet file by name or path — even casually (like \"the xlsx in my downloads\") — and wants something done to it or produced from it. Also trigger for cleaning or restructuring messy tabular data files (malformed rows, misplaced headers, junk data) into proper spreadsheets. The deliverable must be a spreadsheet file. Do NOT trigger when the primary deliverable is a Word document, HTML report, standalone Python script, database pipeline, or Google Sheets API integration, even if tabular data is involved.
anthropics
docx
Use this skill whenever the user wants to create, read, edit, or manipulate Word documents (.docx files). Triggers include: any mention of 'Word doc', 'word document', '.docx', or requests to produce professional documents with formatting like tables of contents, headings, page numbers, or letterheads. Also use when extracting or reorganizing content from .docx files, inserting or replacing images in documents, performing find-and-replace in Word files, working with tracked changes or comments, or converting content into a polished Word document. If the user asks for a 'report', 'memo', 'letter', 'template', or similar deliverable as a Word or .docx file, use this skill. Do NOT use for PDFs, spreadsheets, Google Docs, or general coding tasks unrelated to document generation.
anthropics