Skip to main content
Glama

more room for play.

debuff is an open-source framework for 2D browser games that handles the basics for you (the game loop, controls, sound, levels, testing, shipping) so you get to that game sooner and spend your time on what makes it yours.

  • The groundwork, done. Start from a running game in under a minute. Crisp pixels on every screen, keyboard, touch and gamepad, sound that plays, levels from Tiled or LDtk, and a build you can put anywhere on the web, game portals like Poki and CrazyGames included (publishing guide).

  • Tune it until it feels right. Speeds, timings and other feel values become live sliders in the dev panel, with undo.

  • When something breaks, it tells you. Errors say whose bug it is and point at the line. Replays and scenario tests bring a bug back exactly, so you can fix it and move on.

  • Room to grow. Small (the starter ships at about 23 kB) and fast: its renderer, spryte, draws moving sprites 2-4x faster than the most popular 2D web renderer, at about a seventh of its size: 1.6 million at 60 fps on our test laptop, against 400,000 (benchmarks, run them yourself), so the engine doesn't hold your idea back.

  • Agents help if you want them, you decide. Coding agents can play the game you have open, read what's happening and check their changes. Creative calls stay with you.

Status: 0.9, early development. APIs will change, and feedback from real games shapes them.

Try it

You need Node.js 22 or newer.

npm create debuff@latest my-game
cd my-game
npm install
npm run dev

Open the URL it prints, then press </kbd> in the game for the dev panel. Edit src/main.tsand the game reloads. The first command asks which template you want. Base templates are starting points for your own game:basic(the minimal starter),topdown(a tile world seen from above),isometric(a 2:1 grid),sidescroller(run and jump) andpointclick(rooms, hotspots and an inventory), all but the first with pixel art drawn in [tenten](https://github.com/debuffjp/tenten). Examples are finished small games to learn from:platformer, mossfell(a top-down adventure) andsquish(a match-3 that plays well on phones). Skip the question with-- --template . pnpm, Yarn and Bun work too (pnpm create debuff`, and so on).

New projects include a .mcp.json, so a coding agent like Claude Code can play and inspect the game you have open, and draw its pixel art with tenten. See the agent guide.

Working on debuff itself? Clone the repo, then run npm install and npm run build. cd templates/platformer && npx debuff dev runs a template against your local packages, and the repo's .mcp.json points the MCP server at it. See CONTRIBUTING.

Related MCP server: agent-game-engine

Why not just canvas and JavaScript?

Raw canvas + JS

debuff

Sprites at 60 fps

~5,000

~100,000 one call each, ~800,000 in bulk (spryte: WebGL2 with a Canvas 2D fallback)

Small game, shipped

what you write

~19 kB brotli for the starter, everything included

A crash in update

the loop dies silently

stops, says whose bug it is, links the source line

Tuning feel

edit, reload, replay

sliders while you play, with undo and copy back to code

AI agents

read code and guess

play your game: state, frames and errors, and you see what they did

More in Why debuff. Agents can start from llms.txt.

Packages

Package

What it does

@debuffjp/core

Game loop, fixed-step clock, seeded RNG, scenes, camera, sprites, params, storage, frame stats

@debuffjp/input

Keyboard and pointer/touch with per-step edges and programmatic input

@debuffjp/assets

Manifest-driven loader with preload groups and actionable errors

@debuffjp/audio

Web Audio buses, autoplay unlock, a placeholder synth. Music and SFX go through plonk on its music bus

@debuffjp/tilemap

Tilemaps: culled batched rendering, tile collision, Tiled and LDtk import

@debuffjp/ui

Screen transitions, menus and framed panels

@debuffjp/juice

Tweens, easing, pooled particles, trails, squash-and-stretch

@debuffjp/share

Clips of the last few seconds, the system share sheet, screenshots and "beat my run" challenge links

@debuffjp/dev

Dev panel (perf, tune, state, explained errors, replays, rewind) and window.__DEBUFF_DEV__, stripped from production

@debuffjp/cli

debuff dev · build · assets · test · scenario · fuzz · inspect · report

spryte

2D renderer: WebGL2 with a Canvas 2D fallback, plus Phaser and PixiJS adapters. Standalone; core draws with it

myaku

Frame profiler for any web game: finds the hitches players feel and says why in plain words. Standalone; debuff dev runs it for you

plonkjs

Game music made in code: songs as text, synthesized live with Web Audio, under 4 kB brotli. Standalone; plays through audio.bus("music")

keiko

Fast, deterministic logic tests for any web game: the real game in Node, no browser. Standalone; debuff integrates it

henka

Tests for your tests: mutation testing that breaks your code one small change at a time and checks a test fails. npx henka for Vitest projects, adapters for any runner. Standalone; keiko mutate uses it

create-debuff

npm create debuff scaffolder

@debuffjp/mcp

MCP server: agents inspect, build, test and play your game

CLI

debuff create [dir]     scaffold from a template
debuff dev              dev server, hot reload, asset manifest watching
debuff build            production build + size report (fails on dev leaks)
debuff assets           regenerate manifest, list unused assets
debuff test             logic tests (keiko): the real game in Node, no browser, in milliseconds
debuff scenario         run scenarios/*.json headless, compare captures
debuff fuzz             random playtesting; crashes come back as replay files
debuff inspect          JSON project summary for agents
debuff doctor           check Node, package versions, config, assets and browser in one pass
debuff report           size report for an existing dist/

Every command accepts --json for machine-readable output where applicable.

Repository layout

packages/    browser runtime libraries (@debuffjp/*)
tooling/     Node-side tools (CLI, scaffolder)
templates/   starter templates; built and scenario-tested in CI
docs/        architecture, roadmap, decisions (docs/adr)

Community

License

MIT

Available Tools

21 tools
buildProduction buildA

Build for production and return the size report (raw, gzip, brotli per file). leaks lists dev-only code found in the output; it must be empty.

Inputs: root.

fuzzFuzz playtestA

Play the game headlessly with random but plausible input (movement keys held, action keys tapped) to find runtime errors, stuck states and back-and-forth loops. Each finding includes the explained error (kind, source-mapped file:line, hint) and repro: a scenario file that replays it exactly. Pass that file to run_scenarios to reproduce, then again after fixing to verify. The same seed gives the same inputs.

Inputs: keys, root, runs, seed, +1 more.

game_captureCapture frameB
Read-only

Screenshot of the current frame as a PNG image.

Inputs: no named parameters.

game_errorsRuntime errorsA
Read-only

Runtime errors since the game started, explained: kind (your-code, debuff-usage, debuff-bug, outside), where (source file:line, source-mapped), a hint, the loop phase and tick, and a repeat count. A loop error stops the game; fix it, then game_pause false to resume. For debuff-bug, tell the human and share reportUrl rather than working around it.

Inputs: no named parameters.

game_framesFrame breakdownA
Read-only

Recent frames, oldest first: intervalMs (what the player feels), updateMs, renderMs, steps (>1 means catching up), quads, drawCalls and longTaskMs (browser-reported main-thread stalls). Use it to explain stutter; in headless mode times reflect stepping, not real play.

Inputs: count.

game_inputSend inputA

Keyboard or pointer input. press/release take a KeyboardEvent.code (e.g. Space, ArrowLeft, KeyZ). tap/pointer_down/pointer_move take logical x, y. Input takes effect on the next game_step.

Inputs: action (required), x, y, code.

game_notesHuman notesA
Read-only

Moments the human flagged in the overlay (live mode): their words, the tick, the scene's inspect() state then, and the frames leading up to it.

Inputs: no named parameters.

game_paramsList paramsB
Read-only

Every tunable param group: schema (type, default, min, max, units, description) and current values.

Inputs: no named parameters.

game_pausePause or resumeA

Pause or resume a live game (headless games are always paused). game_step also pauses first.

Inputs: paused (required).

game_profileFrame profileA
Read-only

Why the game stutters, from myaku: frame-time percentiles (p50/p95/p99), hitches per minute, and the worst hitches explained. Each has a cause (script, gc, upload, compile, layout, throttled, hidden, unknown), a confidence, the script and function to look at when known, and a hint. Spans show time in debuff's update and render. Prefer this over game_frames to explain stutter; measure in live mode, since headless stepping doesn't reflect real play.

Inputs: no named parameters.

game_replaySave a replayA

Everything played since the game loaded (keys, pointer, param changes) up to toTick (default: now), saved as a scenario in .debuff/replays/ that replays it exactly. Use a note's tick to reproduce what the human saw when they flagged it, then run_scenarios with the returned file. warnings lists anything a replay can't reproduce (for example slow motion).

Inputs: toTick.

game_rewindRewind the live gameA

Live mode only. Take the human's game back (or forward, within the known session) to tick: the page reloads, replays the session's inputs to that tick and stays paused, so the state is exactly what it was then. Use a note's tick to look at the moment the human flagged. The page needs a second to reload; then use game_state or game_capture.

Inputs: tick (required).

game_set_paramSet paramA

Set a tunable param live. Values are validated against the param's type and range. Changes last until game_start or a reload.

Inputs: key (required), group (required), value (required).

game_startStart gameA

Connect to the game. auto (default): attach to the human's live game if debuff dev has it open in a browser, else start a private headless copy, paused. Returns the mode, state and how many notes the human has flagged. Replaces any running session.

Inputs: mode, page, root.

game_stateGame stateB
Read-only

Current scene, tick, time, renderer, frame stats, the scene's inspect() data and plugin inspect data.

Inputs: no named parameters.

game_stepAdvance timeA

Advance the simulation by fixed steps (60 per second by default) and return the new state.

Inputs: steps (required).

game_stopStop gameA

Headless: close the browser and dev server. Live: resume the human's game and disconnect.

Inputs: no named parameters.

inspect_projectInspect projectC
Read-only

Summary of the project: dependencies, plugins and their contributions, assets, last build size.

Inputs: root.

list_assetsList assetsB
Read-only

Run the asset pipeline: every asset id, type, size and importer, plus generated files, warnings and possibly unused ids.

Inputs: root.

run_scenariosRun scenariosB

Run scenarios/*.json (or the given files) in a headless browser. Returns per-step results, runtime errors, captures and final state.

Inputs: root, files, update.

run_testsRun logic testsA

Run the logic tests in tests/**/*.test.ts (keiko): the real game in Node, no browser, in milliseconds. Each failure has its message, the source line, and the game's tick, scene and state when it failed. Use after every change; write a test for each mechanic you add.

Inputs: root, files, filter.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.6/5.0

    Scored across 21 tools

    Disambiguation4/5

    Most tools have clearly distinct purposes, and descriptions actively disambiguate overlapping ones (game_profile says 'prefer this over game_frames'). A few frame/state inspection tools (game_frames, game_profile, game_state, game_capture) sit close together, but the descriptions steer selection well. game_replay vs game_rewind are clearly differentiated by their docs.

    Naming Consistency4/5

    Strong, readable convention: a game_ prefix groups all live-game tools (game_start, game_step, game_input, game_pause, etc.) with consistent snake_case verb/noun forms. Project/build/test tools (inspect_project, list_assets, build, run_tests, run_scenarios, fuzz) drop the prefix but remain snake_case and predictable. Minor deviation in grouping rather than style.

    Tool Count4/5

    21 tools is on the heavier side but justified by a broad domain spanning project inspection, asset/build, live game control, testing, fuzzing, and profiling. Each tool maps to a distinct capability rather than being redundant. Slightly high, but no filler.

    Completeness4/5

    The surface covers a full debugging lifecycle: inspect project/assets, build, connect/step/input/pause the game, capture state and frames, profile stutter, record/rewind replays, capture errors, run tests and scenarios, and fuzz. Tunable params have both read (game_params) and write (game_set_param). Minor gaps only, e.g. no explicit teardown/scaffold for new projects.

    Maintenance

    ActivityActive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers