This guide explains how to create, test, and publish templates for AgenticGoKit (AGK). Templates allow developers to scaffold new projects with pre-configured agents, workflows, and tools.
An AGK template is simply a directory containing:
- Code: Source files (Go, Markdown, Configs) that structure the project.
agk-template.toml: A manifest file defining metadata, variables, and behavior.
Templates are processed using Go's text/template engine with Sprig functions enabled, allowing for dynamic content generation based on user input.
A typical template structure looks like this:
my-template/
├── agk-template.toml # Manifest (REQUIRED)
├── go.mod.tmpl # Go module file template
├── main.go.tmpl # Main application code template
├── README.md # Template documentation
├── .gitignore # Standard gitignore
└── pkg/ # Subfolders are fully supported
└── helper.go.tmpl # Will be rendered to <project>/pkg/helper.go
- Files ending in
.tmplwill be processed as templates. The.tmplextension is removed in the generated project (e.g.,main.go.tmplbecomesmain.go). - Files without
.tmplare copied as-is, unless they are binary files or excluded by the manifest. - You can use template variables in filenames (feature coming soon).
The agk-template.toml file is the heart of your template. It defines how agk init interacts with your template.
[template]
name = "my-custom-agent"
version = "1.0.0"
description = "A specialized agent for data analysis"
author = "Jane Doe"
license = "MIT"
min_agk_version = "0.1.0"
# Define variables to ask the user during initialization
[template.variables]
[template.variables.agent_name]
type = "string"
description = "Name of your agent"
required = true
default = "MyAgent"
[template.variables.include_memory]
type = "bool"
description = "Enable vector memory?"
default = true
[template.variables.model_type]
type = "choice"
description = "Primary model to use"
options = ["gpt-4o", "claude-3-5-sonnet"]
default = "gpt-4o"
# Control which files are copied
[template.files]
include = ["**/*"]
exclude = [".git", "agk-template.toml", "test-data/**"]
# Commands to run after generation
[template.hooks]
post_create = ["go mod tidy", "go fmt ./..."]string: simple text input.bool: Yes/No prompt.choice: Selection from a list ofoptions.
Use standard Go templating syntax ({{ }}) in your files.
The following data is available to your templates:
| Variable | Description |
|---|---|
.ProjectName |
The name of the project folder (e.g., "my-bot") |
.Description |
Project description provided by CLI flag |
.LLMProvider |
Selected provider (openai, anthropic, ollama) |
.LLMModel |
Default model for the provider |
.WorkflowName |
Name of the workflow (for workflow templates) |
.APIKeyEnv |
Env var name for the key (e.g., OPENAI_API_KEY) |
.AgentType |
Agent type string |
.Variables |
(Planning) Access custom variables defined in TOML |
package main
import (
"log"
"os"
"github.com/agenticgokit/agenticgokit"
)
func main() {
// Project: {{ .ProjectName }}
// Generated by AGK
config := agenticgokit.Config{
Provider: "{{ .LLMProvider }}", // e.g. openai
Model: "{{ .LLMModel }}", // e.g. gpt-4o
}
// ...
}You can use Sprig functions for complex logic:
{{ if eq .LLMProvider "ollama" }}
// Ollama specific setup
{{ end }}
// Helper: {{ .ProjectName | title }}You can test your template locally without publishing it.
mkdir my-template
cd my-template
# ... create files and agk-template.toml ...Use agk template add to point AGK to your local folder.
# Add current directory as a template
agk template add .
# Or specify full path
agk template add /absolute/path/to/my-templateTry to initialize a project using your template.
cd /tmp
agk init test-project --template my-custom-agentNote: The --template name must match the name field in your agk-template.toml.
Make changes to your template files. You typically don't need to re-add the template if you pointed to a local path, but if you cached it, you might need to run add again to update the cache.
To share your template with the community:
- Host on GitHub: Push your template to a public GitHub repository.
- Verify Fetch: Test that AGK can fetch it directly from the URL.
agk template add github.com/username/my-template
- Submit to Registry:
- Fork the agk-templates/registry repository.
- Add your template metadata to
index.json. - Submit a Pull Request.
Once accepted, users will be able to see your template in agk init --list or use it by name!