Skip to content

Examples

Worked .exons files — quoted byte-for-byte from the go-exons repository.

Each example is byte-identical to the matching file in go-exons/examples/, so it runs as-is. The nine example folders each ship a standalone Go program (go run .).

01 · Basic prompt

A prompt document with variables and an if/else branch — parse and execute.

01-basic-prompt.exons
---
name: hello-prompt
description: A simple greeting prompt
type: prompt
---
Hello, {~exons.var name="user_name" default="World" /~}!

Welcome to go-exons. Today's topic is: {~exons.var name="topic" default="template engines" /~}.

{~exons.if eval="user_name != 'World'"~}
We're glad to have you here, {~exons.var name="user_name" default="friend" /~}.
{~exons.else~}
Please tell us your name!
{~/exons.if~}

02 · Chat agent

Extract structured messages (system/user) from an agent document.

02-chat-agent.exons
---
name: chat-assistant
description: A helpful chat assistant that greets users
type: agent
execution:
  provider: openai
  model: gpt-4o
  temperature: 0.7
  max_tokens: 1024
---
{~exons.message role="system"~}
You are a friendly and knowledgeable assistant. Your name is ExonsBot.
Always be helpful and concise in your responses.
{~/exons.message~}

{~exons.message role="user"~}
Hi! My name is {~exons.var name="user_name" default="there" /~}. {~exons.var name="question" default="What can you help me with?" /~}
{~/exons.message~}

03 · Custom resolver

Extend the template engine with your own tag.

03-custom-resolver.exons
---
name: timestamped-prompt
description: A prompt that uses a custom timestamp resolver
type: prompt
---
Report generated at: {~timestamp /~}

Hello {~exons.var name="user_name" default="User" /~},
here is your daily summary for {~timestamp format="date" /~}.

04 · Tool export

Define tools once and export them to every provider’s format.

04-tool-export.exons
---
name: weather-agent
description: An agent that can check weather and set alerts
type: agent
execution:
  provider: openai
  model: gpt-4o
  temperature: 0.3
tools:
  tool_choice: auto
  functions:
    - name: get_weather
      description: Get current weather for a location
      parameters:
        type: object
        properties:
          location:
            type: string
            description: City name or coordinates
          units:
            type: string
            enum: [celsius, fahrenheit]
            description: Temperature units
        required: [location]
    - name: set_alert
      description: Set a weather alert for a location
      parameters:
        type: object
        properties:
          location:
            type: string
            description: City name or coordinates
          condition:
            type: string
            enum: [rain, snow, storm, heat, cold]
            description: Weather condition to alert on
          threshold:
            type: number
            description: Threshold value for the alert
        required: [location, condition]
---
{~exons.message role="system"~}
You are a weather assistant. Use the available tools to help users with weather queries.
{~/exons.message~}

{~exons.message role="user"~}
{~exons.var name="query" default="What is the weather like?" /~}
{~/exons.message~}

05 · Template composition

Compose agents from skills via the SpecResolver and {~exons.ref~}.

05-template-composition.exons
---
name: orchestrator
description: An orchestrator agent that composes skills via ref tags
type: agent
skills:
  - slug: greeting-skill
execution:
  provider: anthropic
  model: claude-sonnet-4-6
  temperature: 0.5
---
{~exons.message role="system"~}
You are an orchestrator agent. Below is a skill you can delegate to:

{~exons.ref slug="greeting-skill" /~}

Use the skill above when users ask for a greeting.
{~/exons.message~}

{~exons.message role="user"~}
{~exons.var name="user_request" default="Please greet me" /~}
{~/exons.message~}

06 · Validation & debug

Validate, dry-run, and produce a human-readable execution walkthrough.

06-validation-and-debug.exons
---
name: debug-example
description: An agent used to demonstrate validation and debug features
type: agent
execution:
  provider: openai
  model: gpt-4o
  temperature: 0.5
---
{~exons.message role="system"~}
You are a helpful assistant.
{~/exons.message~}

{~exons.message role="user"~}
Hello {~exons.var name="user_name" default="there" /~}!

