Your first .em.hcl model
Install the CLI, write a small model, validate it, and render it locally.
1 · Install the CLI
Use Go 1.25 or newer to install emhcl for your user account. You can also use a release archive.
Option A: install with Go
Go writes the executable to GOBIN. If GOBIN is unset, Go writes it to $(go env GOPATH)/bin. Add that directory to your PATH. Then you can run emhcl from any directory:
Option B: download a release
Replace linux_amd64 with darwin_amd64, darwin_arm64, linux_arm64, windows_amd64, or windows_arm64 as needed. The Windows archives are .zip files, not .tar.gz. If you have GitHub CLI 2.49.0 or newer, make sure that this repository's release workflow produced the archive:
Option C: build from source
Make sure that the command runs:
2 · Write your first model
Save this model as pet.em.hcl. It is the same minimal model that this site uses throughout. It has one bounded context, one Event, and one State Change workflow:
3 · Validate it
If the document is valid, the command prints:
The command prints diagnostics like file:line:column: Severity EMxxx: message for errors and warnings. See the quality page to learn which diagnostics are hard errors and which are warnings to review.
4 · Render the canvas
pet.html is one self-contained file. It has no external dependencies and needs no build step. Open it in a browser.
To render again each time you save the file, run emhcl serve pet.em.hcl. Then open the URL that it prints.
If one file becomes too large to read, split whole top-level blocks into a folder of .em.hcl files. The validate, diagram, serve, and export commands accept the folder path. Format each member file with emhcl fmt -w. The formatter refuses a folder. See Folder models.
For a folder model, serve reloads when you add, remove, rename, or edit a member file. Diagnostics name the file that needs attention.
In the browser playground, use file tabs to add, rename, or remove files. All tabs form one model. Select a diagnostic to open its file.
Optional: publish the diagram
The model and the rendered canvas are files. You can commit them beside the code and host the canvas with GitHub or GitLab Pages:
Because the model is in the repository, you can version and review it with the code.
A coding agent can draft, validate, fix, and render a model before human review. See Using .em.hcl with coding agents.