Edit an existing plan
Change a .arch file without breaking what already works.
If archlang is not on the path, write npx -y @chanmeng666/archlang in its place.
Never run a bare arch: on Linux, macOS and Git Bash that name is the coreutils command.
This skill is a workflow, not a language reference. Run archlang spec for the language and
archlang <cmd> --help for a command's flags.
Scope
- Run the
archlang CLI commands below and no other program.
- Change the one
.arch file the user asked you to edit (plan.arch below). If the user has not
named it, ask. Besides it, write only the drawing the CLI renders and the .bak copy that
--backup keeps.
- The user's explicit instructions take priority over these steps.
Steps
- Record the starting state. Run
archlang validate plan.arch --json and
archlang describe plan.arch --select rooms,totals --json. Keep both results: they are what you
compare against at the end. If the plan already has errors, tell the user before you edit.
- Choose the locks, then check the edit. Before you edit, list the ids the request does not
name: those are the locks. For a change to one top-level
let, ask first, with nothing written:
archlang impact plan.arch --set NAME=value --lock <ids> --json. For any other edit, make it in a
copy new.arch and check it after: archlang impact new.arch --against plan.arch --lock <ids> --json. Exit 2 with E_LOCKED_ELEMENT_CHANGED names a locked element the edit moves: change the
edit, not the lock. A lock names elements by the id= written in the source (an unnamed one is
refused with E_LOCK_UNNAMED).
- Read only what the change touches.
archlang describe plan.arch --room <ids> --json returns
those rooms with the doors, windows and furniture that touch them.
archlang describe plan.arch --select freedom --json says which positions the author typed
(absolute) and which the compiler derives. Change a typed number; a derived one moves by
itself when the thing it depends on moves.
- Read the language for the forms you will write.
archlang spec.
- Make the smallest edit. Change the statements the request names and leave the rest as they
are: same ids, same order, same comments. Do not reformat the file and do not rewrite
statements you were not asked to change. When a room changes size, check the walls, doors,
windows and neighbouring rooms that share its edges.
- Compile.
archlang compile plan.arch -o plan.svg --json. If ok is false, preview the
mechanical fixes with archlang fix plan.arch --dry-run --json and read the diff before you apply
them with archlang fix plan.arch --backup.
- Move furniture out of the way if needed. If the edit pushed a piece into a wall, a doorway
or a door swing,
archlang repair plan.arch -o plan.arch moves it. Read unresolved for the pieces
it could not move.
- Verify the change and nothing else. Run the two commands from step 1 again, and
the
impact check from step 2 on the edited file. The rooms you meant to change differ as
intended. Every other room has the same area and the same connections. No diagnostic is new unless the request causes it; if one is, tell the user.
- Refresh the sheet if the drawing grew.
archlang finish plan.arch --dry-run --json shows what
is missing. If it reports that the drawing no longer fits the authored paper or scale,
archlang finish plan.arch --reissue may replace those two statements and nothing else.
When another agent may edit the same file
Pass the file's current revision as --expected-hash <hash>, as in
archlang fix plan.arch --expected-hash <hash> --json. The --json result of each command that
rewrites the file (fix, finish, repair -o plan.arch, fmt --write) says which hash that is:
source_hash is the file as the command read it, and written_hash the file once the command has
written it. A result that hands you rewritten text instead (repair --json, a --dry-run, or the
MCP repair, fix and finish tools) gives output_hash, the file's revision once you write that
text to it unchanged. archlang fmt plan.arch --json reports source_hash without writing. If the
file changed since, the command writes nothing and exits 4 with E_STALE_SOURCE: read the file
again, redo your edit on what is there now, and use the new hash. This narrows the window for a
clash; it is not a lock.
Report to the user
- The statements you changed, as a short diff.
- Before and after for the facts the request is about (for example the room's area).
- Any new warning, and whether the request causes it.
When something goes wrong
- Exit code
2 is a fault in the source: read the diagnostic, do not retry unchanged. 3 is a
wrong flag: run archlang <cmd> --help.
archlang explain <CODE> --json explains a diagnostic code.
- If the request needs a new door or window and you are unsure where it can go,
archlang suggest plan.arch --json returns candidates with the reason for each.
1---2name: archlang-edit-plan3description: Use when the user wants to change an existing ArchLang .arch floor plan, e.g. "make the bedroom 1 m wider", "add a bathroom next to the hall", "move the front door to the south wall", "merge the kitchen into the living room". Reads the plan's facts with the archlang CLI, makes the smallest edit that does the job, and re-verifies. Not for writing a plan from a brief (archlang-brief-to-plan).4license: MIT5compatibility: Needs a shell with Node 18+ and the archlang CLI (npx -y @chanmeng666/archlang, or npm i -g @chanmeng666/archlang for a global archlang).6metadata:7 source: https://skillmd.com/skills/chanmeng666/archlang-edit-plan8---910# Edit an existing plan1112Change a `.arch` file without breaking what already works.13If `archlang` is not on the path, write `npx -y @chanmeng666/archlang` in its place.14Never run a bare `arch`: on Linux, macOS and Git Bash that name is the coreutils command.1516This skill is a workflow, not a language reference. Run `archlang spec` for the language and17`archlang <cmd> --help` for a command's flags.1819## Scope2021- Run the `archlang` CLI commands below and no other program.22- Change the one `.arch` file the user asked you to edit (`plan.arch` below). If the user has not23 named it, ask. Besides it, write only the drawing the CLI renders and the `.bak` copy that24 `--backup` keeps.25- The user's explicit instructions take priority over these steps.2627## Steps28291. **Record the starting state.** Run `archlang validate plan.arch --json` and30 `archlang describe plan.arch --select rooms,totals --json`. Keep both results: they are what you31 compare against at the end. If the plan already has errors, tell the user before you edit.322. **Choose the locks, then check the edit.** Before you edit, list the ids the request does not33 name: those are the locks. For a change to one top-level `let`, ask first, with nothing written:34 `archlang impact plan.arch --set NAME=value --lock <ids> --json`. For any other edit, make it in a35 copy `new.arch` and check it after: `archlang impact new.arch --against plan.arch --lock <ids>36 --json`. Exit `2` with `E_LOCKED_ELEMENT_CHANGED` names a locked element the edit moves: change the37 edit, not the lock. A lock names elements by the `id=` written in the source (an unnamed one is38 refused with `E_LOCK_UNNAMED`).393. **Read only what the change touches.** `archlang describe plan.arch --room <ids> --json` returns40 those rooms with the doors, windows and furniture that touch them.41 `archlang describe plan.arch --select freedom --json` says which positions the author typed42 (`absolute`) and which the compiler derives. Change a typed number; a derived one moves by43 itself when the thing it depends on moves.444. **Read the language for the forms you will write.** `archlang spec`.455. **Make the smallest edit.** Change the statements the request names and leave the rest as they46 are: same ids, same order, same comments. Do not reformat the file and do not rewrite47 statements you were not asked to change. When a room changes size, check the walls, doors,48 windows and neighbouring rooms that share its edges.496. **Compile.** `archlang compile plan.arch -o plan.svg --json`. If `ok` is false, preview the50 mechanical fixes with `archlang fix plan.arch --dry-run --json` and read the diff before you apply51 them with `archlang fix plan.arch --backup`.527. **Move furniture out of the way if needed.** If the edit pushed a piece into a wall, a doorway53 or a door swing, `archlang repair plan.arch -o plan.arch` moves it. Read `unresolved` for the pieces54 it could not move.558. **Verify the change and nothing else.** Run the two commands from step 1 again, and56 the `impact` check from step 2 on the edited file. The rooms you meant to change differ as57 intended. Every other room has the same area and the same connections. No diagnostic is new unless the request causes it; if one is, tell the user.589. **Refresh the sheet if the drawing grew.** `archlang finish plan.arch --dry-run --json` shows what59 is missing. If it reports that the drawing no longer fits the authored `paper` or `scale`,60 `archlang finish plan.arch --reissue` may replace those two statements and nothing else.6162## When another agent may edit the same file6364Pass the file's current revision as `--expected-hash <hash>`, as in65`archlang fix plan.arch --expected-hash <hash> --json`. The `--json` result of each command that66rewrites the file (`fix`, `finish`, `repair -o plan.arch`, `fmt --write`) says which hash that is:67`source_hash` is the file as the command read it, and `written_hash` the file once the command has68written it. A result that hands you rewritten text instead (`repair --json`, a `--dry-run`, or the69MCP `repair`, `fix` and `finish` tools) gives `output_hash`, the file's revision once you write that70text to it unchanged. `archlang fmt plan.arch --json` reports `source_hash` without writing. If the71file changed since, the command writes nothing and exits `4` with `E_STALE_SOURCE`: read the file72again, redo your edit on what is there now, and use the new hash. This narrows the window for a73clash; it is not a lock.7475## Report to the user7677- The statements you changed, as a short diff.78- Before and after for the facts the request is about (for example the room's area).79- Any new warning, and whether the request causes it.8081## When something goes wrong8283- Exit code `2` is a fault in the source: read the diagnostic, do not retry unchanged. `3` is a84 wrong flag: run `archlang <cmd> --help`.85- `archlang explain <CODE> --json` explains a diagnostic code.86- If the request needs a new door or window and you are unsure where it can go,87 `archlang suggest plan.arch --json` returns candidates with the reason for each.