developing-genkit-js
Skill này làm gì
Skill này giúp lập trình viên xây dựng tính năng AI bằng JavaScript và TypeScript với Genkit SDK. Skill dành cho các đội web và Node.js muốn thêm agent hoặc lệnh gọi mô hình.
Khi nào nên dùng
- ✓Khi bạn muốn xây một agent, flow hoặc công cụ AI bằng JavaScript hoặc TypeScript với Genkit.
- ✓Khi bạn đang sửa lỗi Genkit, lỗi xác thực hoặc lỗi kiểu trong một dự án Node.js.
- ✓Khi bạn muốn file prompt và các cuộc hội thoại agent nhiều lượt trong một ứng dụng Genkit.
Liên kết skill
https://github.com/google/skills/blob/main/skills/cloud/developing-genkit-js/SKILL.mdSao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.
Cách dùng
Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.
Tin nhắn có sẵn để dán
Dành cho Claude Code, Codex hoặc Cursor: chạy lệnh trong thư mục dự án của bạn và skill sẽ được cài đặt.
Tải tệp SKILL.md về và thả vào thư mục skill của agent.
Ví dụ cách nhờ AI
“Thiết lập Genkit trong dự án TypeScript của tôi và tạo một flow viết một câu đùa về một chủ đề.”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
Skill kiểm tra phiên bản genkit CLI trước, rồi viết mã TypeScript dùng API Genkit cho flow, công cụ và prompt. Skill chỉ đến các hướng dẫn tham chiếu cho thiết lập và từng tính năng cụ thể.
Nội dung kỹ thuật (SKILL.md gốc)
Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.
Genkit JS
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.
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;
});
Prompts (Dotprompt)
.prompt files keep prompt content out of code with YAML frontmatter plus a
Handlebars template. See Dotprompt: promptDir,
ai.prompt() (call/stream/render), variants, partials, named schemas via
ai.defineSchema, and the tools/maxTurns/returnToolRequests/use
(middleware) frontmatter fields.
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, waiting, and resuming failed or aborted runs.
- 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, including background delegation and
continue_task. - Advanced custom agents:
defineCustomAgentfor full turn control. - Deploying agents: serving agents over HTTP (multiple agents, CORS, web UI, other frameworks).
Generative UI (A2UI)
Genkit has an A2UI (Agent-to-UI) plugin (@genkit-ai/a2ui) that
lets an agent stream interactive UI surfaces (cards, lists, forms, buttons),
not just prose. The whole server-side integration is the a2ui() model
middleware in an agent's (or ai.generate's) use array; the browser renders
surfaces with an @a2ui/* renderer plus the helpers in @genkit-ai/a2ui/client.
It builds on the beta agent client (genkit/beta + genkit/beta/client).
- A2UI: server middleware, options, client rendering, user actions/forms, custom catalogs, and the security/trust boundary.
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,contextCompression) plus built-in core middleware. - Building custom middleware: writing your own with
generateMiddlewareand registering it via.plugin().
Observability
Traces show up in the Dev UI under genkit start with no setup. For production
export to an OTLP backend (OpenTelemetry GenAI semantic conventions via
@genkit-ai/otel), custom instrumentation, or running the reflection API
outside dev, see Observability.
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
g
Câu hỏi thường gặp
Cần phiên bản genkit CLI nào?
Phiên bản 1.29.0 trở lên. Skill có thể cài hoặc nâng cấp cho bạn.
Skill có hỗ trợ file prompt không?
Có. Skill bao gồm các file Dotprompt với template và schema.
Skill có hỗ trợ agent không?
Có. Skill bao gồm API agent bản preview cho các cuộc hội thoại nhiều lượt.
Chi tiết
Mô tả gốc của tác giả
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.
repo: google/skills
Độ phổ biến
- Sao GitHub
- 22k
- Vị trí xếp hạng
- #10257
- Giấy phép
- Apache-2.0
- Cập nhật
- 2/11/2026
Bình luận
- …
Thêm skill từ kho mã này
finding-google-skills
22kGiúp agent của bạn tìm hướng dẫn Google phù hợp cho việc thiết lập, như hosting, cơ sở dữ liệu, lưu trữ, đăng nhập hoặc phục vụ mô hình AI.
gcloud
22kGiúp agent của bạn viết và kiểm tra các lệnh gcloud của Google Cloud, tra cứu cú pháp chính xác trước khi chạy bất cứ thứ gì để không đoán các flag.
google-cloud-recipe-auth
22kHướng dẫn agent của bạn qua quản lý danh tính và quyền truy cập của Google Cloud, gồm cách con người và dịch vụ đăng nhập và những quyền họ nhận được.
google-cloud-recipe-onboarding
22kHướng dẫn một lập trình viên mới qua các bước đầu tiên trên Google Cloud, gồm chọn dự án, liên kết thanh toán và triển khai tài nguyên đầu tiên.
Skill tương tự
api-connector-builder
280kGiúp agent của bạn xây dựng kết nối API mới theo đúng mẫu đã có, dùng khi bạn cần thêm một tích hợp mà không tạo cách làm mới.
api-design
280kGiúp agent của bạn thiết kế REST API theo các thực hành tốt nhất, hữu ích để định nghĩa cách API giao tiếp, hiển thị lỗi và tổ chức dữ liệu.
backend-patterns
280kGiúp agent của bạn với các mẫu kiến trúc phía máy chủ và tối ưu cơ sở dữ liệu, hữu ích khi xây dựng hoặc rà soát code chạy trên máy chủ.