<!-- GENERATED by scripts/gen-cli-reference.ts from src/manifest.ts — do not edit by hand. Run `npm run gen:cli`. -->

# CLI reference

Every `archlang` command, flag, format and exit code — generated from the same capability
manifest that `archlang manifest --json` serves, so this page cannot fall behind the CLI.

The CLI is ArchLang's **primary agent interface**. Every command takes `--json` (structured
result on **stdout**, human messages on **stderr**), and every command that reads source
accepts a file path or `-` for stdin.

```bash
npx -y @chanmeng666/archlang help        # zero-install
npm i -g @chanmeng666/archlang           # or install the archlang command
archlang manifest --json                 # this page, as data
```

`arch` is installed as an alias of `archlang`, but on Linux, macOS and Git Bash coreutils owns
that name, so this page never uses it.

A flag that takes a value takes it either way: `--level 2` or `--level=2`.

## Exit codes

| Code | Meaning |
| --- | --- |
| `0` | ok |
| `1` | internal / IO error |
| `2` | user-source error (deterministic — fix it, don't blindly retry) |
| `3` | bad usage |
| `4` | stale source: the file is not the revision --expected-hash names (re-read it, redo the edit) |

## Output formats

`-f <format>` on `compile`, `batch`, `md` and `preview`.

| Format | Dependency |
| --- | --- |
| `svg` | zero-dep (built in) |
| `dxf` | zero-dep (built in) |
| `txt` | zero-dep (built in) |
| `json` | zero-dep (built in) |
| `pdf` | needs optional `pdfkit` |
| `png` | needs optional `@resvg/resvg-js` |

## Global flags

| Flag | Does |
| --- | --- |
| `--json` | structured result on stdout, messages on stderr |
| `--quiet, -q` | suppress human messages on stderr |

## Commands

### `archlang compile`

render a plan to SVG/DXF/TXT/PDF/PNG, or to Plan JSON

**Input:** `<file.arch|-> (Plan JSON with --from-json)` · **Output:** file (or stdout with -o -) — with --json and no -o nothing is written

| Flag | Does |
| --- | --- |
| `--out, -o <file\|->` | output file, or '-' for stdout; a missing directory is created (default: the input path with the format's extension) |
| `--format, -f <svg\|dxf\|txt\|json\|pdf\|png>` | output format (default: the -o extension, else svg); json writes the Plan JSON that --from-json reads |
| `--level <n>` | render only this storey of a multi-storey plan (level blocks) to the plain -o target, instead of one &lt;stem&gt;.L&lt;level&gt;.&lt;ext&gt; file per level; {level} in -o names each storey's file (no `level` blocks: exit 3) |
| `--width, -w <px>` | page width hint in pixels |
| `--scale, -s <n>` | raster scale for the PNG backend (ignored by the non-raster formats) |
| `--cols <n>` | text renderer (-f txt / preview --ascii) grid width in characters (default 80) |
| `--charset <unicode\|ascii>` | text renderer glyph set (default unicode) |
| `--overlay <circulation>` | draw an opt-in diagnostic overlay (circulation walks + bottleneck markers); default output is unchanged |
| `--theme <blueprint\|mono\|dark\|presentation\|rendered>` | draw with this named colour theme instead of the plan's own: it wins over the source's `theme` statement, `theme from`, `style` blocks and a single `furniture` colour (which `rendered` replaces with its material tints) for every key it sets, and a key it leaves unset (a `lineWeight`, a `font`) keeps the source's value; default: the plan's theme, else the built-in one. Refused (exit 3) with -f json, -f txt and -f dxf, which carry no theme colours |
| `--error-svg` | on a broken plan, still emit a self-describing error-card image listing the diagnostics (exit code stays 2); it is an output like any other, so with --json and no -o nothing is written and the card is not in the payload — pass -o &lt;file&gt; to get the image |
| `--accessible` | emit &lt;title&gt;/&lt;desc&gt;/role/aria accessibility metadata (the describe() caption) into the SVG; default output is unchanged |
| `--acc-id-prefix <prefix>` | with --accessible, prefix the &lt;title&gt;/&lt;desc&gt; element ids (default arch, giving arch-title/arch-desc) so several plans inlined in one HTML page do not share them; ignored without --accessible |
| `--from-json` | read the input as Plan JSON (RPLAN shape) instead of .arch, convert it, then compile |
| `--install` | auto-install the optional dep for the chosen format if missing (PNG/PDF) |
| `--import-root <dir>` | read `import`ed modules from under this directory (default: the working directory); a module outside it, a non-.arch file or one over 1 MiB is refused with a diagnostic, never read |
| `--json` | structured result on stdout, messages on stderr |
| `--quiet, -q` | suppress human messages on stderr |
| `--view <iso\|axon>` | DEPRECATED (removed in 2.0; ArchLang draws plans) — render an illustrative axonometric of the building instead of the plan (iso = true isometric, axon = the 30/60 plan oblique) — a picture, never a measured drawing: no scale, no title block, no dimensions, and `describe`/`lint` are unaffected |

**Examples**

```bash
# render to the named file; structured result on stdout
$ archlang compile plan.arch -o plan.svg --json

# check it compiles and WRITE NOTHING (no -o names a file) — reports written:false, bytes, diagnostics, summary
$ archlang compile plan.arch --json

# render SVG next to the input (plan.svg)
$ archlang compile plan.arch

# compile source from stdin straight to SVG on stdout
$ archlang compile - -o - < plan.arch

# export the Plan JSON; `archlang compile plan.json --from-json` renders it back
$ archlang compile plan.arch -f json -o plan.json

# rasterize to PNG, fetching the optional renderer if it is missing
$ archlang compile plan.arch -f png -o plan.png --install --json

# a multi-storey plan writes one sheet per level (house.L1.svg, house.L2.svg …) and reports outputs[]
$ archlang compile house.arch -o house.svg --json

# name each storey's file yourself: storey-1.svg, storey-2.svg …
$ archlang compile house.arch -o "storey-{level}.svg"

# render just the upper storey of a multi-storey plan to one file
$ archlang compile house.arch --level 2 -o upper.svg

# draw with the `rendered` colour theme without writing `theme rendered` into the source; the flag wins over the source's own `theme` and `style` blocks
$ archlang compile plan.arch --theme rendered -o plan.svg

# an illustrative isometric of the whole building (every storey in ONE drawing, so no per-level fan-out)
$ archlang compile house.arch --view iso -o house-iso.svg
```

### `archlang batch`

render many .arch files in one call, concurrently

**Input:** `<a.arch> <b.arch> …` · **Output:** one file per input; --json gives a results[] array

| Flag | Does |
| --- | --- |
| `--out, -o <dir>` | output DIRECTORY for every rendered file, created if missing; two inputs that would write one file (same name) are refused (default: alongside each input) |
| `--format, -f <svg\|dxf\|txt\|json\|pdf\|png>` | output format (default: the -o extension, else svg); json writes the Plan JSON that --from-json reads |
| `--jobs, -j <n>` | max concurrent renders (default: CPU count) |
| `--width, -w <px>` | page width hint in pixels |
| `--scale, -s <n>` | raster scale for the PNG backend (ignored by the non-raster formats) |
| `--cols <n>` | text renderer (-f txt / preview --ascii) grid width in characters (default 80) |
| `--charset <unicode\|ascii>` | text renderer glyph set (default unicode) |
| `--overlay <circulation>` | draw an opt-in diagnostic overlay (circulation walks + bottleneck markers); default output is unchanged |
| `--theme <blueprint\|mono\|dark\|presentation\|rendered>` | draw with this named colour theme instead of the plan's own: it wins over the source's `theme` statement, `theme from`, `style` blocks and a single `furniture` colour (which `rendered` replaces with its material tints) for every key it sets, and a key it leaves unset (a `lineWeight`, a `font`) keeps the source's value; default: the plan's theme, else the built-in one. Refused (exit 3) with -f json, -f txt and -f dxf, which carry no theme colours |
| `--error-svg` | on a broken plan, still emit a self-describing error-card image listing the diagnostics (exit code stays 2) |
| `--accessible` | emit &lt;title&gt;/&lt;desc&gt;/role/aria accessibility metadata (the describe() caption) into the SVG; default output is unchanged |
| `--acc-id-prefix <prefix>` | with --accessible, prefix the &lt;title&gt;/&lt;desc&gt; element ids (default arch, giving arch-title/arch-desc) so several plans inlined in one HTML page do not share them; ignored without --accessible |
| `--install` | auto-install the optional dep for the chosen format if missing (PNG/PDF) |
| `--import-root <dir>` | read `import`ed modules from under this directory (default: the working directory); a module outside it, a non-.arch file or one over 1 MiB is refused with a diagnostic, never read |
| `--json` | structured result on stdout, messages on stderr |
| `--quiet, -q` | suppress human messages on stderr |

**Examples**

```bash
# render design variants concurrently; one result row per input
$ archlang batch a.arch b.arch c.arch -o out/ --json

# export a whole directory to DXF, 4 renders at a time
$ archlang batch plans/*.arch -f dxf -j 4 --json
```

### `archlang md` _(alias: `markdown`)_

render every ```arch block in a Markdown file and rewrite to image links

**Input:** `<doc.md>` · **Output:** out.md + one image per block

| Flag | Does |
| --- | --- |
| `--out, -o <out.md\|->` | rewritten Markdown file, or '-' for stdout (default: &lt;name&gt;.out.md) |
| `--format, -f <svg\|png>` | image format for the blocks (default svg) |
| `--width, -w <px>` | page width hint in pixels |
| `--scale, -s <n>` | raster scale for the PNG backend (ignored by the non-raster formats) |
| `--overlay <circulation>` | draw an opt-in diagnostic overlay (circulation walks + bottleneck markers); default output is unchanged |
| `--theme <blueprint\|mono\|dark\|presentation\|rendered>` | draw with this named colour theme instead of the plan's own: it wins over the source's `theme` statement, `theme from`, `style` blocks and a single `furniture` colour (which `rendered` replaces with its material tints) for every key it sets, and a key it leaves unset (a `lineWeight`, a `font`) keeps the source's value; default: the plan's theme, else the built-in one. Refused (exit 3) with -f json, -f txt and -f dxf, which carry no theme colours |
| `--error-svg` | on a broken plan, still emit a self-describing error-card image listing the diagnostics (exit code stays 2) |
| `--accessible` | emit &lt;title&gt;/&lt;desc&gt;/role/aria accessibility metadata (the describe() caption) into the SVG; default output is unchanged |
| `--acc-id-prefix <prefix>` | with --accessible, prefix the &lt;title&gt;/&lt;desc&gt; element ids (default arch, giving arch-title/arch-desc) so several plans inlined in one HTML page do not share them; ignored without --accessible |
| `--install` | auto-install the optional dep for the chosen format if missing (PNG/PDF) |
| `--import-root <dir>` | read `import`ed modules from under this directory (default: the working directory); a module outside it, a non-.arch file or one over 1 MiB is refused with a diagnostic, never read |
| `--json` | structured result on stdout, messages on stderr |
| `--quiet, -q` | suppress human messages on stderr |

**Examples**

```bash
# render the fenced arch blocks to SVGs and rewrite them to image links
$ archlang md README.md -o README.out.md --json

# PNG images; a broken block still yields an error card
$ archlang md doc.md -f png --error-svg --json
```

### `archlang preview`

render a PNG you can look at (zero-install where the optional binary is present)

**Input:** `<file.arch|->` · **Output:** PNG file (or ASCII text on stdout with --ascii)

| Flag | Does |
| --- | --- |
| `--out, -o <out.png\|->` | output PNG file, or '-' for stdout (default: &lt;name&gt;.png) |
| `--scale, -s <n>` | raster scale (default 1; without -w/-s the page auto-targets ~1600px wide for legibility) |
| `--width, -w <px>` | page width hint in pixels |
| `--ascii` | print a zero-dependency ASCII text plan to stdout instead of a PNG |
| `--review` | render the REVIEW SHEET instead of the plain plan: the access graph over the plan, every element a compile or default-lint warning names ringed with its number and code, a legend (number → code → message) and fixed-scale close-ups of the flagged openings and furniture pieces, the first 24 in mark order (default output &lt;name&gt;.review.png; --json adds marks[] with each warning's span and ringed elements, crops[] and cropsOmitted[], boxes in plan mm). One mark per warning; a warning from a repeated statement that does not say which copy it means is listed, not ringed. One storey per sheet (--level); not with --ascii, --view or --overlay |
| `--level <n>` | preview this storey of a multi-storey plan (default: the lowest level, i.e. page 1) |
| `--cols <n>` | text renderer (-f txt / preview --ascii) grid width in characters (default 80) |
| `--charset <unicode\|ascii>` | text renderer glyph set (default unicode) |
| `--overlay <circulation>` | draw an opt-in diagnostic overlay (circulation walks + bottleneck markers); default output is unchanged |
| `--theme <blueprint\|mono\|dark\|presentation\|rendered>` | draw with this named colour theme instead of the plan's own: it wins over the source's `theme` statement, `theme from`, `style` blocks and a single `furniture` colour (which `rendered` replaces with its material tints) for every key it sets, and a key it leaves unset (a `lineWeight`, a `font`) keeps the source's value; default: the plan's theme, else the built-in one. Refused (exit 3) with -f json, -f txt and -f dxf, which carry no theme colours; also with --ascii and --review |
| `--error-svg` | on a broken plan, still emit a self-describing error-card image listing the diagnostics (exit code stays 2) |
| `--install` | auto-install @resvg/resvg-js if missing, then render |
| `--view <iso\|axon>` | DEPRECATED (removed in 2.0; ArchLang draws plans) — render an illustrative axonometric of the building instead of the plan (iso = true isometric, axon = the 30/60 plan oblique) — a picture, never a measured drawing: no scale, no title block, no dimensions, and `describe`/`lint` are unaffected |
| `--import-root <dir>` | read `import`ed modules from under this directory (default: the working directory); a module outside it, a non-.arch file or one over 1 MiB is refused with a diagnostic, never read |
| `--json` | structured result on stdout, messages on stderr |
| `--quiet, -q` | suppress human messages on stderr |

**Examples**

```bash
# a zero-dependency text plan an agent can read on stdout
$ archlang preview plan.arch --ascii --json

# raster the plan so a vision model can look at it
$ archlang preview plan.arch -o plan.png --json

# look at one storey of a multi-storey plan
$ archlang preview house.arch --level 2 -o upper.png --json

# the reviewer's sheet: every warning ringed and numbered on the plan, with close-ups of each flagged opening and piece
$ archlang preview plan.arch --review -o review.png --json

# raster an illustrative plan-oblique of the building so a vision model can look at it
$ archlang preview house.arch --view axon -o house-axon.png --json
```

### `archlang link`

print a playground URL that opens the plan, rendered, with nothing to install

**Input:** `<file.arch|->` · **Output:** the playground URL; --json gives { ok, playground, embed, bytes } (embed: the plan alone, for an iframe; bytes: the compressed plan). A plan that does not compile still gets a link: ok false with an errors count, one warning on stderr; exits 0 on a plan that does not parse, and `errors` is the diagnostic count (`archlang validate --json` lists them)

| Flag | Does |
| --- | --- |
| `--json` | structured result on stdout, messages on stderr |
| `--quiet, -q` | suppress human messages on stderr |

**Examples**

```bash
# a URL to give the user: it opens the plan in the hosted playground
$ archlang link plan.arch

# the playground and embed URLs as data, and whether the plan compiles
$ archlang link plan.arch --json
```

### `archlang watch`

recompile on save (interactive)

**Input:** `<file.arch>` · **Output:** file, rewritten on each save

| Flag | Does |
| --- | --- |
| `--out, -o <file\|->` | output file, or '-' for stdout; a missing directory is created (default: the input path with the format's extension) |
| `--format, -f <svg\|dxf\|txt\|json\|pdf\|png>` | output format (default: the -o extension, else svg); json writes the Plan JSON that --from-json reads |
| `--level <n>` | render only this storey of a multi-storey plan (level blocks) to the plain -o target, instead of one &lt;stem&gt;.L&lt;level&gt;.&lt;ext&gt; file per level; {level} in -o names each storey's file (no `level` blocks: exit 3) |
| `--width, -w <px>` | page width hint in pixels |
| `--scale, -s <n>` | raster scale for the PNG backend (ignored by the non-raster formats) |
| `--cols <n>` | text renderer (-f txt / preview --ascii) grid width in characters (default 80) |
| `--charset <unicode\|ascii>` | text renderer glyph set (default unicode) |
| `--overlay <circulation>` | draw an opt-in diagnostic overlay (circulation walks + bottleneck markers); default output is unchanged |
| `--theme <blueprint\|mono\|dark\|presentation\|rendered>` | draw with this named colour theme instead of the plan's own: it wins over the source's `theme` statement, `theme from`, `style` blocks and a single `furniture` colour (which `rendered` replaces with its material tints) for every key it sets, and a key it leaves unset (a `lineWeight`, a `font`) keeps the source's value; default: the plan's theme, else the built-in one. Refused (exit 3) with -f json, -f txt and -f dxf, which carry no theme colours |
| `--error-svg` | on a broken plan, still emit a self-describing error-card image listing the diagnostics (exit code stays 2); it is an output like any other, so with --json and no -o nothing is written and the card is not in the payload — pass -o &lt;file&gt; to get the image |
| `--accessible` | emit &lt;title&gt;/&lt;desc&gt;/role/aria accessibility metadata (the describe() caption) into the SVG; default output is unchanged |
| `--acc-id-prefix <prefix>` | with --accessible, prefix the &lt;title&gt;/&lt;desc&gt; element ids (default arch, giving arch-title/arch-desc) so several plans inlined in one HTML page do not share them; ignored without --accessible |
| `--from-json` | read the input as Plan JSON (RPLAN shape) instead of .arch, convert it, then compile |
| `--install` | auto-install the optional dep for the chosen format if missing (PNG/PDF) |
| `--import-root <dir>` | read `import`ed modules from under this directory (default: the working directory); a module outside it, a non-.arch file or one over 1 MiB is refused with a diagnostic, never read |
| `--json` | structured result on stdout, messages on stderr |
| `--quiet, -q` | suppress human messages on stderr |

**Examples**

```bash
# recompile on every save (interactive; agents should use compile)
$ archlang watch plan.arch -o plan.svg
```

### `archlang validate`

parse + resolve + lint, no render (is it valid & sound?)

**Input:** `<file.arch|->` · **Output:** diagnostics (plus a graph{} report with --graph and an intent{ ok, satisfied, total, subscores, violations, measures? } block with --intent; `measures` lists each brief-bound size with its measured value and signed residual), then `keeps` when the plan declares one (each { keep, grade, level?, holds, residual_mm, at?, measured_mm?, span }), then `next`: the one item to fix first { tier, code, message, span?, hint? } or null (tiers: error, warning, validity, drafting, intent, profile, taste, info). Each diagnostic and intent violation carries its authoring `stage`; with --stage, an `at_stage` { stage, held_back, clean } block precedes `keeps`

| Flag | Does |
| --- | --- |
| `--strict, --fail-on-warning` | advisory warnings fail too (exit 2) |
| `--graph <graph.json>` | also check the plan's interior-door adjacency against an intended graph (bare dict or {input_graph:{…}}); mismatch → exit 2 |
| `--intent <intent.json>` | gate the plan against a brief's intent JSON; a failing gating assertion (room count/existence/area/windows) → exit 2. Adjacency/reachability score but never gate. Composes with --graph. |
| `--feedback` | with --intent, append a deterministic per-violation correction prompt (advisory data, never applied) |
| `--profile <residential-basic\|accessibility-advisory\|cn-residential-advisory\|uk-residential-advisory\|us-residential-advisory>` | lint under this advisory ruleset too (as `lint --profile`); its own warnings rank as `next` tier profile |
| `--taste <generic\|cn-residential-advisory\|uk-residential-advisory\|us-residential-advisory>` | let `next` fall back to the lowest-scoring taste criterion (ADR 0032); never gates |
| `--stage <brief\|rooms\|walls\|openings\|fixtures\|drafting>` | only the findings meaningful up to this authoring stage (errors always); `next`, `ok` and --strict read that set, `summary` says how many later-stage findings are held back; taste only at drafting |
| `--code <CODE[,CODE…]>` | show only diagnostics with these codes — a DISPLAY filter: the exit code and `ok` still come from the unfiltered set |
| `--severity <error\|warning>` | show only diagnostics of this severity — a DISPLAY filter, like --code (never changes the exit code) |
| `--import-root <dir>` | read `import`ed modules from under this directory (default: the working directory); a module outside it, a non-.arch file or one over 1 MiB is refused with a diagnostic, never read |
| `--json` | structured result on stdout, messages on stderr |
| `--quiet, -q` | suppress human messages on stderr |

**Examples**

```bash
# the ship gate: errors and advisory warnings both fail
$ archlang validate plan.arch --strict --json

# gate on a brief's intent contract and get per-violation correction prompts
$ archlang validate plan.arch --intent brief.json --feedback --json

# check interior-door adjacency against an intended room graph
$ archlang validate plan.arch --graph rooms.json --json

# read `next` first: the one diagnostic to fix before anything else, by fixed precedence
$ archlang validate plan.arch --json --taste generic

# author in stages: fix what the rooms alone decide, advance to walls once `at_stage.clean`
$ archlang validate plan.arch --stage rooms --json

# read only the blocking errors; `ok` and the exit code still weigh every diagnostic
$ archlang validate plan.arch --severity error --json
```

### `archlang describe`

semantic facts: rooms, areas, adjacency, what doors connect

**Input:** `<file.arch|->` · **Output:** facts (JSON or a summary), narrowed by --room/--zone/--select/--level

| Flag | Does |
| --- | --- |
| `--room <id[,id…]>` | keep only these rooms; doors/windows/openings/furniture narrow to the ones touching them (plan-level facts — bbox, totals, caption — stay whole-plan) |
| `--zone <path[,path…]>` | keep only the rooms declared in these `zone` blocks (nested zones roll up; paths are dotted, e.g. west.galleries) — a DISPLAY filter: `ok` and the exit code still weigh the whole plan |
| `--select <key[,key…]>` | emit only these top-level keys of the --json object (rooms, doors, totals, access, circulation, freedom, …); the ok/plan/units/diagnostics envelope is always kept |
| `--level <n>` | report this storey of a multi-storey plan as the top-level facts (a DISPLAY filter — `ok` and the exit code still weigh the whole plan) |
| `--facts <symmetry\|syntax\|depends\|clearances\|quantities[,…]>` | also compute these opt-in facts: `symmetry` (the plan's symmetry group per layer — shell, rooms, full — and its repeated rooms), `syntax` (space-syntax depth, mean depth, RA, integration and control on the access graph), `depends` (per element, the ids it derives from and the `let`/parameter names it reads) and `clearances` (what each clearance rule measured, per storey under the default ruleset: a WC's sides, a tall unit's and a hob's cover of a window, a hob's nearest tall unit, a doorway's clear width and approach, a stair's run and landings) and `quantities` (per storey, geometry only: wall length per category on the centreline and on the faces, room perimeters on the centreline and net, the net floor area, door and window counts by kind and width, wall face areas when the plan authors heights); absent by default |
| `--waste <pct>` | with the `quantities` fact, also report `floor_area_with_waste_m2` = the net floor area × (1 + pct/100), pct from 0 to 100; absent unless given |
| `--import-root <dir>` | read `import`ed modules from under this directory (default: the working directory); a module outside it, a non-.arch file or one over 1 MiB is refused with a diagnostic, never read |
| `--json` | structured result on stdout, messages on stderr |
| `--quiet, -q` | suppress human messages on stderr |

**Examples**

```bash
# rooms, areas, adjacency, door connections, caption, freedom — confirm the plan means what you intended
$ archlang describe plan.arch --json

# describe source piped on stdin, no temp file
$ archlang describe - --json < plan.arch

# just the rooms and the totals — keep a big plan's facts inside a bounded context
$ archlang describe plan.arch --select rooms,totals --json

# only those two rooms and the doors/windows/furniture that touch them
$ archlang describe plan.arch --room kitchen,bath --json

# only the west wing's rooms and what touches them; `zones[]` reports every declared wing, its rooms and its area
$ archlang describe museum.arch --zone west --json

# the upper storey's rooms/areas/access as the top-level facts (`levels[]` carries every storey)
$ archlang describe house.arch --level 2 --json

# add the symmetry group per layer, repeated rooms, and space-syntax integration on the access graph
$ archlang describe plan.arch --facts symmetry,syntax --json

# per element, the ids it derives from (`on`) and the `let`/parameter names it reads (`params`) — what follows a change
$ archlang describe plan.arch --facts depends --json --select depends

# wall lengths, room perimeters, net floor area (and with 10% waste), door and window counts — geometry only
$ archlang describe plan.arch --facts quantities --waste 10 --json --select quantities
```

### `archlang takeoff`

quantities as csv or md

**Input:** `<file.arch|->` · **Output:** the table on stdout, or with --json { ok, plan, units, quantities, levels?: [{ level, name?, quantities }], diagnostics } (exit 2 when the plan does not resolve)

| Flag | Does |
| --- | --- |
| `--format, -f <csv\|md>` | csv: one row per figure (`level,section,item,width_mm,field,value`, the field named as in `describe`); md: one table per section and storey (default md) |
| `--waste <pct>` | with the `quantities` fact, also report `floor_area_with_waste_m2` = the net floor area × (1 + pct/100), pct from 0 to 100; absent unless given |
| `--import-root <dir>` | read `import`ed modules from under this directory (default: the working directory); a module outside it, a non-.arch file or one over 1 MiB is refused with a diagnostic, never read |
| `--json` | structured result on stdout, messages on stderr |
| `--quiet, -q` | suppress human messages on stderr |

**Examples**

```bash
# wall lengths (centreline and face), room perimeters, net floor area, door and window counts, one figure per row
$ archlang takeoff plan.arch --format csv > takeoff.csv

# the same as Markdown tables, with the net floor area plus a 10% waste allowance you chose
$ archlang takeoff plan.arch --waste 10
```

### `archlang score`

continuous intent satisfaction (satisfied/total) as data — the refine-loop reward — or, with --taste, the plan's taste score. Measures, never gates (validate --intent is the gate).

**Input:** `<file.arch|->` · **Output:** --brief: { ok, satisfied, total, score, subscores, violations, measures? }; --taste: { profile, ok, score, uncapped, capped, validity, advisory, coverage, subscores, criteria } (exit 0 on a successful measurement, whatever the score)

| Flag | Does |
| --- | --- |
| `--brief <intent.json>` | the intent JSON to measure satisfaction against (this or --taste) |
| `--taste <generic\|cn-residential-advisory\|uk-residential-advisory\|us-residential-advisory>` | score taste instead (ADR 0032): sourced criteria in [0,1], capped at 0.5 while a validity lint warning stands; never gates (not with --brief) |
| `--import-root <dir>` | read `import`ed modules from under this directory (default: the working directory); a module outside it, a non-.arch file or one over 1 MiB is refused with a diagnostic, never read |
| `--json` | structured result on stdout, messages on stderr |
| `--quiet, -q` | suppress human messages on stderr |

**Examples**

```bash
# continuous intent satisfaction as the refine-loop reward; always exits 0 on a measurement
$ archlang score plan.arch --brief brief.json --json

# taste advice per criterion with its source and an A_* code; read after lint is clean, never a gate
$ archlang score plan.arch --taste generic --json
```

### `archlang lint`

architectural soundness warnings

**Input:** `<file.arch|->` · **Output:** W_* warnings (narrowed by --code/--severity; `filtered`/`total_diagnostics` mark a filtered result), then a `coverage` block naming the rule families skipped and why

| Flag | Does |
| --- | --- |
| `--profile <residential-basic\|accessibility-advisory\|cn-residential-advisory\|uk-residential-advisory\|us-residential-advisory>` | advisory ruleset |
| `--strict, --fail-on-warning` | warnings fail (exit 2) |
| `--rules` | print the ruleset in force and each number's source; takes no plan |
| `--code <CODE[,CODE…]>` | show only diagnostics with these codes — a DISPLAY filter: the exit code and `ok` still come from the unfiltered set |
| `--severity <error\|warning>` | show only diagnostics of this severity — a DISPLAY filter, like --code (never changes the exit code) |
| `--import-root <dir>` | read `import`ed modules from under this directory (default: the working directory); a module outside it, a non-.arch file or one over 1 MiB is refused with a diagnostic, never read |
| `--json` | structured result on stdout, messages on stderr |
| `--quiet, -q` | suppress human messages on stderr |

**Examples**

```bash
# architectural soundness warnings as data, each with a fix
$ archlang lint plan.arch --json

# gate on the accessibility ruleset (any warning exits 2)
$ archlang lint plan.arch --profile accessibility-advisory --strict

# read only the reachability warnings; the exit code still reflects every diagnostic
$ archlang lint plan.arch --code W_ROOM_UNREACHABLE,W_NO_ENTRANCE --json

# that ruleset's numbers with their sources (advisory)
$ archlang lint --rules --profile uk-residential-advisory --json
```

### `archlang ast`

parse only (no resolve/render) and print the span-bearing AST as JSON

**Input:** `<file.arch|->` · **Output:** AST JSON (scripting nodes unexpanded)

| Flag | Does |
| --- | --- |
| `--json` | structured result on stdout, messages on stderr |
| `--quiet, -q` | suppress human messages on stderr |

**Examples**

```bash
# span-bearing parse tree with no resolve or render — locate a statement by byte offset
$ archlang ast plan.arch --json
```

### `archlang complete`

completion items in scope at a source byte offset (the LSP completion() core)

**Input:** `<file.arch|->` · **Output:** { items: [...] } completion items; exits 0 on a plan that does not parse (items are still offered; run `archlang validate --json` for the diagnostics)

| Flag | Does |
| --- | --- |
| `--at <byteOffset>` | source byte offset to list completions at (required) |
| `--json` | structured result on stdout, messages on stderr |
| `--quiet, -q` | suppress human messages on stderr |

**Examples**

```bash
# what may legally be written at byte offset 120
$ archlang complete plan.arch --at 120 --json

# completions for source on stdin
$ archlang complete - --at 0 --json < plan.arch
```

### `archlang fmt`

canonical formatting

**Input:** `<file.arch|->` · **Output:** formatted source (or in place with --write); exits 0 and returns the source verbatim when it does not parse; `fmt --write` leaves the file untouched

| Flag | Does |
| --- | --- |
| `--write` | format the file in place |
| `--expected-hash <sha256>` | refuse with E_STALE_SOURCE (exit 4) unless the input file's bytes hash to this SHA-256 (`source_hash` in a --json result); checked first, under --dry-run and -o too, and again just before writing: a narrower race, not a lock |
| `--json` | structured result on stdout, messages on stderr |
| `--quiet, -q` | suppress human messages on stderr |

**Examples**

```bash
# canonical source plus a `changed` flag, nothing written
$ archlang fmt plan.arch --json

# rewrite the file in canonical form
$ archlang fmt plan.arch --write
```

### `archlang repair`

explicit source-to-source corrector (furniture out of walls) + change log

**Input:** `<file.arch|->` · **Output:** corrected source + change log on stderr; exits 0 on a plan that does not parse (nothing is changed; the reason is in `unresolved[]` of --json)

| Flag | Does |
| --- | --- |
| `--out, -o <file\|->` | output file for the corrected source, or '-' for stdout (default: stdout) |
| `--expected-hash <sha256>` | refuse with E_STALE_SOURCE (exit 4) unless the input file's bytes hash to this SHA-256 (`source_hash` in a --json result); checked first, under --dry-run and -o too, and again just before writing: a narrower race, not a lock |
| `--json` | structured result on stdout, messages on stderr |
| `--quiet, -q` | suppress human messages on stderr |

**Examples**

```bash
# the geometric corrector: `source` + a `changes[]` log of every furniture move
$ archlang repair plan.arch --json

# write the corrected source to a new file
$ archlang repair plan.arch -o repaired.arch
```

### `archlang fix`

apply the machine-applicable fix suggestions on a plan's diagnostics (bounded fixpoint)

**Input:** `<file.arch|->` · **Output:** fixed source (to the input file or -o) + a unified diff and change log on stderr

| Flag | Does |
| --- | --- |
| `--out, -o <file\|->` | output file for the fixed source, or '-' for stdout (default: rewrite the input file in place) |
| `--unsafe` | also apply `maybe-incorrect` fixes (default: machine-applicable only) |
| `--dry-run` | compute the result but do not write it (the diff preview still prints) |
| `--backup` | before rewriting a file in place, save the original bytes to &lt;file&gt;.bak |
| `--force` | keep a pass even if it raises the error count |
| `--expected-hash <sha256>` | refuse with E_STALE_SOURCE (exit 4) unless the input file's bytes hash to this SHA-256 (`source_hash` in a --json result); checked first, under --dry-run and -o too, and again just before writing: a narrower race, not a lock |
| `--import-root <dir>` | read `import`ed modules from under this directory (default: the working directory); a module outside it, a non-.arch file or one over 1 MiB is refused with a diagnostic, never read |
| `--json` | structured result on stdout, messages on stderr |
| `--quiet, -q` | suppress human messages on stderr |

**Examples**

```bash
# preview the exact unified diff `fix` would write, changing nothing on disk
$ archlang fix plan.arch --dry-run

# the same preview as data: which fixes would be applied, plus the `diff` they produce
$ archlang fix plan.arch --dry-run --json

# apply the machine-applicable fixes in place, keeping the original as plan.arch.bak
$ archlang fix plan.arch --backup --json

# also apply the maybe-incorrect fixes, leaving the input untouched
$ archlang fix plan.arch -o fixed.arch --unsafe --json

# rewrite in place only if plan.arch is still the bytes an earlier --json run reported as `source_hash`; else exit 4, E_STALE_SOURCE, nothing written
$ archlang fix plan.arch --expected-hash <source_hash> --json
```

### `archlang finish`

furnish the rooms that hold no furniture, then add the sheet statements a plan lacks (paper, scale, dims auto, title, schedule rooms, legend); deletes nothing

**Input:** `<file.arch|->` · **Output:** finished source (to the input file or -o) + a unified diff and change log on stderr

| Flag | Does |
| --- | --- |
| `--out, -o <file\|->` | output file for the finished source, or '-' for stdout (default: rewrite the input file in place) |
| `--only <sheet\|furnish>` | run only this stage (available: sheet, furnish; default: furnish, then sheet) |
| `--reissue` | allow `paper` and `scale` (nothing else) to be replaced when the drawing does not fit the authored sheet |
| `--dry-run` | compute the result but do not write it (the diff preview still prints) |
| `--backup` | before rewriting a file in place, save the original bytes to &lt;file&gt;.bak |
| `--expected-hash <sha256>` | refuse with E_STALE_SOURCE (exit 4) unless the input file's bytes hash to this SHA-256 (`source_hash` in a --json result); checked first, under --dry-run and -o too, and again just before writing: a narrower race, not a lock |
| `--import-root <dir>` | read `import`ed modules from under this directory (default: the working directory); a module outside it, a non-.arch file or one over 1 MiB is refused with a diagnostic, never read |
| `--json` | structured result on stdout, messages on stderr |
| `--quiet, -q` | suppress human messages on stderr |

**Examples**

```bash
# preview the furniture and sheet statements `finish` would add: `changes[]`, `unresolved[]` and the `diff`
$ archlang finish plan.arch --dry-run --json

# complete the drawing in place once lint is clean, keeping the original as plan.arch.bak
$ archlang finish plan.arch --backup

# preview only the furniture: one `furniture` statement per piece, and each room left empty with the reason
$ archlang finish plan.arch --only furnish --dry-run --json

# also replace a paper/scale the drawing does not fit, leaving the input untouched
$ archlang finish plan.arch --reissue -o issued.arch
```

### `archlang reroll`

offer a proven-equivalent `for` loop for a repeated statement run

**Input:** `<file.arch|->` · **Output:** suggestions (JSON or a summary), or the rewritten file with --write; exits 0 on a plan that does not parse, with `suggestions: []` (run `archlang validate --json` for the diagnostics)

| Flag | Does |
| --- | --- |
| `--write` | apply every non-overlapping suggestion and re-verify the combined result's compiled SVG is byte-identical to the original before writing (no --dry-run/--backup: a failed re-verify writes nothing, and every suggestion is already proven byte-for-byte before it is offered) |
| `--expected-hash <sha256>` | refuse with E_STALE_SOURCE (exit 4) unless the input file's bytes hash to this SHA-256 (`source_hash` in a --json result); checked first, under --dry-run and -o too, and again just before writing: a narrower race, not a lock |
| `--import-root <dir>` | read `import`ed modules from under this directory (default: the working directory); a module outside it, a non-.arch file or one over 1 MiB is refused with a diagnostic, never read |
| `--json` | structured result on stdout, messages on stderr |
| `--quiet, -q` | suppress human messages on stderr |

**Examples**

```bash
# each candidate run as { span, replacement, count, loopVar, tokensBefore, tokensAfter }
$ archlang reroll plan.arch --json

# splice in every proven loop; { ok, wrote, target, applied, skipped } (wrote/target as in `archlang fix`)
$ archlang reroll plan.arch --write --json
```

### `archlang impact`

change one number: what moved and why, what held, what broke

**Input:** `<file.arch|->` · **Output:** { ok, set?, lets, changed[] (each with its `why` dependency chain and `root`), held[], diagnostics: { broke, healed, unchanged_count }, keeps? (when either side declares a keep: { broke, held, healed, added, removed, unchanged_count }, each { keep, grade (or { before, after } when an edit changed it), level?, occurrence, residual_mm: { before, after }, at?, changed, span }; a broken hard keep is reported here, never also under diagnostics), lock? (with --lock: { ok, checked, locked, violations[] { code, id, kind, change, detail, message, before?, after? (each { span, file? }) }, refused[] { code, id, message, hint, before?, after? } }), summary } (exit 0 on a report, 2 on a plan that does not parse (`{ ok: false, diagnostics }`), a refused --set, or a lock that changed, was refused or could not be checked)

| Flag | Does |
| --- | --- |
| `--set <NAME=value>` | override the root plan's top-level `let NAME` with a numeric literal (`4500` is mm, `4.5m`) and compare the plan before and after; refused with E_SET_OVERRIDE when NAME is not exactly one top-level let |
| `--against <old.arch>` | compare the input (the new version) against this older file instead; exactly one of --set and --against |
| `--lock <id[,id…]>` | elements that must not change: exit 2 with E_LOCKED_ELEMENT_CHANGED for each that moved, resized, was re-hosted, re-thickened, changed swing or kind, vanished or appeared (a relabel is not a change), with its span on both sides; a lock on an id not written as `id=` (an assigned `room_3` shifts) is refused with E_LOCK_UNNAMED. Lowest storey only, as `changed[]`. A side that does not parse is exit 2 with `{ ok: false, diagnostics }` and no `lock` key: nothing is checked |
| `--import-root <dir>` | read `import`ed modules from under this directory (default: the working directory); a module outside it, a non-.arch file or one over 1 MiB is refused with a diagnostic, never read |
| `--json` | structured result on stdout, messages on stderr |
| `--quiet, -q` | suppress human messages on stderr |

**Examples**

```bash
# widen by one number: every moved/resized/re-hosted element with the chain that moved it, what held, what broke
$ archlang impact plan.arch --set W=4500 --json

# the same report between two versions of a plan (old.arch before, plan.arch after)
$ archlang impact plan.arch --against old.arch

# these written ids must not move, resize, re-host, swing or vanish: exit 2 with E_LOCKED_ELEMENT_CHANGED and both spans when one did
$ archlang impact plan.arch --against old.arch --lock shell,entry,w1,w2 --json
```

### `archlang suggest`

advisory door/window statements for unreachable or windowless rooms

**Input:** `<file.arch|->` · **Output:** suggestions (JSON or a summary); exits 0 on a plan that does not parse, with `suggestions: []` (run `archlang validate --json` for the diagnostics)

| Flag | Does |
| --- | --- |
| `--import-root <dir>` | read `import`ed modules from under this directory (default: the working directory); a module outside it, a non-.arch file or one over 1 MiB is refused with a diagnostic, never read |
| `--json` | structured result on stdout, messages on stderr |
| `--quiet, -q` | suppress human messages on stderr |

**Examples**

```bash
# ready-to-paste door/window statements for unreachable rooms, no entrance, or a windowless bedroom
$ archlang suggest plan.arch --json
```

### `archlang manifest` _(alias: `capabilities`)_

this document: the whole CLI API as structured data

**Input:** `none` · **Output:** the manifest (JSON or a summary)

| Flag | Does |
| --- | --- |
| `--json` | structured result on stdout, messages on stderr |

**Examples**

```bash
# discover every command, flag, format, and error code in one call
$ archlang manifest --json
```

### `archlang spec`

print the one-prompt language spec (spec.llm.md)

**Input:** `none` · **Output:** the spec

| Flag | Does |
| --- | --- |
| `--json` | structured result on stdout, messages on stderr |

**Examples**

```bash
# the whole language on one page — read this before authoring
$ archlang spec
```

### `archlang context`

print the full bundled agent context (spec + workflow + CLI + errors)

**Input:** `none` · **Output:** the full agent context (llms-full.txt), one --section of it, or the one-screen --level starter

| Flag | Does |
| --- | --- |
| `--level <starter\|full>` | starter = one screen (at most 4000 characters) for a small model: the lead example, the statements a plan needs, the loop and the five commonest errors; full = the whole 174 KB bundle (default, unchanged) |
| `--section <spec\|workflow\|cli\|errors>` | print only one section of the bundle instead of all 174 KB of it (spec = the language, 29 KB; workflow = the agent loop, 34 KB; cli = every command, 38 KB; errors = the diagnostic catalog, 72 KB) |
| `--json` | structured result on stdout, messages on stderr |

**Examples**

```bash
# the cold-start bundle: spec + workflow + CLI reference + every diagnostic
$ archlang context

# one screen for a small model: the lead example, the statements a plan needs, the loop and the five errors cold authors hit first
$ archlang context --level starter

# just the diagnostic catalog (72 KB) — read one section instead of paying for the whole 174 KB bundle
$ archlang context --section errors
```

### `archlang new` _(alias: `init`)_

scaffold a starter .arch

**Input:** `none` · **Output:** starter source

| Flag | Does |
| --- | --- |
| `--out, -o <file\|->` | output file — refuses to overwrite an existing one without --force (default: stdout) |
| `--force` | overwrite an existing file |
| `--json` | structured result on stdout, messages on stderr |
| `--quiet, -q` | suppress human messages on stderr |

**Examples**

```bash
# get the starter plan as a `template` string, writing nothing
$ archlang new --json

# scaffold a starter file to edit
$ archlang new -o plan.arch
```

### `archlang import`

convert an OpenPlan3D plan (JSON) to .arch source, reporting what it left out

**Input:** `<file.json|->` · **Output:** the .arch source (stdout or -o); warnings on stderr. With --json: { ok, format, counts, rooms, dropped, fields, notes, ids, diagnostics }, plus `source` when there is no -o

| Flag | Does |
| --- | --- |
| `--from <openplan3d>` | the format of the input file (required); openplan3d is the one there is |
| `--format <web\|handoff>` | read the file as an OpenPlan3D web project (centimetres) or prepared RoomPlan interchange file (metres) instead of detecting which, as OpenPlan3D does |
| `--out, -o <file\|->` | output file for the .arch source, or '-' for stdout (default: stdout) |
| `--json` | structured result on stdout, messages on stderr |
| `--quiet, -q` | suppress human messages on stderr |

**Examples**

```bash
# convert an OpenPlan3D export, then `archlang lint plan.arch` checks it
$ archlang import --from openplan3d plan.openplan.json -o plan.arch

# the source plus a report: per-kind counts, every dropped entity and field with its reason
$ archlang import --from openplan3d scan-openplan3d.json --json
```

### `archlang explain`

look up an error code (cause / fix / example)

**Input:** `<CODE>` · **Output:** catalog entry

| Flag | Does |
| --- | --- |
| `--json` | structured result on stdout, messages on stderr |

**Examples**

```bash
# the catalog entry for a diagnostic code: cause, fix, example
$ archlang explain E_ROOM_SIZE --json
```
