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.

referencesdocs-and-cli.md

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

Genkit Documentation & CLI

This reference lists common tasks and workflows using the genkit CLI. For authoritative command details, always run genkit --help or genkit <command> --help.


Prerequisites:

Ensure that the CLI is on genkit-cli version >= 1.29.0. If not, or if an older version (1.x < 1.29.0) is present, update the Genkit CLI version. Alternatively, to run commands with a specific version or without global installation, prefix them with npx -y genkit-cli@^1.29.0.

Documentation

  • Search docs: genkit docs:search <query>
    • Example: genkit docs:search "streaming"
    • Example: genkit docs:search "rag retrieval"
  • Read doc: genkit docs:read <path>
    • Example: genkit docs:read js/overview.md
  • List docs: genkit docs:list

Development Workflow (recommended)

genkit start unintrusively wraps any Node.js program that uses the Genkit library, running it unchanged while capturing traces from every Genkit action so you can prove tools were actually called and inspect model I/O from the terminal, even for headless checks. It forwards stdio, so interactive CLI tools that rely on stdin/stdout work without issues. Running your app directly (node/tsx/npm start) skips trace capture, so you're debugging blind.

Primary pattern (default): prefix genkit start -- to your normal run command. This collects telemetry from any Genkit code your program runs, whether triggered from the dev UI, your own web server/web UI, or a plain script:

  • Node.js (TypeScript):
    genkit start -- npx tsx --watch src/index.ts
  • Next.js:
    genkit start -- npx next dev
  • Without the Dev UI (still a persistent server):
    genkit start --noui -- npx tsx src/index.ts

genkit start runs until you stop it with Ctrl+C. That is expected and correct for the common cases: a server your web/mobile app calls, or an interactive CLI you exit yourself. --noui only drops the Dev UI; it is not a one-shot command and will not exit on its own. Do not use genkit start as a blocking step in automated/non-interactive contexts; use flow:run (below) for that.

For non-interactive/agent/CI use, add the global --non-interactive flag before -- so the CLI uses defaults and never blocks on a prompt (e.g. the first-run analytics notice), e.g. genkit flow:run myFlow '<input>' --non-interactive -- npx tsx src/index.ts.

Flow Execution (secondary)

  • Run a flow: genkit flow:run <flowName> '<inputJSON>' -- <run cmd>
    • Invokes a specific flow by name from the CLI. Append your run command after -- to spin up the runtime for this run (the command runs as-is to register your flows): it runs once, prints a Trace ID, then exits, so it's the right choice for a quick, non-interactive check that must self-terminate (unlike genkit start). Note: flow:run runs flows (ai.defineFlow), not agents; you can't flow:run an agent (ai.defineAgent) directly. To verify an agent, wrap one turn in a throwaway flow and run that. Traces for the run can be inspected with the tracing commands below.
    • Always pass input JSON explicitly. flow:run sends undefined when the input is omitted and does not fall back to a schema .default(), so a flow with a defaulted input will fail validation unless you pass the value.
    • Simple Input:
      genkit flow:run tellJoke '"chicken"' -- npx tsx src/index.ts
    • Object Input:
      genkit flow:run generateStory '{"subject": "robot", "genre": "sci-fi"}' -- npx tsx src/index.ts

Evaluation

  • Evaluate a flow: genkit eval:flow <flowName> [data] -- <run cmd>

    • Runs a flow and evaluates the output against configured evaluators. As with flow:run, append your run command after -- to spin up the runtime for the run.
    • Example (Single Input):
      genkit eval:flow answerQuestion '[{"testCaseId": "1", "input": {"question": "What is Genkit?"}}]' -- npx tsx src/index.ts
    • Example (Batch Input):
      genkit eval:flow answerQuestion --input inputs.json -- npx tsx src/index.ts
  • Run Evaluation: genkit eval:run <dataset>

    • Evaluates a dataset against configured evaluators.
    • Example:
      genkit eval:run dataset.json --output results.json

Tracing

  • Get a trace: genkit trace:get <traceId>
    • Retrieves detailed information for a specific trace by its ID. This is particularly useful for debugging failed model calls, inspecting tool execution, or analyzing the exact inputs and outputs of a specific step in your flow.
    • Machine-readable output: add --format json (e.g. genkit trace:get <traceId> --format json) to get clean JSON you can pipe into jq or other parsers.
  • List traces: genkit trace:list [options]
    • Lists recent traces. Use this to find trace IDs from recent executions.
  • Piping to parsers: the default trace output is human-oriented (extra banner/log lines, possible truncation on large traces), so don't pipe that form directly into jq. Use --format json for clean JSON, or the Dev UI trace viewer (genkit start) for complex traces.

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.