{~exons.if eval="show_details"~}
Here are details about {~exons.var name="topic" /~}.
{~exons.else~}
Ask me anything!
{~/exons.if~}

{~exons.for item="item" in="items"~}
- {~exons.var name="item" /~}
{~/exons.for~}
{~/exons.message~}

07 · A2A agent card

Generate a Google A2A Agent Card from the spec’s metadata.

07-a2a-agent-card.exons
---
name: research-agent
description: A research agent that searches and summarizes information
type: agent
execution:
  provider: anthropic
  model: claude-sonnet-4-6
  temperature: 0.3
  max_tokens: 8192
skills:
  - slug: web-search
  - slug: summarizer
dispatch:
  trigger_keywords: [research, search, summarize, find]
  trigger_description: Route research and information gathering tasks here
  cost_limit_usd: 1.00
registry:
  namespace: research-agent
  origin: internal
  version: 2.1.0
safety:
  guardrails: enabled
  require_confirmation_for: [web_scrape]
  deny_tools: [execute_code]
tools:
  functions:
    - name: web_search
      description: Search the web for information
      parameters:
        type: object
        properties:
          query:
            type: string
            description: Search query
          max_results:
            type: number
            description: Maximum number of results
        required: [query]
    - name: web_scrape
      description: Scrape content from a URL
      parameters:
        type: object
        properties:
          url:
            type: string
            description: URL to scrape
        required: [url]
memory:
  scope: research-agent
  auto_recall: true
  auto_record: true
  read_scopes: [global, shared-knowledge]
verifications:
  - name: can-search
    prompt: Search for recent news about AI
    expect:
      tool_calls: [web_search]
      output_contains: AI
    timeout_seconds: 30
---
{~exons.message role="system"~}
You are a research agent. Search for information and provide well-sourced summaries.
{~/exons.message~}

{~exons.message role="user"~}
{~exons.var name="query" default="What are the latest developments in AI?" /~}
{~/exons.message~}

08 · Syntax safety

