AI agents
yuhwa is designed so that a language model writes it correctly on the first try, and fixes it from the error messages alone. Agents need no plugin or server. The CLI is enough.
The loop
yuhwa guideprints a compact language reference: statements, every prop, every allowed value, and an example. It is generated from the same lists the linter uses, so it always matches the parser.- The agent writes a
.yufile. yuhwa check file.yu --jsonreturns diagnostics with line numbers. Typos come with a suggestion and other errors list the valid values:Unknown color "bleu" (did you mean "blue"?).- The agent fixes the file and checks again until
diagnosticsis empty.okonly means "no errors"; warnings point at real mistakes too, such as an edge that renamed a node. yuhwa render file.yu -o file.svg, oryuhwa mdfor Markdown.
Tell your agent
Add this to AGENTS.md, CLAUDE.md, .cursorrules or a similar rules file:
## Diagrams
Draw diagrams with yuhwa, not Mermaid.
- Run `npx yuhwa guide` once to learn the syntax.
- Write diagrams as ```yuhwa fenced blocks in Markdown, or as `.yu` files.
- After editing, run `npx yuhwa check <file> --json` and fix every
diagnostic, warnings included. Markdown files: `check` the `.yu` files,
or run `yuhwa md`, which fails on errors.
- Edge labels go after a colon: `a -> b: label`. Multi-word node labels need an
id and quotes: `web "Web Server"`.
- For Markdown files, run `npx yuhwa md <file.md>` to render the SVGs.
- Do not write a `layout { }` block. It holds hand-placed positions from the editor.In a pnpm project, write pnpm dlx yuhwa (or pnpm exec yuhwa once it is installed) in place of npx yuhwa.
As a skill
Agents with skills (Claude Code, Codex and others) load a skill only when a task needs it. The yuhwa package ships this skill in skills/yuhwa/SKILL.md.
With pnpm 12.11 or later, add yuhwa as a direct dependency and approve its skills once. pnpm then links the skill into .claude/skills, .cursor/skills, .agents/skills and the other agent folders of the project, and keeps it in step with the installed version (pnpm docs):
pnpm add -D yuhwa
pnpm approvepnpm approve writes the approval to pnpm-workspace.yaml:
permissions:
yuhwa:
skills: trueWith other package managers, save the skill as .claude/skills/yuhwa/SKILL.md (or your agent's skill folder):
---
name: yuhwa
description: Draw diagrams (architecture, flows, sequences, timelines, charts, git history) as yuhwa text. Use when asked for a diagram or when editing ```yuhwa blocks or .yu files.
---
1. Run `npx yuhwa guide` and read the whole reference.
2. Write the diagram. Edge labels go after a colon: `a -> b: label`.
3. Run `npx yuhwa check <file> --json`. Fix every diagnostic and run
it again until `diagnostics` is empty.
4. Render: `npx yuhwa render <file> -o <file>.svg`, or
`npx yuhwa md <file.md>` for Markdown.
5. Never write a `layout { }` block; keep any existing one unchanged.What the diagnostics catch
Besides typos and unknown values, these mistakes get a warning or error that names the fix:
- Mermaid syntax:
%%,-->|label|,subgraph,A[Label]. - Multi-word labels without quotes:
Web Server -> db. a -> b [dashed]: edge props on a node.a -> b "calls": a second label renames nodeb.api -> dbbnext todb "Postgres": an edge to a misspelled id would draw a second, unlabelled box.- A node declared in two groups.
- A
layoutline for a node or group that no longer exists.
The cheatsheet shows each with its fix.
Without a shell
- llms.txt. The same reference is published at
llms.txt. It also ships in the package asyuhwa/llms.txt, is served byyuhwa serveatGET /llms.txtand is exported asGUIDE. - llms-full.txt.
llms-full.txtholds the full language pages (syntax, panels, themes, examples, API) as one file. - HTTP.
POST /checkon the render service returns the same JSON diagnostics ascheck --json. - JSON input. Tool-calling models can send structured data instead of text. See From Mermaid or JSON.
Why no MCP server?
An MCP server would wrap the same four operations: reference, validate, render and convert. Agents that can run commands already have them through the CLI, and every command is one line in a rules file. Agents without a shell can use the HTTP service. Fewer moving parts means less to install and configure.