Co-editing
How a person in the Studio and an agent over MCP or the CLI edit the same project without losing each other's work, with the journal, SHA-256 checks, pins and layers.
Most art tools assume one person at one keyboard. Mode 8 assumes a team: you painting in the Studio, a coding agent wiring sprites into the game, a script exporting atlases, all on the same project at the same time. This page shows how that stays safe: every edit is journaled and undoable, a write that would overwrite someone else's change is refused, and hand-painted pixels survive the next AI pass.
The examples use --json and MCP calls, because that is what an agent reads.
Three doors, the same files#
There is no hidden state. A project is a folder, and every door into it ends at the same files:
| Who | Door | Recorded as |
|---|---|---|
| A person | mode8 studio, the browser editor | human |
| An agent | mode8 mcp, the mode8_project_* tools | agent |
| Scripts and starters | mode8 layers, mode8 import, mode8 init --template | cli (mode8 layers --actor can say otherwise) |
The Studio watches the folder. When an agent saves a sprite, the open canvas updates; when you paint, the agent sees your pixels and their new hash the next time it reads the asset.
The journal#
Every edit made through Mode 8 is appended to .mode8/history.jsonl: who made it, what it did, which files it touched, and each file's SHA-256 before and after. The old versions are kept in .mode8/snapshots/, so any edit can be undone exactly. Undo is itself an entry, so history is never rewritten.
A real conflict#
Start from a starter project, so there is a hero to edit:
$ mode8 init my-game --template platformer
✓ Created the platformer starter in my-game/
26 assets · palette nes_master_gothic · lint 26/26 passed
hero, slime, ground, wall, window, pillar, ledge_left, ledge, ledge_right, stairs, +6 more + 10 UI pieces
UI kit → my-game/godot/art/ui/ · font → my-game/godot/art/font/
Godot project → my-game/godot/ (runs main.tscn)
Next:
cd my-game
godot -e --path godot
mode8 studio .
mode8 export hero
$ cd my-gameThe agent reads the hero and remembers the master's SHA-256:
$ mode8 layers list --asset hero --json
{
"ok": true,
"asset": "hero",
"layered": false,
"layer_count": 0,
"layers": null,
"master_sha256": "bcf4ffa3f8fb5910d59db0b799a25ffbfce5f4deb5dd35f50f7153a625493bbe",
"can_undo": true,
"can_redo": false,
"next_undo_op": "create_asset",
"next_redo_op": null,
"undo_deletes_asset": true,Show 5 more lines
"next_undo_label": "Create asset",
"next_redo_label": null,
"undo_restores_asset": null,
"project_defaults": {"project_root": "/home/you/work/my-game"}
}Meanwhile, a person changes the hero. They repaint the blue cloak crimson, with colors from the project's palette, on a new layer. (In real life this happens in the Studio; the CLI with --actor human stands in for it here.)
{"#1d438c": "#86101f", "#2370bd": "#c22823", "#50a7e2": "#e26847"}$ mode8 recolor assets/hero/master.png --color-map red-cloak.json --out-dir edits
✓ Recolored 1 sprite → edits/
3 colors mapped
! 11 colors had no mapping and were kept
Next:
mode8 export edits --out-dir exports/edits --name edits
$ mode8 layers add --asset hero --image-path edits/master.png --name "Red cloak" --actor human --json
{
"ok": true,
"action": "add",
"asset": "hero",
"sha256": "bcf4ffa3f8fb5910d59db0b799a25ffbfce5f4deb5dd35f50f7153a625493bbe",
"previous_sha256": "bcf4ffa3f8fb5910d59db0b799a25ffbfce5f4deb5dd35f50f7153a625493bbe",
"entry_id": "20261202T003726539973-dcd6d1bc",
"layers": [
{
"id": "base",
"name": "Base",
"file": "base.png",Show 17 more lines
"visible": true,
"opacity": 255,
"sha256": "bcf4ffa3f8fb5910d59db0b799a25ffbfce5f4deb5dd35f50f7153a625493bbe"
},
{
"id": "layer-1",
"name": "Red cloak",
"file": "layer-1.png",
"visible": true,
"opacity": 255,
"sha256": "bcf4ffa3f8fb5910d59db0b799a25ffbfce5f4deb5dd35f50f7153a625493bbe"
}
],
"layer_id": "layer-1",
"index": 1,
"project_defaults": {"project_root": "/home/you/work/my-game"}
}The master's hash changed. The agent now writes its own edit, a new shading layer, passing the hash it read (--actor agent records it as the agent's, as the MCP tools do):
$ mode8 layers add --asset hero --name Shading --actor agent --expected-sha256 9ec722ff339fbf4f930fe31e130560ec5cdec7ba712cc7204196b2346bf6b28e --json
{
"ok": false,
"error": {
"type": "ConflictError",
"msg": "conflict on assets/hero/master.png: expected sha256 9ec722ff339fbf4f930fe31e130560ec5cdec7ba712cc7204196b2346bf6b28e, found bcf4ffa3f8fb5910d59db0b799a25ffbfce5f4deb5dd35f50f7153a625493bbe",
"conflict": true,
"path": "assets/hero/master.png",
"expected_sha256": "9ec722ff339fbf4f930fe31e130560ec5cdec7ba712cc7204196b2346bf6b28e",
"actual_sha256": "bcf4ffa3f8fb5910d59db0b799a25ffbfce5f4deb5dd35f50f7153a625493bbe",
"hint": "the file changed since you read it; read it again and retry with the new SHA-256"
}
}Mode 8 refuses with a ConflictError (exit 3, HTTP 409 in the Studio) and touches nothing: the file is no longer what the agent saw. The agent recovers the right way: it reads the asset again, redoes its change on top of the person's version, and writes with the new hash:
$ mode8 layers list --asset hero --json > hero.json
$ mode8 layers add --asset hero --name Shading --actor agent --json --expected-sha256 "$(python3 -c 'import json; print(json.load(open("hero.json"))["master_sha256"])')"
{
"ok": true,
"action": "add",
"asset": "hero",
"sha256": "bcf4ffa3f8fb5910d59db0b799a25ffbfce5f4deb5dd35f50f7153a625493bbe",
"previous_sha256": "bcf4ffa3f8fb5910d59db0b799a25ffbfce5f4deb5dd35f50f7153a625493bbe",
"entry_id": "20261202T003727615330-a9267ff5",
"layers": [
{
"id": "base",
"name": "Base",
"visible": true,Show 25 more lines
"opacity": 255,
"file": "base.png",
"sha256": "bcf4ffa3f8fb5910d59db0b799a25ffbfce5f4deb5dd35f50f7153a625493bbe"
},
{
"id": "layer-1",
"name": "Red cloak",
"visible": true,
"opacity": 255,
"file": "layer-1.png",
"sha256": "bcf4ffa3f8fb5910d59db0b799a25ffbfce5f4deb5dd35f50f7153a625493bbe"
},
{
"id": "layer-2",
"name": "Shading",
"file": "layer-2.png",
"visible": true,
"opacity": 255,
"sha256": "ea332466a439a025affa07042ef000705b827c7b00c2fe219dfcdb61e51e7195"
}
],
"layer_id": "layer-2",
"index": 2,
"project_defaults": {"project_root": "/home/you/work/my-game"}
}Both edits survive, and the journal says who did what.
Important
Never "fix" a conflict by writing again without expected_sha256. The conflict is the system working: it means a person just changed the art.
Every write can carry the hash it expects: --expected-sha256 on each mode8 layers command (plus --expected-layer-sha256 on layers set for one layer's file), and expected_sha256 on the MCP project tools and the Studio routes.
History and undo#
Undo and redo work per asset, and the stack is shared: undo reverts the newest change to that asset, whoever made it. In the Studio that is Ctrl+Z and Ctrl+Y. An agent uses mode8_project_history, mode8_project_undo and mode8_project_redo; the CLI has no undo command.
To call them by hand, use the small client from MCP server:
import asyncio, json, os, sys
from mcp import ClientSession, StdioServerParameters
from mcp.client.stdio import stdio_client
async def main(tool: str, args: dict) -> None:
server = StdioServerParameters(command="mode8", args=["mcp"], env=dict(os.environ))
async with stdio_client(server) as (read, write):
async with ClientSession(read, write) as session:
await session.initialize()
result = await session.call_tool(tool, args)
for block in result.content:
if block.type == "text":
print(json.dumps(json.loads(block.text), ensure_ascii=False))
else:
print(f"[{block.type} {block.mime_type}, {len(block.data)} bytes of base64]")
asyncio.run(main(sys.argv[1], json.loads(sys.argv[2])))The hero's journal, oldest edit first: the starter created it (cli), the person added a layer (human), the agent added one (agent). The refused write left no entry.
$ python mcp_call.py mode8_project_history '{"project_root": ".", "asset": "hero", "limit": 3}'
{
"ok": true,
"tool": "mode8_project_history",
"asset": "hero",
"count": 3,
"entries": [
{
"id": "20261202T003720624707-38487da5",
"ts": "2026-12-02T00:37:20.624Z",
"actor": "cli",
"op": "create_asset",
"target_file": "assets/hero/master.png",Show 50 more lines
"before_sha256": null,
"after_sha256": "bcf4ffa3f8fb5910d59db0b799a25ffbfce5f4deb5dd35f50f7153a625493bbe",
"files": ["assets/hero/master.png", "assets/hero/draft.png"],
"sidecar_keys": [
"schema", "name", "size", "palette", "prompt", "preset", "seed", "draft",
"lint", "input_hashes", "created_at", "art_type", "starter_art",
"archetype", "facing", "starter"
],
"meta": {}
},
{
"id": "20261202T003726539973-dcd6d1bc",
"ts": "2026-12-02T00:37:26.539Z",
"actor": "human",
"op": "layer_add",
"target_file": "assets/hero/master.png",
"before_sha256": "bcf4ffa3f8fb5910d59db0b799a25ffbfce5f4deb5dd35f50f7153a625493bbe",
"after_sha256": "bcf4ffa3f8fb5910d59db0b799a25ffbfce5f4deb5dd35f50f7153a625493bbe",
"files": [
"assets/hero/layers/base.png", "assets/hero/layers/layer-1.png",
"assets/hero/layers/layers.json", "assets/hero/master.png"
],
"sidecar_keys": [],
"meta": {"index": 1, "initialized": true, "layer_id": "layer-1"}
},
{
"id": "20261202T003727615330-a9267ff5",
"ts": "2026-12-02T00:37:27.615Z",
"actor": "agent",
"op": "layer_add",
"target_file": "assets/hero/master.png",
"before_sha256": "bcf4ffa3f8fb5910d59db0b799a25ffbfce5f4deb5dd35f50f7153a625493bbe",
"after_sha256": "bcf4ffa3f8fb5910d59db0b799a25ffbfce5f4deb5dd35f50f7153a625493bbe",
"files": [
"assets/hero/layers/layer-2.png", "assets/hero/layers/layers.json",
"assets/hero/master.png"
],
"sidecar_keys": [],
"meta": {"index": 2, "layer_id": "layer-2"}
}
],
"can_undo": true,
"can_redo": false,
"next_undo_op": "layer_add",
"next_redo_op": null,
"undo_deletes_asset": false,
"next_undo_label": "Add layer",
"next_redo_label": null,
"undo_restores_asset": null
}Undo the agent's shading layer:
$ python mcp_call.py mode8_project_undo '{"project_root": ".", "asset": "hero"}'
{
"ok": true,
"tool": "mode8_project_undo",
"action": "undo",
"asset": "hero",
"entry_id": "20261202T003730760458-6d88b9fa",
"undoes": "20261202T003727615330-a9267ff5",
"op": "layer_add",
"actor": "agent",
"sha256": "bcf4ffa3f8fb5910d59db0b799a25ffbfce5f4deb5dd35f50f7153a625493bbe",
"drift": [],
"exists": true,Show 42 more lines
"summary": {
"name": "hero",
"size": [64, 72],
"palette": "nes_master_gothic",
"art_type": "sprite",
"master_sha256": "bcf4ffa3f8fb5910d59db0b799a25ffbfce5f4deb5dd35f50f7153a625493bbe",
"has_draft": true,
"has_parts": false,
"has_pins": false,
"has_rig": false,
"frame_count": 15,
"override_count": 0,
"stale": false,
"can_undo": true,
"can_redo": true
},
"lint": {
"file": "assets/hero/master.png",
"size": [64, 72],
"pass": true,
"errors": [],
"warnings": [],
"metrics": {
"opaque_pixels": 1888,
"colors": 11,
"components": 1,
"draft_iou": 0.798,
"draft_iou_mirrored": 0.529,
"pose_match": 0.798
}
},
"can_undo": true,
"can_redo": true,
"next_undo_op": "layer_add",
"next_redo_op": "layer_add",
"undo_deletes_asset": false,
"next_undo_label": "Add layer",
"next_redo_label": "Add layer",
"undo_restores_asset": null,
"switch_to": null
}
[image image/png, 4408 bytes of base64]Things to know:
- A layer edit is one step. Undoing it restores the layer files,
layers.jsonand the master together. driftlists files that changed outside Mode 8 since that entry (another program wrote them). The undo still restores them and tells you.- A new edit clears redo, as in any editor.
- Nothing to undo is an input error,
NothingToUndoErrororNothingToRedoError(exit2). Every asset report carriescan_undoandcan_redo, so check first.
Pins#
A person's careful pixel work should survive the next AI pass. The Studio pins hand-painted pixels in the asset's pins.png mask. mode8_project_save_master and mode8_project_save_layer keep respect_pins on by default, so pinned pixels are put back after an agent's write, and the report counts them (pinned_pixels, pinned_preserved). On the CLI, mode8 inpaint --pins does the same when it repaints a region.
Layers#
Any asset can become a stack of up to 32 layers, kept in assets/<name>/layers/: a layers.json that lists them bottom to top, and one PNG per layer. The rule that makes layers safe for every other tool: master.png is always the visible layers, flattened. Exports, checks and animation keep working on the master and never need to know about layers.
The stack the example left behind, after the undo:
$ mode8 layers list --asset hero --json
{
"ok": true,
"asset": "hero",
"layered": true,
"layer_count": 2,
"layers": [
{
"id": "base",
"name": "Base",
"visible": true,
"opacity": 255,
"file": "base.png",Show 22 more lines
"sha256": "bcf4ffa3f8fb5910d59db0b799a25ffbfce5f4deb5dd35f50f7153a625493bbe"
},
{
"id": "layer-1",
"name": "Red cloak",
"visible": true,
"opacity": 255,
"file": "layer-1.png",
"sha256": "bcf4ffa3f8fb5910d59db0b799a25ffbfce5f4deb5dd35f50f7153a625493bbe"
}
],
"master_sha256": "bcf4ffa3f8fb5910d59db0b799a25ffbfce5f4deb5dd35f50f7153a625493bbe",
"can_undo": true,
"can_redo": true,
"next_undo_op": "layer_add",
"next_redo_op": "layer_add",
"undo_deletes_asset": false,
"next_undo_label": "Add layer",
"next_redo_label": "Add layer",
"undo_restores_asset": null,
"project_defaults": {"project_root": "/home/you/work/my-game"}
}Every layer command takes --asset (and --project-root when you run it from outside the project), --actor for the journal, and --expected-sha256:
| Command | What it does |
|---|---|
mode8 layers list | Print the stack, bottom to top, and the master's SHA-256 |
mode8 layers add | Add a layer from a PNG of the canvas size (--image-path), or a blank one; a flat asset becomes a stack first |
mode8 layers set | Change a layer's pixels (--image-path), --name, --opacity, --visible or --hidden |
mode8 layers reorder | Put the stack in a new order (--order, every id, bottom to top) |
mode8 layers merge-down | Merge a layer into the one below it |
mode8 layers delete | Delete a layer (never the last one) |
mode8 layers flatten | Drop the stack and keep the flattened master |
Fade the person's cloak layer to half strength:
$ mode8 layers set --asset hero --layer-id layer-1 --opacity 128 --json
{
"ok": true,
"action": "set",
"asset": "hero",
"sha256": "bcf4ffa3f8fb5910d59db0b799a25ffbfce5f4deb5dd35f50f7153a625493bbe",
"previous_sha256": "bcf4ffa3f8fb5910d59db0b799a25ffbfce5f4deb5dd35f50f7153a625493bbe",
"entry_id": "20261202T003731682929-05ec8fc7",
"layers": [
{
"id": "base",
"name": "Base",
"visible": true,Show 17 more lines
"opacity": 255,
"file": "base.png",
"sha256": "bcf4ffa3f8fb5910d59db0b799a25ffbfce5f4deb5dd35f50f7153a625493bbe"
},
{
"id": "layer-1",
"name": "Red cloak",
"visible": true,
"opacity": 128,
"file": "layer-1.png",
"sha256": "bcf4ffa3f8fb5910d59db0b799a25ffbfce5f4deb5dd35f50f7153a625493bbe"
}
],
"layer_id": "layer-1",
"entries": ["20261202T003731682929-05ec8fc7"],
"project_defaults": {"project_root": "/home/you/work/my-game"}
}Over MCP the same operations are mode8_project_layers (read), mode8_project_save_layer (paint or add one layer) and mode8_project_edit_layers (everything else). In the Studio they are the Layers panel.
Because the master of a layered asset is made from its layers, replacing it directly is refused with a LayeredAssetError, so nobody's layer is silently thrown away:
$ python mcp_call.py mode8_project_save_master '{"project_root": ".", "asset": "hero", "image_path": "edits/master.png"}'
{
"ok": false,
"tool": "mode8_project_save_master",
"error": {
"type": "LayeredAssetError",
"msg": "asset 'hero' has 2 layers; edit a layer or pass on_layers='flatten'",
"layered": true,
"asset": "hero",
"layer_count": 2,
"hint": "this asset has a layer stack: pass on_layers='flatten' to mode8_project_save_master to replace the master and drop the layers (one undo restores them), or edit a single layer with mode8_project_save_layer"
}
}Edit one layer instead (mode8_project_save_layer). Pass on_layers as flatten only when a person asked to throw the layers away; even then, one undo brings them back. Layer stacks also travel to and from Aseprite: see Bring in your art.
What breaks the safety#
These all work, but they skip the journal and the conflict check:
- Writing
master.png,layers/*.pngor a sidecar with another program while the project is in use. - Retrying a write without
expected_sha256after a conflict. - Editing the
versioninmode8.toml.
If a file does change behind Mode 8's back, the Studio still picks it up and the next undo lists it under drift. But that change has no journal entry, so it cannot be undone.
Next#
- MCP server: connect an agent.
- Skill and scripts: exit codes and error types.
- Projects: where the journal, snapshots and layers live.