agentleFS
vndeevndee/engineering-skills/.claude/skills/react-feature/SKILL.md

react-feature

Skill3 starsChanged 8 months agoMITView on GitHub

Use when implementing a new React feature, page, component, or hook in a Vite/Bun frontend with testing-library

The file

We split this skill into the rules it gives an agent

4 rules. About 0 are common, 2 are distinctive, and 2 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Core principle: Test what users see and do, not implementation details.

    line 12
  2. Distinctive:

    Always handle all three:

    line 121
  3. Very specific:

    REQUIRED: Follow code-quality standards — virtualize long lists, debounce inputs, paginate API calls, code-split routes

    line 140
  4. Very specific:

    REQUIRED: Update CLAUDE.md if new conventions, commands, or patterns are introduced (claude-md)

    line 141

≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “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 Feature Development

Overview

TDD workflow for React features using Vitest + testing-library. User-centric testing with MSW for API mocking.

Core principle: Test what users see and do, not implementation details.

When to Use

  • Adding a new page or feature module
  • Building reusable components
  • Creating custom hooks
  • Implementing forms, data fetching, or state management

Feature Module Structure

src/features/users/
  components/
    UserList.tsx
    UserList.test.tsx
    UserForm.tsx
    UserForm.test.tsx
  hooks/
    useUsers.ts
    useUsers.test.ts
  api/
    users.ts
  types/
    index.ts
  index.ts           # public API barrel export

Component TDD

Test first:

// UserList.test.tsx
import { render, screen } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import { UserList } from './UserList'

describe('UserList', () => {
  it('renders users', () => {
    render(<UserList users={[{ id: '1', name: 'Alice', email: 'a@b.com' }]} />)
    expect(screen.getByText('Alice')).toBeInTheDocument()
  })

  it('calls onDelete when delete button clicked', async () => {
    const onDelete = vi.fn()
    const user = userEvent.setup()
    render(<UserList users={[{ id: '1', name: 'Alice', email: 'a@b.com' }]} onDelete={onDelete} />)

    await user.click(screen.getByRole('button', { name: /delete/i }))
    expect(onDelete).toHaveBeenCalledWith('1')
  })
})

Custom Hook Testing

import { renderHook, waitFor } from '@testing-library/react'
import { useUsers } from './useUsers'
import { QueryClientProvider, QueryClient } from '@tanstack/react-query'

function wrapper({ children }: { children: React.ReactNode }) {
  return <QueryClientProvider client={new QueryClient()}>{children}</QueryClientProvider>
}

it('fetches users', async () => {
  const { result } = renderHook(() => useUsers(), { wrapper })
  await waitFor(() => expect(result.current.isSuccess).toBe(true))
  expect(result.current.data).toHaveLength(2)
})

API Mocking with MSW

// src/mocks/handlers.ts
import { http, HttpResponse } from 'msw'

export const handlers = [
  http.get('/api/v1/users', () => {
    return HttpResponse.json({
      data: [{ id: '1', name: 'Alice', email: 'a@b.com' }],
    })
  }),
]

// src/mocks/server.ts
import { setupServer } from 'msw/node'
import { handlers } from './handlers'
export const server = setupServer(...handlers)

// vitest.setup.ts
beforeAll(() => server.listen())
afterEach(() => server.resetHandlers())
afterAll(() => server.close())

State Patterns

PatternWhen
useStateLocal component state
useReducerComplex state transitions
React QueryServer state (fetching, caching)
ContextShared UI state (theme, auth)
URL paramsFilters, pagination, selected tab

Loading/Error/Empty States

Always handle all three:

if (isLoading) return <Skeleton />
if (error) return <ErrorMessage error={error} onRetry={refetch} />
if (data.length === 0) return <EmptyState message="No users found" />
return <UserList users={data} />

Accessibility Checklist

  • Interactive elements have accessible names (aria-label or visible text)
  • Forms have associated labels
  • Error messages linked with aria-describedby
  • Keyboard navigation works (Tab, Enter, Escape)
  • Focus management after dynamic changes

Chains

  • REQUIRED: Invoke superpowers:test-driven-development
  • REQUIRED: Follow code-quality standards — virtualize long lists, debounce inputs, paginate API calls, code-split routes
  • REQUIRED: Update CLAUDE.md if new conventions, commands, or patterns are introduced (claude-md)
  • Can develop in parallel with go-feature or py-feature

Download now (ZIP)

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.