Skip to content

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 ​

  1. yuhwa guide prints 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.
  2. The agent writes a .yu file.
  3. yuhwa check file.yu --json returns diagnostics with line numbers. Typos come with a suggestion and other errors list the valid values: Unknown color "bleu" (did you mean "blue"?).
  4. The agent fixes the file and checks again until diagnostics is empty. ok only means "no errors"; warnings point at real mistakes too, such as an edge that renamed a node.
  5. yuhwa render file.yu -o file.svg, or yuhwa md for Markdown.

Tell your agent ​

Add this to AGENTS.md, CLAUDE.md, .cursorrules or a similar rules file:

md
## 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):

sh
pnpm add -D yuhwa
pnpm approve

pnpm approve writes the approval to pnpm-workspace.yaml:

yaml
permissions:
  yuhwa:
    skills: true

With other package managers, save the skill as .claude/skills/yuhwa/SKILL.md (or your agent's skill folder):

md
---
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 node b.
  • api -> dbb next to db "Postgres": an edge to a misspelled id would draw a second, unlabelled box.
  • A node declared in two groups.
  • A layout line 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 as yuhwa/llms.txt, is served by yuhwa serve at GET /llms.txt and is exported as GUIDE.
  • llms-full.txt. llms-full.txt holds the full language pages (syntax, panels, themes, examples, API) as one file.
  • HTTP. POST /check on the render service returns the same JSON diagnostics as check --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.

Released under the MIT License.