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
Steady talk.about the whole repository
Most recently taken up by
- genkit-ai/genkitword for word, first seen Nov 29, 2026
Who's talking about firebase/genkit
- google/dotprompt“[FR] Add embed.FS Support for Search Directory in the Go implementation”GitHub · Jun 19, 2025 · 5 reactions
- genkit-ai/genkit“[Tooling]: Running tooling in CI/CD is interrupted by cookie/analytics message”GitHub · Mar 3, 2025 · 4 reactions
- genkit-ai/genkit“[FR] Support tool calling for any arbitrary (ollama?) model”GitHub · Jul 22, 2024 · 4 reactions
- google/dotprompt“[Go][Bug] dotprompt fails to compile with invopop/jsonschema v0.14.0 due to ordered-map type mismatch”GitHub · Apr 24, 2026 · 3 reactions
- @github-trending-js.bsky.social“📦 firebase / genkit ⭐ 4,615 (+53) 🗒 TypeScript Open-source framework for building AI-powered apps in …”Bluesky · Oct 11, 2025 · 3 likes
The biggest 5 of 65 mentions linking to the repository that our crawl found. Each line is their own headline.
See all 65
Talked about on GitHub, Bluesky, Hacker News and Stack Overflow (65 times).
On GitHub · 50
- Jun 19, 2025[FR] Add embed.FS Support for Search Directory in the Go implementation — google/dotprompt5 reactions · 1 comment
- Mar 3, 2025[Tooling]: Running tooling in CI/CD is interrupted by cookie/analytics message — genkit-ai/genkit4 reactions · 1 comment
- Jul 22, 2024[FR] Support tool calling for any arbitrary (ollama?) model — genkit-ai/genkit4 reactions · 1 comment
- Apr 24, 2026[Go][Bug] dotprompt fails to compile with invopop/jsonschema v0.14.0 due to ordered-map type mismatch — google/dotprompt3 reactions · 9 comments
- Sep 29, 2025[JS] Vertex AI plugin uses incorrect URL for global location in Genkit — genkit-ai/genkit3 reactions · 2 comments
45 more on GitHub
- Sep 16, 2025[Go] Inaccurate and Incomplete Documentation for OpenAI-Compatible Providers in Genkit Go SDK — genkit-ai/genkit3 reactions · 1 comment
- Apr 17, 2025[Go] Add MCP plugin — genkit-ai/genkit3 reactions · 2 comments
- Apr 16, 2025[Go] Genkit SDK v0.5.1 will not build against dependant otel SDK v1.35.0 — genkit-ai/genkit3 reactions · 8 comments
- Jul 21, 2024[JS] ACCESS_TOKEN_EXPIRED When Calling Embedder — genkit-ai/genkit3 reactions · 3 comments
- Sep 24, 2026feat(genkit): add genkit plugin bundling official genkit-ai/skills — pleaseai/claude-code-plugins2 reactions · 6 comments
- Sep 14, 2026deps(deps): bump github.com/firebase/genkit/go from 1.12.0 to 1.13.1 — genkit-ai/aws-bedrock-go-plugin2 reactions · 1 comment
- Apr 15, 2026chore(deps): bump @genkit-ai/mcp from 1.31.0 to 1.32.0 — vortsghost2025/storytime2 reactions · 2 comments
- Feb 11, 2025[cloud_functions] feature request for stream support — firebase/flutterfire2 reactions · 2 comments
- Jan 29, 2025[JS] Log level change + repetitive 'Shutting down all Genkit servers...' message — genkit-ai/genkit2 reactions · 1 comment
- Nov 7, 2024fix(types): fix type cache crash — colinhacks/zod2 reactions · 5 comments
- Oct 20, 2024[Vertex AI Embeddings] add support for multimodalembedding@001 — genkit-ai/genkit2 reactions · 1 comment
- May 18, 2024[JS] TypeError fetch failed. — genkit-ai/genkit2 reactions · 6 comments
- Nov 19, 2026chore(go): upgrade Go sample dependencies and add CI + Dependabot — genkit-ai/samples1 reaction
- Nov 16, 2026chore(deps): update go samples — googleapis/mcp-toolbox1 reaction
- Nov 12, 2026chore(samples): remove deprecated Project IDX / Firebase Studio templates — genkit-ai/genkit1 reaction
- Nov 3, 2026chore(audit): remove vendored Firebase and Xcode agent skills — groupthinking/EventRelay1 reaction · 6 comments
- Nov 2, 2026deps: bump github.com/firebase/genkit/go from 1.13.1 to 1.14.0 — genkit-ai/opentelemetry-go-plugin1 reaction · 1 comment
- Oct 31, 2026Add a Genkit Go runner configured from Dotprompt (spec.config) — google/ax1 reaction
- Oct 30, 2026docs(go): clarify dynamic model resolution and add googlegenai package example — genkit-ai/genkit1 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
- Oct 21, 2026docs: update JS skill for Genkit 1.43 and Go skill for Genkit Go 1.14 — genkit-ai/skills1 reaction
- Oct 12, 2026feat(go/plugins/compat_oai/meta): add Meta Muse plugin with Muse Wonder support — genkit-ai/genkit1 reaction
- Oct 10, 2026feat(go/plugins/postgresql/exp): add a PostgreSQL session store — genkit-ai/genkit1 reaction
- Oct 6, 2026refactor(go/plugins/systemone): split the System One protocol out of the TypeSafe plugin — genkit-ai/genkit1 reaction
- Sep 25, 2026refactor(go): remove the experimental tool surface — genkit-ai/genkit1 reaction
- Sep 17, 2026docs: add Google Genkit A2UI integration guide and framework references — a2ui-project/a2ui1 reaction · 3 comments
- 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
- Sep 3, 2026chore(go): retract v1.13.0 — genkit-ai/genkit1 reaction
- Sep 3, 2026docs(go): move A2UI to the `a2ui/exp` import path — genkit-ai/docsite1 reaction
- Aug 25, 2026feat(go/plugins/middleware): add ContextCompression middleware — genkit-ai/genkit1 reaction
- Aug 25, 2026feat(go/plugins/spark): add iFLYTEK Spark plugin — genkit-ai/genkit1 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
- Aug 13, 2026ai 模块在 Go 1.26 下无法编译(bytedance/sonic v1.14.1 undefined: GoMapIterator) — apache/dubbo-admin1 reaction · 3 comments
- Jun 25, 2026feat(go/plugins/firebase/exp): add Firestore session store — genkit-ai/genkit1 reaction
- Jun 23, 2026Add quickstart samples for every framework guide — genkit-ai/samples1 reaction
- Jun 10, 2026AI observability: support Firebase Genkit (Vertex AI) — PostHog/posthog-js1 reaction · 6 comments
- Apr 27, 2026feat(go): add middleware reference to Genkit Go skill — genkit-ai/skills1 reaction
- Mar 26, 2026[cloud-genkit-go-nano-banana] — googlecodelabs/feedback1 reaction · 1 comment
- Mar 24, 2026chore(deps): update go samples — googleapis/mcp-toolbox1 reaction · 17 comments
- Mar 22, 2026Dependency Dashboard — agentydragon/ducktape1 reaction · 2 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
- Jan 19, 2026feat(js/plugins/anthropic): add input json delta support — genkit-ai/genkit1 reaction · 2 comments
- Jan 13, 2026[Go] InferJSONSchema produces invalid schema for repeated struct types — genkit-ai/genkit1 reaction
- Jan 10, 2026[Go] Prompt Execute Output() fails to parse JSON wrapped in markdown code blocks (regression in v1.3.0) — genkit-ai/genkit1 reaction · 4 comments
On Bluesky · 10
- Oct 11, 2025📦 firebase / genkit ⭐ 4,615 (+53) 🗒 TypeScript Open-source framework for building AI-powered apps in JavaScript, Go, and Python, built… — @github-trending-js.bsky.social3 likes and reposts
- Dec 12, 2024Here's the Genkit repo: github.com/firebase/gen... — @peterfriese.dev3 likes and reposts
- Sep 17, 2025🚀 Skyrocketing! 🚀 (200+ new stars) 📦 firebase / genkit ⭐ 3,590 (+203) 🗒 TypeScript Open-source framework for building AI-powered apps… — @github-trending-js.bsky.social2 likes and reposts
- Jun 19, 2025📦 firebase / genkit ⭐ 2,108 (+23) 🗒 TypeScript An open source framework for building AI-powered apps with familiar code-centric patterns.… — @github-trending.bsky.social2 likes and reposts
- May 22, 2024📦 firebase / genkit ⭐ 189 (+45) 🗒 TypeScript An open source framework for building AI-powered apps with familiar code-centric patterns.… — @github-trending-js.bsky.social2 likes and reposts
5 more on Bluesky
- Sep 15, 2025firebase/genkit Google's multi-model AI framework in Javascript, Go and Python Genkit is an open-source framework for building full-stack… — @functionalprogramming.activitypub.awakari.com.ap.brid.gy1 likes and repost
- Sep 13, 2025📦 firebase / genkit ⭐ 3,013 (+84) 🗒 TypeScript An open source framework for building AI-powered apps with familiar code-centric patterns.… — @github-trending.bsky.social1 likes and repost
- Jun 20, 2025📦 firebase / genkit ⭐ 2,210 (+47) 🗒 TypeScript An open source framework for building AI-powered apps with familiar code-centric patterns.… — @github-trending-js.bsky.social1 likes and repost
- May 12, 2025https://github.com/firebase/genkit — @tom-doerr.bsky.social1 likes and repost
- Apr 11, 2025📦 firebase / genkit ⭐ 1,463 (+54) 🗒 TypeScript An open source framework for building AI-powered apps with familiar code-centric patterns.… — @github-trending-js.bsky.social1 likes and repost
On Hacker News · 3
- Apr 4, 2025Show HN: Genkit, Open framework/tooling to build apps with almost any AI model1 point
- Aug 12, 2024Open source framework from Firebase for building AI-powered apps with Node.js1 point
- Jun 4, 2024Firebase Genkit (beta), an open source framework for adding AI features to apps1 point · 1 comment
On Stack Overflow · 2
- May 21, 2024How do I specify a date property using Zod in Firebase Genkit?1 vote
- May 16, 2024firebase init genkit unsupported1 vote · 2 answers
Other versions1 project uses a version of this.
Word for word · 1
- genkit-ai/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.

