Index of every page on this site: llms.txt
All skills
genkit-ai avatar

/developing-genkit-js

@d12c988
by Genkitgenkit-ai/skills40 stars
13
Run it yourself

Provides guidance on developing 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. Don't use for Genkit in Python, Go, or Dart.

Use this Skill: https://skilld.dev/gh/genkit-ai/skills/developing-genkit-js

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

referencessetup.md

≈1.1k tokens on demand. Your agent reads this file only when SKILL.md points to it.

Genkit JS Setup

Follow these instructions to set up Genkit in the current codebase. These instructions are general-purpose and lack specific codebase knowledge, so use your best judgment when following them.

  1. Tell the user "I'm going to check out your workspace and set you up to use Genkit for GenAI workflows."
  2. If the current workspace is empty or is a starter template, your goal will be to create a simple image generation flow that allows someone to generate an image based on a prompt and selectable style. If the current workspace is not empty, you will create a simple example flow to help get the user started.
  3. Check to see if any Genkit provider plugin (such as @genkit-ai/google-genai or @genkit-ai/oai-compat or others, may start with genkitx-*) is installed.
    • If not, ask the user which provider they want to use.
    • For non-Google providers: Use genkit docs:search "plugins" to find the correct package and installation instructions.
    • If they have no preference, default to @genkit-ai/google-genai for a quick start.
    • If this is a Next.js app, install @genkit-ai/next as well.
  4. Search the codebase for the exact string genkit( (remember to escape regexes properly) which indicates that the user has already set up Genkit in the codebase. If found, no need to set it up again; tell the user "Genkit is already configured in this app." and exit this workflow.
  5. Create an ai directory in the primary source directory of the project (this may be e.g. src but is project-dependent). Adapt this path if your project uses a different structure.
  6. Create {sourceDir}/ai/genkit.ts and populate it using the example below. DO NOT add a next plugin to the file, ONLY add a model provider plugin to the plugins array:
import { genkit, z } from 'genkit';
// Import your chosen provider plugin here. Example:
import { googleAI } from '@genkit-ai/google-genai';

export const ai = genkit({
  plugins: [
    googleAI(), // Add your provider plugin here
  ],
  model: googleAI.model('gemini-flash-latest'), // Set your provider's model here
});

export { z };
  1. Create {sourceDir}/ai/tools and {sourceDir}/ai/flows directories, but leave them empty for now.
  2. Create {sourceDir}/ai/index.ts and populate it with the following (change the import to match import aliases in tsconfig.json as needed):
import './genkit.js';
// import each created flow, tool, etc. here for use in the Genkit Dev UI
  1. Add the genkit-cli to the project's devDependencies (e.g. npm install -D genkit-cli, or the pnpm/yarn/bun equivalent) so the CLI version is pinned per-project and works in CI, then add a genkit:dev script to package.json that runs genkit start -- npx tsx --watch {sourceDir}/ai/index.ts. This is the recommended way to run the app during development: genkit start wraps your program and captures a trace of every Genkit action (prompts, model I/O, tool calls) while serving the Dev UI at http://localhost:4000. Running the app directly (tsx/node/npm start) skips trace capture, so you're debugging blind. DO NOT try to run the script now.
  2. Tell the user "Genkit is now configured and ready for use." Let them know they can start developing with npm run genkit:dev (or the pnpm/yarn/bun equivalent), which stays running until stopped with Ctrl+C and serves the Dev UI at http://localhost:4000. Also remind them to set appropriate env variables (e.g. GEMINI_API_KEY for Google providers). Wait for the user to prompt further before creating any specific flows.

Next Steps and Troubleshooting

  • Documentation: Use the CLI to access documentation (e.g., genkit docs:search).
  • Building Flows: See examples.md for patterns on creating flows, adding tools, and advanced configuration.
  • Running & Verifying: npm run genkit:dev is the default dev loop (persistent, serves the Dev UI). For a quick, non-interactive check that exits on its own, run a single flow with genkit flow:run <flow> '<input>' -- npx tsx {sourceDir}/ai/index.ts and inspect it with genkit trace:get <id>. See docs-and-cli.md.
  • Troubleshooting: If you encounter issues during setup or initialization, check common-errors.md for solutions.

Source: SKILL.md on GitHub

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No alerts13d5 checks · Risk SAFE
  • Gen Agent Trust Hub14d

    The skill is a comprehensive development guide for the Genkit JS framework. It provides technical instructions, code examples, and troubleshooting steps. All referenced tools and packages are official or standard industry dependencies. No security risks were identified.

  • Socket13d

    No alerts

  • Snyk14d

    Risk: LOW · No issues

  • Runlayer8mo

    6 files scanned · No issues

  • ZeroLeaks7mo

    Score: 93/100 · 2 sections analyzed

Signed by skilld at d12c988. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 4 days ago.

Activeupdated 2 weeks ago
metadata
{
  "version": "1.0.0",
  "category": "AiAndMachineLearning"
}
  • TypeScript
  • genkit
  • nodejs
  • ai-agents
  • flows
  • llm
  • google-ai
  • openai
  • anthropic

README badge

README badge for genkit-ai/skills/developing-genkit-js

Develop AI-powered applications using Genkit in Node.js and TypeScript, including flows, tools, and multi-model integrations. Covers Genkit CLI setup, flow definition with schema validation, provider selection (Google AI, OpenAI, Anthropic, Ollama), and error troubleshooting for version 1.29.0 and later.

Generated from the current SKILL.md.

What Genkit CLI version does this skill require?
Minimum CLI version 1.29.0. Verify with `genkit --version` and upgrade with `npm install -g genkit-cli@^1.29.0` if needed.
Does this skill cover pre-1.0 Genkit or older versions?
No. Genkit went through a major breaking API change. This skill assumes v1.x (1.29.0+) and will not reliably handle pre-1.0 code or deprecated APIs.
What AI providers does this skill support?
Genkit is provider-agnostic and supports Google AI, OpenAI, Anthropic, Ollama, and others. The skill defaults to Google AI if no provider is specified.
How should I troubleshoot Genkit errors?
Always read the Common Errors reference first to identify known patterns and their fixes. Use `genkit docs:search` only if the error is not documented there.
Does this skill work with Next.js, Firebase, or Express?
Yes. The skill detects your framework via package.json and adapts the implementation to framework-specific patterns like @genkit-ai/next or @genkit-ai/firebase.

Generated from the current SKILL.md. These answers refresh after source changes.