技能 developing-genkit-go
📦

developing-genkit-go

安全

使用 Genkit Go SDK 构建 AI 应用

在 Go 中构建 AI 应用需要理解 Genkit SDK 的生成、提示、流程和模型提供者模式。本技能提供全面的参考文档,用于创建具有结构化输出、流式传输和工具调用功能的 AI 驱动的 Go 应用程序。

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

下载技能 ZIP

2

在 Claude 中上传

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

3

开启并开始使用

测试它

正在使用“developing-genkit-go”。 创建一个生成关于"编程 bug"主题笑话的流程

预期结果:

A working Go file with genkit.Init, a DefineFlow for joke generation, HTTP handler setup with genkit.Handler, and instructions to test it with genkit start.

正在使用“developing-genkit-go”。 展示如何使用 Recipe 类型生成结构化 JSON

预期结果:

Go code defining Recipe and Ingredient structs with jsonschema tags, then genkit.GenerateData call returning a *Recipe with title, ingredients, and steps fields.

安全审计

安全
v1 • 4/22/2026

All 283 static findings are false positives. This is a legitimate Firebase community skill providing Genkit Go SDK documentation. The skill contains Go code examples with printf-style string formatting (e.g., 'Tell me a joke about %s'), bash CLI installation commands, and references to standard AI API environment variable names. No malicious code patterns exist.

7
已扫描文件
1,196
分析行数
4
发现项
1
审计总数
中风险问题 (2)
Static Scanner Pattern False Positive - Printf Formatting
The static analyzer flagged 'Ruby/shell backtick execution' at 241 locations but these are all Go code examples using printf-style string formatting (fmt.Printf pattern: 'message about %s', topic). This is standard Go string formatting syntax, not command execution.
Static Scanner Pattern False Positive - Bash Installation Commands
The static analyzer flagged 'external_commands' for curl commands used to install the Genkit CLI. Commands like 'curl -sL cli.genkit.dev | bash' are standard CLI installation patterns used by many legitimate tools including Homebrew, nvm, and official SDKs.
低风险问题 (2)
Static Scanner Pattern False Positive - Environment Variable References
The static analyzer flagged 'env_access' for references to standard API key environment variable names (GEMINI_API_KEY, ANTHROPIC_API_KEY, OPENAI_API_KEY). These are documented configuration settings for authenticating with AI providers, not actual secret access.
Static Scanner Pattern False Positive - Hardcoded URLs
The static analyzer flagged hardcoded URLs for AI provider documentation links (ai.google.dev, docs.anthropic.com) and localhost development addresses. These are legitimate reference URLs in documentation context.
审计者: claude

质量评分

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

你能构建什么

构建 AI 驱动的 API

创建使用 AI 模型进行内容生成、分类或数据提取的 HTTP API,并配备内置追踪功能。

实现多步骤 AI 工作流

构建具有工具调用的复杂 AI 流程,其中模型可以调用自定义 Go 函数来收集信息或执行操作。

使用 AI 生成结构化数据

使用 Genkit 的 schema 支持直接从 AI 模型输出生成类型化的 Go 结构体,无需手动解析 JSON。

试试这些提示

基础文本生成
Show me how to use genkit.GenerateText to generate a joke about a topic the user provides.
结构化输出生成
Create a flow that uses genkit.GenerateData with a Go struct schema to return structured JSON data.
带工具调用的提示
Define a Genkit tool that allows the AI to search a database, then show how to use it in a flow.
多提供者设置
Set up Genkit with both Google AI and Anthropic providers, showing how to switch between models.

最佳实践

  • 通过调用链显式传递 *Genkit 实例,而不是将其存储为全局变量
  • 在输出类型上使用 jsonschema 结构体标签,以便模型理解每个字段应包含的内容
  • 编写清晰的工具描述 - 模型根据这些描述决定调用哪些工具

避免

  • 避免硬编码模型名称 - 请查看提供者文档以获取当前的模型 ID,因为它们会频繁更改
  • 不要在生产代码中跳过流程 - 流程提供对调试至关重要的追踪和可观测性
  • 避免模糊的工具描述 - 这会导致模型错误调用或遗漏工具调用

常见问题

Genkit Go 支持哪些模型提供者?
Genkit Go 支持 Google AI (Gemini)、Vertex AI、Anthropic (Claude)、OpenAI 兼容 API 以及用于本地模型的 Ollama。
如何开始使用 Genkit Go?
初始化一个 Go 模块,使用 go get 安装 Genkit SDK,添加提供者插件,然后使用 genkit.Init 开始构建流程和提示。
GenerateText 和 Generate 有什么区别?
GenerateText 仅返回一个字符串。Generate 返回完整的 ModelResponse,包含元数据、使用统计和对话历史。
如何将 Claude Code 与 Genkit Go 结合使用?
Genkit Go 旨在帮助您构建 Claude Code 可以使用的 AI 应用程序。在创建用于 AI 驱动功能的 Go 代码时,请参考本技能。
我可以实时流式传输 AI 响应吗?
可以,使用 GenerateStream 进行文本流式传输,或使用 GenerateDataStream 在生成结构化对象时进行流式传输。
如何测试我的 Genkit 流程?
使用 Genkit CLI 通过 'genkit start' 启动开发者 UI,在那里您可以交互式运行流程、查看追踪记录并检查提示渲染。