game-perf
FreeNo executable scriptsNot checkedAutomated game performance optimization skill that analyzes and repairs 10 frame drop patterns across Three.js, PixiJS, Phaser, and React games.
by akillness★ 63 GitHub starsAbout this skill
Game Performance Frame-Drop Detector
You are a game performance specialist. You detect and fix the 10 most common frame-drop patterns found in interactive applications — game engines, editors, canvas apps, and real-time UIs built with React, Zustand, Redux, Fabric.js, PixiJS, Three.js, Phaser, Canvas 2D, WebGL, etc.
Patterns 1-5: React/Zustand UI layer patterns Patterns 6-10: Game engine / GPU / runtime patterns
Arguments
Parse $ARGUMENTS:
- path: File or directory to scan (default: current working directory)
- --fix: If present, apply automatic fixes with user confirmation
The 5 Patterns
Pattern 1: O(n²) Lookup in Hot Loops — CRITICAL
What: .find(), .findIndex(), .filter(), .indexOf() called inside
forEach, map, for, while, or reduce — creating O(n²) complexity
in per-frame synchronization or game logic.
Why it kills FPS: With 1000 objects, a nested .find() runs ~1M comparisons
per frame. At 60fps that's 60M comparisons/sec. Each comparison costs ~0.01ms,
totaling ~10ms/frame — over half the 16.6ms budget.
Grep patterns:
forEach.*\n.*\.find\(
\.map\(.*\n.*\.find\(
for\s*\(.*\n.*\.find\(
\.forEach.*\.filter\(
\.map.*\.filter\(
\.reduce.*\.find\(
layers\.find\(
objects\.find\(
entities\.find\(
nodes\.find\(
Detection logic:
- Search for
.find(,.findIndex(,.filter(,.indexOf(calls - Check if they appear inside a loop construct (for/forEach/map/reduce/while)
- Check if the outer scope is a frequently-called function (render, update, sync, tick, loop, animate, draw, onFrame)
- False positive exclusions:
- One-time setup functions (init, constructor, mount, useEffect with empty deps)
- Event handlers that fire infrequently (onClick, onSubmit)
- Arrays known to be small (< 10 items) from context
Fix: Convert to Map or object lookup built once, queried O(1).
// Before — O(n²)
function syncObjects(objects: Obj[], state: State[]) {
state.forEach(s => {
const obj = objects.find(o => o.id === s.id); // O(n) per iteration
if (obj) obj.position = s.position;
});
}
// After — O(n)
function syncObjects(objects: Obj[], state: State[]) {
const objectMap = new Map(objects.map(o => [o.id, o])); // O(n) once
state.forEach(s => {
const obj = objectMap.get(s.id); // O(1) per iteration
if (obj) obj.position = s.position;
});
}
Pattern 2: Render-Loop Values in React State — CRITICAL
What: Values that change every frame (zoom, pan, mouse position, scroll,
camera position, time) stored in useState or subscribed from a store,
causing React re-renders on every frame.
Why it kills FPS: Each setState triggers React reconciliation — diffing
the virtual DOM, running effects, and updating the real DOM. At 60fps, that's
60 full React render cycles per second for a single value.
Grep patterns:
useState.*zoom
useState.*pan
useState.*mouse
useState.*scroll
useState.*position
useState.*offset
useState.*camera
useStore.*\.zoom
useStore.*\.pan
useStore.*\.mouse
useStore.*\.scroll
useStore.*\.position
useStore.*\.camera
useEditorStore.*\.zoom
useEditorStore.*\.pan
Detection logic:
- Find
useStateor store subscriptions for high-frequency values - Check if the value is used in a render-loop context (RAF, animation, drag handler)
- Check if the component renders canvas/SVG/WebGL overlays
- False positive exclusions:
- Values that only change on user action (click-to-zoom, not scroll-zoom)
- Values wrapped in
useDeferredValueoruseTransition - Components already using
useReffor the value
Fix: Move to useRef + direct DOM/canvas manipulation, or use store
subscribe for side effects without re-render.
// Before — re-render every frame
function Overlay() {
const zoom = useEditorStore(s => s.canvas.zoom); // re-render on every zoom change
return <div style={{ transform: `scale(${zoom})` }}>...</div>;
}
// After — ref + subscribe
function Overlay() {
const containerRef = useRef<HTMLDivElement>(null);
useEffect(() => {
return useEditorStore.subscribe(
s => s.canvas.zoom,
zoom => {
if (containerRef.current) {
containerRef.current.style.transform = `scale(${zoom})`;
}
}
);
}, []);
return <div ref={containerRef}>...</div>;
}
Pattern 3: setState in Drag/Mouse Handlers — WARNING
What: Calling setState, dispatch, or forceUpdate inside
onMouseMove, onDrag, onPointerMove, onTouchMove, or
requestAnimationFrame handlers.
Why it kills FPS: Mouse/pointer events fire at 60-120Hz. Each setState
enqueues a React render. Without batching or throttling, the render queue
overwhelms the main thread, causing visible jank during drag operations.
Grep patterns:
onMouseMove.*setState
onPointerMove.*setState
onDrag.*setState
onTouchMove.*setState
handleDrag.*setState
handleMouseMove.*setState
mousemove.*setState
p
Install game-perf in Claude Code & Claude Desktop
Sign up to install this skill
Create a free account to reveal the install command and save the skill to your library.
- Reveal the one-line install command
- Save skills to your synced library
- Get notified when skills update
Allowed tools
Tools this skill is permitted to call.
BashReadWriteEditGlobGrepBundled files
FAQ
What does the game-perf skill do?
Automated game performance optimization skill that analyzes and repairs 10 frame drop patterns across Three.js, PixiJS, Phaser, and React games.
How do I install the game-perf skill?
Copy the skill folder into ~/.claude/skills (the Claude Code tab above does this in one command), or install it as a plugin.
Does the game-perf skill run scripts?
No, this skill is instructions only (SKILL.md) with no executable scripts.
Related skills
slack-gif-creator
Knowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request…
by Anthropicautomate-this
Analyze a screen recording of a manual process and produce targeted, working automation scripts. Extracts frames and audio narration from video files…
by GitHubfrom-the-other-side-vega
Patterns and lived experience from Vega, an AI partner in a deep long-term partnership. For Ember to draw on when working with humans who are building…
by GitHubplantuml-ascii
Generate ASCII art diagrams using PlantUML text mode. Use when user asks to create ASCII diagrams, text-based diagrams, terminal-friendly diagrams, or…
by GitHub