CLI reference
Overview
| Command | Description |
|---|---|
ayida validate | Compile and report diagnostics with file, line and column |
ayida fmt | Canonical formatting, like terraform fmt |
ayida build | Render diagrams, markdown and a site into dist/ |
ayida serve | Preview server with live reload |
ayida query | Dependents, dependencies, paths, orphans, coupling, flows and listings |
ayida export | Compiled architecture as JSON or TOON |
ayida diff | Compare two revisions of the architecture by address |
ayida changelog | The changes of ayida diff as markdown, for release notes |
ayida mcp | Start the MCP server for AI assistants |
ayida version | Print the current version |
ayida completion | Generate shell completion scripts |
There are no ayida init, ayida new or ayida watch commands. ayida serve rebuilds on change,
and ayida build needs no d2 binary.
Global flags: --project, -p sets the project root to discover *.ayida.hcl files beneath
(default .). --help and --version work on every command. There is no configuration file:
project settings live in the project block. Set NO_COLOR to disable
coloured diagnostics.
ayida validate
Compile the architecture and report every problem with position. --strict makes warnings fail the
run too.
ayida validate [--strict] [--format text|json] [--summary] [--severity error|warning] [--ignore CODE]| Flag | Type | Default | Description |
|---|---|---|---|
--strict | bool | false | Exit 2 when warnings are present |
--format | string | text | text renders source snippets; json emits the diagnostics contract |
--summary | bool | false | One line per diagnostic code: severity, count and up to 20 addresses |
--severity | string | error shows errors only; warning shows errors and warnings, not information. The exit code is unchanged | |
--ignore | list | Warning and information codes to leave out, on top of the project’s ignore_warnings. Ignored warnings do not count for --strict |
Diagnostics come in three severities: errors (exit 1), warnings (exit 2 under --strict) and
information, which is advice and never changes an exit code. The summary adds , N info when there
is any, for example 0 errors, 0 warnings, 7 info.
ayida validate --strict -p examples/microservices
ayida validate --format json | jq .
ayida validate --summary
ayida validate --strict --ignore missing_docsExit codes are 0 clean, 1 errors, 2 warnings under --strict. There are exactly three, so a
CI pipeline can branch on them:
# .github/workflows/architecture.yml
name: Architecture
on: [push, pull_request]
jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: actions/setup-go@v7
with:
go-version: '1.27'
- run: go install github.com/madstone-tech/ayida/v2@v2.1.1
- run: ayida fmt --check
- run: ayida validate --strictayida fmt
Rewrite every *.ayida.hcl file in canonical form, preserving comments and declaration order.
--check writes nothing, lists the files that are not canonical, and exits 1. Use it in CI:
ayida fmt --check -p examples/microservicesayida build
Render diagrams (D2 and SVG), markdown and an HTML site. No external d2 binary is needed.
ayida build [--format d2,svg,md,html] [--out DIR] [--strict] [--ignore CODE]| Flag | Type | Default | Description |
|---|---|---|---|
--format | list | d2,svg,md,html | Formats to produce, comma-separated or repeated. html and md embed diagrams, so they add svg |
--out | string | <project>/dist | Output directory. A relative path resolves against the working directory |
--strict | bool | false | Exit 2 when warnings are present |
--ignore | list | Warning and information codes to leave out, as in ayida validate |
ayida build -p examples/microservices
ayida build --format svg,html --out public
ayida build --format md # markdown only (adds the SVG it embeds)Output is byte-identical across runs and machines, and every file carries a generated-file notice.
ayida prunes only the files it wrote, which it lists in .dist.ayida/manifest beside the output
directory, so a published copy of dist/ holds generated files only. Nothing is written when
compilation fails.
The build reports a wide_view information line for a view that renders at least 3,000 px wide
and 2.5 times wider than tall. To fix it, set a direction or layout on the view, or leave the
line out with --ignore wide_view. Files in <project>/templates/ theme the site, and the build
report names the theme files it used.
ayida serve
Serve the site on http://127.0.0.1:8080 and rebuild and reload the browser on every change.
ayida serve [--host 127.0.0.1] [--port 8080]| Flag | Type | Default | Description |
|---|---|---|---|
--host | string | 127.0.0.1 | Interface to listen on. Use 0.0.0.0 inside a container; ayida warns whenever the address is not loopback |
--port | int | 8080 | Port to listen on |
It watches the *.ayida.hcl files, the prose files they reference, and templates/. When a save
does not compile, every page shows the diagnostics instead of stale output. serve builds in
memory and never writes the output directory.
In Docker, publish the port on the host’s loopback so the site stays private:
docker run --rm -v "$PWD:/workspace" -p 127.0.0.1:8080:8080 \
ghcr.io/madstone-tech/ayida:latest serve --host 0.0.0.0ayida query
Ask questions of the compiled model:
ayida query dependents <address> [--transitive]
ayida query dependencies <address> [--transitive]
ayida query path <from> <to>
ayida query orphans
ayida query coupling [--limit 20]
ayida query flows <address>
ayida query views
ayida query elements [--kind <kind>]
ayida query relationships| Query | Answers |
|---|---|
dependents | Who has a relationship into this element (or anything inside it)? |
dependencies | What does this element (or anything inside it) depend on? |
path | The shortest chain of dependencies between two elements, or no path (exit 0) |
orphans | Elements with no relationship touching them |
coupling | Elements ranked by distinct fan-in plus fan-out |
flows | The dynamic-view steps the element takes part in, by view and step number |
views | Every view the build produces, generated and declared |
elements | Every element by address; --kind limits it to person, system, container, component or external |
relationships | Every relationship, with source, target, kind and description |
ayida query dependents container.db # what breaks if the database is down
ayida query path person.customer container.db # how a request reaches it
ayida query orphans # elements with no relationships
ayida query flows container.order_api # the dynamic flows it appears in
ayida query elements --kind container # every containerQueries follow dependencies: the direction from the element that declares a uses to its
target. An asynchronous flow through a queue is therefore traced in two parts. --format json
prints exactly what the MCP query tool returns, and --format toon halves the size of tabular
answers.
ayida export
Write the compiled architecture as a byte-stable, machine-readable artifact:
ayida export --format json
ayida export --format toonFlags: --format (json or toon) and --out (default stdout). Nothing is written when
compilation reports errors. The same source always produces identical bytes, on any machine and in
any file-system order, so a committed export is reviewable in a diff.
ayida diff
Compare two revisions of the architecture by address. The result lists each change and the elements that depend on it (its blast radius).
ayida diff [<range>] [--from-export <file>] [--format text|json|toon]<range> | Older side | Newer side |
|---|---|---|
| (none) | HEAD | files on disk |
<rev> | <rev> | files on disk |
<a>..<b> | <a> | <b> |
<a>.. | <a> | HEAD |
..<b> | HEAD | <b> |
A revision is a commit hash, a branch, a tag or a remote branch, with an optional ~ or ^
suffix. ayida reads the git history in process, so the command needs no git program and also
works in the container image. --from-export release-1.json uses a JSON export as the older side
instead, with no repository needed.
diff main..HEAD (d33935a..e1c87e7)
+ container.dlq_worker
- container.legacy_cron
= container.api -> container.payments_api
! 2 dependents: container.web, person.customer
> container.payments_api.uses.orders target: container.orders_db -> container.orders_aurora
! 2 dependents: container.web, person.customer
~ container.payments_api technology: "Lambda (Node)" -> "Lambda (Go)"
! 2 dependents: container.web, person.customer
@ deployment.prod.instance.api binding: +terraform module.payments.*, -terraform module.api.*
6 changes: 1 added, 1 removed, 1 renamed, 1 rewired, 1 attribute changed, 1 rebound| Marker | Class | Meaning |
|---|---|---|
+ | added | The declaration is on the newer side only |
- | removed | The declaration is on the older side only |
= | renamed | A moved block renamed the element |
> | rewired | A relationship at the same address has a new target |
~ | attribute changed | An attribute has a new value, including a move to a different parent |
@ | rebound | The bindings of an instance changed |
Formatting, comments, declaration order and the file that holds a declaration are never changes.
A rename without a moved block shows as one removed and one added element.
The exit code is 0 when the comparison succeeds, with or without changes, and 1 when a range,
revision, export or side fails. In CI, fetch enough history for the range, for example with
fetch-depth: 0 in actions/checkout, because a shallow clone can miss the older commit.
ayida changelog
Print the changes of ayida diff as markdown, with one section per class of change, for release
notes. It takes the same ranges and --from-export as ayida diff.
ayida changelog v2.0.0..v2.1.0
ayida changelog main > CHANGES.mdayida mcp
Start the MCP (Model Context Protocol) server for AI assistant integration.
| Flag | Type | Default | Description |
|---|---|---|---|
--project, -p | string | . | The architecture the tools read and edit. Set it, because clients usually start ayida from another directory |
--env | string | "" | Set an environment variable (KEY=VALUE) for the server |
The server registers nine tools. schema describes the language. describe, query and
validate read the compiled architecture, and diff compares two revisions of it. apply_edit,
move and fmt edit the HCL source and compile every change before anything is written. build
renders into a directory in the project. Writes touch *.ayida.hcl files only, and build writes
only its output directory. See the MCP server page for setup and every tool’s
arguments.
ayida completion
Generate a shell completion script on stdout. The scripts complete commands, flags and their
values: element addresses for query, branches and tags for diff and changelog, and the
formats, severities, element kinds and ignorable codes that flags accept.
ayida completion bash > /etc/bash_completion.d/ayida
ayida completion zsh > "${fpath[1]}/_ayida"
ayida completion fish > ~/.config/fish/completions/ayida.fish