genkit / go
AGENTS.md6.6k starsChanged 6 days agoApache-2.0View on GitHub
As an AI developer working on this codebase, you MUST adhere to these operational protocols:
1 other project uses a version of this.
Trending
More talk lately.about the whole repository
Most recently taken up by
- firebase/genkitword for word, first seen Nov 29, 2026
Who's talking about genkit-ai/genkit
- genkit-ai/docsite“docs: use kebab-case for CLI commands and options in evaluation docs”GitHub · Sep 30, 2026 · 2 reactions
- vortsghost2025/storytime“chore(deps): bump @genkit-ai/mcp from 1.31.0 to 1.33.0”GitHub · Apr 29, 2026 · 2 reactions
- vortsghost2025/storytime“chore(deps): bump @genkit-ai/mcp from 1.31.0 to 1.32.0”GitHub · Apr 15, 2026 · 2 reactions
- genkit-ai/docsite“docs: document dynamic model resolution across JS, Python, and Dart”GitHub · Oct 28, 2026 · 1 reactions
- nozomi-koborinai/ableton-osc-mcp“deps: bump github.com/firebase/genkit/go from 1.13.1 to 1.14.0 in the minor-and-patch group”GitHub · Oct 24, 2026 · 1 reactions
The biggest 5 of 26 mentions linking to the repository that our crawl found. Each line is their own headline.
See all 26
Talked about on GitHub (26 times).
On GitHub · 26
- Sep 30, 2026docs: use kebab-case for CLI commands and options in evaluation docs — genkit-ai/docsite2 reactions
- Apr 29, 2026chore(deps): bump @genkit-ai/mcp from 1.31.0 to 1.33.0 — vortsghost2025/storytime2 reactions · 1 comment
- Apr 15, 2026chore(deps): bump @genkit-ai/mcp from 1.31.0 to 1.32.0 — vortsghost2025/storytime2 reactions · 2 comments
- Oct 28, 2026docs: document dynamic model resolution across JS, Python, and Dart — genkit-ai/docsite1 reaction · 2 comments
- Oct 24, 2026deps: bump github.com/firebase/genkit/go from 1.13.1 to 1.14.0 in the minor-and-patch group — nozomi-koborinai/ableton-osc-mcp1 reaction · 1 comment
21 more on GitHub
- Oct 21, 2026docs: update JS skill for Genkit 1.43 and Go skill for Genkit Go 1.14 — genkit-ai/skills1 reaction
- Sep 30, 2026docs: replace deprecated genkit ui:start with genkit start — genkit-ai/docsite1 reaction
- Sep 6, 2026deps: bump github.com/firebase/genkit/go from 1.10.0 to 1.13.1 — nozomi-koborinai/ableton-osc-mcp1 reaction · 1 comment
- Aug 23, 2026deps: bump github.com/firebase/genkit/go from 1.10.0 to 1.12.0 — nozomi-koborinai/ableton-osc-mcp1 reaction · 2 comments
- Aug 17, 2026docs(go): bring the Go docs onto the current API and link the sample suite — genkit-ai/docsite1 reaction
- May 25, 2026feat(dart): Add interrupt releated span metadata — genkit-ai/genkit-dart1 reaction
- May 14, 2026docs(go): Document Anthropic strict tool use — genkit-ai/docsite1 reaction
- Apr 27, 2026feat(go): add middleware reference to Genkit Go skill — genkit-ai/skills1 reaction
- Mar 24, 2026chore(deps): update go samples — googleapis/mcp-toolbox1 reaction · 17 comments
- Mar 18, 2026docs: Update GitHub repository URLs from firebase/genkit to genkit-ai/genkit while preserving Go package paths — genkit-ai/docsite1 reaction · 1 comment
- Nov 2, 2026[JS] MCP tool calls fail on input JSON schema that has an array property whose items are `$ref` — ssbushi/genkit0 reactions · 4 comments
- Oct 28, 2026A2UI CLI distributed as a binary artifact that can be downloaded by developers — a2ui-project/a2ui0 reactions · 3 comments
- Oct 21, 2026[JS] MCP tool calls fail on input JSON schema that has an array property whose items are `$ref` — ssbushi/genkit0 reactions
- Oct 13, 2026agents: served agents send error cause and toString() in AgentOutput.error — genkit-ai/genkit-dart0 reactions
- Aug 25, 2026Feat: allowed_tools support — genkit-ai/genkit-dart0 reactions
- Jun 5, 2026[Add] Genkit (genkit-ai/genkit) — PyTorchKR/landscape0 reactions · 3 comments
- May 31, 2026Broken links detected (2026-06-14) — awesome-ai-tools/curated-mcp-servers0 reactions
- May 25, 2026Integration proposal: Google Genkit Middleware (auto-drafted 2026-05-25) — OpenCircuitDev/codetalker0 reactions
- May 12, 2026may 2026 — kimtth/azure-openai-llm-notes0 reactions
- May 4, 2026[bot] Firebase Genkit (`genkit`) not instrumented — no tracing for generate, chat, embed, or flow execution in JavaScript — braintrustdata/braintrust-sdk-javascript0 reactions
- Mar 20, 2026The MCP tools + built in search doesn't work properly yet — Gerifield/hAIry-botter0 reactions · 1 comment
Other versions1 project uses a version of this.
Word for word · 1
- firebase/genkit★ 6.6k100% same
Edited · 0
None found.
Wrote their own version · 0
None found.
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about code style.
Of the AGENTS.md files we read, the 35,196 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository5 other files it gives its agents.
- AGENTS.mdAGENTS.md
- genkit-tools/AGENTS.mdAGENTS.md
- js/AGENTS.mdAGENTS.md
- genkit-tools-cliSkill
- genkit-tools-testingSkill
The file
Show its rules and text
We split this AGENTS.md into the rules it gives an agent
48 rules. About 0 are common, 22 are distinctive, and 26 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈22
Distinctive · estimate
This author's own choices. Worth a look.
26
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 8
Context is Mandatory: Every Genkit function and tool execution requires a context.Context.
- Distinctive: line 9
Schema Strictness: When defining input/output types for Flows or Tools, use clear, JSON-tagged Go structs.
- Very specific: line 11
Idiomatic Concurrency: Prefer Go's native concurrency (goroutines/channels) but be mindful of the context lifecycle within long-running …
- Very specific: line 30
Use functional options (e.g., ai.WithModel, genkit.WithPlugins) for optional configuration parameters in constructors and method calls.
- Very specific: line 35
Use genkit.DefineFlow for orchestration tasks.
- Very specific: line 78
Use genkit.GenerateData to get structured output from a model directly into a Go struct.
- Very specific: line 94
Run Linting: Always run go vet ./... from the go/ directory for all Go code changes.
- Very specific: line 95
Format Code: Run bin/fmt (which runs go fmt) to ensure code is formatted correctly.
- Very specific: line 96
Pass All Tests: Ensure all unit tests pass (go test ./...).
- Distinctive: line 100
No Warning Suppression: Avoid ignoring linter warnings unless there is a compelling, documented reason.
- Very specific: line 109
Regenerating gen.go: If updates to types in go/ai/gen.go are needed:
- Very specific: line 123
Overwrite Risk: Do not edit genkit-tools/genkit-schema.json directly.
- Very specific: line 124
Note: When adding new Part types, ensure schemas.config is updated to add the new Part type on all existing Parts and add "omit" to it …
- Very specific: line 131
Environment: Use go mod for dependency management.
- Very specific: line 136
Use standard Go formatting (gofmt).
- Very specific: line 137
Use idioms like if err != nil for error handling.
- Very specific: line 138
Prefer short variable names for short scopes (e.g., i for index, ctx for context).
- Distinctive: line 140
Concurrency: Use channels and goroutines for concurrency.
- Distinctive: line 143
Start function comments with the function name.
- Very specific: line 144
Use // TODO(issue-id): Fix this later.
- Very specific: line 145
Ensure that go vet passes without errors.
- Distinctive: line 149
Format: Write comprehensive GoDoc-style comments for exported packages, types, and functions.
- Distinctive: line 152
Visuals: Prefer using diagrams if helpful to explain complex flows.
- Distinctive: line 159
When you are not sure about the API or concepts, please refer to the JavaScript implementation for the same.
- Distinctive: line 160
Keep examples in documentation and comments simple.
- Distinctive: line 161
Add links to relevant documentation on the Web or elsewhere in the relevant places in comments.
- Distinctive: line 162
Always update package comments and function comments when updating code.
- Very specific: line 167
Always add unit tests to improve coverage.
- Distinctive: line 169
When aiming to achieve parity the API and behavior should be identical to the JS canonical implementation.
- Distinctive: line 170
Always add/update samples to demonstrate the usage of the API or functionality.
- Distinctive: line 171
Use default input values for flows and actions to make them easier to use.
- Distinctive: line 173
Avoid mentioning sample specific stuff in core framework or plugin code.
- Very specific: line 174
Always check for missing dependencies in go.mod for each sample and add them if we're using them.
- Distinctive: line 175
When a plugin such as a model provider is updated or changes, please also update relevant documentation and samples.
- Distinctive: line 176
Avoid boilerplate comments in the code.
- Distinctive: line 177
Always update the README.md (if exists) to match the updated code changes.
- Distinctive: line 178
Make sure to not leave any dead code or unused imports.
- Very specific: line 188
Framework: Use the standard testing package.
- Very specific: line 190
Assertions: Use plain if/else blocks following the want/got pattern.
- Distinctive: line 207
Scope: Write comprehensive unit tests following the fail-fast approach.
- Very specific: line 208
Execution: Run via go test ./....
- Very specific: line 211
Modernize: Consider using modernize to update code to modern Go idioms (e.g., slices, maps) when fixing underlying issues.
- Very specific: line 213
Test Actions Directly: Use flow.Run(ctx, input) or tool.Run(ctx, input) to test the logic of your Genkit components.
- Very specific: line 214
Verify Schemas: Ensure that the Action returned by DefineX has the expected input and output schemas.
- Distinctive: line 215
Mock Models: When testing Flows that call models, use a mock model implementation to ensure deterministic tests.
- Very specific: line 221
Format: Use structured logging keys and values.
- Distinctive: line 251
Add a rationale paragraph explaining the why and the what before listing all the changes.
- Distinctive: line 254
Keep it short and simple.
≈ “Common” is an estimate: at least 1 in 5 of the 45,344 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Go Development Guidelines
Agent Instructions
As an AI developer working on this codebase, you MUST adhere to these operational protocols:
- Registry-First Thinking: Genkit is built around a central registry. Always use
genkit.DefineX(e.g.,DefineFlow,DefineTool) for any component that should be discoverable by tools or the Dev UI. - Context is Mandatory: Every Genkit function and tool execution requires a
context.Context. Pass it through faithfully; never usecontext.Background()inside an implementation unless it is the entry point. - Schema Strictness: When defining input/output types for Flows or Tools, use clear, JSON-tagged Go structs. The model uses these tags and types to understand the interface.
- Search Before Implementing: Many common utilities exist in
internal/baseorai/. Check there before implementing new JSON parsing or string manipulation logic. - Idiomatic Concurrency: Prefer Go's native concurrency (goroutines/channels) but be mindful of the
contextlifecycle within long-running background tasks.
Architecture & Patterns
- Package Structure:
genkit: The main entry point for application developers. Contains high-level functions for defining flows, prompts, and tools.ai: Contains the core AI types and interfaces (Model, Prompt, Tool, Embedder, Retriever, etc.).core: Contains the underlying framework primitives (Actions, Flows, Tracing, Registry). Mostly for internal use or plugin development.plugins: Contains implementations for specific providers (Google AI, Vertex AI, Ollama, etc.).internal: Contains private implementations, shared utilities, and development tools.base: Low-level utilities for JSON (extraction, normalization, validation) and context handling.cmd: Internal command-line tools for code generation (jsonschemagen), file synchronization (copy), and documentation (weave).registry: Implementation of the Genkit action and schema registry.metrics: OpenTelemetry instrumentation for framework metrics.fakeembedder: Testing utilities for simulating embedding providers.
- Constructors:
DefineX(e.g.,DefineFlow,DefineTool): Creates and registers a component with the registry. Use this for components that should be discoverable by the reflection API (and thus the Dev UI).NewX(e.g.,NewTool): Creates a component without registering it. Use this for internal components, dynamic creation, or testing.
- Options Pattern:
- Use functional options (e.g.,
ai.WithModel,genkit.WithPlugins) for optional configuration parameters in constructors and method calls. This maintains API stability while allowing for expansion.
- Use functional options (e.g.,
Canonical Coding Patterns
Defining a Flow
Use genkit.DefineFlow for orchestration tasks. Use typed structs for input and output to ensure schema generation.
type OrderInput struct {
ID int `json:"id"`
}
type OrderOutput struct {
Status string `json:"status"`
}
// Define the flow
var GetOrderStatusFlow = genkit.DefineFlow(g, "getOrderStatus",
func(ctx context.Context, input *OrderInput) (*OrderOutput, error) {
// Use genkit.Run to create a trace span for a specific step
status, err := genkit.Run(ctx, "lookup-db", func() (string, error) {
return "Shipped", nil
})
if err != nil {
return nil, err
}
return &OrderOutput{Status: status}, nil
},
)Defining a Tool
Tools are used by models. The description is crucial as the model uses it to decide when to call the tool.
type WeatherInput struct {
Location string `json:"location"`
}
var WeatherTool = genkit.DefineTool(g, "getWeather", "fetches current weather for a location",
func(ctx *ai.ToolContext, input *WeatherInput) (string, error) {
// Implementation logic
return "Sunny", nil
},
)Generation with Typed Data
Use genkit.GenerateData to get structured output from a model directly into a Go struct.
type Recipe struct {
Name string `json:"name"`
Ingredients []string `json:"ingredients"`
}
recipe, _, err := genkit.GenerateData[Recipe](ctx, g,
ai.WithModelName("googleai/gemini-flash-latest"),
ai.WithPrompt("Suggest a pancake recipe"),
)Code Quality & Linting
- Run Linting: Always run
go vet ./...from thego/directory for all Go code changes. - Format Code: Run
bin/fmt(which runsgo fmt) to ensure code is formatted correctly. - Pass All Tests: Ensure all unit tests pass (
go test ./...). - Production Ready: The objective is to produce production-grade code.
- Shift Left: Employ a "shift left" strategy—catch errors early.
- Strict Typing: Go is statically typed. Do not use
interface{}(orany) unless absolutely necessary and documented. - No Warning Suppression: Avoid ignoring linter warnings unless there is a compelling, documented reason.
- Group imports: standard library first, then third-party, then internal.
goimportshandles this automatically.
Generated Files & Data Model
- Do Not Edit Generated Files: Files generated by tools (like protobufs or strict-type generators) should not be modified directly.
- Do Not Edit gen.go:
go/ai/gen.gois an auto-generated file. DO NOT MODIFY IT DIRECTLY. - Generator/Sanitizer: Any necessary transformations to the core types must be applied to the generator script or the schema sanitizer.
- Canonical Parity: The data model MUST be identical to the JSON schema defined in the JavaScript (canonical) implementation.
Regenerating gen.go: If updates to types in
go/ai/gen.goare needed:- Modify the Zod schemas in
genkit-tools/common/src/types/(e.g.,model.tsforToolDefinition). Regenerate the JSON schema:
cd genkit-tools && pnpm run export:schemasRegenerate the Go code:
cd go/core && go run ../internal/cmd/jsonschemagen -outdir .. -config schemas.config ../../genkit-tools/genkit-schema.json ai
- Overwrite Risk: Do not edit
genkit-tools/genkit-schema.jsondirectly. It is a generated file and will be overwritten by theexport:schemasscript. - Note: When adding new Part types, ensure
schemas.configis updated to add the new Part type on all existing Parts and add "omit" to it accordingly.
- Modify the Zod schemas in
Detailed Coding Guidelines
Target Environment
- Go Version: Target Go 1.24 or newer.
- Environment: Use
go modfor dependency management.
Typing & Style
- Syntax:
- Use standard Go formatting (
gofmt). - Use idioms like
if err != nilfor error handling. - Prefer short variable names for short scopes (e.g.,
ifor index,ctxfor context).
- Use standard Go formatting (
- Interfaces: Define interfaces where they are used (consumer-side), not where they are implemented (producer-side).
- Concurrency: Use channels and goroutines for concurrency. Avoid shared mutable state where possible.
- Comments:
- Use proper punctuation.
- Start function comments with the function name.
- Use
// TODO(issue-id): Fix this later.format for stubs.
- Ensure that
go vetpasses without errors.
Documentation
- Format: Write comprehensive GoDoc-style comments for exported packages, types, and functions.
- Content:
- Explain Concepts: Explain the terminology and concepts used in the code to someone unfamiliar with the code.
- Visuals: Prefer using diagrams if helpful to explain complex flows.
- Required Sections:
- Overview: Description of what the package/function does.
- Examples: Provide examples for complex APIs (using
Examplefunctions in_test.gofiles is best practice).
- External Packages: Use the
go doccommand to understand type and function definitions when working with external packages. - References:
- Please use the descriptions from genkit.dev and github.com/genkit-ai/docsite as the source of truth for the API and concepts.
- When you are not sure about the API or concepts, please refer to the JavaScript implementation for the same.
- Keep examples in documentation and comments simple.
- Add links to relevant documentation on the Web or elsewhere in the relevant places in comments.
- Always update package comments and function comments when updating code.
- Scan documentation for every package you edit and keep it up-to-date.
Implementation
- Always add unit tests to improve coverage. Use Genkit primitives and helper functions instead of mocking types.
- When aiming to achieve parity the API and behavior should be identical to the JS canonical implementation.
- Always add/update samples to demonstrate the usage of the API or functionality.
- Use default input values for flows and actions to make them easier to use.
- In the samples, explain the whys, hows, and whats of the sample in the package comment so the user learns more about the feature being demonstrated. Also explain how to test the sample.
- Avoid mentioning sample specific stuff in core framework or plugin code.
- Always check for missing dependencies in
go.modfor each sample and add them if we're using them. - When a plugin such as a model provider is updated or changes, please also update relevant documentation and samples.
- Avoid boilerplate comments in the code. Comments should tell why, not what.
- Always update the README.md (if exists) to match the updated code changes.
- Make sure to not leave any dead code or unused imports.
Formatting
- Tool: Format code using
go fmt(viabin/fmtor editor). - Line Length: Go doesn't have a strict line length limit, but keep it reasonable (e.g., 80-100 characters).
- Strings: Wrap long lines and strings appropriately.
Testing
- Framework: Use the standard
testingpackage. Do not use external assertion libraries (liketestify) for new core code.- Note: Existing plugins may use
testify, but prefer standard library for consistency.
- Note: Existing plugins may use
- Assertions: Use plain
if/elseblocks following thewant/gotpattern.Example:
if got := func(); got != want { t.Errorf("func() = %v, want %v", got, want) }For complex object comparisons (structs, slices, maps), use
github.com/google/go-cmp/cmp(andcmpoptsif needed).if diff := cmp.Diff(want, got); diff != "" { t.Errorf("mismatch (-want +got):\n%s", diff) }
- Scope: Write comprehensive unit tests following the fail-fast approach.
- Execution: Run via
go test ./.... - Porting: Maintain 1:1 logic parity accurately if porting tests. Do not invent behavior.
- Fixes: Fix underlying code issues rather than special-casing tests.
- Modernize: Consider using
modernizeto update code to modern Go idioms (e.g.,slices,maps) when fixing underlying issues. - Genkit Testing:
- Test Actions Directly: Use
flow.Run(ctx, input)ortool.Run(ctx, input)to test the logic of your Genkit components. - Verify Schemas: Ensure that the
Actionreturned byDefineXhas the expected input and output schemas. - Mock Models: When testing Flows that call models, use a mock model implementation to ensure deterministic tests.
- Trace Inspection: For complex flows, use tests to verify that
genkit.Runsteps are being executed as expected.
- Test Actions Directly: Use
Logging
- Library: Use the
core/loggerpackage-level functions (logger.Debug(ctx, ...),logger.Info,logger.Warn,logger.Error) whenever acontext.Contextis available; they use the context's logger and let handlers correlate records with the active trace span (Dev UI, Cloud Logging). Fall back tolog/slogonly where there is no context (package init, load-time code). - Format: Use structured logging keys and values. Messages are lowercase, stable phrases with no trailing punctuation; put variable data in attributes, never
fmt.Sprintfinto the message. Use"error"(not"err") as the key for errors. - Levels:
Debugfor per-request detail (spans, model turns, tool runs, middleware hooks);Infosparingly for one-time lifecycle events (init complete, server listening);Warnfor misconfiguration, fallbacks, and skipped work;Erroronly where the error is not also returned to the caller (background goroutines, server handlers writing 500s). Never log-and-return the same error.
Licensing
Include the Apache 2.0 license header at the top of each file (update year as needed):
// Copyright [year] Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// SPDX-License-Identifier: Apache-2.0Git commit message guidelines
- Please draft a plain-text commit message after you're done with changes.
- Please do not include absolute file paths as links in commit messages.
- Since lines starting with
#are treated as comments, please use a simpler format for headings. - Add a rationale paragraph explaining the why and the what before listing all the changes.
- Please use conventional commits for the format.
- For scope, please refer to release-please configuration if available.
- Keep it short and simple.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

