Your First Topology
A step-by-step tutorial for building a content pipeline topology from scratch
Your First Topology
This tutorial walks you through building a complete content pipeline topology, one block at a time. By the end you'll have a working .at file with agents, conditional flow routing, and a trigger.
Start with the topology declaration
Every .at file begins with a topology declaration. This names your topology and declares which patterns it uses:
topology content-pipeline : [pipeline, human-gate] {
}content-pipelineis the name. Use kebab-case.: [pipeline, human-gate]declares the patterns this topology implements. Patterns give the validator rules to check against.
Add the meta block
The meta block holds version and description metadata:
topology content-pipeline : [pipeline, human-gate] {
meta {
version: "1.0.0"
description: "Research, write, and review — a minimal content pipeline"
}
}The version field follows semver. The description is used in generated documentation and the visualizer.
Add an orchestrator
The orchestrator coordinates the overall flow. It handles entry and exit points:
orchestrator {
model: sonnet
generates: "commands/create.md"
handles: [intake, done]
}modelsets which LLM the orchestrator uses.generatesis the file the orchestrator produces for bootstrapping.handleslists the named flow endpoints this orchestrator manages.
Add agents
Now define the agents that do the actual work. Each agent has a role, a model, a phase number, and the tools it can use.
The researcher
agent researcher {
role: researcher
model: sonnet
phase: 1
tools: [Read, Grep, Glob, WebSearch]
writes: ["workspace/research.md"]
}phase: 1means this agent runs first in the pipeline.toolslists the MCP tools the agent is allowed to call.writesdeclares which files this agent produces.
The writer
agent writer {
role: writer
model: sonnet
phase: 2
tools: [Read, Write, Glob]
reads: ["workspace/research.md"]
writes: ["workspace/draft.md"]
outputs: { confidence: high | medium | low }
}readsdeclares file dependencies. The writer needs the researcher's output.outputsdefines structured output fields. Other agents and flow conditions can reference these.
The reviewer
agent reviewer {
role: reviewer
model: opus
phase: 3
tools: [Read, Grep, Glob]
reads: ["workspace/draft.md", "workspace/research.md"]
outputs: { verdict: approve | revise | reject }
}The reviewer reads both the draft and the original research, then produces a verdict. This verdict drives the conditional routing in the flow.
Define the flow
The flow block describes how agents connect and under what conditions:
flow {
intake -> researcher
researcher -> writer
writer -> reviewer
reviewer -> writer [when reviewer.verdict == revise, max 2]
reviewer -> researcher [when reviewer.verdict == reject, max 1]
reviewer -> done [when reviewer.verdict == approve]
}Reading flow edges
Each line is an edge: source -> target. Optional conditions go in brackets:
when reviewer.verdict == revise-- this edge only fires when the reviewer's verdict output equalsrevise.max 2-- this edge can fire at most 2 times, preventing infinite loops.
The flow above creates a feedback loop: the reviewer can send work back to the writer (up to twice) or all the way back to the researcher (once). When the verdict is approve, the flow ends at the done endpoint.
Add triggers
Triggers define how users invoke the topology:
triggers {
command create {
pattern: "/create <TOPIC>"
argument: TOPIC
}
}This registers a /create command. When a user types /create AI safety, the TOPIC argument is set to "AI safety" and passed into the flow.
The complete file
Here is the full topology:
topology content-pipeline : [pipeline, human-gate] {
meta {
version: "1.0.0"
description: "Research, write, and review — a minimal content pipeline"
}
orchestrator {
model: sonnet
generates: "commands/create.md"
handles: [intake, done]
}
agent researcher {
role: researcher
model: sonnet
phase: 1
tools: [Read, Grep, Glob, WebSearch]
writes: ["workspace/research.md"]
}
agent writer {
role: writer
model: sonnet
phase: 2
tools: [Read, Write, Glob]
reads: ["workspace/research.md"]
writes: ["workspace/draft.md"]
outputs: { confidence: high | medium | low }
}
agent reviewer {
role: reviewer
model: opus
phase: 3
tools: [Read, Grep, Glob]
reads: ["workspace/draft.md", "workspace/research.md"]
outputs: { verdict: approve | revise | reject }
}
flow {
intake -> researcher
researcher -> writer
writer -> reviewer
reviewer -> writer [when reviewer.verdict == revise, max 2]
reviewer -> researcher [when reviewer.verdict == reject, max 1]
reviewer -> done [when reviewer.verdict == approve]
}
triggers {
command create {
pattern: "/create <TOPIC>"
argument: TOPIC
}
}
}Validate and scaffold
Run validation to check for errors:
agentopology validate content-pipeline.atThen scaffold to your target platform:
agentopology scaffold content-pipeline.at --target claude-codeInspect the generated files. You'll find agent-specific CLAUDE.md files with role prompts, tool restrictions, and file access rules -- all derived from your single .at file.
What's next
- Explore the Language Reference to learn every block and field available
- Browse Patterns to see what pipeline, supervisor, fan-out, and other patterns offer
- Check out more Examples for real-world topologies