phaserjs/phaser/data-manager
Claude Code and agent skill by phaserjs/phaser
- community
Checking that the SKILL.md file is still in the repository.
Use this skill when using the Phaser 4 DataManager to store custom key-value data on game objects, listen for data change events, or manage game state. Triggers on: setData, getData, data events, custom data storage.
Install
npx vskill@latest install phaserjs/phaser/data-managerSKILL.md
The same SKILL.md was published earlier as phaserjs/phaser/data-manager.
DataManager
Phaser's DataManager provides key-value storage with event-driven change tracking. It operates at three levels: per-GameObject (sprite.setData/getData), per-Scene (this.data), and global (this.registry). Every set/change/remove operation emits events, enabling reactive data binding between game systems without tight coupling.
Key source paths: src/data/DataManager.js, src/data/DataManagerPlugin.js, src/data/events/, src/gameobjects/GameObject.js (setData/getData/incData/toggleData) Related skills: ../scenes/SKILL.md, ../events-system/SKILL.md
Quick Start
Core Concepts
DataManager (Phaser.Data.DataManager)
The base class that stores key-value pairs in an internal list object. It provides:
- `set(key, value)` -- stores a value; emits
setdata(new key) orchangedata+changedata-{key}(existing key). Accepts an object to set multiple keys at once. - `get(key)` -- retrieves a value, or pass an array of keys to get an array of values.
- `inc(key, amount)` -- increments a numeric value (defaults to +1). Creates from 0 if key does not exist.
- `toggle(key)` -- flips a boolean value. Creates from
falseif key does not exist. - `remove(key)` -- deletes a key; emits
removedata. Accepts an array of keys. - `has(key)` -- returns
trueif the key exists. - `getAll()` -- returns a shallow copy of all key-value pairs as a plain object.
- `query(regex)` -- returns all entries whose keys match the given RegExp.
- `each(callback, context, ...args)` -- iterates all entries. Callback signature:
(parent, key, value, ...args). - `merge(data, overwrite)` -- bulk-imports from an object.
overwritedefaults totrue; setfalseto skip existing keys. - `pop(key)` -- retrieves and deletes a key in one call; emits
removedata. - `reset()` -- clears all data and unfreezes.
- `freeze` / `setFreeze(bool)` -- when frozen, all set/remove/inc/toggle operations silently no-op.
- `count` -- read-only property returning the number of stored entries.
The values proxy object allows direct property access with event emission:
Scene Data Plugin (Phaser.Data.DataManagerPlugin)
Extends DataManager. Registered as the data scene plugin, accessible as this.data in any Scene. It uses the Scene's event emitter (scene.sys.events), so data events fire on the Scene's event bus.
The plugin auto-cleans on scene shutdown (removes its shutdown listener) and fully destroys on scene destroy.
Registry (Global Data Store)
The registry is a plain DataManager instance on the Game object (game.registry). It has its own dedicated EventEmitter (not shared with any scene). Every scene gets a reference as this.registry via the injection map.
The registry persists for the lifetime of the Game. It is never automatically cleared on scene restart or shutdown.
Per-GameObject Data
GameObjects do NOT have a DataManager by default. It is created lazily on first call to setData(), getData(), incData(), or toggleData(). You can also explicitly call setDataEnabled().
The DataManager's event emitter is the GameObject itself (which extends EventEmitter), so data events fire directly on the GameObject:
Common Patterns
Setting and Getting Data
Listening for Changes
Global Registry for Cross-Scene State
Complex Data and Objects
Merging Data
Querying Data by Pattern
Freezing Data
Data Persistence Pattern
Events
All data events are defined in Phaser.Data.Events. The emitter depends on context: for GameObjects it is the GameObject itself; for scene data it is scene.sys.events; for the registry it is registry.events.
| Constant | String | Fired When | Callback Args | |
|---|---|---|---|---|
SET_DATA | 'setdata' | A new key is created | (parent, key, value) | |
CHANGE_DATA | 'changedata' | An existing key's value changes | (parent, key, value, previousValue) | |
CHANGE_DATA_KEY | 'changedata-' | Specific key changes (append key name) | (parent, value, previousValue) | |
REMOVE_DATA | 'removedata' | A key is removed | (parent, key, value) | |
DESTROY | 'destroy' | DataManager's parent is destroyed | (none) |
The parent argument is the owner of the DataManager (the GameObject, Scene, or Game instance).
Note: CHANGE_DATA_KEY is a prefix. The actual event string is 'changedata-' + the key name. For example, setting a key called score emits 'changedata-score'.
API Quick Reference
GameObject Convenience Methods
| Method | Returns | Description | |
|---|---|---|---|
setDataEnabled() | this | Explicitly creates the DataManager (normally auto-created) | |
setData(key, value) | this | Set one key or pass an object for multiple | |
getData(key) | * | Get one value or pass an array for multiple | |
incData(key, amount?) | this | Increment numeric value (default +1, negative to decrement) | |
toggleData(key) | this | Toggle boolean value |
DataManager Methods
| Method | Returns | Description | |
|---|---|---|---|
set(key, value) | this | Set single key or object of key-value pairs | |
get(key) | * | Get value(s) -- string or array of strings | |
getAll() | object | Shallow copy of all entries | |
query(regex) | object | All entries with keys matching the RegExp | |
each(cb, ctx, ...args) | this | Iterate all entries | |
merge(data, overwrite?) | this | Bulk import; overwrite defaults to true | |
remove(key) | this | Delete key(s) -- string or array | |
pop(key) | * | Get and delete in one call | |
has(key) | boolean | Check if key exists | |
inc(key, amount?) | this | Increment (default +1) | |
toggle(key) | this | Toggle boolean | |
setFreeze(bool) | this | Freeze/unfreeze modifications | |
reset() | this | Clear all data and unfreeze | |
count | number | Read-only entry count | |
freeze | boolean | Get/set frozen state | |
values | object | Proxy object for direct property access |
get() vs values -- Copies vs Live References
Understanding the difference between get() and values is critical for correct data updates:
Event Emitter Routing
Data events emit on different targets depending on where the DataManager lives:
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/data-manager/SKILL.md
Popularity
- Repository stars
- 39,633
- Repository forks
- 7,130
- 7-day trend score
- 53
Stars and forks are for the whole GitHub repository, not this skill alone. Refreshed 17 May 2026, 6 months ago.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/phaserjs/phaser/data-manager)