# Commands and undo

> Every change to a map is a small command, which is why undo always works and why an assistant can build maps safely.

Every change to a map, whatever made it, is a small **command**: add a part, move a zone, change a line’s rate. Hand edits, undo and redo, a scenario’s **Apply** and an assistant such as Claude all go through the same commands, which are checked before they apply.

_Diagram: Three things change a map: you editing, a scenario's Apply, and an assistant such as Claude. Each sends a command. Flozu checks it against the map's rules. If it passes, the map changes and you get one step to undo. If not, it's refused with a message, and the map stays as it was._

_Hand edits, fixes and assistants all go through the same door, so undo always works and nothing can break a map._

Dragging the Orders API across the canvas, for example, is one command: move this part to here. Applying a scenario’s fix is one command: set this part’s capacity to 126. An assistant drawing a whole map is one batch of commands. Each is checked the same way, and each is one step to undo.

## Why it matters to you

- **Undo always works.** Each gesture is one command, so one `⌘Z` puts it back. A drag is one command however far it goes. Putting a part on a line, which may move other parts to make room, is one command too.
- **A map can’t end up broken.** A command that would break one of [the map’s rules](https://docs.flozu.app/concepts/the-map.md#what-the-map-keeps-true) is refused, with a message a person can read, and the map stays as it was.
- **Changes clean up after themselves.** Removing a part removes its lines and every mention of it in views, stories and scenarios, in the same step. A failure in a scenario that has nothing left to break goes too.

Flozu keeps the last 200 steps of history for each open map, for as long as it stays open.

## The commands

| Things                  | Commands                  |
| ----------------------- | ------------------------- |
| The map                 | update, replace           |
| Parts                   | add, update, move, remove |
| Lines                   | add, update, remove       |
| Zones                   | add, update, move, remove |
| Notes                   | add, update, move, remove |
| Views                   | add, update, remove       |
| Stories and their steps | add, update, move, remove |
| Scenarios               | add, update, remove       |

A **batch** applies several commands as one step, all or nothing.

## How an assistant uses them

The commands are plain JSON, described by a JSON Schema that can be handed to an AI model as its tools. When you [connect an assistant such as Claude](https://docs.flozu.app/guides/map-your-code.md) to your account, it changes a map by sending a batch of these commands. They go through the same checks as a hand edit, so an assistant can’t break a map either. Its changes arrive as a [proposal](https://docs.flozu.app/guides/versions-and-proposals.md) for you to compare and adopt, unless you ask it to change the map itself, and then Flozu saves a version first so you can go back.
