agentopology
v0.12.6
Published
The declarative language for multi-agent systems. Write once, scaffold for any platform.
Maintainers
Readme
The Problem
Building one AI agent is easy. Building a team of agents that actually works together is brutal.
You want a marketing team? A dev pipeline? A support squad? You spend hours wiring up AGENT.md files, soul.md configs, MCP servers, hooks, and scripts. You get it working in Claude Code. Then you need the same team in OpenClaw — and you start from scratch. Different config format. Different directory structure. Different conventions. Same agents, same logic, zero portability.
OpenClaw alone needs soul.md, skill files, channel configs, gateway setup, and workspace definitions — for each agent. Multiply that by 5 agents and you're maintaining 20+ files that you can't visualize, validate, or hand off to anyone.
And that's just the platform problem. The architecture problem is worse:
- How do you see the big picture? Your topology is scattered across 15 files in nested directories. No diagram. No single source of truth.
- How do agents talk to each other? You hack together file-based protocols or copy-paste context between prompts. There's no standard.
- How do you enforce quality? You want a gate between stages but there's no standard way to define one.
- How do you move fast? Every new agent means touching 5-12 files across multiple tools.
AgenTopology fixes all of this.
Write your agent team in one .at file. Marketing, development, support, copywriting — any team, any structure. Visualize it. Validate it. Scaffold it to any platform in one command.
topology code-review : [pipeline] {
agent researcher { model: sonnet tools: [Read, Grep, WebSearch] }
agent writer { model: sonnet tools: [Read, Write] }
agent reviewer { model: opus tools: [Read, Grep] }
flow {
researcher -> writer -> reviewer
reviewer -> writer [when reviewer.verdict == revise, max 2]
}
}agentopology scaffold my-team.at --target claude-code # → .claude/agents/
agentopology scaffold my-team.at --target claude-workflow # → my-team.workflow.js (+ SEAM/README/LOSSY-REPORT)
agentopology scaffold my-team.at --target codex # → .codex/
agentopology scaffold my-team.at --target cursor # → .cursor/rules/One file. Every platform. The topology IS the documentation.
Hybrid: host + embedded workflow
One .at topology can compile to two coupled targets at once. claude-code is the host — the event-driven layer that owns agents, hooks, the Blackboard, concurrent observability, and the human/gate/branching nodes. claude-workflow is the embedded deterministic rung — the parallel fan-out phases, compiled into a Claude Workflow tool script. The host launches the rung and observes its Blackboard writes live (via a PostToolUse hook), so you get concurrent observability the Workflow runtime can't do on its own.
Mark a phase for the rung with extensions { claude-workflow { execution: workflow } }, then scaffold both:
agentopology scaffold my-team.at --target claude-code # the host
agentopology scaffold my-team.at --target claude-workflow # the embedded rungThe hybrid is opt-in — a topology with no execution: workflow marker compiles to pure claude-code, unchanged. See docs/AT_VS_WORKFLOW_STRATEGY.md for why.
What It Does
AgenTopology is a declarative language (.at files) for describing a team of agents —
who works, when they work, and what they know when they work. One file, two ways to use it.
┌────────────┐
┌──────────────┐ │ Parser & │ scaffold ──▶ Platform configs
│ .at file │─▶│ Validator │──┤ ├── .claude/agents/
│ (you write) │ │ 136 rules │ │ ├── <topology>.workflow.js
└──────────────┘ └────────────┘ │ ├── .codex/ .cursor/rules/
│ └── …
│
└── plan ──────▶ Execution brief
│
▼
your coding agent runs it
with its own sub-agents
— nothing written to diskscaffold generates platform-native config. You stop hand-maintaining files, and the
topology becomes the single source of truth.
plan skips generation entirely. The coding agent already in your session is the
runtime — it plans, spawns sub-agents, runs them in parallel and re-plans. It does not need
generated files to do that; it needs to know the shape of the work. plan validates the
topology, resolves the execution order, and hands it a brief.
Same declaration. A lifetime choice, not a strategy one.
Quick Start
npm install -g agentopologyValidate — catch errors before you scaffold:
agentopology validate my-team.atRun it — enact the topology now, with nothing written to disk:
agentopology plan my-team.at --task "Add rate limiting to the API"Prints the flow, then a brief your coding agent follows to run the team with its own subagents. Nothing is scaffolded. See below.
Scaffold — generate platform configs, when the team should outlive the session:
agentopology scaffold my-team.at --target claude-codeVisualize — see your topology as an interactive graph:
agentopology visualize my-team.atThe page is one offline HTML file (light and dark themes, no network). Six lenses switch from the lens bar: Flow (gates and their grades as chips on the edges they guard, human steps in a seat lane, stores on a rail, phase stages collapsed until you open them), Sessions (places, who may message whom with the message kind, the hub, who decides what, and which sessions have no talk guard on disk), Guards (a grade for every gate, approval step, permission rule and session guard: refuse, hope, none, unverified, from guard --check), Seats (one row per human step and declared decision, with its timeout and grade), Coverage (what the project holds against what the .at accounts for, by kind, from validate --inventory) and Index (every item with its line, and the .at text with a jump to each line). Run visualize with --dir in the project to fill in the grades and coverage; without it they read "not checked". Link straight to a view with #lens=sessions, #node=<id> or #lens=index&line=<n>.
List targets — see all supported platforms:
agentopology targetsTwo Lifecycles: Compile It, or Just Run It
A .at file has always compiled to a persisted harness. It can also be enacted
directly by the coding agent already in your session.
| | scaffold | plan |
|---|---|---|
| Who executes | the platform, later | this session's agent, now |
| On disk | .claude/, .codex/, … | nothing |
| Lifetime | outlives the session | dies with it |
| Portable | 8 targets | wherever the host agent runs |
| Gates | real hooks, mechanically enforced | evidence contract |
| Cost to change | regenerate and reconcile | free |
Not a strategy choice — a lifetime choice. A team that should exist next week scaffolds. A delegation plan for the task in front of you runs.
Why this works: the host coding agent is already the runtime. It plans, spawns subagents, runs them in parallel and re-plans. It does not need generated agent files to do any of that — it needs to know who works, when they work, and what they know when they work. That is what a topology says.
plan cannot spawn agents itself, so it does not pretend to. It validates
(the agent that wrote the file can write an illegal one), applies the spec's
defaults, resolves execution order, and emits a brief that resolves what the host
would otherwise guess: what crosses each handoff, what each reader must not
read, which roles are mutually blind, and every declaration that cannot be
enforced at runtime.
Five features are platform registrations rather than steps — triggers,
schedules, mcp-servers, hooks, and per-agent tools/permissions. They
cannot work fileless on any vendor, and plan names them instead of silently
skipping them.
agentopology docs interpreted-modeClaude Code Skill — The Fastest Way to Start
You don't need to learn .at syntax. AgenTopology ships with an interactive skill that turns Claude Code into a topology designer. Describe the team you want in plain English — the skill generates everything.
Setup (one time)
# Install globally
npm install -g agentopology
# Link the skill into your project
ln -s $(npm root -g)/agentopology/skill .claude/skills/agentopologyUsage
In Claude Code, type /agentopology — or just ask naturally:
> /agentopology
┌─────────────────────────────────────┐
│ AgenTopology │
│ Build agent teams in minutes. │
├─────────────────────────────────────┤
│ │
│ build Design a new topology │
│ templates Pick a proven team │
│ validate Check an .at file │
│ scaffold Generate platform files│
│ visualize Open graph viewer │
│ │
└─────────────────────────────────────┘Say "I want a code review team with an analyzer, security scanner, and reviewer" — the skill:
- Generates the
.atfile with the right syntax - Validates it against 136 rules
- Scaffolds it to Claude Code (or an experimental target: Codex, Cursor)
Full agent team in under 2 minutes. No docs to read. No syntax to memorize. You describe what you want, the skill handles the rest.
Evolving Your Topology
You have a working .at file and want to make it better? Just tell the skill what you need:
- "Add a security scanner agent before the reviewer" — the skill adds the agent, wires it into the flow, and re-validates
- "Add a hook that formats code after every write" — generates the hook block with the right lifecycle event
- "Add an MCP server for GitHub" — adds the server config with environment variables
- "Add a quality gate between the builder and reviewer" — inserts a gate with halt-on-fail
- "Switch the target to Codex" — re-scaffolds the entire topology for an experimental target
The workflow is always the same: describe the change → the skill updates the .at file → validates → re-scaffolds. You never touch config files manually.
After any change, agentopology visualize updates the interactive graph so you can see exactly what changed — every agent, connection, tool, hook, and gate in one view.
Full language reference and guides at agentopology.com/docs.
The Language
.at files are human-readable and version-controllable. Here's a real topology:
topology content-pipeline : [pipeline, human-gate] {
meta {
version: "1.0.0"
description: "Research, write, review — with quality gate"
}
agent researcher {
model: sonnet
description: "Gathers information and sources"
tools: [Read, Grep, WebSearch]
writes: ["workspace/research.md"]
prompt {
Search broadly for relevant sources.
Compile findings into structured research notes.
Include citations and source URLs.
}
}
agent writer {
model: sonnet
description: "Drafts content from research"
tools: [Read, Write]
reads: ["workspace/research.md"]
writes: ["workspace/draft.md"]
}
agent reviewer {
model: opus
description: "Reviews drafts for quality"
tools: [Read, Grep]
reads: ["workspace/draft.md"]
outputs: { verdict: approve | revise | reject }
}
gates {
gate quality-check {
after: reviewer
run: "scripts/check-quality.sh"
on-fail: halt
}
}
flow {
researcher -> writer -> reviewer
reviewer -> writer [when reviewer.verdict == revise, max 2]
}
}This defines three agents, their tools and memory, a quality gate, and a flow with a conditional retry loop — all in 40 lines.
Supported Platforms
| Target | Command | What It Generates |
|--------|---------|-------------------|
| Claude Code | --target claude-code | .claude/agents/, .claude/skills/, .mcp.json, .claude/settings.json (the event-driven host) |
| Claude Workflow (experimental) | --target claude-workflow | <topology>.workflow.js (deterministic fan-out rung) + -SEAM.md, -README.md, -LOSSY-REPORT.md |
| Codex (experimental) | --target codex | .codex/config.toml, AGENTS.md |
| Cursor (experimental) | --target cursor | .cursor/rules/*.mdc, .cursor/mcp.json, .cursor/hooks.json |
Claude Code is the supported target. The experimental ones are kept, not verified the way claude-code is. gemini-cli, copilot-cli, openclaw and kiro were removed in 0.10.0 (use 0.9.x for them).
Language Features
Agents & Models
agent planner {
model: opus
tools: [Read, Write, Bash]
permissions: plan
thinking: high
thinking-budget: 4000
max-turns: 20
}Flow Graphs
flow {
intake -> researcher
researcher -> writer
writer -> reviewer
reviewer -> writer [when verdict == revise, max 3]
reviewer -> done [when verdict == approve]
}Group Chats
group debate-arena {
members: [pro, con]
speaker-selection: "round-robin"
max-rounds: 5
termination: "judge declares winner"
}Quality Gates
gates {
gate security-scan {
after: builder
run: "scripts/security.sh"
checks: [vulnerabilities, secrets]
on-fail: halt
}
}Hooks & Events
hooks {
hook format-on-save {
on: PostToolUse
matcher: "Write"
run: "scripts/format.sh"
}
}MCP Servers
mcp-servers {
github {
command: "npx"
args: ["-y", "@mcp/server-github"]
env { TOKEN: "${GITHUB_TOKEN}" }
}
}Company Brain — agent-maintained, Obsidian-portable
store brain {
type: brain # markdown, no DB
path: "brain/"
format: obsidian # ports both ways
}
agent librarian {
custodian-of: [brain] # owns its upkeep
}Provenance styling — color the graph by source
store brain {
sources {
gmail { color: "#EA4335" icon: "./gmail.svg" }
slack { color: "#4A154B" }
}
}Plus: memory stores (semantic, graph, episodic — 11 backends), retrieval strategies (scoring weights, cache-hit routing), schemas, artifacts, metering, circuit breakers, scale configs, depth levels, environment overrides, prompt variants, composition via imports, and more.
Interpreted Execution — Run It Without Building It
agentopology plan review.at --task "Review PR 412" --mode plan review v1.0.0 · pipeline, fan-out
1 ▪ intake action
│
2 ▸ analyzer ∥ security-scanner agent ×2, parallel · sonnet
│
3 ▸ reviewer agent · opus
│
4 ◆ human-approval gate · blocking · on-fail: halt
│
5 ▸ reporter agent · haiku
⚠ 4 role(s) declare tool restrictions that cannot be set inline — running unrestricted
⛔ 2 triggers, 1 hook declared — these need `agentopology scaffold`Then a brief your coding agent follows. It resolves what the agent would otherwise have to guess:
| The brief answers | Because |
|---|---|
| What crosses each handoff | computed as writes ∩ reads, not left to interpretation |
| What each reader must not read | a validator that reads the builder's self-review is not independent |
| Which same-step roles are mutually blind | two researchers who see each other's work are one opinion, paid for twice |
| Which declarations can't be enforced at runtime | a sub-agent's tool grant cannot be set inline on any platform — so it says so |
Three autonomy notches — plan shows it and waits, execute runs and announces
material changes, auto runs and reports at the end.
Every guess the agent has to make is logged with a concrete .at edit that would
remove it. The log is a patch queue for your topology, not a diary.
Group Chats — Agents That Talk to Each Other
Groups aren't fan-out. They're real conversations. Each agent reads what others wrote and responds:
group design-review {
members: [architect, security-lead, tech-lead]
speaker-selection: "round-robin"
max-rounds: 3
termination: "consensus reached"
}In Claude Code, this compiles to a file-based protocol — a shared transcript file that agents read and append to sequentially. No HTTP, no message bus. Just the filesystem as shared state.
Company Brain — Knowledge That Builds Itself
A brain is a folder of linked markdown that agents maintain, not you. It's the Obsidian graph model — notes connected by [[wikilinks]] and #tags — but agent-maintained instead of hand-curated.
store brain {
type: brain # file-native: markdown, no database, no embeddings
path: "brain/"
format: obsidian # ports both ways — open it in Obsidian, the graph just works
}
agent librarian {
custodian-of: [brain] { # OWNS the brain's upkeep, not just read access
does: [link, tag, index, dedupe]
}
}- Custodian agents own a memory layer. Drop a note in, the librarian wires it into the graph — resolving
[[links]], assigning#tags, updating hub notes. Humans drop; agents wire. - Ingester agents feed it from anywhere. One agent per source (Gmail, Slack, calendar) writes raw notes; the librarian links them. See
examples/company-brain-team.at. - Pure markdown, zero infrastructure. No vector DB, no MCP server. Coding agents retrieve with
grep. The whole brain is a folder you cangit clone. - 100% Obsidian-compatible. The vault is an Obsidian vault — agents build it, you open it in Obsidian for the graph view. Or use our built-in graph viewer (below) and skip Obsidian entirely.
See it without Obsidian — render any brain vault as an interactive graph in a single self-contained HTML file:
agentopology visualize-brain brain/Nodes are colored by what they are (person / org / topic) and by where they came from (declare sources { gmail { color, icon } } and notes from Gmail render in Gmail red with the logo). When you visualize a topology that owns brains, the two graphs cross-link — jump from the team diagram to its brain and back.
This is brain as code: you declare the brain's architecture — its layers, its custodians, its sources — the same way you declare the agent team. See docs/company-brain.md for the full walkthrough.
Programmatic API
import { parse, validate, bindings } from "agentopology";
// Parse
const ast = parse(atSource);
// Validate (136 built-in rules, V1-V136)
const issues = validate(ast);
// Scaffold — generate platform files
const files = bindings["claude-code"].scaffold(ast);
// Plan — resolve for interpreted execution, generate nothing
import { buildExecutionBrief, renderBriefMarkdown } from "agentopology/plan";
const brief = buildExecutionBrief(ast, { task: "Add rate limiting", autonomy: "execute" });
const markdown = renderBriefMarkdown(brief);
// Render the flow as a terminal graph
import { renderAscii } from "agentopology/render";
console.log(renderAscii(ast));
// Visualize
import { generateVisualization } from "agentopology";
const html = generateVisualization(ast);Create Your Own Binding
Implement the BindingTarget interface to add any platform:
import type { BindingTarget } from "agentopology";
export const myBinding: BindingTarget = {
name: "my-platform",
description: "My AI Platform",
scaffold(ast) {
return [
{ path: "agents.json", content: JSON.stringify(ast.nodes) },
];
},
};Focus on Structure, Not Config Files
The .at file IS your architecture diagram. When you open it, you see:
- Who the agents are
- What tools they have
- How work flows between them
- Where the quality gates are
- What happens when things fail
You can agentopology visualize it into an interactive graph. You can hand it to a new team member and they understand the system in 30 seconds. Try doing that with 15 scattered AGENT.md files.
| | Config files | AgenTopology |
|---|---|---|
| Switch platforms | Rewrite everything | Change --target |
| Add an agent | Update 5-12 files across 3 tools | Add 4 lines to .at file |
| See the architecture | Read YAML, JSON, TOML, Markdown across 6 dirs | One .at file. Or visualize it. |
| Validate | Hope for the best | 136 built-in rules catch errors before deploy |
| Onboard someone | "Read these 15 files and figure it out" | "Read this .at file" |
| Version control | Diff 47 generated files | Diff one .at file |
| Move to a new tool | Start over | --target new-tool |
Examples
simple-pipeline.at— Research → write → review with quality gatecode-review.at— Multi-agent code review with security scanningdata-processing.at— ETL pipeline with batch processing and meteringscheduled-monitor.at— Monitoring system with scheduled health checksopenclaw-assistant.at— Customer support with routing and schedulingcompany-brain.at— A plug-and-play company brain (librarian + researcher)company-brain-team.at— A team that ingests (Gmail/Slack/calendar), wires, and audits a brain
CLI Reference
agentopology validate <file> Validate an .at file (136 rules)
agentopology plan <file> Resolve for interpreted execution — no files written
agentopology scaffold <file> --target <t> Generate platform configs
agentopology sync <file> --target <t> --dir <d> Sync platform files back to .at
agentopology import --target <t> --dir <d> [--output <o>] [--force] Reverse-engineer platform files to .at; refuses (exit 1) when the .at exists, --force overwrites; exit 2 when the .at it wrote has validation errors
agentopology visualize <file> Interactive topology graph (+ cross-links any brains)
agentopology visualize-brain <folder> Render a brain vault as an Obsidian-style graph (no Obsidian)
agentopology export <file> --format <fmt> Export as markdown, mermaid, json, ascii, or brief
agentopology info <file> Topology analysis and suggestions
agentopology guard <file> --check [--dir <d>] What the project enforces today: refuse / cited / none / hope per gate
agentopology guard <file> --target claude-code [--dir <d>] [--dry-run] Write only the guards (hook scripts, gates, checks, settings hooks and permissions) into a hand-built project
agentopology inventory [<dir>] [--at <file>] [--user] What is live in the project (the .claude tree, and for Codex the .codex agents, hooks.json entries, rules, config.toml MCP servers and .agents/skills), as JSON (writes nothing); --at adds the folders the .at lists in `inventory { roots }`, --user adds ~/.claude
agentopology validate <file> --inventory <dir> Coverage: live things the .at accounts for; unmapped, missing
agentopology validate --inventory <dir> a.at b.at Per-file coverage, then one union number (mapped when any file maps it)
agentopology validate <file> --inventory <dir> --user Also counts ~/.claude apart, and checks the `needs` block (user skills, memory path) against the home folder
agentopology targets List supported platforms
agentopology docs [topic] Language reference (43 topics)Known issues in 0.12.6
- In a gate's or a hook's
run:, write the interpreter and the script (python3 tools/x.py,python3 -I tools/x.py) or a script path, notenv …orcommand ….scaffoldandguard --targetcan read the first word as a script name and write a stub with that name that blocks every step.guard --checkgrades such a gatenone, with a note that its check script is still a stub and a line saying how many gates are graded so. - A hand-written hook in
.claude/settings.jsonthat runs a script directly, or by a program other than the interpretersrun:reads (./.claude/hooks/x.sh "a b",dash x.sh "a b"), and passes it quoted arguments is changed byimportthenscaffold: a direct run is rewritten with its quotes escaped, and for another program a second entry with escaped quotes is added beside the original, so the script runs twice, once with different arguments. Write it with one of those interpreters (bash ./.claude/hooks/x.sh "a b"), which round-trips as written. Fixed in a later release. - A hook you add by hand that runs a script the
.atnames as your own file (arun:on.claude/hooks/x.sh) can be removed by the nextscaffoldwithout a message. Until a fix ships, keep a copy of.claude/settings.jsonbeforescaffoldand compare after, or declare that hook in the.at. Fixed in a later release.
Contributing
We welcome contributions. The easiest ways to start:
- Add a new example topology
- Improve a binding
- Add tests
- Write documentation
Grammar and AST changes require an RFC.
License
Apache 2.0 — see LICENSE.
