# Tutorial: dynamic editor recompile

Every editor build loads game code as a dynamic module, regardless of the host linkage selected by `--type`. The toolbar **Recompile** rebuilds that module and swaps it when Edit mode allows — without restarting the whole editor.

Deep reference: [Assets and Shinra](/docs/systems/assets-and-shinra.md) (recompile table), [Frontends and drivers](/docs/systems/frontends-and-drivers.md). Sample project: `hikari-games/example/`.

## When Recompile is enough

- Changed game Zig under `hikari-games/example/src/` (entities, session, config).
- Added a new `*_entity.zig` (manifest regenerates with the game build).
- Tweaked gameplay logic that stays behind the thin `hikari_game` / `HostApi` surface.
- Editor-only menu/panel contributions (`registerEditor` / `hi.editor`) when the module was compiled with `-Deditor-contrib=true` (always true on editor recompile).

Flow: Edit mode → Recompile → wait for success → scene stays open; missing archetypes soft-fail if you removed a type still referenced in the document.

## When you must rebuild the editor

> [!WARNING]
> Rebuild the editor after changing the thin game ABI (`HostApi`, `GameModule`, `abi_version`). A host/game mismatch in ABI version, Zig version, optimize mode, or profiler flags cannot be fixed by recompiling only the game module.

- Recompile **build** fails — previous dylib stays; fix compile errors and retry.
- Recompile succeeds but register/load fails — editor restores the previous module; panic only if restore itself fails.

Monolithic editor host linkage still loads game modules dynamically for recompile; a full product rebuild is only required for host/ABI changes.

## Verify

1. Dynamic editor: change a log line in `cube_entity.zig` → Recompile → Play → see the log.
2. Remove an archetype still placed in the open scene → soft placeholders + audit after recompile.
3. After a `HostApi` / `GameModule` semantic change → full `bin/kaji/kaji editor --workspace=$PWD --project=$PWD/../hikari-games/example …` rebuild (not only Recompile).

## Next

- [First project](/docs/tutorials/first-project.md)
- [First entity](/docs/tutorials/first-entity.md)
