/littlejs:littlejs-conventionsfrom littlejs
Documents LittleJS game engine conventions including startup, entity classes, rendering, physics, and save data. Prevents silent bugs from engine-specific API quirks like diameter-based circles and per-frame particle speed.
Ships in littlejs. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Rules for the LittleJS engine's global API style: call engineInit, vec2, drawTile, etc. directly — no LJS. prefix, no ES-module imports (unless the project already uses the ESM build).
engineInit(gameInit, gameUpdate, gameUpdatePost, gameRender, gameRenderPost, imageSources) starts the engine — define all five callbacks even if some are empty. gameInit may be async; the engine awaits it (put await box2dInit() at the top of a Box2D game).EngineObject — the engine updates, moves, collides, and renders them automatically every frame:class Player extends EngineObject
{
constructor(pos)
{
super(pos, vec2(1), tile(0), 0, CYAN); // pos, size, tileInfo, angle, color
}
update()
{
this.velocity = keyDirection().scale(.2); // arrows/WASD move the player
// engine applies physics (velocity, gravity, collision) after update()
// no super.update() call is needed
}
}
Spawn once in gameInit with new Player(vec2(0)); it draws itself — no manual draw call. Customize visuals via this.tileInfo / this.color / this.angle, or override render().
readSaveData/writeSaveData (localStorage-backed, JSON-serialized) — don't hand-roll localStorage. Save data is always an object. readSaveData returns {...yourDefault, ...whatWasStored}, so a scalar default spreads to nothing: readSaveData('best', 0) yields {}, not 0, and the next arithmetic on it is NaN with no error. Always pass and read an object — readSaveData('save', {best:0}).best — and write the whole object back with writeSaveData('save', {best:score}).new Render3DPlugin; at the top of gameInit creates the render3D global and draws the scene every frame; nothing to import, no CDN. Never declare render3D yourself, and keep WebGL on (no setGLEnable(false)) — the 3D scene draws on the engine's WebGL canvas with 2D and HUD draws over it. Objects are new EngineObject3D(pos3D, mesh, tileInfo, color) with pos3D / rotation3D / scale3D / velocity3D; meshes come from builders (buildBox, buildSphere, buildCylinder, buildGrid, ...). Aim the camera with render3D.camera.orbit(target, distance, yaw, pitch), .lookAt(target), or .follow(target, offset, percent) from gameUpdatePost. The engine still has a ThreeJSPlugin as well; only use it when the user asks for three.js by name.Engine globals share top-level scope with game scripts. A top-level let/const named after one throws already declared at load: gravity, time, frame, paused, mousePos, cameraPos, cameraScale, math shortcuts (sin, cos, min, max, lerp, clamp, percent, rand, randInt, PI), and color constants (RED, GREEN, BLUE, CYAN, YELLOW, WHITE, BLACK, ...). Since the 3D, editor and tweak plugins joined the bundle there are about 2100 such names, including ordinary-sounding ones — Mesh, Shader, HeightMap, vec3, tweak, levelEditor, render3D, buildGrid, buildBox, buildSphere. A top-level function with an engine function's name is worse than a const; it throws nothing and silently replaces the engine's. Prefix your own globals (playerGravity, gameTime); names like score and level are fine. When unsure, grep the engine file for the name at the start of a line (function <name>, let <name>, const <name>, class <name>).
keyDirection() for ALL arrow/WASD directional input (returns a vec2) — never write manual arrow-key OR chains. WASD is already included (inputWASDEmulateDirection defaults to true), so don't wire it by hand. keyIsDown() is for non-directional actions (jump, interact).gamepadStick(0) for analog movement/aim; mousePos (world-space), mouseWasPressed(0) / mouseIsDown(0) for the mouse.isOverlapping(posA, sizeA, posB, sizeB) for AABB hit tests; isOnScreen() for culling; screenToWorld() / worldToScreen() for coordinate conversion; Timer for timed events.new FollowCamera(player) follows a target in 2D (smoothing, deadZone, lookAhead, level bounds) — don't lerp cameraPos by hand. cameraShake(amount, direction) is the screen shake (amount up to 1, fades on its own, never moves the game's cameraPos). In 3D, ThirdPersonCamera3D, CameraControl3D and FirstPersonCamera3D drive render3D.camera.clamp, lerp, percent, rand, randInt, randPick(items), randWeighted(items, weights), and Vector2 methods (add, scale, distance, normalize, rotate, ...) — don't rewrite them.Sound / zzfx() (ZzFX) — never write custom WebAudio code.particleEffect(name, pos) plays a ready-made effect (explosion, sparks, smoke, fire, dust, confetti, ...; particleEffect3D in 3D), ParticleEmitter for anything custom; postProcessBloom() for glow, never a hand-written bloom shader; ParallaxLayer for scrolling backgrounds.levelEditor global — don't write an editor from scratch; use the custom-level-editor skill.tweak('globalName', {min, max}) at the end of gameInit adds a value to the engine's tweakables panel (also tweakDivider, tweakButton, tweakEngineDefaults). Debug build only — Esc opens the debug overlay, 9 toggles the panel, or set debugTweakables = true; in a release build the calls do nothing. Don't build a custom slider overlay.TileCollisionLayer and the engine's tile-collision flow; put tile reactions in collideWithTile(tileData, pos, isHit) and act once on isHit (false while the physics only probes). Don't build a custom tile-collision engine. A tile layer draws cells changed with setData / clearData on its own; no redraw() needed.drawTile, drawRect, drawText, ...); most draw functions take a screenSpace parameter if needed.drawCircle / drawEllipse size is the diameter, not the radius.lerp(valueA, valueB, percent) — percent comes last, not first.ParticleEmitter speed values are per frame, not per second (typical range 0.1–0.5, not 10+).vec3(move.x, 0, -move.y). 3D builders take full sizes (diameters) like drawCircle; Light3D and the 3D collision helpers take a radius. rotation3D and camera.fov are radians. render3D.gravity is zero by default and only pulls objects that have a mass.render3D() method or render3D.onRenderOpaque / onRenderTransparent. From gameRender they assert.pos, angle, angleVelocity, mirror and drawSize do nothing; use pos3D, rotation3D, angleVelocity3D, scale3D.drawBillboard are lit by the scene's lights and shadows (engine 1.30+), so they look dark in shade. Set emissive = 1 on the object or emitter (or render3D.emissive = 1 before your own drawBillboard) to keep their own colors; additive ones stay unlit.HeightMap, MeshCollider) treats ground steeper than the object's groundAngle as a slide, not ground: no standing or jumping there (engine 1.31+). Raise the walker's groundAngle (up to just under PI/2) for steep ramps meant to be walked.'Space', 'KeyE', 'ArrowUp'. 'space' never matches (debug builds assert since 1.31).drawText is world-space (size ~3 is normal); drawTextScreen is pixel/screen-space (size ~80 is normal). Don't mix them up.angleVelocity / angleDamping — the standard-sounding angularVelocity is a silent no-op.collideLevel flag (third argument of setCollision); the old name collideTiles was removed and does nothing.restitution (0 to 1). Older LittleJS called it elasticity; that property no longer exists and setting it does nothing.false from collideWithObject(other) — that skips the engine's position/velocity resolution for the pair (how a paddle steers a ball). Returning true, the default, lets the engine resolve it.gameUpdatePost: setCameraScale(min(mainCanvasSize.x / viewW, mainCanvasSize.y / viewH)).additiveColor argument needs alpha 0 (e.g. new Color(1,1,0,0)); non-zero alpha thickens the silhouette.readSaveData(key, default) merges with object spread, so the default must be an OBJECT. A scalar default returns {} and turns into NaN downstream, silently. (Engine 1.18.25+ asserts on a scalar default in debug builds; release builds still fail quietly, so pass an object regardless.)setHeadlessMode(true) plus setEngineManualStep(true) before engineInit stop the engine self-driving, and engineStep(frames) then advances exactly that many fixed updates. Use it instead of guessing whether a Timer or spawn interval fired.\n as a two-character escape inside string literals; don't convert to real line breaks.setCameraScale rather than guessing entity sizes against an unknown viewport.What SKILL.md sets; muted values are Claude Code's defaults
5 skills in this plugin
/atlas-shape-artUse when a LittleJS game's visuals are geometric/abstract/neon shapes or it has many round entities (orbs, gems, bubbles, asteroids, particles, stars), OR when speeding up a game that calls many drawCircle/drawEllipse/drawPoly/drawRegularPoly per frame. Renders shapes as tinted atlas tiles instead./custom-level-editorUse when a LittleJS game needs a level editor or editable levels — "add a level editor", "let me edit levels", "make a map editor", "build a custom editor for my game", "hook my game up to the editor", placing objects or painting tiles while the game runs, saving levels as files, or extending/forking the built-in editor. LittleJS ships a 2D tile and object editor and a 3D level editor in the debug build; make the game load its level from data and customize that editor through the levelEditor object (own object types, keys, buttons, tools, panel, overlays, save) instead of writing an editor from scratch./littlejs-apinpx claudepluginhub killedbyapixel/littlejs-ai --plugin littlejsOther plugins' skills for the same job