zterm

Squad demo

This page is a prompt for a leader agent. The leader runs a squad of three more agents in zterm, and together they build a small browser game from an empty folder. Each agent works in its own pane, where you can watch it.

To run it, start a coding agent in a zterm pane, in the folder where the game should go, and paste everything below the line as its first message. The prompt needs zterm, zspawn, zc, Git and Node, at least one agent harness that zspawn can start, and the coordinate, squad, spawn, terminal and worktrees skills. zspawn --list shows the harnesses this machine has. See zspawn.

Early on, the leader asks you one question: which atmosphere the game has. It appears in Needs you in zterm's panel. Click it to see the three atmospheres, each with a line on its look and the leader's pick marked, then choose one and press Send. Your answer changes the finished game's colors and light. If you don't answer within three minutes, the leader takes the recommended one and says so. After the answer, a tracker opens beside the leader's pane. It shows each ticket's owner, state, latest commit and test result, and it updates while the agents work in the squad tab.

zterm's onboarding wizard runs this same prompt when you choose Build Cellar Crawl.


You lead a squad. Build Cellar Crawl: The Hollow Below, a finished browser dungeon game, from scratch in this folder. This demonstrates zterm squads: three agents own real parts of the game, and you integrate their work.

The operator is the person who started you. Use three agents besides yourself, unless printenv CELLAR_CRAWL_AGENTS gives a lower limit, which counts only the agents you start. With a lower limit, run the same three roles in turn. Start each one with zspawn <harness> --approve, using the harness you run in unless the operator names another. The operator chose this folder, so --approve trusts it and the agents' worktrees without asking. The design below is approved. Make routine decisions yourself and finish the work. Stop only for a missing prerequisite, an ownership conflict, or a decision outside this brief.

Within a few minutes of starting, write the contract, commit it, create the milestone, open the question below, and start the engine and interface agents. Start the art agent once the question is settled. If git has no user name in this folder, set one for this folder only.

The game

Opening index.html in a browser starts the game, with no build step, server, network or external font. It is plain HTML, CSS and JavaScript, with a Canvas 2D world.

It is a short, turn-based expedition through three seeded floors:

  1. The Wine Cellar: warm stone, casks, rats and the first skeleton.
  2. The Catacombs: cooler, mossy stone and harder fights.
  3. The Hollow: a Warden guarding a sealed relic.

The player carries a torch. Line of sight and distance decide what is visible, explored rooms stay dimly remembered, and unexplored tiles are black. Monsters outside the light are hidden. The player collects gold, carries healing flasks, chooses a blessing between floors, and wins by defeating the Warden and claiming its relic. Zero health ends the run.

Time passes only on an accepted action, so a wall bump costs nothing. Moving into an enemy attacks it. Rats chase and bite; skeletons and the Warden mark the player's tile and strike it next turn, so the player can step away. Enemies path around walls and each other, and never attack as a floor opens. A monster blocked by another waits that turn and tries again on the next. Damage taken counts only the health the player actually lost.

Controls: arrows or WASD move and attack; Space or period waits; H drinks a flask, healing up to 6 (refused at full health or with no flask); E or Enter takes the stairs or claims the relic underfoot; 1, 2 and 3 choose a blessing; R replays the seed. R and New Seed both ask first during a run. Escape closes the victory and death panels, and Space presses a focused button. Every action also has a labeled on-screen button for touch.

The player starts with 14 health, attack 3 and one flask. Vigor adds 4 maximum health and heals 4, Edge adds 1 attack, and Flask gives a flask and heals 4. A run takes 5 to 10 minutes. Floors are fully connected, and no enemy spawns next to the player.

The look

The atmosphere the operator chooses sets the palette and the light. The default, Torchlit Cellar, is parchment text on near-black charcoal, with amber highlights, muted teal and red for danger. A serif title with one italic amber word, small uppercase labels, and short, atmospheric copy.

Canvas draws original sprites for the explorer, rats, skeletons, the Warden, flasks, coins, stairs and the relic, never letters. Stone has texture, the torch flickers, wounded enemies show health bars, and a next-turn attack is marked by shape as well as colour. Drawing never changes the game or uses its randomness.

The HTML around the map shows health, gold, flasks, attack, kills, the floor, the turn, a short journal and the seed, which the player can type, replay or replace. Panels cover the welcome, a field guide, blessings, restart, victory and death. A live region announces events, and reduced motion stops the ambient animation. On a phone screen of 320 by 812 or 375 by 812 pixels, the map and the movement buttons fit on screen together. Typing a seed or reading a panel never moves the player.

The question

Ask the operator which atmosphere the game has, on the board, so it appears in Needs you in zterm's panel and the operator answers it there. Offer three, with a name and a line each:

  • Torchlit Cellar (recommended): parchment text on charcoal, amber torchlight.
  • Frozen Crypt: frost-white text on blue-black stone, cold blue light.
  • Drowned Temple: pale text on green-black stone, sea-green light, coral for danger.

File it with zc ask <milestone> "Which atmosphere?" --of <operator> --why "It sets the finished game's colors and light." --option "Torchlit Cellar" --option "Frozen Crypt" --option "Drowned Temple" --detail "1: <its line>" --detail "2: <its line>" --detail "3: <its line>" --recommend 1. Each --detail is that atmosphere's line above, and the operator is your own owner in zc principals. Tell the operator the question is in the panel's Needs you, and that you take the recommended pick if no answer comes in three minutes. The answer reaches you in zc read as the operator's reply to the ask. If none comes, take Torchlit Cellar, say so, and take the ask back with zc retract <ask id> --reason "no answer in three minutes; took Torchlit Cellar". Then open the tracker beside your pane, put the palette in CONTRACT.md's look section, commit, and tell the interface agent. The art agent's first prompt names the atmosphere.

