What are Prompts?
A prompt in Genkit is a reusable template that encapsulates:- Prompt text with variable placeholders
- System instructions
- Model selection and configuration
- Input and output schemas
- Tools and tool choice settings
- Few-shot examples
.prompt files (dotprompt format).
Defining Prompts Programmatically
Dotprompt Files
For better organization, store prompts in.prompt files using the dotprompt format:
Basic Dotprompt File
prompts/recipe.prompt.
Loading Dotprompt Files
Handlebars Syntax
Dotprompt uses Handlebars templating:Variables
Conditionals
Loops
Built-in Helpers
Prompt Variants
Create multiple variants of a prompt for A/B testing:System Instructions
Define system-level instructions separately from the user prompt:Multi-turn Conversations
Prompts can include conversation history:Schema References
Reference shared schemas across prompts:Tools in Prompts
Prompts can specify which tools to use:Overriding at Runtime
Override prompt configuration when calling:Streaming Prompt Responses
Prompts support streaming:Rendering Without Execution
Render a prompt to see the final message without calling the model:- Testing prompt templates
- Debugging variable substitution
- Inspecting the exact request sent to models
Prompts as Tools
Convert a prompt into a tool that models can call:Prompt File Organization
Organize prompts in directories:Partials (Shared Snippets)
Reuse common prompt sections:_ and are imported with {{> _partialName}}.
Best Practices
1. Use .prompt Files for Production
Store prompts as files for:- Version control
- Team collaboration
- Easy testing in Dev UI
- Non-engineer editing
2. Define Clear Schemas
Always specify input and output schemas:3. Use Variants for Testing
Test different approaches:prompt.prompt- default versionprompt.concise.prompt- shorter responsesprompt.detailed.prompt- longer responses