Skip to main content
rule CX Codex

perf-r3f-perf — Claude Code rule: React Three Fiber monitoring

The perf-r3f-perf rule teaches Claude Code about r3f-perf, a performance monitoring library for Three.js scenes in real time. Spot frame drops, memory leaks, and unnecessary matrix recalculations as they happen.

MIT ★ 4,719 updated 2026-10-24

Install into Claude Code · Manually: put the files in place All methods and platforms ↓
.claude/rules/perf-r3f-perf.md
Open on GitHub

What perf-r3f-perf does

r3f-perf displays FPS, frame time (milliseconds), CPU and GPU load, memory usage, and draw call count directly on screen. Enable deep analysis to profile render time per object, though it adds overhead. The component positions itself in any corner, supports minimal mode (FPS only), and can render a live performance graph.

The rule shows Claude Code how to add <Perf /> to Canvas, adjust its props, and conditionally disable it in production via process.env.NODE_ENV === 'development'. The monitor itself consumes resources—disable or minimize it before shipping.

What it helps with

  • spot frame rate drops in Three.js scenes
  • detect geometry and texture memory leaks
  • count draw calls and optimize rendering batches
  • profile render time for individual objects

Example prompts for the agent

  • Add r3f-perf to Canvas to see live FPS and frame timing
  • Position the monitor and enable the performance graph for visual feedback
  • Turn on deepAnalyze to find which object consumes the most render time

How to install perf-r3f-perf

Manually: put the files in place

.claude/rules/perf-r3f-perf.md

The paths frontmatter field limits the files

Step by step, with commands for each platform: AGENTS.md vs CLAUDE.md: what they are and which one to use

Questions about perf-r3f-perf

How do I install perf-r3f-perf in Claude Code?

Create .claude/rules/perf-r3f-perf.md with the rule content. Claude Code loads it automatically on the next project start.

What does r3f-perf monitor?

Frames per second, milliseconds per frame, JavaScript execution time, WebGL draw time, memory for geometries and textures, and matrix recalculation count. All output appears on screen during development.

When should I use deepAnalyze mode?

Only when hunting for a specific bottleneck. The mode increases CPU cost, so enable it briefly—deep analysis itself can skew measurements and slow things down.

Source text

perf-r3f-perf.md · MIT
# r3f-perf for Performance Monitoring

> Source: [100 Three.js Tips - Utsubo](https://www.utsubo.com/blog/threejs-best-practices-100-tips)

Use r3f-perf for comprehensive React Three Fiber performance monitoring.

## Installation

```bash
npm install r3f-perf
```

## Basic Usage

```jsx
import { Perf } from 'r3f-perf';

function App() {
  return (
    <Canvas>
      <Perf position="top-left" />
      <Scene />
    </Canvas>
  );
}
```

## Available Props

```jsx
<Perf
  position="top-left"     // Position: top-left, top-right, bottom-left, bottom-right
  minimal={false}         // Minimal mode (just FPS)
  showGraph={true}        // Show performance graph
  matrixUpdate={true}     // Show matrix updates
  deepAnalyze={false}     // Deep analysis (more CPU intensive)
  overClock={false}       // Over-clock mode for high refresh rate monitors
  logsPerSecond={10}      // Logs per second
/>
```

## What It Monitors

- **FPS** - Frames per second
- **MS** - Milliseconds per frame
- **CPU** - JavaScript execution time
- **GPU** - WebGL draw time (estimated)
- **Memory** - Geometries, textures, draw calls
- **Matrix Updates** - Number of matrix recalculations

## Conditional Rendering for Production

```jsx
import { Perf } from 'r3f-perf';

function App() {
  const isDev = process.env.NODE_ENV === 'development';

  return (
    <Canvas>
      {isDev && <Perf position="top-left" />}
      <Scene />
    </Canvas>
  );
}
```

## Deep Analyze Mode

For detailed per-object analysis:

```jsx
<Perf
  deepAnalyze={true}
  className="custom-perf"
/>
```

Shows render times for individual objects but has higher CPU overhead.

## Best Practices

1. **Remove in production** - Always hide in production builds
2. **Use sparingly** - Performance monitor itself has overhead
3. **Check draw calls** - Target under 100 draw calls
4. **Monitor memory** - Watch for leaking geometries/textures
5. **Use alongside renderer.info** - For detailed WebGL stats

© zebbern · MIT · zebbern/claude-code-guide

Similar IDE rules

All IDE rules for Frontend and UI →

From the same set86

The whole set →
memory-dispose-geometry memory-dispose-geometry is a Claude Code rule that tells the agent to release geometry when removing scene objects. It applies to Three.js resource cleanup. CX Codex +1 ★ 4,719repo stars root-cause-debugger The root-cause-debugger subagent for Claude Code and Codex reproduces failures and finds bug root causes before code changes. It helps diagnose bugs without editing code. CX Codex ★ 4,719repo stars code-reviewer code-reviewer is a Claude Code subagent that checks completed work for bugs and regressions. It runs after implementation or when an existing diff needs review. CX Codex ★ 4,719repo stars perf-visibility-toggle perf-visibility-toggle guides the AI to toggle the visible prop on Three.js components rather than conditionally unmounting them, avoiding GPU shader recompilation. CX Codex +1 ★ 4,719repo stars codebase-mapper codebase-mapper maps repository structure, call chains, and data flows before code changes without mutating any files. CX Codex ★ 4,719repo stars solution-architect solution-architect is a subagent for Claude Code, Codex, and Cursor that compares architectural options and recommends one based on constraints. It is used when requirements are set but several designs are viable. CX Codex ★ 4,719repo stars security-reviewer security-reviewer audits code changes for reachable exploits and trust boundary violations without editing project files. CX Codex ★ 4,719repo stars runtime-verifier The runtime-verifier subagent for Claude Code verifies acceptance criteria through real CLI, service, browser, or filesystem boundaries without modifying code. CX Codex ★ 4,719repo stars

Project sponsors

Companies that keep this analytics open