
developing-genkit-js
★ 14by genkit-ai · part of genkit-ai/skills
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.
Inspect the full instructions your agent will receiveExpandCollapse
This is the exact playbook injected into your agent when the skill activates — shown here so you can audit it before installing. You don't need to read it to use the skill.
by genkit-ai
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.
npx skills add https://github.com/genkit-ai/skills --skill developing-genkit-js
Download ZIPGitHub14
Genkit JS
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;
});
Agents (Beta)
Genkit has a preview agent API for persistent, multi-turn conversations
(sessions, snapshots, interrupts, branching, background execution). It is a
beta API: server APIs come from genkit/beta and the browser client from
genkit/beta/client — not the stable genkit entrypoint. **Requires genkit
= 1.39.0.**
For more details see:
-
Agents: defining/serving an agent and client-managed state (start here).
-
Sessions & persistence: session stores (
InMemory/File/Firestore). -
Human-in-the-loop / interrupts: pausing for approval/input and resuming.
-
Branching: forking a conversation from a snapshot.
-
Background agents: detaching long-running turns and polling.
-
Working with state: typed custom session state, auto-synced to the client.
-
Artifacts: producing and reading named deliverables.
-
Multi-agent orchestration: delegating to sub-agents.
-
Advanced custom agents:
defineCustomAgentfor full turn control. -
Deploying agents: serving agents over HTTP (multiple agents, CORS, web UI, other frameworks).
Middleware
Middleware wraps generation (retries, fallback, extra tools, request/response
transforms) and attaches via the use: [...] array on ai.generate, prompts,
and agents.
-
Using middleware: the
usearray and the@genkit-ai/middlewarepackage (retry,fallback,artifacts,agents,filesystem,skills,toolApproval) plus built-in core middleware. -
Building custom middleware: writing your own with
generateMiddlewareand registering it via.plugin().
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.
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.
-
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.
-
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" -
List all docs:
genkit docs:list -
Read a guide:
genkit docs:read <path> -
Example:
genkit docs:read js/flows.md
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).
-
Agents (Beta): Agent basics, serving, and client-managed state. Deeper topics: sessions, human-in-the-loop, branching, background agents, state, artifacts, multi-agent, custom agents, deployment.
-
Middleware: using middleware and the
@genkit-ai/middlewarepackage. See also building custom middleware.
Related Skills
azure-quotas microsoft
Check/manage Azure quotas and usage across providers. For deployment planning, capacity validation, region selection. WHEN: "check quotas", "service limits", "current usage", "request quota increase", "quota exceeded", "validate capacity", "regional availability", "provisioning limits", "vCPU limit", "how many vCPUs available in my subscription". official devops aws
playwright-mcp-dev microsoft
Developer guide for extending Playwright MCP tools and CLI commands. Add new MCP tools in packages/playwright/src/mcp/browser/tools/ , register in tools.ts , and define capabilities in config.d.ts CLI commands map to MCP tools; register new commands in packages/playwright/src/mcp/terminal/commands.ts and update help generator if adding a category Config options require updates across program.ts (CLI option), config.d.ts (definition), and config.ts (implementation and environment mapping) Run... official
converting-minikit-to-farcaster base
Converts Mini Apps from MiniKit (OnchainKit) to native Farcaster SDK. Use when migrating from @coinbase/onchainkit/minikit, converting MiniKit hooks, removing… official
guizang-ppt-skill op7418
生成横向翻页网页 PPT(单 HTML 文件),含 WebGL 背景、章节幕封、数据大字报、图片网格等模板。提供两种风格:① "电子杂志 × 电子墨水"(衬线 + 流体背景 + 暖色) ② "瑞士国际主义"(无衬线 + 网格点阵 + IKB/柠檬黄/柠檬绿/安全橙高亮)。当用户需要制作分享 / 演讲 / 发布会风格的网页 PPT,或提到"杂志风 PPT"、"瑞士风 PPT"、"Swiss Style"、"horizontal swipe deck"时使用。 creative design document
presentation-creator sentry
Create data-driven presentation slides using React, Vite, and Recharts with Sentry branding. Use when asked to "create a presentation", "build slides", "make a… official
azure-ai-contentsafety-java microsoft
Build content moderation applications with Azure AI Content Safety SDK for Java. Use when implementing text/image analysis, blocklist management, or harm… official
rust-review cloudflare
Rust code review for workerd. Covers CXX FFI safety, unsafe code patterns, JSG resource conventions, error handling, and a review checklist adapted from the… official
java-refactoring-extract-method github
Java method extraction refactoring for improved readability and maintainability. Identifies methods exceeding complexity thresholds (LOC > 15, statements > 10, cyclomatic complexity > 10) and extracts logical code blocks into focused helper methods Produces fully compilable Java 17 code with descriptive method names and single-line documentation comments Preserves all original functionality while reducing cognitive load and improving testability through smaller, single-responsibility methods official
npx skills add https://github.com/genkit-ai/skills --skill developing-genkit-jsRun this in your project — your agent picks the skill up automatically.
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.
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.
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.