
improve-threejs
Audit and fix Three.js and React Three Fiber apps for frame-loop performance, GPU memory leaks, scene-graph correctness, and visual defects like z-fighting, shadow acne, wrong color space, and broken resize handling. Uses React Doctor as the scanning engine plus a visual rubric checked against rendered output. Use when the user asks to improve, audit, scan, or clean up a Three.js, R3F, react-three-fiber, drei, or WebGL app, or types /improve-threejs.
- Installs
- 320
- Last 24h
- —
- Trending rank
- —
- Security
- Not audited
Install
Works with every agent the skills CLI supports.
npx skills add https://github.com/millionco/react-doctor --skill improve-threejs- 01
Install
Run the command in your project. The CLI asks which agents to install for.
- 02
Describe the task
Ask your agent for something this skill covers. It loads improve-threejs automatically when relevant.
- 03
Review the result
The agent follows the SKILL.md steps, scripts and references bundled with the skill.
SKILL.md
The instructions your agent reads when the skill is triggered.
Improve Three.js
Audits a Three.js or React Three Fiber (R3F) codebase and fixes what hurts most: work that runs every frame, GPU resources that never get disposed, scene-graph objects rebuilt on every render, and visual defects the user can see. React Doctor supplies the machine-verified code scan; this skill supplies the frame-loop judgment and the visual inspection a general React scanner lacks.
The core principle: severity follows the render loop. Code inside useFrame or a requestAnimationFrame callback runs 60 times per second, so a minor inefficiency there outweighs a major one in a settings panel. Rank every finding by where it runs, not by the rule's default severity.
Workflow
Step 1: Recon
Identify the stack before scanning: plain Three.js or R3F, which helper libraries are in use (drei, postprocessing, rapier), and where the render loop lives (useFrame hooks, requestAnimationFrame, the <Canvas frameloop> setting).
Build a hot-path map: every useFrame body, every RAF callback, every pointer-move handler. These files get the strictest review in Step 3.
Step 2: Scan
Run React Doctor read-only to collect structured evidence:
npx react-doctor@latest --verbose
For a regression check after making changes, run with --scope changed and confirm the score did not drop.
Step 3: Triage by frame-loop leverage
Re-rank the scanner's findings using the hot-path map, then hunt for the Three.js-specific problems the scanner cannot see. Confirm every finding at its file:line before reporting it.
HIGH severity, runs every frame or leaks GPU memory:
- Allocation inside
useFrame:new Vector3(),new Color(), or fresh arrays passed to Three.js APIs each frame. Fix: hoist a scratch object to module scope oruseMemo, then mutate it in place setStateinsideuseFrame: re-renders the React tree on every frame. Fix: mutate refs directly; reserve state for discrete changes like selection or visibility- Missing disposal: geometries, materials, textures, or render targets created imperatively and never disposed. Fix: call
dispose()in the cleanup function, or move the object into R3F's declarative tree so it owns the lifecycle - Object reconstruction in render: geometry or material instances created without
useMemo, or inlineargsarrays whose identity changes each render, forcing R3F to rebuild the underlying object
MEDIUM severity, per-render or per-interaction waste:
- Unstable scene-graph props: inline
new THREE.Vector3()or fresh material objects as props (plain arrays likeposition={[x, y, z]}are fine; R3F handles them) - Missing instancing: hundreds of identical meshes rendered individually instead of through
<Instances>orInstancedMesh - Wasted frames:
frameloop="always"on a scene that only changes on interaction. Fix:frameloop="demand"plusinvalidate() - Uncached asset loading: textures and models loaded outside
useLoader,useTexture, oruseGLTF, losing caching and Suspense integration
LOW severity, hygiene: React Doctor findings on non-canvas UI code, missing <Preload>, oversized textures.
Step 4: Visual audit
Inspect what the scene actually renders. Every visual finding needs evidence: a screenshot, a frame capture, or a reproduced observation, never a guess from reading source. When a dev server and browser are available, load the app, capture the first stable frame, then capture again after moving the camera and interacting. When no browser is available, check the code-level causes listed below and label each finding as inferred from source.
Apply the mini rubric. A row fails only when the evidence shows the failure condition:
| Area | Check | Fail when |
|---|---|---|
| Render sanity | The scene reaches a stable frame after load | Black canvas, WebGL context errors, or content that never appears |
| Geometry | Move the camera along seams, edges, and boundaries | Gaps, missing faces, visible backfaces, or two surfaces flickering at the same depth (z-fighting) |
| Transparency and depth | Cross depth-order boundaries with overlapping or transmissive surfaces | Wrong sort order, halos, opaque surfaces that should transmit, or flicker at grazing angles |
| Textures | View mapped surfaces close, far, and at grazing angles | Missing textures, stretching, seams, moiré, shimmer, or washed-out colors from a wrong color space |
| Materials and lighting | Change light and view direction on lit surfaces | Surfaces that ignore light direction, or reflective metals with no environment to reflect |
| Shadows | Move casters, receivers, and the light through their range | Acne, detached or floating shadows, flicker at rest, or shadows that outlive their caster |
| Camera | Follow the primary subject through movement and transitions | Subject leaves frame, camera clips into geometry, or foreground blocks the play area |
| Scale and contact | Compare object scale and resting contact against surroundings | Objects float above, sink into, or intersect their support surface, or sit at implausible scale |
| Image stability | Pan the camera slowly at supported resolutions | Silhouettes, thin geometry, or highlights that crawl, sparkle, or ghost |
| Resize and DPR | Change viewport size, zoom, and device pixel ratio | Distortion, blur, stretched output, or content leaving the viewport |
Each rubric row has a small set of usual code-level causes. Check these first when a row fails:
- Washed-out or too-dark colors:
renderer.outputColorSpacenot set toSRGBColorSpace, color textures missingtexture.colorSpace = SRGBColorSpace, or a data texture (normal, roughness) wrongly marked sRGB - Z-fighting: coplanar geometry needing
polygonOffsetor a position nudge, or a near plane set far too small for the scene scale - Shadow acne or floating shadows:
shadow.biasandshadow.normalBiasuntuned, or a shadow camera frustum far larger than the scene - Blurry or stretched canvas: renderer size not synced to canvas CSS size,
setPixelRationever called, or a resize handler that forgetscamera.updateProjectionMatrix() - Black metals:
metalness: 1with noscene.environmentset - Transparency sorting glitches: large transparent meshes needing
depthWrite: false, manualrenderOrder, or a split into smaller meshes - Shimmer and crawl: missing texture anisotropy, antialiasing disabled, or thin geometry needing thicker forms
Step 5: Fix
Fix in severity order: HIGH performance findings and failed visual rows first. When a finding maps to a React Doctor rule, fetch the canonical recipe instead of improvising:
https://www.react.doctor/prompts/rules/<plugin>/<rule>.md
For Three.js-specific findings, apply the fix named in the triage list or the cause list above.
Step 6: Validate
Run npx react-doctor@latest --verbose --scope changed and confirm the score did not regress. Re-check every visual rubric row that failed, using the same viewpoint and interaction as the original evidence, and confirm it now passes. Then verify behavior: the scene renders, animations play, and interactions respond. If browser dev tools are available, watch the memory profile while orbiting an idle scene; a rising heap during idle means a disposal leak survived.
Checks the scanner always misses
Review these by hand on every audit:
dispose()coverage for every imperatively created GPU resource- Allocations and
setStateinsideuseFrameand RAF callbacks - Event listeners and
ResizeObservers on the canvas or window without cleanup - Raycasting against the full scene on every pointer move instead of a filtered target list
- Shadows or postprocessing enabled globally when one part of the scene needs them
- Color space configuration on the renderer and every color texture
FAQ
What does the improve-threejs skill do?
Audit and fix Three.js and React Three Fiber apps for frame-loop performance, GPU memory leaks, scene-graph correctness, and visual defects like z-fighting, shadow acne, wrong color space, and broken resize handling. Uses React Doctor as the scanning engine plus a visual rubric checked against rendered output. Use when the user asks to improve, audit, scan, or clean up a Three.js, R3F, react-three-fiber, drei, or WebGL app, or types /improve-threejs.
How do I install improve-threejs?
Run npx skills add https://github.com/millionco/react-doctor --skill improve-threejs in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/improve-threejs/ (personal) or .claude/skills/improve-threejs/ (project).
Which AI agents can use improve-threejs?
Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.
Is improve-threejs safe to install?
No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.
Who maintains improve-threejs?
It is published by millionco in millionco/react-doctor. It has 320 recorded installs.
More from millionco/react-doctor
react-doctor
millionco/react-doctor
Use when finishing a feature, fixing a bug, before committing React code, or when the user types /doctor, asks to scan, triage, or clean up React diagnostics. Covers lint, accessibility, bundle size, architecture. Includes a regression check and a full local-triage workflow that fetches the canonical playbook.
improve-react
millionco/react-doctor
Survey a whole React codebase as a senior React engineer, using React Doctor's scan as evidence, then produce a prioritized audit and self-contained implementation plans for other agents (or cheaper models) to execute. Read-only on source code — it plans improvements, it does not apply them. Use when the user asks to "improve the React code", "audit this codebase", "make this app faster / more robust", or wants a roadmap of fixes rather than a review of a single diff. For a regression check or a fix-it-now pass, use the react-doctor skill instead.
deslop
millionco/react-doctor
Simplify and refine recently modified code while preserving functionality. Use when asked to "deslop", "clean up code", "simplify code", or after making changes that could benefit from refinement.
rule-validate
millionco/react-doctor
Validate an implemented React Doctor rule before merge. Use after focused tests pass to review detector correctness, inspect open-source hits, run pull request parity, add regression coverage, prepare a changeset, write pull request copy, or address review findings.
find-similar-functions
millionco/react-doctor
Use truffler to find similar or pre-existing JavaScript/TypeScript symbols before implementing new code, especially helpers, utilities, parsers, formatters, scanners, fuzzy matchers, and other reusable functions. Agents should use this skill whenever they are about to add or refactor functionality in a JS/TS repository and need to avoid duplicating existing code, even if the user does not explicitly mention deduplication.
rule-writing
millionco/react-doctor
Implement React Doctor rules from a validated contract. Use when writing oxlint rules, planning syntax or control-flow detection, designing adversarial tests, reusing syntax tree utilities, or updating rule registration.
Popular frontend & design skills
setup-matt-pocock-skills
mattpocock/skills
Configure this repo for the engineering skills: set up its issue tracker, triage label vocabulary, and domain doc layout. Run once before first use of the other engineering skills.
frontend-design
anthropics/skills
Guidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making choices that don't read as templated defaults.
hyperframes-animation
heygen-com/hyperframes
All animation knowledge for HyperFrames — atomic motion rules, multi-phase scene blueprints, scene transitions, broader motion-design techniques, AND the seven runtime adapters (GSAP default, plus Lottie, Three.js, Anime.js, CSS keyframes, Web Animations API, TypeGPU). Use for any motion or animation task: pick 2-4 rules and compose, or load a blueprint, or look up runtime-specific API (e.g. GSAP eases / Lottie player / Three.js mixer). Also covers auditing an existing composition's choreography (animation map) and 24 named text-animation effects. HyperFrames-native: single paused timeline, seek-safe, deterministic.
prototype
mattpocock/skills
Build a throwaway prototype to answer a design question. Use when the user wants to sanity-check whether a state model or logic feels right, or explore what a UI should look like.
hyperframes-core
heygen-com/hyperframes
The HyperFrames composition contract — build one renderable project. Use for composition structure, the data- timing attributes, class="clip", tracks, sub-compositions, variables, framework-owned media playback, deterministic-render rules, and validation. Read before writing composition HTML.
vercel-react-best-practices
vercel-labs/agent-skills
React and Next.js performance optimization guidelines from Vercel Engineering. This skill should be used when writing, reviewing, or refactoring React/Next.js code to ensure optimal performance patterns. Triggers on tasks involving React components, Next.js pages, data fetching, bundle optimization, or performance improvements.