Change a running Snail program without restarting it, with snailc run --hot (Windows and Linux). Use when building, testing or debugging a Snail game live, when asked to open a hot window or keep a game running while editing it, or when a session prints Patched, Kept, Paused, Reset, Saved, Restored, Error, Note or Restarting lines. Tells how to drive a session with snailc hot wait, how to test, look at and debug the game in its own window (shots, played input, probes, checkpoints) instead of ...
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Snail Hot?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/codeadopter-snail-hot)
---
name: snail-hot
description: Change a running Snail program without restarting it, with snailc run --hot (Windows and Linux). Use when building, testing or debugging a Snail game live, when asked to open a hot window or keep a game running while editing it, or when a session prints Patched, Kept, Paused, Reset, Saved, Restored, Error, Note or Restarting lines. Tells how to drive a session with snailc hot wait, how to test, look at and debug the game in its own window (shots, played input, probes, checkpoints) instead of in copies or scripts, what patches, what waits for a reset, how to save and restore the game's state, and what to do after a crash.
---
# Hot mode: changing a running program
`snailc run --hot` builds a debug build, starts it, and keeps it running while its code changes.
Each time a file it was built from is saved, the session compiles the change and the changed
functions go into the running program at its next frame, about 0.1 seconds after the save when only
function bodies changed, however large the program, and up to a second or so in a large program
when a declaration changed. The window, the game's state and where the player was all stay, through new struct
fields, new parameters and crashes too: a whole game can be built in one window that never closes.
It works on Windows and Linux. The language is in `snailc guide`, games in `snailc guide game`.
## Running a session as an agent
1. Start it in the background with its output going to a file, from the project folder:
`snailc run --hot > hot.log 2>&1`. Program arguments go after `--`.
2. Wait for the `Hot` line, as in `until grep -q ' Hot ' hot.log; do sleep 0.2; done`. An error
after `Compiling` and no `Hot` line means the program did not build: fix it and start again.
3. After each save, run `snailc hot wait`. It waits until the session has taken every change saved
so far and prints what it said about the last one: `Patched` and `Kept`, the compile's errors,
`Note`s, or `Paused` when the new code crashed. It exits 1 after an error or a crash. Its first
line, `Change save 7: models.snail`, names the save it took, so after several quick saves you
know whether your latest one is in.
4. Every write of a file is a save. Make each save one small step that compiles, then run
`snailc hot wait` and look; order a change that needs several edits so each one compiles where
you can, a function or a field before its first use. An edit that leaves the code half-written
prints an Error, which is harmless: the game keeps its last good code.
5. `snailc hot shot` saves a picture of the game's next frame and prints its path: look at it to
see what the change did. `snailc hot shot path.png` saves it there. The game can be played too:
`snailc hot send "press Space"`, `"hold Right 30"` (frames) or `"click 400 300"`; then take a
shot to see what happened. A lib/engine game also takes its remote's commands, such as `"pause"`,
`"step 1"`, `"speed 0.5"` or `"set name value"` for a knob.
6. `snailc hot get score lives pos.x drops.len drops[0]` prints the game's values by name, between
frames: globals and `main`'s locals, fields, list lengths and items. Use it instead of prints
and guessing from shots.
7. A frame that takes long, such as a first frame that meshes sculpted models in a debug build,
delays `shot`, `send` and `get` until it ends (up to a minute); the session prints `Busy frame 1
has run 4.2 s, in Scene3D_sculpted > make_sculpted > ...` meanwhile, and `snailc hot status`
shows it too.
8. `snailc hot reset` starts the program over in the same window, and `snailc hot status` prints
the session's last lines again. Each takes the program as `run` does, or the current project.
9. To work on one moment of a game, such as a boss fight, get there and run `snailc hot save`;
`snailc hot restore` puts that state back whenever you want, under the newest code. `snailc hot
loop` saves it and then starts every change there, until `snailc hot loop off`; a lib/engine
game also plays the input since the checkpoint again, so the change is seen in the same play.
10. The session ends when the program does: when the window is closed or the program's process is
stopped. The program runs as `main.exe` (named after the main file) in
`%LOCALAPPDATA%\snailc\builds\main-hot-<hash>\`. Stop it by its id:
`Get-Process main | Select-Object Id, Path`, then `Stop-Process -Id <id>`. On Linux it is `main`
in `~/.cache/snailc/builds/main-hot-<hash>/`: `pgrep -af main-hot`, then `kill <id>`.
| Line | Means |
|---|---|
| `Change save 7: models.snail` | First line of `snailc hot wait` and `status`: the save they tell of, and the files in it |
| `Patched main (main.snail:6), twice (main.snail:2) 92 ms` | The running program has the new code: these functions, and the time from the save |
| `Kept world; Shot: new speed, kind gone` | A struct changed, and these variables' values moved to its new layout |
| `<path>:12:5: error: ...`, then `Error the program goes on with its last good code` | Fix the error and save again; nothing else changed |
| `Paused a panic; save a fix, ...` | The new code crashed; the program waits at its frame loop with its state. Save a fix and it goes on (`Resumed`) |
| `Note ...` | Part of the change waits for a reset; the note says which |
| `Reset the program started over in its window` | `snailc hot reset`, or a change whose values could not move: fresh state, same window |
| `Saved 1: 23 values and 349 blocks, 113.4 MB, in 22.7 ms` | `snailc hot save`: a checkpoint of the whole state |
| `Restored 1, in 8.7 ms` | A checkpoint came back, by `snailc hot restore` or after a change in a loop |
| `Unchanged the running program has this code already` | The save changed nothing that runs, such as a comment, or it undid an error |
| `Busy frame 1 has run 4.2 s, in Scene3D_sculpted > make_sculpted > ...` | A frame is taking long, such as one meshing models in a debug build; messages, shots and `get` wait for it to end |
| `Waiting the program has not reached a hot point...` | The program is not in its frame loop: it is paused in a dialog, or it is not a game |
| `Restarting <reason>`, then `Built <name> 450 ms` | Rare: a crash outside main's frame loop, or a change the program cannot take; a new process |
A `Patched` line also lists library functions used for the first time and functions whose lines
moved, and a long list ends in `and 7 more`, so your function may be among those. A new function
that nothing calls yet is not listed. Program output (`print`) goes to the same log, between the
session's lines, which start with a right-aligned word; give your own prints a prefix to find them.
## Test and debug in the window
While a session runs, its window is where the game is built, tested and debugged, in the project's
own files. Every check below uses `snailc hot` and the game's code. None needs a copy of the
project, a second `snailc run`, a frames-only run (`SNAIL_GAME_FRAMES`) or a script in another
language, and a copy starts with none of the state the window has built up.
- **Try things in the real files.** The running game is safe to experiment in: a save that does
not compile leaves the last good code running, a crash pauses the game until a fix, and the next
save takes out what did not work.
- **Look after each step** with `snailc hot shot`. To compare, take `snailc hot shot before.png`,
save the change, take `snailc hot shot after.png`, and look at both pictures; a reference
picture the user gave is looked at the same way. To see something small up close, zoom the
game's view on it for a shot (`win.zoom`, `win.look_at(p)`), then put the view back.
- **Ask the game for numbers.** Draw them in the window and take a shot, or `print` them with a
prefix and read the log: `grep PROBE hot.log | tail -5`. Print once a second with a `Timer`,
not every frame. A `var` added to `main` starts when the code arrives, so a probe and its
counters can come and go while the game runs. Take probes out once they have answered.
- **Get to the moment that matters.** Play there with `snailc hot send` (`"hold Right 120"`,
`"press Space"`, `"click 400 300"`). For one that is slow to reach, such as a hundred enemies,
add a debug key (`if win.pressed(F2)`) and run `snailc hot send "press F2"`. Once there,
`snailc hot save`: `snailc hot restore` brings that moment back under the newest code, and
`snailc hot loop` does it after every change.
- **Keep what is worth keeping in the project, in Snail**: a debug key, an overlay behind F3, a
`test` block for logic that needs no window (`snailc test`).
```snail
use game
fn main()
var win = window("Probe", 1280, 720)
var rng = Rng.seeded(1)
var dots: [..]Vec2
var probe = Timer.every(1.0) # a probe, taken out once it has answered
while win.frame()
if win.pressed(F2) # a debug key: snailc hot send "press F2"
for _ in 0..100
dots.push(win.center + rng.in_circle(300.0))
for d in dots
win.circle(d, 4.0, rgb(240, 200, 80))
win.text(16.0, 16.0, "dots {dots.len}") # seen in a snailc hot shot
if probe.tick(win.dt): print("PROBE dots {dots.len}, {win.fps:.0} fps")
```
## What a save can do while the program runs
- Change any function's body, including `main`'s frame loop. `main` goes on at the same loop with
its variables as they were.
- Change a function's parameters or result: its callers change with it.
- Add, remove, reorder or retype a struct's fields. At the end of the frame every value of the
struct moves to the new layout: in globals, in `main`'s variables, in lists, arrays and other
structs, and in objects made with `new` or `alloc`, and pointers into them follow. Fields keep
their values by name, a new field starts at its default, and a number whose type changed is
converted. Function values kept in them follow their function. A `Kept` line names what moved.
- Add, remove or reorder an enum's members: each value keeps its member.
- Add functions, structs, enums, globals and constants, and use library functions for the first
time. A new global computed as the program starts, such as `var seed = now_ms()`, is computed
when the change arrives.
- Add a `var` or `let` to `main`, before its loop or inside it: its declaration runs once, when
the new code arrives, even with a computed value such as `Timer.every(0.25)`.
- Change a `let`'s value in `main`: it is made again with the new value. A `var` keeps the value it
has (a note says so), because it holds state.
- Change any constant, a number, text, array or struct: every function that uses it is patched.
- Add an `extern include` of a C header.
## Crashes, resets and what waits
- **A crash or panic in new code pauses the program** at its frame loop instead of ending it, with
a `Paused` line naming what happened, such as `an access violation reading address 0x0 in
update`. Its window and state stay. Save a fix and it goes on at the same loop; `snailc hot
resume` goes on without one, and `snailc hot reset` starts over. New code that keeps the game
from its next frame for three seconds, such as a `while` that never ends, is paused the same way:
`a loop that does not end in update`.
- **Waits for a reset**, with a note: statements before `main`'s loop other than declarations
(they ran already), a `var`'s new starting value, a global's new starting value, and a new
`init` block. `snailc hot reset` runs them.
- **A reset** starts the program over in the same process: every global and `main` variable goes
back to its starting value and `main` runs from the top. lib/game's window and lib/engine's
window, GPU device and sound stay open, so the game draws in the same window at once. A global
marked `@keep`, or a struct marked `@keep`, is left as it is, for state that should survive.
- **A change whose values cannot move for certain** comes in with a reset, and the `Reset` line
says why: a pointer to a changed struct into memory that `new`, `alloc` and lists did not give
out, a union holding a changed type, a function value whose parameters changed, or an enum member
that is gone while a value holds it.
## Writing code that stays hot
- Keep the frame loop in `main` (`while win.frame()` or `while app.frame()`), and put what you
will tune inside the loop or in a `let`, not in code that runs once before it.
- Keep a game's state in `main`'s variables and in globals, in structs, lists and objects made with
`new`: that is what moves when a struct changes.
- A program with a loop of its own takes changes where it calls `hot_point()` once a pass.
lib/game and lib/engine call it in their `frame()`. Elsewhere `hot_point()` does nothing.
- What a program opens, such as a file or a database, stays open through a reset, held by the old
state: close it in a function marked `@on_reset`, which a reset calls first, or open it once and
keep it in a `@keep` global.
- `hot_changes()` counts the changes the program has taken (patches, resets, checkpoints brought
back), and is 0 in any other build: work that only a code change can change, such as building a
model, can wait until the count moves.
- `snailc hot send <message>` reaches a program with a loop of its own: `hot_message()` gives the
message at its next `hot_point()` and `hot_reply(text)` answers it. lib/game's `win.frame()`
takes `shot <file.png>`, `press`, `hold` and `click` itself. A lib/game game takes commands of
its own through debug keys, or sets `win.takes_messages = true`: the window then keeps any other
message in `win.message` (a `[..]u8`) for the game to answer with `hot_reply` and clear.
lib/engine passes the messages it does not know to its remote: `pause`, `step 1`, `get` and
`set` of a knob, and any other for the game to take from `app.remote.next`.
```snail
fn main()
var turn = 0
while turn < 1000
hot_point() # a running hot build takes saved changes here
turn += 1
if turn % 100 == 0: print("turn {turn}")
sleep_ms(16)
```
## Starting from an empty window
```
snailc init --game sketch
cd sketch
snailc run --hot > hot.log 2>&1 # in the background
```
Then grow `main.snail` one save at a time, running `snailc hot wait` after each: a square, keys
that move it, a list of shots fired on click, enemies on a timer, fields added to them as the game
grows. Each save shows up in the open window.