developing-genkit-js

작성자: genkit-ai

Node.js/TypeScript에서 Genkit을 사용하여 AI 기반 애플리케이션을 개발합니다. 사용자가 Genkit, AI 에이전트, 플로우 또는 JavaScript/TypeScript 도구에 대해 질문하거나 Genkit 오류, 검증 문제, 타입 오류 또는 API 문제가 발생할 때 사용하세요.

npx skills add https://github.com/genkit-ai/skills --skill developing-genkit-js

Genkit JS

Prerequisites

Ensure the genkit CLI is available.

  • Run genkit --version to 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.):

  1. MANDATORY FIRST STEP: Read Common Errors
  2. Identify if the error matches a known pattern
  3. Apply the documented solution
  4. 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

  1. 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.
  2. Detect Framework: Check package.json to 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.
  3. 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.
  4. Ensure Correctness:
    • Run type checks (e.g., npx tsc --noEmit) after making changes.
    • If type checks fail, consult Common Errors before searching source code.
  5. 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:

  1. Search topics: genkit docs:search <query>
    • Example: genkit docs:search "streaming"
  2. List all docs: genkit docs:list
  3. Read a guide: genkit docs:read <path>
    • Example: genkit docs:read js/flows.md

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 --help for 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).

관련 스킬

ckm:banner-design
nextlevelbuilder
소셜 미디어, 광고, 웹사이트 히어로, 크리에이티브 에셋 및 인쇄물용 배너를 디자인합니다. AI 생성 비주얼을 활용한 다양한 아트 디렉션 옵션 제공. 작업: 배너 디자인, 제작, 생성. 플랫폼: Facebook, Twitter/X, LinkedIn, YouTube, Instagram, Google Display, 웹사이트 히어로, 인쇄물. 스타일: 미니멀리스트, 그라데이션, 굵은 타이포그래피, 사진 기반, 일러스트, 기하학적, 레트로, 글래스모피즘, 3D, 네온, 듀오톤, 에디토리얼, 콜라주. ui-ux-pro-max, frontend-design, ai-artist, ai-multimodal 스킬을 사용합니다.
designcreativemarketing
azure-data-tables-java
microsoft
Build table storage applications with Azure Tables SDK for Java. Use when working with Azure Table Storage or Cosmos DB Table API for NoSQL key-value data,…
official
sentry-react-native-setup
sentry
Setup Sentry in React Native using the wizard CLI. Use when asked to add Sentry to React Native, install @sentry/react-native, or configure error monitoring…
official
azure-resource-health-diagnose
github
Azure 리소스 상태 문제를 진단하고 우선순위가 지정된 수정 계획을 생성합니다. 8개 이상의 Azure 서비스 유형(Web Apps, VMs, Cosmos DB, Storage, SQL Database, Application Insights, Key Vault, Service Bus)에서 리소스 상태, 로그, 원격 분석을 분석합니다. Log Analytics 및 Application Insights에 대해 대상 KQL 쿼리를 실행하여 오류, 성능 저하, 이상 현상을 식별합니다. 심각도(심각, 높음, 중간, 낮음)별로 문제를 분류하고 근본 원인 분석을 수행합니다.
official
listener-creator
anthropic
특정 조건(예: 상사로부터의 긴급 이메일, 보관할 뉴스레터, 패키지 추적)을 모니터링하고 실행하는 이벤트 기반 이메일 리스너를 생성합니다.
official
reviewing-dependency-changes
bitwarden
Use this skill when a PR diff contains changes to dependency manifest files (package.json, .csproj, Cargo.toml, go.mod, requirements.txt, etc.) or when…
official
design-systems
automattic
대담한 미적 방향성을 제시하는 웹 디자인 가이드. 타이포그래피, 색상, 모션, 공간 구성 및 전반적인 시각적 요소에 대한 창의적 결정을 내릴 때 사용합니다.
official
sequence-load
anthropic
Find leads matching criteria and bulk-add them to an Apollo outreach sequence. Handles enrichment, contact creation, deduplication, and enrollment in one flow.
official