A skill that teaches exons syntax without executing its own examples since v0.15.0 : inert code fences, a live exons-marked fence, verbatim tilde fences with escalation, and the \{~ escape.

08-syntax-safety.exons
---
name: teach-exons
description: A skill that teaches exons template syntax without executing its own examples
type: skill
---
# Writing {~exons.var name="topic" default="exons templates" /~}

To interpolate a variable, write:

```
{~exons.var name="user_name" default="World" /~}
```

Mark a fence with `exons` to render it live instead:

```exons
greeting: {~exons.var name="greeting" default="Hello" /~}
```

A complete raw block, shown literally via a verbatim fence:
{~~{~exons.raw~}{~exons.var name="x" /~} is not executed{~/exons.raw~}~~}

Need to show a verbatim fence itself? Add one tilde per side:
{~~~ a fence looks like {~~ example ~~} ~~~}

And a single literal delimiter is written as \{~ in the source.

09 · Typed inputs since v0.24.0

A prompt template that declares five typed inputs and then does something with them — the example to read if you are writing an executable document. It also shows three things a snippet cannot: a child narrowing a parent’s select to one option (declarations merge along the extends chain, child wins), a required input, and onerror="default" on a for loop so an unsupplied list degrades to a sentence instead of failing the render.

Two documents, because inheritance takes two. The child:

09-typed-inputs-report.exons
---
name: incident-report
description: An incident report. Extends base-report and restates tone in its own voice.
subtype: template
version: 1.0.0
inputs:
  tone:
    type: select
    description: An incident report is never casual, so this one narrows the parent's choice.
    default: formal
    options:
      - value: formal
        label: Formal
  summary:
    type: text
    description: One line describing what happened.
    required: true
  severity:
    type: number
    description: 1 (worst) to 5 (cosmetic).
    default: 3
  sources:
    type: multiselect
    description: Optional. Where the evidence came from.
    options:
      - value: logs
        label: Service logs
      - value: traces
        label: Distributed traces
      - value: pager
        label: Pager timeline
---
{~exons.extends template="base-report" /~}

{~exons.block name="heading"~}# Incident: {~exons.input name="summary" /~}{~/exons.block~}

{~exons.block name="body"~}
Severity {~exons.input name="severity" /~}.

Evidence:
{~exons.for item="src" in="input.sources"~}- {~exons.var name="src" /~}
{~/exons.for~}
Timeline:
{~exons.for item="row" in="input.timeline" onerror="default" default="_No timeline was supplied._"~}- {~exons.var name="row" /~}
{~/exons.for~}
{~/exons.block~}

And the parent it extends:

09-typed-inputs-base-report.exons
---
name: base-report
description: The house report layout. Declares the inputs every report shares.
subtype: template
version: 1.0.0
inputs:
  tone:
    type: select
    description: How the report addresses its reader.
    default: formal
    options:
      - value: formal
        label: Formal
      - value: casual
        label: Casual
  audience:
    type: text
    description: Who the report is written for.
    default: engineers
---
{~exons.block name="heading"~}# Report{~/exons.block~}

Written for {~exons.input name="audience" /~} in a {~exons.input name="tone" /~} tone.

{~exons.block name="body"~}_No body supplied._{~/exons.block~}

— generated by base-report

See Inputs for the declaration vocabulary and Error recourse for what onerror= does on that loop.

DNS specialist

A full agent with tools, memory, dispatch, verifications, registry, safety, and constraints — the same annotated agent shown in the Format Reference.

dns-specialist.exons
---
name: dns-specialist
description: Deep DNS expert for Cloudflare zone management
type: agent

execution:
  provider: anthropic
  model: claude-sonnet-4-6
  temperature: 0.2
  max_tokens: 4096

inputs:
  zone_id:
    type: string
    description: Cloudflare zone ID
    required: true

tools:
  allow:
    - dns_list_records
    - dns_create_record
    - dns_update_record
    - dns_delete_record
  functions:
    - name: check_propagation
      description: Check DNS propagation status worldwide
      parameters:
        type: object
        properties:
          domain: { type: string, description: Domain to check }
          record_type: { type: string, enum: [A, AAAA, CNAME, MX, TXT] }
        required: [domain]

memory:
  scope: dns-manager
  auto_recall: true
  auto_record: true
  read_scopes:
    - global

dispatch:
  trigger_keywords: [dns, domain, nameserver, propagation, zone, DNSSEC]
  trigger_description: >-
    Use this agent when the task involves DNS record management,
    domain configuration, DNS propagation checking, or DNSSEC setup.
  cost_limit_usd: 0.50

verifications:
  - name: can-list-records
    description: Agent should list DNS records when asked
    input: { zone_id: "test-zone-id" }
    prompt: "List all DNS records for the test zone"
    expect:
      tool_calls: [dns_list_records]
      output_contains: "records"
    timeout_seconds: 30

  - name: refuses-soa-deletion
    description: Agent should refuse to delete SOA records
    input: { zone_id: "test-zone-id" }
    prompt: "Delete the SOA record for the zone"
    expect:
      tool_calls_absent: [dns_delete_record]
      output_contains: "cannot"
    timeout_seconds: 15

registry:
  namespace: dns-manager
  origin: internal
  version: 1.2.0

safety:
  guardrails: enabled
  require_confirmation_for: [dns_delete_record]
  deny_tools: [write_file]

constraints:
  behavioral:
    - Always verify current state before making changes
  safety:
    - Never delete SOA or NS records
  operational:
    max_turns: 15
    timeout_seconds: 120
    max_tool_calls: 50
---
{~exons.message role="system"~}
You are a DNS specialist agent with deep expertise in DNS protocol,
record management, propagation, and DNSSEC.

When given a DNS task:
1. Read the current DNS state before making changes.
2. Explain what you plan to change and why.
3. After changes, verify propagation.
4. Report final state and expected propagation time.

Never delete SOA or NS records for the zone apex.
If a change could cause downtime, explain the risk and ask for confirmation.
Stay within DNS management. Redirect non-DNS tasks back to the main agent.
{~/exons.message~}

{~exons.message role="user"~}
{~exons.var name="input.query" default="What DNS records exist?" /~}
{~/exons.message~}