agentleFS
TangleMLTangleML/tangle-ui/.claude/skills/react-patterns/SKILL.md

react-patterns

Skill104 starsChanged 3 days agoApache-2.0View on GitHub

React and React Compiler patterns for this project. Use when writing React components, hooks, providers, or working with React Compiler compatibility.

We split this skill into the rules it gives an agent

21 rules. 0 are common, 13 are distinctive, and 8 are very specific to this project.

  • 0

    Common

    Most of the 32 edited versions we read keep these.

  • 13

    Distinctive

    This author's own choices. Worth a look.

  • 8

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use functional components with hooks exclusively (no class components)

    line 10
  2. Distinctive:

    Use proper dependency arrays in useEffect

    line 11
  3. Distinctive:

    Follow the existing component structure

    line 12
  4. Distinctive:

    Use React 19 features and patterns

    line 13
  5. Distinctive:

    Use proper TypeScript return types

    line 36
  6. Very specific:

    Follow existing patterns in src/hooks/

    line 37
  7. Distinctive:

    Use Tanstack Query for server state

    line 58
  8. Distinctive:

    Use Tanstack Router for routing

    line 59
  9. Distinctive:

    Use React hooks for local component state

    line 60
  10. Very specific:

    Use Context providers for app-wide state (see existing providers in src/providers/)

    line 61
  11. Distinctive:

    Follow Rules of Hooks strictly: - no conditional hooks, no hooks in loops, proper dependency arrays

    line 96
  12. Very specific:

    Don't spread props with {...props} unnecessarily

    line 99
  13. Distinctive:

    Avoid dynamic property access on objects when possible

    line 100
  14. Distinctive:

    Keep component logic predictable

    line 101
  15. Very specific:

    When a file is added to react-compiler.config.js:

    line 105
  16. Very specific:

    Remove unnecessary useCallback and useMemo (compiler handles this)

    line 107
  17. Very specific:

    Verify no compiler violations with pnpm run validate

    line 108
  18. Distinctive:

    Test the component still works correctly

    line 109
  19. Very specific:

    Consolidate entries by folder: when all files in a directory are compiler-enabled (e.g., use /path/to/folder instead of listing each file …

    line 110
  20. Very specific:

    If you encounter existing useMemo/useCallback/memo in a file, remove them when the file is enabled in react-compiler.config.js

    line 123
  21. Distinctive:

    Follow existing patterns for optimization

    line 125

“Common” is measured: kept by at least 6 in 10 of the 32 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

React Patterns

Core Rules

  • Use functional components with hooks exclusively (no class components)
  • Use proper dependency arrays in useEffect
  • Follow the existing component structure
  • Use React 19 features and patterns
  • Import modules from React: import module from react. Do not use inline React.[module]

Component Structure

// ComponentName/ComponentName.tsx — import directly, no index.ts barrel
interface ComponentNameProps {
  ...
}

export const ComponentName = ({ }: ComponentNameProps) => {
  ...
  return (
    ...
  );
};

Custom Hooks

  • Prefix with use
  • Return objects for multiple values, not arrays
  • Use proper TypeScript return types
  • Follow existing patterns in src/hooks/

Provider Pattern

const Context = createContext<ContextType | null>(null);

export const Provider = ({ children }: { children: ReactNode }) => {
  ...
  return <Context.Provider value={value}>{children}</Context.Provider>;
};

export const useContext = () => {
  const context = useContext(Context);
  if (!context) throw new Error('useContext must be used within Provider');
  return context;
};

State Management

  • Use Tanstack Query for server state
  • Use Tanstack Router for routing
  • Use React hooks for local component state
  • Use Context providers for app-wide state (see existing providers in src/providers/)
  • Use useRequiredContext to simplify context usage and avoid null checks

React Compiler

This project uses the React Compiler for automatic memoization. Files/directories are incrementally adopted in react-compiler.config.js.

Writing React Compiler Compatible Code

For new files, ensure they follow React Compiler rules from the start:

  1. Don't mutate values during render

    // Bad - mutating during render
    const items = props.items;
    items.push(newItem);
    
    // Good - create new reference
    const items = [...props.items, newItem];
  2. Don't read/write refs during render

    // Bad - reading ref during render
    const value = myRef.current;
    return <div>{value}</div>;
    
    // Good - read refs in effects or callbacks
    useEffect(() => {
      const value = myRef.current;
    }, []);
  3. Follow Rules of Hooks strictly - no conditional hooks, no hooks in loops, proper dependency arrays
  4. Avoid patterns the compiler can't optimize
    • Don't spread props with {...props} unnecessarily
    • Avoid dynamic property access on objects when possible
    • Keep component logic predictable

Adding Files to React Compiler

When a file is added to react-compiler.config.js:

  • Remove unnecessary useCallback and useMemo (compiler handles this)
  • Verify no compiler violations with pnpm run validate
  • Test the component still works correctly
  • Consolidate entries by folder when all files in a directory are compiler-enabled (e.g., use /path/to/folder instead of listing each file individually)

React Compiler Config Structure

Files are organized by cleanup effort in react-compiler.config.js:

  • Top section: Already enabled directories/files
  • Middle: Ready to enable (0 useCallback/useMemo)
  • Bottom (commented): Need cleanup before enabling

Performance

  • Do not use useMemo, useCallback, or memo manually — the React Compiler handles memoization automatically
  • If you encounter existing useMemo/useCallback/memo in a file, remove them when the file is enabled in react-compiler.config.js
  • Lazy load heavy components when possible
  • Follow existing patterns for optimization

Download now (ZIP)

  • Other versions36 projects use a version of this.

    Word for word · 0

    None found.

    Edited · 0

    None found.

    Wrote their own version · 36

    1. openstory-so/openstory★ 693same name
    2. involvex/youtube-music-cli★ 468same name
    3. xenitV1/Antigravity-Workflows★ 130same name
    4. maxyeh0817/Forge★ 34same name
    5. VoDaiLocz/kilo-kit-mcp★ 28same name
    6. Fandry96/k3-agentic-skills★ 27same name
    7. komluk/scaffolding★ 15same name
    8. xfstudio/skills★ 9same name
    9. gongyijie85/dsh-ecc★ 8same name
    10. jdanigo/hydraia★ 8same name

    26 more not listed

    How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.

  • Used alongsideProjects with it also use typescript-strict, docker-expert and 8 more.

    Other files people use alongside this one.

    Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
    • Greg-KleinSkill

      typescript-strict

      TypeScript strict mode conventions and type safety rules

      Also in 3 projects that use this

    • xfstudioSkill

      docker-expert

      Docker containerization expert with deep knowledge of multi-stage builds, image optimization, container security, Docker Compose orchestration, and production deployment patterns. Use PROACTIVELY for Dockerfile optimization, container issues, image size problems, security hardening, networking, and orchestration challenges.

      Also in 3 projects that use this

    • BlockSkill

      testing-strategy

      Guidelines for writing effective tests in this project

      Also in 4 projects that use this

    • LangChainSkill

      docker-patterns

      Best practices for Docker containerization and multi-stage builds

      Also in 3 projects that use this

    • mstuder-slalomSkill

      golang-patterns

      Idiomatic Go patterns, best practices, and conventions for building robust, efficient, and maintainable Go applications.

      Also in 3 projects that use this

    • MicrosoftSkill

      api-design

      Guide for designing and documenting RESTful APIs. Use when asked to design an API, create endpoints, or document an API.

      Also in 8 projects that use this

  • In this repository20 other files it gives its agents.

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.