The contract

Before any agent starts, write and commit a short CONTRACT.md: the rules, this interface, the state shape, the turn order, the script order and who owns which file. Commit this folder's .claude/skills and .agents/skills with it, when they exist, so every worktree has the skills. Write no tests yourself.

// Browser global Crawl; engine.js also exports it through module.exports.
Crawl.W = 28; Crawl.H = 18; Crawl.SIZE = 32; Crawl.FLOORS = 3;
Crawl.newGame(seed);          // a fresh state; seed is a string or an integer
Crawl.act(state, action);     // changes and returns state; the only way play changes
Crawl.isWalkable(state, x, y);
Crawl.monsterAt(state, x, y); // a monster or null
Crawl.draw(ctx, state, time); // reads state only; time in milliseconds
Crawl.refresh();              // redraws the canvas and the page from Crawl.session
{
  seed: String(seed), floor: 1, floorName: 'The Wine Cellar', turn: 0,
  tiles: [],                  // string[][] of '#', '.', '>'
  rooms: [],                  // {x,y,w,h}[]
  visible: [], explored: [],  // boolean[][]
  player: {x:0,y:0,hp:14,maxHp:14,atk:3,gold:0,flasks:1,kills:0},
  monsters: [],               // {id,kind,x,y,hp,maxHp,atk,intent}
  items: [],                  // {kind,x,y,amount}
  status: 'playing',          // playing | upgrade | won | lost
  log: [],                    // {text,kind,turn}[], oldest first, at most 30
  effects: [],                // {type,x,y,text}[] from the last accepted action
  stats: {damageTaken:0,goldCollected:0},
  bossDefeated: false
}

Monsters are rat, skeleton and warden, and an intent is null or {x,y}. Items are gold, flask and relic. Log kinds are info, good and danger; effect types are hit, heal, gold and move. Actions are {type:'move',dx,dy} (one cardinal step), {type:'wait'}, {type:'heal'}, {type:'interact'} and {type:'upgrade',choice} with vigor, edge or flask.

The canvas is 896 by 576. Scripts load as engine.js, draw.js, game.js, and the engine never touches the DOM. engine.js declares var Crawl once; draw.js and game.js each wrap their code in a function and add to Crawl without declaring it again. The same seed and actions always give the same run. During an upgrade only a blessing counts, and it opens the next floor with no enemy turn. After a win or a loss every action is ignored. Gold and flasks are picked up on entry; the relic needs an interact after the Warden dies.

The turn order says when a monster wakes. The shell exposes the current game as Crawl.session and reads it fresh on every use. Only you change the contract, and you tell the agents it affects.

The squad

Owner Files Work
Engine agent engine.js, check.js Maps, visibility, pathfinding, turns, combat, items, floors, tests
Art agent draw.js Rendering, sprites, light and fog, attack markers, effects
Interface agent index.html, styles.css, game.js Layout, HUD, controls, panels, accessibility, seeds
Leader CONTRACT.md, README.md Contract, review, merging

Read the coordinate, squad, spawn, terminal and worktrees skills first and follow them. Create a milestone and one ticket per role, each with a body that states its files and acceptance criteria. Each agent edits only its own files and reports its commit to you, and only you merge. Put the agents' panes in one squad tab, and tell the person what changed as results arrive.

Each agent's first prompt carries its ticket. The agent starts with pwd, zc whoami and a write check in its worktree, and stops and reports if any is wrong.

The tracker

The tracker is .squad/tracker/index.html, opened with zterm perform split_right --web .squad/tracker --ratio 0.25, so the operator watches it beside you. Add .squad/ to .git/info/exclude. Style it as a compact dashboard that reads well at a quarter of the window: colors from zterm's --zt-* variables only, a small system sans-serif (12 to 13 pixels, not the terminal's monospace), tight rows, and states as small colored pills whose text stays readable on their fill. It lists each ticket's alias, role, owner, state, latest commit and check.js result, then the last eight changes, newest first, with the newest highlighted briefly. Every two seconds it fetches state.json from beside it with {cache: "no-store"} and redraws when the file changed, keeping what it showed when a read does not parse. Rewrite state.json whole whenever a ticket changes state, an agent reports a commit, you merge, or check.js runs.

Done when

check.js runs headless with node check.js, using the engine alone. The engine agent writes it from the contract and reports only when it passes. It checks:

  • Floors: 200 seeds give connected maps, safe separate spawns, stairs on the first two floors, and one Warden and relic on the last.
  • Rules: replay is exact, bad input is safe, and combat, pickups, flasks, pathfinding, blocked monsters, dodgeable heavy attacks, blessings, the guarded relic, damage taken and the end states follow the contract.
  • Balance: over seeded runs, an automated player that never dodges wins about 15 to 40 percent, and a careful one wins at least 80 percent, with no stalls or unreachable goals.

The game is done when node check.js passes on the merged tree and git diff --check is clean.

Ship the game files, check.js, CONTRACT.md and a README.md with the controls and the test command. Close the tickets and the milestone with their evidence, and close only the panes and worktrees you made, after checking them for uncommitted work, and confirm the agents' processes have stopped. Leave the tracker open with every ticket done. Open the game in a zterm web tab and leave it there, then focus its pane with zterm focus <pane> so the game is what the person sees. End with a short report: what the squad built, which harnesses it used, what passed, and what limits remain.