Skip to content

Template Variables

Bonsai uses Go’s text/template engine to render .tmpl files at generation time. Every template has access to a TemplateContext that provides project and agent information.

VariableTypeDescription
{{ .ProjectName }}stringProject name from .bonsai.yaml
{{ .ProjectDescription }}stringProject description from .bonsai.yaml
{{ .AgentName }}stringAgent type identifier (e.g., tech-lead, backend)
{{ .AgentDisplayName }}stringHuman-readable agent name (e.g., Tech Lead Agent, Backend Agent)
{{ .AgentDescription }}stringAgent description from agent.yaml
{{ .OtherAgents }}[]OtherAgentList of sibling agents installed in the same project
{{ .Workspace }}stringAgent’s workspace directory path (e.g., station/, backend/)
{{ .DocsPath }}stringProject docs path from .bonsai.yaml (e.g., station/)
{{ .Protocols }}[]stringList of installed protocol names for this agent
{{ .Skills }}[]stringList of installed skill names for this agent
{{ .Workflows }}[]stringList of installed workflow names for this agent
{{ .Routines }}[]stringList of installed routine names for this agent

Each item in the {{ .OtherAgents }} list has:

FieldTypeDescription
{{ .AgentType }}stringAgent type identifier (e.g., backend)
{{ .Workspace }}stringAgent’s workspace directory path (e.g., backend/)
FunctionDescriptionExample
{{ title .AgentName }}Converts a kebab-case string to Title Case. Capitalizes the first letter of each word (split on hyphens and spaces).tech-lead becomes Tech-Lead

Template:

# {{ .ProjectName }} — {{ .AgentDisplayName }}

Rendered (for the Bonsai project, Tech Lead agent):

# Bonsai — Tech Lead Agent

Template:

{{ if .Routines }}
## Routines
This agent has {{ len .Routines }} routines installed.
{{ end }}

Rendered (for an agent with routines):

## Routines
This agent has 7 routines installed.

Template:

Installed protocols:
{{ range .Protocols }}- {{ . }}
{{ end }}

Rendered:

Installed protocols:
- memory
- scope-boundaries
- security
- session-start

Template:

{{ if .OtherAgents }}
## Sibling Agents
{{ range .OtherAgents }}- **{{ title .AgentType }}** at `{{ .Workspace }}`
{{ end }}{{ end }}

Rendered (for a project with backend and frontend agents):

## Sibling Agents
- **Backend** at `backend/`
- **Frontend** at `frontend/`

Template:

Your assigned plan lives at `{{ .DocsPath }}Playbook/Plans/Active/`.
Check `{{ .Workspace }}agent/Core/memory.md` for working memory.

Rendered:

Your assigned plan lives at `station/Playbook/Plans/Active/`.
Check `station/agent/Core/memory.md` for working memory.

Files ending in .tmpl are rendered through the template engine during generation. The .tmpl extension is stripped from the output filename.

File typeTemplate extensionExample
Agent identity.md.tmplidentity.md.tmpl renders to identity.md
Agent memory.md.tmplmemory.md.tmpl renders to memory.md
Sensor scripts.sh.tmplsession-context.sh.tmpl renders to session-context.sh
Routine procedures.md.tmplbacklog-hygiene.md.tmpl renders to backlog-hygiene.md
Scaffolding templates.md.tmplStatus.md.tmpl renders to Status.md

Files without .tmpl are copied as-is — no template rendering is applied.