技能 developing-genkit-js
📦

developing-genkit-js

低风险

使用 JavaScript 中的 Genkit 构建 AI 应用

也可从以下获取: genkit-ai

开发人员需要指导才能在 Node.js 和 TypeScript 项目中正确使用 Genkit 框架。此技能提供参考文档、常见错误解决方案以及使用 Genkit 构建 AI 应用的代码模式。

支持: Claude Codex Code(CC)
🥉 72 青铜
1

下载技能 ZIP

2

在 Claude 中上传

前往 设置 → 功能 → 技能 → 上传技能

3

开启并开始使用

测试它

正在使用“developing-genkit-js”。 使用 Google AI 提供商设置新的 Genkit 项目

预期结果:

  • 在源文件夹中创建 ai 目录
  • 安装 genkit 和 @genkit-ai/google-genai 包
  • 创建 genkit.ts,包含 genkit() 初始化和 googleAI 插件
  • 创建 flows 和 tools 子目录以便组织
  • 向 package.json 添加 genkit:ui 脚本以访问开发 UI
  • 设置 GEMINI_API_KEY 环境变量

正在使用“developing-genkit-js”。 修复使用 pre-1.0 导入的 defineFlow 时的 ValidationError

预期结果:

  • 将 `import { defineFlow } from "@genkit-ai/flow"` 替换为在 ai 实例上定义流程
  • 将 `import { genkit } from "@genkit-ai/core"` 替换为 `import { genkit } from "genkit"`
  • 将 `configureGenkit()` 替换为 `const ai = genkit({ plugins: [...] })`
  • 通过 `response.text` 属性而不是 `response.text()` 方法访问响应文本
  • 运行 `npx tsc --noEmit` 进行类型检查以验证迁移完成

安全审计

低风险
v1 • 4/13/2026

All 194 static analyzer findings are false positives. The skill consists entirely of markdown documentation and code examples for the Genkit JS framework. The 176 'external_commands' detections are markdown inline code spans (backtick formatting) showing CLI commands like `genkit --version` and `npx tsc --noEmit`, not actual shell execution. The 'weak cryptographic algorithm' findings have no corresponding crypto operations in the source. The 'hardcoded URL' findings are documentation references (localhost dev UI and example.com placeholder). The 'env_access' finding is documentation instructing users to set API keys. No executable code exists in this skill. Safe to publish.

