Setup react compiler

From redpanda-data/ui-harness · View interactive version

Setup react compiler is an AI agent skill from the GitHub repository redpanda-data/ui-harness. Install React Compiler with rsbuild and enforce compiler-friendly patterns via PostToolUse hooks. Flags manual memoization, derived state, useRef cache. Use when setting up React Compiler or post-compiler patterns.

How to use this skill

Skill file

Setup React Compiler

What This Sets Up

See REFERENCE.md for post-compiler rules.

Steps

1. Install

bun add -D babel-plugin-react-compiler @rsbuild/plugin-babel --yarn

2. Configure rsbuild

import { pluginBabel } from '@rsbuild/plugin-babel';
export default {
  plugins: [
    pluginBabel({
      babelLoaderOptions: {
        plugins: [['babel-plugin-react-compiler', {
          compilationMode: 'annotation', // 'infer' for greenfield
        }]],
      },
    }),
  ],
};

Brownfield: set REACT_COMPILER_MODE=annotation in session-env.sh.

3. Component library

Add 'use no memo' to all .tsx in component library dir.

4. Hook

Copy scripts/react-compiler-check.sh + scripts/_hook-lib.sh -> .claude/hooks/. chmod +x. Add to PostToolUse (Edit|Write).

5. Verify

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.