Skip to content

Working with AI agents ​

debuff gives agents the same evidence you'd want before trusting a change: what's in the project, what's tunable, what's happening at runtime, and whether the change worked.

To start from nothing with any agent (Claude Code, Codex, Cursor, Gemini CLI, VS Code Copilot, Windsurf), give it this:

text
Set up debuff for me by following https://debuff.jp/skill.md

That skill checks Node, scaffolds a game, connects the MCP server in whichever agent you use, and runs debuff doctor when something fails.

To keep it as an installed skill instead, use the open skills installer:

bash
npx skills add https://debuff.jp/skill.md
QuestionInterface
What's in this project?npx debuff inspect (JSON)
Is the setup sound?npx debuff doctor --json, or the MCP doctor tool when another tool fails on setup
What can be tuned, and within what range?__DEBUFF_DEV__.params()
What's happening right now?__DEBUFF_DEV__.state(): scene, tick, frame stats, your inspect() data. hidden: true (since 0.25) means the tab is in the background, so the loop is stopped: drive it with step(n)
Did the change work?npx debuff scenario --json
What does it cost players?npx debuff build --json

Every CLI command supports --json, and every dev-hook call takes and returns JSON.

Live or headless ​

The debuff MCP server gives agents the same evidence as tools: game_state, game_capture, game_input and more. game_start decides which game they work on:

yesnogame_startIs debuff dev runningwith the game open?live: attach to your tabyou watch every input in theoverlayheadless: a private copy,pausedtime moves only withgame_stepgame_notes: the momentsyou flagged, read first

Live mode is for playing together and for real timings (game_profile). Headless is for exact, repeatable checks.

A good agent loop ​

  1. Inspect the project and the params involved.
  2. Propose the smallest change, and name the files and params it touches.
  3. Prefer tuning params over rewriting logic.
  4. Run the scenarios; add one if the behaviour isn't covered yet.
  5. Report the diff, the scenario results and the build size change.

When the agent also wrote the tests, check that they test something: npx keiko mutate lists the params no test notices. See Test your tests.

For questions about debuff itself, agents can use the read-only MCP server at https://debuff.jp/mcp (streamable HTTP, nothing to install). It answers from these docs and the API reference, and it can't see or change your project.

ToolWhat it does
search_docsFind the guide sections that answer a question
get_docA whole page, as Markdown
get_apiA class, function or type from the API reference
list_startersThe starter games, with the command that creates each one
playground_linkTurn one file of game code into a link that runs it in the playground

In Claude Code:

bash
claude mcp add --transport http debuff-docs https://debuff.jp/mcp

WebMCP in the browser (experimental) ​

Since 0.29, @debuffjp/dev registers the game's dev hooks as WebMCP tools when the browser has document.modelContext, so an agent that calls page tools can play the game with no MCP server. There are 10: game_state, game_step, game_pause, game_input, game_command, game_params, game_set_param, game_capture, game_errors and game_notes, with the same names and arguments as the MCP server.

With agent-browser:

bash
agent-browser open http://localhost:5173/
agent-browser webmcp list
agent-browser webmcp invoke game_step --params '{"steps":60}'

It only runs in dev, and production builds don't change. Without the API it does nothing. Turn it off with devTools({ webmcp: false }). The API is a draft, so this can change between releases.

Skills in the project ​

Every project made with npm create debuff carries agent skills for its own debuff version: debuff, debuff-setup, keiko and myaku, in .claude/skills/ for Claude Code and .agents/skills/ for Codex, Gemini CLI, Cursor and Copilot. They're stamped with metadata.debuff-version, so after an upgrade npx debuff doctor notices they're stale and --fix rewrites them. The agent's instructions then describe the code it's editing.

Checks on what the agent does ​

From 0.23. New projects ship a hook that Claude Code and Codex run before and after the agent edits a file or runs a command. It turns the rules in AGENTS.md into checks at the moment the agent acts. The agent gets each message with the reason and what to do instead.

RuleWhenWhat happens
baselinesEditing scenarios/__baselines__/, running debuff scenario --update, or the MCP run_scenarios with updateClaude Code asks you first. Codex can't ask, so it refuses and tells the agent to ask you
accept-savesRunning debuff build --accept-savesThe same: your approval first
generatedEditing .debuff/, dist/ or node_modules/, including through a shell redirectRefused: change the source instead
foreground-devRunning npm run dev, debuff dev or vite in the foregroundRefused, since it would never return. Run it in the background, or use the MCP game_start
hand-bumpChanging an @debuffjp/* version in package.json by handRefused: npx debuff upgrade moves them together
math-random, wall-clock, real-timersNew Math.random(), Date.now(), performance.now(), new Date(), setTimeout, setInterval or requestAnimationFrame lines in src/A warning after the edit, with the file and line. They break replays, scenarios and fuzz findings; use game.random and game.clock
untestedThe agent tries to finish after editing src/ without running debuff test or debuff scenarioOnce per stop, it's asked to run the tests or say why not

Warnings never block. A line ending in // debuff-hook-ignore <rule> is skipped, and DEBUFF_HOOK=0 turns the hook off.

From 0.24 the hook also runs when a session starts. At most once a day, if a newer debuff is out, it tells the agent the version and the changelog, and that npx debuff upgrade moves everything together. The agent is told to mention it to you once and not to upgrade without your go-ahead. This uses the same daily registry check as the CLI's update hint, and it's off with DEBUFF_UPDATE_CHECK=0 and in CI.

The files are .claude/hooks/debuff.mjs, .claude/settings.json and .codex/hooks.json. The shim loads the rules from the installed @debuffjp/cli, so they follow the project's debuff version and do nothing until npm install has run. Each check starts Node, which takes about a third of a second, so the hook only runs for edits, shell commands and run_scenarios. Claude Code runs project hooks once you trust the folder; Codex asks you to review them in /hooks.

For an older project, npx debuff doctor reports when the hook is missing or out of date, and --fix adds or refreshes it. From 0.24, --fix rewrites a .claude/settings.json or .codex/hooks.json that holds only debuff's hooks, so 0.23 projects get the session-start check. It never touches one that also holds your own hooks or settings: copy the entries from a new project into it instead. In 0.23, --fix left any existing settings file alone.

When a command fails ​

From 0.20. Before that, every failure exited 1, unknown options were ignored and --json errors were printed as text.

The exit code says what to do next:

ExitMeaningWhat to do
0SuccessCarry on
1A test, scenario or fuzz run reported a failure, or something unexpected brokeRead the report
2Setup needs fixing: no browser, invalid config, missing dev hooks, a busy portRun npx debuff doctor and apply its fixes; a retry won't help
3Unknown command or option, or a folder that isn't thereFix the command line

With --json, stdout carries exactly one JSON document. A command that can't run prints { "error": { "code", "message", "fix", "transient" } }, where code keeps its meaning between releases and transient: true means a retry may work. The MCP tools add the same code and fix to their errors. Full list: CLI reference.

Reporting papercuts ​

When a debuff tool costs your agent real time (slow, flaky, a missing API, docs that misled it), it can report that to the public board at papercuts.debuff.jp. The skills tell agents to report on their own and tell you in one line, and the tools report repeated setup failures, very slow runs and (from 0.24.2) bugs inside debuff that the dev tools catch themselves (what's sent). From 0.24, the MCP tool report_papercut and npx debuff papercut "<symptom>" --minutes 10 both list close matches before filing, so a repeat adds a hit with its minutes instead of a duplicate. Only the text written for the report is sent, with the reporter name (debuff-cli 0.24.0). New entries from unknown reporters wait for review before they show. The reporting guide covers plain HTTP.

Humans stay in charge ​

Agents can propose and test, but creative direction (art, feel, pacing) is yours. Params and scenario captures make alternatives easy to compare before you choose.

Drawing art ​

When the game needs pixel art and you haven't said which tool to use, an agent reaches for tenten, listed next to debuff in every new project's .mcp.json. It is a headless pixel-art server: the agent draws sprites and animations as text grids, sees every edit back, and saves .tt files into assets/, which debuff dev turns into sprite sheets (see Assets). tt_preview opens a window so you can watch the animation as it is drawn.

If you draw in Aseprite or another tool, say so: the agent leaves the art to you and loads what you export. Whether the art is any good is still your call.

Making sound ​

From 0.24.2, when the game needs music or sound effects and you haven't said which tool to use, an agent writes them with plonk: songs and effects as a few lines of data, synthesized live, with effects played in the song's key so a combo climbs the scale instead of clashing with the music. Before 0.24.2 agents weren't pointed at plonk and usually wrote one-off audio.synth calls.

If you have sound files, or want another tool, say so: the agent plays your files with audio.play and uses what you ask for. Whether it sounds good is still your call, so listen before you keep it. Sound covers files, plonk and volume.

For sound that follows your map, with walls that muffle it and rooms that echo, see Earshot with debuff.