Appearance
Working with agents
Kiln is designed around the loop a coding agent runs: change files, ask the tools whether the change is right, fix what they report. This page is that loop, and the files an agent reads.
The loop
bash
kiln describe # traits, systems in run order (reads/writes/after), resources, events
kiln test # bun test over scenarios/ (headless, deterministic)
kiln replay recordings/x.json # replay a play session the user recorded (F8 in the game)
kiln run --steps 600 --snapshot Transform,Health --resources Score # JSON world after N steps
kiln check # determinism lint (Math.random, Date.now, performance.now)
kiln shot --steps 120 out.png # one rendered frame from headless Chromium, when you need eyes
kiln docs # regenerate AGENTS.md
kiln add <plugin> # vendor a community plugin into src/plugins/ (kiln add --list)Work in this order:
- Write or change files.
kiln describe. Schedule errors (write conflicts, cycles, a bad.after()) show here.- Write a scenario test for the change.
kiln test.kiln shotonly if the change is visual.kiln docsif exports or the schedule changed.
Every command takes --json and prints errors as error <code>: <message>. The message names the fix, so the usual next step is to do what it says. The full command reference is in CLI.
AGENTS.md
Every game has an AGENTS.md at its root, which agents that follow the AGENTS.md convention read before working. It has two parts:
- The Kiln guide at the top: the API, the phases, the rules the schedule enforces, every plugin, testing, recordings, a TSL cheat sheet and a table of common errors.
kiln newwrites it frompackages/kiln/docs/agents-guide.md. You may edit this part;kiln docskeeps it. - This game, below a marker comment, generated by
kiln docsfrom the code: the config, the plugins, the schedule as a table (writes, reads, resources and order for every system, with the file it lives in), every trait with its fields, every relation, prefab, resource, event, system and plugin with its JSDoc, and the names of the scenario tests.
bash
kiln docs # rewrite the generated section, keep everything above the marker
kiln docs --guide # also replace the top with the current Kiln guide
kiln docs --check # exit 1 if AGENTS.md is out of date (for CI)kiln docs also prints a note for each trait, system, plugin, resource, event or prefab without JSDoc, since that line is what the next agent will read about it.
This site, for agents
The guides on this site are also published as plain text, following the llms.txt convention:
/llms.txt: an index of every page with its description./llms-full.txt: every guide page in one file.- Each page as Markdown at its own URL with
.mdappended.
The API reference is generated by TypeDoc from the same JSDoc the code carries, so it is never out of step with the source.
Habits that keep agents fast
- One feature, a few exports. A trait in
data.ts, a system insystems.ts, one line inmain.ts. Don't spread a feature across a new folder until a file is genuinely long. - Read before guessing.
kiln describeanswers "what runs, in what order, touching what" faster and more reliably than reading the code. - Assert on JSON.
kiln run --snapshotand scenario tests are exact. Screenshots are for checking that something looks right, not that it happened. - Reproduce from recordings. When a user says "I recorded it", run
kiln replaybefore reading code. See Recordings and replay. - Keep it deterministic. Randomness from
res.mut(Rng), time fromctx.time.kiln checkflags the rest. See Determinism.