Skip to content

CLI reference

GitHub →

Overview

CommandDescription
ayida validateCompile and report diagnostics with file, line and column
ayida fmtCanonical formatting, like terraform fmt
ayida buildRender diagrams, markdown and a site into dist/
ayida servePreview server with live reload
ayida queryDependents, dependencies, paths, orphans, coupling, flows and listings
ayida exportCompiled architecture as JSON or TOON
ayida diffCompare two revisions of the architecture by address
ayida changelogThe changes of ayida diff as markdown, for release notes
ayida mcpStart the MCP server for AI assistants
ayida versionPrint the current version
ayida completionGenerate 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]
FlagTypeDefaultDescription
--strictboolfalseExit 2 when warnings are present
--formatstringtexttext renders source snippets; json emits the diagnostics contract
--summaryboolfalseOne line per diagnostic code: severity, count and up to 20 addresses
--severitystringerror shows errors only; warning shows errors and warnings, not information. The exit code is unchanged
--ignorelistWarning 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_docs

Exit 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 --strict

ayida 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/microservices

ayida 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]
FlagTypeDefaultDescription
--formatlistd2,svg,md,htmlFormats to produce, comma-separated or repeated. html and md embed diagrams, so they add svg
--outstring<project>/distOutput directory. A relative path resolves against the working directory
--strictboolfalseExit 2 when warnings are present
--ignorelistWarning 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]
FlagTypeDefaultDescription
--hoststring127.0.0.1Interface to listen on. Use 0.0.0.0 inside a container; ayida warns whenever the address is not loopback
--portint8080Port 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.0

ayida 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
QueryAnswers
dependentsWho has a relationship into this element (or anything inside it)?
dependenciesWhat does this element (or anything inside it) depend on?
pathThe shortest chain of dependencies between two elements, or no path (exit 0)
orphansElements with no relationship touching them
couplingElements ranked by distinct fan-in plus fan-out
flowsThe dynamic-view steps the element takes part in, by view and step number
viewsEvery view the build produces, generated and declared
elementsEvery element by address; --kind limits it to person, system, container, component or external
relationshipsEvery 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 container

Queries 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 toon

Flags: --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 sideNewer side
(none)HEADfiles 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
MarkerClassMeaning
+addedThe declaration is on the newer side only
-removedThe declaration is on the older side only
=renamedA moved block renamed the element
>rewiredA relationship at the same address has a new target
~attribute changedAn attribute has a new value, including a move to a different parent
@reboundThe 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.md

ayida mcp

Start the MCP (Model Context Protocol) server for AI assistant integration.

FlagTypeDefaultDescription
--project, -pstring.The architecture the tools read and edit. Set it, because clients usually start ayida from another directory
--envstring""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