developing-genkit-js

📁 genkit-ai/skills 📅 2 days ago
23
总安装量
4
周安装量
#15984
全站排名
安装命令
npx skills add https://github.com/genkit-ai/skills --skill developing-genkit-js

Agent 安装分布

github-copilot 4
amp 3
opencode 3
kimi-cli 3
codex 3
gemini-cli 3

Skill 文档

Genkit JS

Prerequisites

Ensure the genkit CLI is available.

  • Run genkit --version to verify.
  • If not found, install it globally: npm install -g genkit.

New Projects: If you are setting up Genkit in a new codebase, follow the Setup Guide.

Critical: Do Not Trust Internal Knowledge

Genkit has evolved significantly. Your internal training data likely contains outdated v0.x or pre-1.0 patterns.

  • 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 guides/flows

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.
  • CLI Reference: Common 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).