Agent skill

R3f Best Practices

by zebbern in zebbern/claude-code-guide

React Three Fiber (R3F) and Poimandres ecosystem best practices.

MITAuto-check passedGame Development

Install R3f Best Practices

skills CLI
$ npx skills add zebbern/claude-code-guide --skill r3f-best-practices -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install zebbern/claude-code-guide r3f-best-practices --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/zebbern/claude-code-guide.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/r3f-best-practices .claude/skills/r3f-best-practices && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
r3f-best-practices
GitHub stars
4.7k
Token cost
~2k tokens
SKILL.md length
588 words
Files
9
Skills in repo
46
Repo updated
First seen
Licence
MIT

At a glance

React Three Fiber (R3F) and Poimandres ecosystem best practices.

  • Works in 11 steps: Performance & Re-renders (CRITICAL) → useFrame & Animation (CRITICAL) → Component Patterns (HIGH) → …
  • Optimizing R3F code
  • SKILL.md covers Sources & Credits, When to Apply, Ecosystem Coverage and Rule Categories by Priority, plus 4 more sections
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md

What it does

R3f Best Practices is an agent skill from zebbern/claude-code-guide. React Three Fiber (R3F) and Poimandres ecosystem best practices. Use when writing, reviewing, or optimizing R3F code. Triggers on tasks involving @react-three/fiber, @react-three/drei, zustand, @react-three/postprocessing, @react-three/rapier, or leva.

Its SKILL.md is about 2k tokens, which your agent loads only when the skill is triggered. The skill folder holds 9 other files (for example `rules/_sections.md`, `rules/drei-use-gltf.md` and `rules/frame-delta-time.md`).

It sits in Game Development, covering State management and 3D graphics and WebGL. It works with React and Zustand. The repository describes itself as: Claude Code Guide - Setup, Commands, workflows, agents, skills & tips-n-tricks from beginner to power user! The licence is MIT.

When your agent uses it

  • Optimizing R3F code
  • Tasks involving @react-three/fiber
  • @react-three/drei
  • @react-three/postprocessing

Example prompts

  • “/r3f-best-practices”

Workflow steps

11 steps, taken from the step headings in SKILL.md.

  1. Performance & Re-renders (CRITICAL)
  2. useFrame & Animation (CRITICAL)
  3. Component Patterns (HIGH)
  4. Canvas & Setup (HIGH)
  5. Drei Helpers (MEDIUM-HIGH)
  6. Loading & Suspense (MEDIUM-HIGH)
  7. State Management (MEDIUM)
  8. Events & Interaction (MEDIUM)
  9. Post-processing (MEDIUM)
  10. Physics Rapier (LOW-MEDIUM)
  11. Leva (LOW)

What it can do on your machine

Read from SKILL.md and the folder at commit 7ff9fbb. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md (its code samples are javascript).

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    Links to these hosts (documentation or services it may open):

    • utsubo.com

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

R3f Best Practices loads about 2k tokens when it runs. Until then it costs about 68 tokens; SKILL.md has 588 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~68
When it runs · the whole SKILL.md, loaded when a task matches
~2k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from zebbern/claude-code-guide at commit 7ff9fbb, republished under its MIT licence (© zebbern). 588 words, ~2,007 tokens.

