dart-genkit
Skill30 starsChanged 9 months agoMITView on GitHub
Use when building AI workflows, tool calling agents, structured outputs, or LLM pipelines using the Genkit Dart SDK.
- Reads credentials
In this repository44 other files it gives its agents.
- AGENTS.mdAGENTS.md
- .github/copilot-instructions.mdCopilot instructions
- dart-add-unit-testSkill
- dart-build-cli-appSkill
- dart-collect-coverageSkill
- dart-fix-runtime-errorsSkill
- dart-generate-test-mocksSkill
- dart-logic-patternsSkill
- dart-memorySkill
- dart-migrate-to-checks-packageSkill
- dart-modern-syntaxSkill
- dart-optimizationSkill
- dart-run-static-analysisSkill
- dart-toolingSkill
- dart-use-pattern-matchingSkill
- flutter-add-integration-testSkill
- flutter-add-widget-previewSkill
- flutter-add-widget-testSkill
- flutter-apply-architecture-best-practicesSkill
- flutter-bloc-formsSkill
- flutter-blocSkill
- flutter-build-responsive-layoutSkill
- flutter-code-genSkill
- flutter-configSkill
- flutter-debuggingSkill
- flutter-devtoolsSkill
- flutter-dioSkill
- flutter-firebaseSkill
- flutter-fix-layout-issuesSkill
- flutter-implement-json-serializationSkill
- flutter-isarSkill
- flutter-nativeSkill
- flutter-securitySkill
- flutter-setup-declarative-routingSkill
- flutter-setup-localizationSkill
- flutter-spmSkill
- flutter-testingSkill
- flutter-uiSkill
- flutter-use-http-packageSkill
- flutter-wasm-webSkill
- changelog-writingSkill
- git-commitSkill
- github-actionsSkill
- github-prSkill
The file
We split this skill into the rules it gives an agent
3 rules. About 0 are common, 1 is distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 25
Add the Genkit package to your Dart project's pubspec.yaml:
- Very specific: line 138
Exhaustive Schema Definitions: Always define explicit inputSchema and outputSchema for tools and flows to ensure the LLM generates …
- Distinctive: line 139
Environment Isolation: Do not hardcode API keys. Use environment variables or secure credential storage.
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill 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
AI Engineering with Genkit Dart
Build structured, type-safe, and observable AI-powered workflows and agents using the Genkit Dart SDK.
Contents
- Project Setup
- Defining Prompts & Models
- Creating Custom Tools
- Orchestrating Flows
- Best Practices
Project Setup
- Add the Genkit package to your Dart project's
pubspec.yaml:dependencies: genkit: ^0.1.0-preview # Replace with the latest version google_generative_ai: ^0.4.0 - Set up your API credentials (e.g., Gemini API key) in your environment:
export GEMINI_API_KEY="your_api_key_here"
Defining Prompts & Models
Genkit separates model invocation and prompt structure from core application logic using structured prompts.
import 'package:genkit/genkit.dart';
import 'package:google_generative_ai/google_generative_ai.dart';
void main() async {
// Initialize Genkit
final ai = Genkit(
model: 'gemini-1.5-flash',
apiKey: String.fromEnvironment('GEMINI_API_KEY'),
);
// Invoke the model with a simple prompt
final response = await ai.generate(
prompt: 'Explain the concept of monads in Dart.',
);
print(response.text);
}Creating Custom Tools
Genkit agents utilize Tools to execute tasks (e.g., database queries, web scraping, mathematical calculations).
import 'package:genkit/genkit.dart';
// 1. Define schemas for input and output
final additionInputSchema = Schema.object({
'a': Schema.number(description: 'First number'),
'b': Schema.number(description: 'Second number'),
});
// 2. Define the tool
final addTool = ai.defineTool(
name: 'addNumbers',
description: 'Adds two numbers together.',
inputSchema: additionInputSchema,
action: (input) async {
final a = input['a'] as num;
final b = input['b'] as num;
return {'result': a + b};
},
);Orchestrating Flows
Flows are executable pipelines that support structured input and output schemas, built-in telemetry, and error handling.
import 'package:genkit/genkit.dart';
// Define the input and output schemas
final jokeRequestSchema = Schema.object({
'topic': Schema.string(description: 'The topic for the joke'),
});
final jokeResponseSchema = Schema.object({
'setup': Schema.string(),
'punchline': Schema.string(),
});
// Define the Flow
final jokeFlow = ai.defineFlow(
name: 'jokeFlow',
inputSchema: jokeRequestSchema,
outputSchema: jokeResponseSchema,
action: (input) async {
final topic = input['topic'] as String;
final response = await ai.generate(
prompt: 'Tell me a structured joke about $topic.',
responseSchema: jokeResponseSchema,
);
return response.structuredOutput!;
},
);
void main() async {
// Run the flow
final result = await jokeFlow.run({'topic': 'coding'});
print('Setup: ${result['setup']}');
print('Punchline: ${result['punchline']}');
}Best Practices
- Exhaustive Schema Definitions: Always define explicit
inputSchemaandoutputSchemafor tools and flows to ensure the LLM generates correctly structured arguments. - Environment Isolation: Do not hardcode API keys. Use environment variables or secure credential storage.
- Trace Observability: Enable Genkit's trace observability in development to inspect agent decision trees and tool invocations.
- Error Handling: Wrap tool execution in standard
try-catchblocks and return error details gracefully so the agent can self-correct.
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.

