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 Use Dev Mode?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/blit386-use-dev-mode)
---
name: use-dev-mode
description:
Gate code on `BT.isDevMode` (engine 1.5.0+) so cheat keys, verbose logging, and test fixtures run only in dev builds
and vanish from the shipped game, and expose game state for play-testing with `testState()` (engine 1.8.0+). Use to
tell a dev build from a release build. To show values like score or FPS on screen, use `show-debug-overlay` instead.
---
# Use dev mode
`BT.isDevMode` tells you whether the game is running as a development build or a release build, so you do not have to
invent your own signal for it.
## How to do it
```js
update() {
if (BT.isDevMode && BT.isKeyPressed('KeyG')) {
this.godMode = !this.godMode; // dev-only cheat key
}
}
render() {
// ...
if (BT.isDevMode) {
console.log('player', this.player.x, this.player.y); // dev-only verbose logging
}
}
```
`BT.isDevMode` is a getter (no parentheses) and needs no setup beyond having `blit386/vite` installed - every scaffold
has it already (see `use-hot-reload`). It reads `true` while `{{pmRunDev}}` is running the game through that plugin, and
`false` in a built/shipped game (`{{pmRunBuild}}`).
## What dev mode turns on for you (engine 1.7.0+)
These come free with a dev build, without any code:
- **`window.BT`** - the engine puts itself on the page, so you can type `BT.ticks`, `BT.activeBackend`, or
`BT.palette.get(1)` straight into the browser console and inspect the running game. It is not assigned in a built
game. Override it either way with `bootstrap(Game, { exposeGlobal: true })` (or `false`) if you need to.
- **F9 / Shift+F9 frame capture** - F9 copies the current frame to the clipboard, Shift+F9 saves it as a PNG. Turn both
off with `isFrameCaptureShortcutEnabled: false` in `configure()` when your game wants F9 for itself. See the
`save-a-screenshot` skill.
- **`window.__btInputTrace`** (engine 1.9.0+) - records which clicks, keys, and pad buttons each `update()` and each
frame saw, so you can check that one click counted once. It sits next to `window.BT` and follows the same
`exposeGlobal` switch. See the `test-the-game` skill.
Left alone, all three follow `BT.isDevMode`, so none ships to players by accident. Each also has an explicit override
that wins over that default - `exposeGlobal: true` for `window.BT` and the input trace,
`isFrameCaptureShortcutEnabled: true` for F9 - if you want one in a release build on purpose.
## Let an agent read the game's state (engine 1.8.0+)
Add a `testState()` method to your game class that returns what a play-tester needs to check, as plain JSON:
```js
testState() {
return {
score: this.score,
lives: this.lives,
player: { x: this.player.x, y: this.player.y },
};
}
```
Then, in a dev build, `window.BT.testState()` in the browser console (or an agent's JavaScript call) returns
`{ ticks, backend, state }`: the engine's tick counter, the active backend, and a copy of what your method returned.
Read it twice about a second apart and `ticks` should have grown by about 60.
- Nothing else to wire up: no `window.__game`, no `declare global` block, no `if (BT.isDevMode)` around it. It rides on
`window.BT`, which only a dev build has.
- Keep it plain JSON: numbers, strings, booleans, `null`, arrays, and plain objects. The engine copies the result, so a
`Vector2i` arrives as `{ x, y }` and functions or `undefined` fields are dropped.
- Without the method, `state` is `null` and `ticks` and `backend` still work.
- If the method throws or returns something JSON cannot hold (an object that contains itself, a `BigInt`), the call
still returns: `state` is `null`, `error` holds the message, and the browser console shows `[BT] testState() threw:`.
- It keeps working after a hot reload rebuilds the game object - the engine asks the current one every time.
- The engine never calls it on its own, so it costs nothing during play. See `test-the-game` for using it.
To read one exact moment instead of a live game, freeze it with `BT.renderAt` first - see the `test-the-game` skill.
## Notes
- `BT.isDevMode` is tied to the dev server, not to `NODE_ENV` or any bundler define - there is nothing else to
configure.
- It answers exactly one question: is this a dev build. It has nothing to do with your own game state (paused, in a
menu, level number) - keep those as your own fields.
- The engine gates one thing on this by itself: the BLIT386 splash plays in a release build and not in a dev build. Add
`?splash` to the URL to see it while developing, or turn it off for good with `isSplashEnabled: false` in
`configure()`. See `docs/basics.md` (The splash).
- This is a convenience for you, the developer, not a security boundary. A player who really wants to could still flip
it on in a shipped build; do not rely on it to hide content you actually need to protect.
- Needs blit386 `^1.5.0`.