Download SKILL.mdSave it as .claude/skills/r3f-best-practices/SKILL.md (or your agent's skills folder). This skill also uses 8 other files; get the full folder from GitHub.
name
r3f-best-practices
description
React Three Fiber (R3F) and Poimandres ecosystem best practices. Use when writing, reviewing, or optimizing R3F code. Triggers on tasks involving @react-three/fiber, @react-three/drei, zustand, @react-three/postprocessing, @react-three/rapier, or leva.
license
MIT
metadata.author
three-agent-skills
metadata.version
1.1.0

React Three Fiber Best Practices

Comprehensive guide for React Three Fiber and the Poimandres ecosystem. Contains 70+ rules across 12 categories, prioritized by impact.

Sources & Credits

Additional tips from 100 Three.js Tips by Utsubo

When to Apply

Reference these guidelines when:

  • Writing new R3F components
  • Optimizing R3F performance (re-renders are the #1 issue)
  • Using Drei helpers correctly
  • Managing state with Zustand
  • Implementing post-processing or physics

Ecosystem Coverage

  • @react-three/fiber - React renderer for Three.js
  • @react-three/drei - Useful helpers and abstractions
  • @react-three/postprocessing - Post-processing effects
  • @react-three/rapier - Physics engine
  • zustand - State management
  • leva - Debug GUI

Rule Categories by Priority

PriorityCategoryImpactPrefix
1Performance & Re-rendersCRITICALperf-
2useFrame & AnimationCRITICALframe-
3Component PatternsHIGHcomponent-
4Canvas & SetupHIGHcanvas-
5Drei HelpersMEDIUM-HIGHdrei-
6Loading & SuspenseMEDIUM-HIGHloading-
7State ManagementMEDIUMstate-
8Events & InteractionMEDIUMevents-
9Post-processingMEDIUMpostpro-
10Physics (Rapier)LOW-MEDIUMphysics-
11Leva (Debug GUI)LOWleva-

Quick Reference

1. Performance & Re-renders (CRITICAL)
  • perf-never-set-state-in-useframe - NEVER call setState in useFrame
  • perf-isolate-state - Isolate components that need React state
  • perf-zustand-selectors - Use Zustand selectors, not entire store
  • perf-transient-subscriptions - Use transient subscriptions for continuous values
  • perf-memo-components - Memoize expensive components
  • perf-keys-for-lists - Use stable keys for dynamic lists
  • perf-avoid-inline-objects - Avoid creating objects/arrays in JSX
  • perf-dispose-auto - Understand R3F auto-dispose behavior
  • perf-visibility-toggle - Toggle visibility instead of remounting
  • perf-r3f-perf - Use r3f-perf for performance monitoring
2. useFrame & Animation (CRITICAL)
  • frame-priority - Use priority for execution order
  • frame-delta-time - Always use delta for animations
  • frame-conditional-subscription - Disable useFrame when not needed
  • frame-destructure-state - Destructure only what you need
  • frame-render-on-demand - Use invalidate() for on-demand rendering
  • frame-avoid-heavy-computation - Move heavy work outside useFrame
3. Component Patterns (HIGH)
  • component-jsx-elements - Use JSX for Three.js objects
  • component-attach-prop - Use attach for non-standard properties
  • component-primitive - Use primitive for existing objects
  • component-extend - Use extend() for custom classes
  • component-forwardref - Use forwardRef for reusable components
  • component-dispose-null - Set dispose={null} on shared resources
4. Canvas & Setup (HIGH)
  • canvas-size-container - Canvas fills parent container
  • canvas-camera-default - Configure camera via prop
  • canvas-gl-config - Configure WebGL context
  • canvas-shadows - Enable shadows at Canvas level
  • canvas-frameloop - Choose appropriate frameloop mode
  • canvas-events - Configure event handling
  • canvas-linear-flat - Use linear/flat for correct colors
Show full SKILL.md (250 more words)Show less
5. Drei Helpers (MEDIUM-HIGH)
  • drei-use-gltf - useGLTF with preloading
  • drei-use-texture - useTexture for texture loading
  • drei-environment - Environment for realistic lighting
  • drei-orbit-controls - OrbitControls from Drei
  • drei-html - Html for DOM overlays
  • drei-text - Text for 3D text
  • drei-instances - Instances for optimized instancing
  • drei-use-helper - useHelper for debug visualization
  • drei-bounds - Bounds to fit camera
  • drei-center - Center to center objects
  • drei-float - Float for floating animation
6. Loading & Suspense (MEDIUM-HIGH)
  • loading-suspense - Wrap async components in Suspense
  • loading-preload - Preload assets with useGLTF.preload
  • loading-use-progress - useProgress for loading UI
  • loading-lazy-components - Lazy load heavy components
  • loading-error-boundary - Handle loading errors
7. State Management (MEDIUM)
  • state-zustand-store - Create focused Zustand stores
  • state-avoid-objects-in-store - Be careful with Three.js objects
  • state-subscribeWithSelector - Fine-grained subscriptions
  • state-persist - Persist state when needed
  • state-separate-concerns - Separate stores by concern
8. Events & Interaction (MEDIUM)
  • events-pointer-events - Use pointer events on meshes
  • events-stop-propagation - Prevent event bubbling
  • events-cursor-pointer - Change cursor on hover
  • events-raycast-filter - Filter raycasting
  • events-event-data - Understand event data structure
9. Post-processing (MEDIUM)
  • postpro-effect-composer - Use EffectComposer
  • postpro-common-effects - Common effects reference
  • postpro-selective-bloom - SelectiveBloom for optimized glow
  • postpro-custom-shader - Create custom effects
  • postpro-performance - Optimize post-processing
10. Physics Rapier (LOW-MEDIUM)
  • physics-setup - Basic Rapier setup
  • physics-body-types - dynamic, fixed, kinematic
  • physics-colliders - Choose appropriate colliders
  • physics-events - Handle collision events
  • physics-api-ref - Use ref for physics API
  • physics-performance - Optimize physics
11. Leva (LOW)
  • leva-basic - Basic Leva usage
  • leva-folders - Organize with folders
  • leva-conditional - Hide in production

How to Use

Read individual rule files for detailed explanations and code examples:

rules/perf-never-set-state-in-useframe.md
rules/drei-use-gltf.md
rules/state-zustand-selectors.md

Full Compiled Document

For the complete guide with all rules expanded: ../R3F_BEST_PRACTICES.md

Critical Patterns

NEVER setState in useFrame
jsx
// BAD - 60 re-renders per second!
function BadComponent() {
  const [position, setPosition] = useState(0);
  useFrame(() => {
    setPosition(p => p + 0.01); // NEVER DO THIS
  });
  return <mesh position-x={position} />;
}

// GOOD - Mutate refs directly
function GoodComponent() {
  const meshRef = useRef();
  useFrame(() => {
    meshRef.current.position.x += 0.01;
  });
  return <mesh ref={meshRef} />;
}
Zustand Selectors
jsx
// BAD - Re-renders on ANY store change
const store = useGameStore();

// GOOD - Only re-renders when playerX changes
const playerX = useGameStore(state => state.playerX);

// BETTER - No re-renders, direct mutation
useFrame(() => {
  const { value } = useStore.getState();
  ref.current.position.x = value;
});
Drei useGLTF
jsx
import { useGLTF } from '@react-three/drei';

function Model() {
  const { scene } = useGLTF('/model.glb');
  return <primitive object={scene} />;
}

// Preload for instant loading
useGLTF.preload('/model.glb');
Suspense Loading
jsx
function App() {
  return (
    <Canvas>
      <Suspense fallback={<Loader />}>
        <Model />
      </Suspense>
    </Canvas>
  );
}
r3f-perf Monitoring
jsx
import { Perf } from 'r3f-perf';

function App() {
  return (
    <Canvas>
      <Perf position="top-left" />
      <Scene />
    </Canvas>
  );
}
Toggle Visibility (Not Remounting)
jsx
// BAD: Remounting destroys and recreates
{showModel && <Model />}

// GOOD: Toggle visibility, keeps instance alive
<Model visible={showModel} />

© zebbern, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 8 other files in skills/r3f-best-practices of zebbern/claude-code-guide.

  • SKILL.md
  • rules/_sections.md
  • rules/drei-use-gltf.md
  • rules/frame-delta-time.md
  • rules/loading-suspense.md
  • rules/perf-never-set-state-in-useframe.md
  • rules/perf-r3f-perf.md
  • rules/perf-visibility-toggle.md
  • rules/perf-zustand-selectors.md

Open the folder on GitHubat commit 7ff9fbb

Compare with similar skills

R3f Best Practices next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

R3f Best Practices compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
R3f Best Practices this skillzebbern/claude-code-guide4.7k—~2kAutomated safety check: PassMIT
Reactflow Expertcuriositech/some_claude_skills244—~2.1kAutomated safety check: NotesMIT
23rdradiumcoders/23rd.dev145—~2.8kAutomated safety check: PassNone
Polycsslayoutit/polycss767—~2.4kAutomated safety check: PassMIT
React Flow Node TSmicrosoft/skills3.1k6 repos~502Automated safety check: PassMIT
React Generate Skilljiushiwon/wg-skills114—~2.8kAutomated safety check: PassApache-2.0

Similar skills

  • Reactflow Expert

    curiositech/some_claude_skills

    Builds DAG visualizations using ReactFlow v12 with custom nodes, ELKjs auto-layout, Zustand state management, and live state updates via WebSocket.

    244 GitHub stars~2.1k tokensUpdated 1 mo ago
    Frontend & DesignAuto-check: notes
  • 23rd

    radiumcoders/23rd.dev

    Install, choose, and compose 23rd shadcn/ui registry components for React and Svelte 5.

    145 GitHub stars~2.8k tokensUpdated 4 days ago
    Game DevelopmentAuto-check passed
  • Polycss

    layoutit/polycss

    Build PolyCSS scenes that render 3D meshes, primitive shapes, or custom polygons as DOM/CSS polygon elements.

    767 GitHub stars~2.4k tokensUpdated 1 mo ago
    Game DevelopmentAuto-check passed
  • React Flow Node TS

    microsoft/skills

    Official

    Create React Flow node components with TypeScript types, handles, and Zustand integration.

    3.1k GitHub starsUsed in 6 repos~502 tokens
    Frontend & DesignAuto-check passed
  • React Generate Skill

    jiushiwon/wg-skills

    This skill should be used when the user wants to create a standardized React 18 + TypeScript + Vite + Zustand project from scratch.

    114 GitHub stars~2.8k tokensUpdated 3 days ago
    Frontend & DesignAuto-check passed
  • Motion Design

    WrongStack/WrongStack

    Implement web and React animation, gesture feedback, layout transitions and scroll sequences.

    371 GitHub stars~852 tokensUpdated today
    Game DevelopmentAuto-check passed

More from zebbern/claude-code-guide

All 46 skills in this repo
  • Localization Toolkit

    zebbern/claude-code-guide

    This skill should be used when setting up, auditing, or enforcing internationalization/localization in UI codebases (React/TS, i18next or similar, JSON locales), including installing/configuring the…

    4.7k GitHub starsUsed in 1 repo~1.3k tokens
    Auto-check passed
  • Audit Flow

    zebbern/claude-code-guide

    Interactive system flow tracing across CODE, API, AUTH, DATA, NETWORK layers with SQLite persistence and Mermaid export.

    4.7k GitHub stars~4.2k tokensUpdated today
    Auto-check passed
  • Chart Image

    zebbern/claude-code-guide

    Generate publication-quality PNG chart images from data, supporting line, bar, area, candlestick, pie, and heatmap charts.

    4.7k GitHub stars~2.7k tokensUpdated today
    Auto-check passed
  • Code To Diagram

    zebbern/claude-code-guide

    Analyze codebases and automatically generate architecture diagrams, flowcharts, and org charts.

    4.7k GitHub stars~972 tokensUpdated today
    Auto-check passed
  • Code Vuln Audit

    zebbern/claude-code-guide

    Scan code for security issues: dependency vulnerabilities (npm/pip audit), secret leaks (regex and entropy analysis), and OWASP anti-patterns like SQL injection, XSS, or command injection.

    4.7k GitHub stars~1.3k tokensUpdated today
    Auto-check passed
  • Idor Testing

    zebbern/claude-code-guide

    This skill should be used when the user asks to "test for insecure direct object references," "find IDOR vulnerabilities," "exploit broken access control," "enumerate user IDs or object references,"…

    4.7k GitHub starsUsed in 8 repos~3.1k tokens
    Auto-check passed

Works with

Questions about R3f Best Practices

What does R3f Best Practices do?

React Three Fiber (R3F) and Poimandres ecosystem best practices. R3f Best Practices is an agent skill from zebbern/claude-code-guide. React Three Fiber (R3F) and Poimandres ecosystem best practices.

When should I use R3f Best Practices?

R3f Best Practices fits situations like: optimizing R3F code; tasks involving @react-three/fiber; @react-three/drei; @react-three/postprocessing.

How do I install R3f Best Practices in Claude Code?

Run `npx skills add zebbern/claude-code-guide --skill r3f-best-practices -a claude-code`. Or copy the skill folder (skills/r3f-best-practices in zebbern/claude-code-guide) into .claude/skills/r3f-best-practices in your project. Claude Code loads it when a task matches its description.

How do I install R3f Best Practices in Codex?

Run `npx skills add zebbern/claude-code-guide --skill r3f-best-practices -a codex`. Or copy the skill folder (skills/r3f-best-practices in zebbern/claude-code-guide) into .agents/skills/r3f-best-practices in your project. Codex loads it when a task matches its description.

Can I use R3f Best Practices in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add zebbern/claude-code-guide --skill r3f-best-practices -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/r3f-best-practices, .gemini/skills/r3f-best-practices, .github/skills/r3f-best-practices and .opencode/skills/r3f-best-practices in your project.

What does R3f Best Practices need to run?

SKILL.md names no scripts, command-line tools or credentials: R3f Best Practices is instructions for the agent only.

Does R3f Best Practices access the network?

SKILL.md names 1 domain. As links in the text: utsubo.com. This is read from the text; nothing was executed.

Is R3f Best Practices safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does R3f Best Practices use?

R3f Best Practices is published under the MIT licence (declared in SKILL.md). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does R3f Best Practices use?

About 2k tokens (SKILL.md is roughly 8k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to R3f Best Practices?

Skills that share tags, products or a category with R3f Best Practices: Reactflow Expert (curiositech/some_claude_skills, 244 stars), 23rd (radiumcoders/23rd.dev, 145 stars), Polycss (layoutit/polycss, 767 stars) and React Flow Node TS (microsoft/skills, 3.1k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains R3f Best Practices?

zebbern (a GitHub user) maintains it in zebbern/claude-code-guide, which has 4,650 GitHub stars. The repository holds 46 skills in this directory. The repository was last updated on October 10, 2026.

Source: zebbern/claude-code-guide on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.