# Rule Stack: Chain Colour Rules to Rebuild a Cube Wall

> Turn a wall of isometric cubes into the goal shape by chaining rules, in one offline HTML file: paint one colour into another, cap stacks, sort, fuse pairs, tuck cubes in, flip the wall. Every rule in the pipeline draws its own wall on the board, so you see where a program goes wrong. Drag to reorder, reset to start over; 18 levels in three chapters, each with a stored solution the tests replay.

- Type: Lab Skill (downloadable Agent Skill)
- Category: [Game creation](https://www.sandbase.ai/skills/games)
- Version: 0.1.1
- Runs online: yes
- Page: https://www.sandbase.ai/skills/games/rule-stack

## What you get

Bring the pieces and the colours, and optionally new rules, new levels or chapters, the board layout and the text. The Skill returns a downloadable Skill (the puzzle project, a customize guide, headless verification) and one playable example run.

## Install

Download the Skill package from https://www.sandbase.ai/skills/games/rule-stack (sign-in required), unzip it into your agent's skills folder, then ask your agent to use it:

```text
/rule-stack make a puzzle where players chain rules to turn <your pieces> into <your goal shapes>
```

## How it works

1. **Copy the finished puzzle project** Rule Stack hands your agent a complete game: run node scripts/new-project.mjs --out my-rules, then npm ci inside it. The project holds the rule engine in src/rules.js, 18 authored levels in src/levels.js, the isometric renderer in src/iso.js and src/board.js, pipeline UI in src/ui.js and main.js, and a window.__scene test API. It calls no model.
2. **Customize rules, levels or look** references/customize.md lists each common request with the files and symbols to change. Colours and backdrop are usually one value in src/theme.js. A new level is an L(...) entry in src/levels.js with a stored solution, which must replay through runPipeline and solved before shipping. Rules such as paint, cap and sort are pure functions over a wall.
3. **Build single file and shoot** npm run build:single writes dist-single/index.html, which opens with a double-click and must stay under 8 MiB with no network, storage, workers, dialogs or pointer lock. npm run shoot plays it in local Chrome, adding, reordering and removing rules, resetting, solving early and late levels and a phone game, and writes shots/report.json plus screenshots to check.

## FAQ

### What kind of game is Rule Stack?

Rule Stack is a calm puzzle where you chain colour rules to rebuild an isometric wall of cubes into a goal shape. Each rule in the Pipeline draws its own intermediate wall on the board, so you watch the transform step by step. Matching the goal shows Solved with a Next level button, across 18 levels in three chapters.

### Does Rule Stack call a model or need a key?

No. Rule Stack is a finished game plus a customize guide, and nothing in it calls a model or a paid service. npm ci pulls pinned Vite and playwright-core from the public npm registry, and the built page makes no network calls, so playing or modifying it carries no SandBase charge.

### Does Rule Stack have hints or a solver?

No. Rule Stack stores a solution with every level so the tests can replay it, but the game never shows it. A stored solution proves a level can be beaten, not that it is the shortest. To check par, the repository's solve.mjs re-derives a minimal solution, and you can copy it into your project.

### Can I undo a move in Rule Stack?

No. Rule Stack has no undo, and any sequence the chapter library allows can be built, even one that makes the level unsolvable from the current wall. Press R or Reset to return to the starting wall. Drag pipeline chips to reorder them, or drag one out or click it to remove it.

### How big is a Rule Stack build and where does it run?

Rule Stack's game and styles come to about 30 KiB in one HTML file, against an 8 MiB limit. It opens from disk, hosts anywhere and runs in a sandboxed iframe. Inside a sandbox there is no storage, so solved marks and best step counts reset on reload.

### Does Rule Stack work with touch?

Yes. Rule Stack accepts mouse and one-finger touch: tap a rule to add it and drag pipeline chips to reorder or remove them. Phone play was verified under headless touch emulation, not on real devices.

## Examples

- Rule Stack cube-pipeline puzzle (scene)
- Standard Run (video)
