game-perf
БесплатноБез исполняемых скриптовНе проверенDetect and fix 10 common frame-drop patterns in game/interactive app code. Covers React/Zustand UI patterns AND game engine patterns (Three.js, WebGL, Canvas…
от akillness★ 63 звезды на GitHubОб этом скилле
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
Установить game-perf в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
GrepGlobReadEditAgentВложенные файлы
FAQ
Что делает скилл game-perf?
Detect and fix 10 common frame-drop patterns in game/interactive app code. Covers React/Zustand UI patterns AND game engine patterns (Three.js, WebGL, Canvas 2D, PixiJS, Phaser, ECS). Triggers: performance, frame drop, fps, jank, stutter, lag, optimization, game loop, render loop, requestAnimationFrame, animation performance, three.js, webgl, canvas, pixi, phaser, gc, draw call, dispose, pool, timestep
Как установить скилл game-perf?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл game-perf запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic