react-skills

React 18 patterns for LlamaFarm Designer. Covers components, hooks, TanStack Query, and testing.

830 stars

Best use case

react-skills is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

React 18 patterns for LlamaFarm Designer. Covers components, hooks, TanStack Query, and testing.

Teams using react-skills should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/react-skills/SKILL.md --create-dirs "https://raw.githubusercontent.com/llama-farm/llamafarm/main/.claude/skills/react-skills/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/react-skills/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How react-skills Compares

Feature / Agentreact-skillsStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

React 18 patterns for LlamaFarm Designer. Covers components, hooks, TanStack Query, and testing.

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

Related Guides

SKILL.md Source

# React Skills for LlamaFarm Designer

Best practices and patterns for React 18 development in the Designer subsystem.

## Tech Stack

- **React 18.2** with StrictMode
- **TypeScript 5.2+** for type safety
- **TanStack Query v5** for server state management
- **React Router v7** for client-side routing
- **TailwindCSS** with `tailwind-merge` and `clsx` for styling
- **Radix UI** primitives for accessible components
- **Vite** for build tooling
- **Vitest** + React Testing Library for testing

## Directory Structure

```
designer/src/
  api/          # API service functions
  components/   # React components (feature-organized)
  contexts/     # React context providers
  hooks/        # Custom hooks
  lib/          # Utility functions (cn, etc.)
  types/        # TypeScript type definitions
  utils/        # Helper functions
  test/         # Test utilities and mocks
```

## Core Patterns

### Component Composition

- Use composition over inheritance
- Prefer small, focused components
- Use `forwardRef` for components that wrap DOM elements
- Apply `displayName` to forwardRef components for DevTools

### State Management

- **Local UI state**: `useState`, `useReducer`
- **Server state**: TanStack Query (`useQuery`, `useMutation`)
- **Shared UI state**: React Context with custom hooks
- **Form state**: Controlled components with validation

### Hooks

- Follow Rules of Hooks (top-level, consistent order)
- Create custom hooks for reusable logic
- Use query key factories for TanStack Query
- Memoize expensive computations with `useMemo`
- Stabilize callbacks with `useCallback`

### Styling

- Use `cn()` from `lib/utils` to merge Tailwind classes
- Use `cva` (class-variance-authority) for component variants
- Follow dark mode conventions with `dark:` prefix

## Related Guides

- [components.md](./components.md) - Component patterns
- [hooks.md](./hooks.md) - Hook patterns and rules
- [state.md](./state.md) - State management patterns
- [performance.md](./performance.md) - Performance optimization
- [security.md](./security.md) - Security best practices

## Quick Reference

```typescript
// Utility for merging Tailwind classes
import { cn } from '@/lib/utils'
cn('base-class', condition && 'conditional-class', className)

// Query key factory pattern
export const projectKeys = {
  all: ['projects'] as const,
  lists: () => [...projectKeys.all, 'list'] as const,
  list: (ns: string) => [...projectKeys.lists(), ns] as const,
}

// Context with validation hook
const MyContext = createContext<MyContextType | undefined>(undefined)
export function useMyContext() {
  const ctx = useContext(MyContext)
  if (!ctx) throw new Error('useMyContext must be within MyProvider')
  return ctx
}
```

## Testing

```typescript
import { renderWithProviders } from '@/test/utils'
import { screen } from '@testing-library/react'

test('renders component', () => {
  renderWithProviders(<MyComponent />)
  expect(screen.getByText('Hello')).toBeInTheDocument()
})
```

Related Skills

typescript-skills

830
from llama-farm/llamafarm

Shared TypeScript best practices for Designer and Electron subsystems.

server-skills

830
from llama-farm/llamafarm

Server-specific best practices for FastAPI, Celery, and Pydantic. Extends python-skills with framework-specific patterns.

runtime-skills

830
from llama-farm/llamafarm

Universal Runtime best practices for PyTorch inference, Transformers models, and FastAPI serving. Covers device management, model loading, memory optimization, and performance tuning.

rag-skills

830
from llama-farm/llamafarm

RAG-specific best practices for LlamaIndex, ChromaDB, and Celery workers. Covers ingestion, retrieval, embeddings, and performance.

python-skills

830
from llama-farm/llamafarm

Shared Python best practices for LlamaFarm. Covers patterns, async, typing, testing, error handling, and security.

go-skills

830
from llama-farm/llamafarm

Shared Go best practices for LlamaFarm CLI. Covers idiomatic patterns, error handling, and testing.

generate-subsystem-skills

830
from llama-farm/llamafarm

Generate specialized skills for each subsystem in the monorepo. Creates shared language skills and subsystem-specific checklists for high-quality AI code generation.

config-skills

830
from llama-farm/llamafarm

Configuration module patterns for LlamaFarm. Covers Pydantic v2 models, JSONSchema generation, YAML processing, and validation.

common-skills

830
from llama-farm/llamafarm

Best practices for the Common utilities package in LlamaFarm. Covers HuggingFace Hub integration, GGUF model management, and shared utilities.

cli-skills

830
from llama-farm/llamafarm

CLI best practices for LlamaFarm. Covers Cobra, Bubbletea, Lipgloss patterns for Go CLI development.

electron-skills

830
from llama-farm/llamafarm

Electron patterns for LlamaFarm Desktop. Covers main/renderer processes, IPC, security, and packaging.

designer-skills

830
from llama-farm/llamafarm

Designer subsystem patterns for LlamaFarm. Covers React 18, TanStack Query, TailwindCSS, and Radix UI.