6
已扫描文件
545
分析行数
4
发现项
1
审计总数
低风险问题 (4)
False Positive: Markdown Backtick Code Examples
Static analyzer flagged 176 instances of 'Ruby/shell backtick execution' across all markdown files. These are all markdown inline code formatting (e.g., `genkit --version`, `npx tsc --noEmit`, `npm install -g genkit-cli`). No actual shell execution or code injection exists. The skill contains only documentation text.
False Positive: Hardcoded URLs in Documentation
Static analyzer flagged hardcoded URLs at references/docs-and-cli.md:21 (http://localhost:4000, the Genkit Dev UI localhost address) and references/examples.md:128 (https://example.com/photo.jpg, a placeholder example URL). These are documentation references, not actual network requests.
False Positive: Environment Variable Documentation
Static analyzer flagged 'Generic API/secret keys' at references/setup.md:40. This line instructs users to set environment variables like GEMINI_API_KEY. It is documentation guidance, not actual credential access or exfiltration.
False Positive: Weak Cryptographic Algorithm
Static analyzer flagged 'weak cryptographic algorithm' at multiple locations in SKILL.md, references/best-practices.md, references/common-errors.md, and references/examples.md. No cryptographic operations exist in any file. These are likely false matches on model names or configuration strings in documentation text.
审计者: claude

质量评分

45
架构
100
可维护性
87
内容
50
社区
82
安全
91
规范符合性

你能构建什么

设置新的 Genkit 项目

开发人员希望使用 Genkit 向现有 Node.js 应用程序添加 AI 功能。该技能指导目录结构、包安装、插件配置和初始流程创建。

从 Genkit pre-1.0 迁移到 v1.x

团队维护一个在 v1.0 版本之前构建的 Genkit 应用程序。该技能识别已弃用的 API,为导入、模型引用和流程定义提供迁移模式。

构建多模态 AI 功能

产品团队希望向其应用程序添加图像生成或文本转语音功能。该技能为 Gemini 多模态模型提供正确配置的工作示例。

试试这些提示

在新项目中设置 Genkit
我想使用 Genkit 向我的 Node.js 项目添加 AI 功能。帮助我设置项目结构、安装所需的包,并创建一个生成文本的简单流程。
修复 Genkit 类型错误
我的 Genkit 流程中出现 TypeScript 错误。检查常见错误参考,并帮助我确定这是否是已弃用的 API 问题或导入问题。
创建结构化输出流程
我需要一个使用 Zod 架构返回结构化 JSON 输出的 Genkit 流程。向我展示如何定义架构、创建流程以及访问类型化输出。
添加流式图像生成
我想构建一个使用 Gemini 2.5 Flash 图像模型生成图像并流式传输部分结果的 Genkit 流程。包含正确的 responseModalities 配置,并解释如何处理媒体输出。

最佳实践

  • 始终使用 Genkit CLI(`genkit docs:search`、`genkit docs:read`)查找最新文档,而不是依赖内部知识,因为 Genkit API 在版本之间经常更改。
  • 将 API 密钥和敏感配置存储在环境变量或 .env 文件中。永远不要在源文件中硬编码凭据或将它们提交到版本控制。
  • 使用 `genkit` 包(而不是独立的 `zod` 包)中的 Zod 架构进行所有输入和输出定义。添加 `.describe()` 注释以指导 LLM 正确填充架构字段。

避免

  • 不要从已弃用的包(如 `@genkit-ai/core`、`@genkit-ai/ai` 或 `@genkit-ai/flow`)导入。改为直接从 `genkit` 包导入核心功能。
  • 在故障排除时不要跳过阅读常见错误参考。许多错误是由已记录解决方案的已弃用 API 使用引起的。
  • 不要使用已停用的模型版本,如 `gemini-2.0-*` 或 `gemini-1.5-*`。始终使用最佳实践参考中指定的最新一代模型。

常见问题

什么是 Genkit,此技能有什么作用?
Genkit 是一个用于在 JavaScript 和 TypeScript 中构建 AI 应用的框架。此技能提供参考文档、常见错误解决方案和代码模式,帮助您正确使用 Genkit 进行开发。
Genkit 支持哪些 AI 模型提供商?
Genkit 支持多个提供商,包括 Google AI、OpenAI、Anthropic 和 Ollama。此技能默认使用 Google AI 示例,但您可以使用 `genkit docs:search plugins` 搜索文档以找到其他提供商的配置。
所需的最低 Genkit CLI 版本是多少?
所需的最低 CLI 版本是 1.29.0。您可以使用 `genkit --version` 验证您的版本,并使用 `npm install -g genkit-cli@^1.29.0` 安装或升级。
如何排查 Genkit 错误?
首先始终阅读常见错误参考。大多数错误是由已弃用的 pre-1.0 API 使用引起的。将您的错误与记录的模式匹配,并在搜索外部来源之前应用解决方案。
如何启用 Genkit 开发人员 UI?
使用 `genkit start -- <your-start-command>` 运行您的应用程序。这将启用开发人员 UI,通常可在 http://localhost:4000 访问,您可以在其中测试流程并监控执行。
我可以将此技能与 Next.js 或 Firebase 项目一起使用吗?
可以。Genkit 与 Next.js(通过 @genkit-ai/next)和 Firebase(通过 @genkit-ai/firebase)集成。该技能从 package.json 检测您的框架并相应地调整其指导。