# Deleting one element touched six things in the file

Deleting one actor from a small Archi model removes six things across two views. Miss one and Archi will not open the file.

By Arslan Rakhmatullin, Nov 9, 2026. https://arslanr.com/posts/amcli-one-delete-six-things/

The finding: Miss any of the 6 linked parts and Archi won’t open the file.

Deleting one Business Actor (a person or team in the model) from a small test model removes six things: the actor, the Assignment relationship it was part of, its boxes on two views, and the two lines drawn from those boxes. One more attribute, `targetConnections`, has to be rebuilt on the boxes those lines pointed at.[^1]

That count comes from a test in [amcli](https://github.com/arslanrakh/amcli), a CLI I built for ArchiMate models, the `.archimate` files that Archi saves. It reads, edits, checks and draws them without Archi or a JVM. The README says it is built for AI agents.

## Why the agent stays out of the XML

The amcli skill has a blunt rule: never read a `.archimate` file with Read or cat.[^2] Its description gives the reasons. These files run to megabytes, reading one wastes context, and an edit by hand corrupts the model so that Archi refuses to open it.[^3]

The delete shows how. In the test file the actor is one line. Its id also sits on three other lines: as the `source` of the relationship, and in the `archimateElement` attribute of a box on each of two views. The relationship's id sits in the `archimateRelationship` attribute of two lines on those views. Delete the element line alone and those ids name nothing. Archi then refuses to open the model.

This is not hypothetical. The commit that added amcli's edits calls it the worst bug in the tool amcli replaced. That tool deleted concepts and left those references dangling.

Some of the damage is quieter. `targetConnections` lists the lines that point at a box, a copy of what the lines already say. A comment in the code says Archi tolerates a stale one in memory but fails on it at load. amcli does not patch it. It rebuilds it from the lines that survive.[^4]

An agent editing the XML would have to find all of that itself, on every delete. The CLI finds it once, in code that has a test.

## What a checked edit gives the agent

A delete that would take other things with it is refused by default. The refusal is the impact report, and `-y` runs the delete once the agent has read it.

Every new relationship is checked against ArchiMate's rules for which element types may connect, and how. A duplicate of the same type between the same pair is refused, and so are mixed types at a junction. The refusal names what is permitted between those two types, so the agent's next call can be the right one.

Exit codes name the failure (not found, ambiguous, invalid, a conflict), and each comes with the next step: the nearest names, or the candidates with an id to paste.

`amcli apply` takes a JSONL batch and writes once. If any line fails, the file is byte-identical.[^5] Bytes an edit did not touch stay as they were, so renaming one element changes one line in git.

At the end, `amcli validate` reports its findings, with the line in the file and a `fix` command where it has one. For a relationship whose end no longer exists, that is `amcli relation delete` and the id.

## What to copy

- **Keep agents out of files where one fact sits in several places.** Give the agent a command that changes all of them, and say in the skill not to open the file.
- **Make the refusal teach.** An error that names the allowed option saves the agent a guess. Exit codes let it branch without parsing text.
- **Test what the target app will load.** amcli's tests reopen the model after edits. Its identity test asserts that parsing and writing every real Archi file in the test corpus changes no byte.

96 of the repo's 102 commits carry a Claude co-author line. The tool is Apache-2.0, and releases are still 0.x.

If your agents edit a file that another program has to open, count how many places one delete has to touch.

[^1]: The test that counts the six. https://github.com/arslanrakh/amcli/blob/3487b6dfdb1a5159723054ab8295e2b0aa8037b2/crates/amcli-model/tests/edit.rs#L146
[^2]: The rule. https://github.com/arslanrakh/amcli/blob/3487b6dfdb1a5159723054ab8295e2b0aa8037b2/skills/amcli/SKILL.md#L35
[^3]: The reasons, in the skill's description. https://github.com/arslanrakh/amcli/blob/3487b6dfdb1a5159723054ab8295e2b0aa8037b2/skills/amcli/SKILL.md#L14
[^4]: Rebuild, don't patch. https://github.com/arslanrakh/amcli/blob/3487b6dfdb1a5159723054ab8295e2b0aa8037b2/crates/amcli-model/src/edit.rs#L737
[^5]: Atomic batches. https://github.com/arslanrakh/amcli/blob/3487b6dfdb1a5159723054ab8295e2b0aa8037b2/README.md#L94
