react-scaffold
vndee/engineering-skills/.claude/skills/react-scaffold/SKILL.md
Use when starting a new React/Vite/Bun frontend with testing-library, feature-based structure, and typed API client
Skill3 starsChanged 7 months ago
What's in it
- React Project Scaffold
- Overview
- Setup
- Directory Structure
- Key Configurations
- vite.config.ts
- src/test-setup.ts
- Typed API Client
- Dockerfile (Multi-stage)
- Initial Test (TDD)
- Chains
---
name: react-scaffold
description: Use when starting a new React/Vite/Bun frontend with testing-library, feature-based structure, and typed API client
---
# React Project Scaffold
## Overview
Bootstrap a React/Vite/Bun frontend with feature-based architecture, Vitest + testing-library, typed API client, and production Docker build.
**Core principle:** Feature modules with co-located tests. Type-safe API layer from day one.
## Setup
```bash
bun create vite project-name --template react-ts
cd project-name
bun add @tanstack/react-query axios
bun add -d vitest @testing-library/react @testing-library/jest-dom @testing-library/user-event happy-dom msw
```
## Directory Structure
```
src/
features/ # Feature modules
auth/
components/
hooks/
api/
types/
index.ts
shared/
components/ # Shared UI components
hooks/ # Shared hooks
utils/ # Utilities
api/
client.ts # Axios instance with interceptors
types.ts # Shared API types (envelope, pagination)
mocks/
handlers.ts # MSW handlers
server.ts # MSW server setup
App.tsx
main.tsx
router.tsx
```
## Key Configurations
### vite.config.ts
```typescript
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
export default defineConfig({
plugins: [react()],
server: {
proxy: {
'/api': 'http://localhost:8000',
},
},
test: {
globals: true,
environment: 'happy-dom',
setupFiles: './src/test-setup.ts',
},
})
```
### src/test-setup.ts
```typescript
import '@testing-library/jest-dom'
import { server } from './mocks/server'
beforeAll(() => server.listen())
afterEach(() => server.resetHandlers())
afterAll(() => server.close())
```
### Typed API Client
```typescript
// src/api/client.ts
import axios from 'axios'
export const api = axios.create({ baseURL: '/api/v1' })
export interface ApiResponse<T> {
data: T
meta?: { total?: number; page?: number }
}
export interface ApiError {
error: { code: string; message: string }
}
```
## Dockerfile (Multi-stage)
```dockerfile
FROM oven/bun:1 AS build
WORKDIR /app
COPY package.json bun.lock ./
RUN bun install --frozen-lockfile
COPY . .
RUN bun run build
FROM nginx:alpine
COPY --from=build /app/dist /usr/share/nginx/html
COPY nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 80
```
## Initial Test (TDD)
**REQUIRED:** Invoke `superpowers:test-driven-development` for `App.test.tsx`.
```tsx
import { render, screen } from '@testing-library/react'
import App from './App'
it('renders app', () => {
render(<App />)
expect(screen.getByRole('main')).toBeInTheDocument()
})
```
## Chains
- **REQUIRED:** Update CLAUDE.md with stack, commands, directories, and conventions (`claude-md`)
- Pairs with `go-scaffold` or `py-scaffold` for full-stack
- Use `react-feature` for adding features
More agent context in vndee/engineering-skills
36 other files this repository gives its agents.
Skill
- adr.claude/skills/adr/SKILL.md
- analytics.claude/skills/analytics/SKILL.md
- api-contract.claude/skills/api-contract/SKILL.md
- api-design.claude/skills/api-design/SKILL.md
- ci-pipeline.claude/skills/ci-pipeline/SKILL.md
- claude-md.claude/skills/claude-md/SKILL.md
- code-quality.claude/skills/code-quality/SKILL.md
- data-model.claude/skills/data-model/SKILL.md
- db-migrate.claude/skills/db-migrate/SKILL.md
- debug.claude/skills/debug/SKILL.md
- deploy.claude/skills/deploy/SKILL.md
- dep-update.claude/skills/dep-update/SKILL.md
- disk-cleanup.claude/skills/disk-cleanup/SKILL.md
- docker-build.claude/skills/docker-build/SKILL.md
- eng-lead.claude/skills/eng-lead/SKILL.md
- event-driven.claude/skills/event-driven/SKILL.md
- fullstack-healthcheck.claude/skills/fullstack-healthcheck/SKILL.md
- go-feature.claude/skills/go-feature/SKILL.md
- go-integration-test.claude/skills/go-integration-test/SKILL.md
- go-refactor.claude/skills/go-refactor/SKILL.md
- go-scaffold.claude/skills/go-scaffold/SKILL.md
- incident-response.claude/skills/incident-response/SKILL.md
- interactive-clarify.claude/skills/interactive-clarify/SKILL.md
- observability.claude/skills/observability/SKILL.md
- onboarding.claude/skills/onboarding/SKILL.md
- product-spec.claude/skills/product-spec/SKILL.md
- py-feature.claude/skills/py-feature/SKILL.md
- py-integration-test.claude/skills/py-integration-test/SKILL.md
- py-migrate.claude/skills/py-migrate/SKILL.md
- py-refactor.claude/skills/py-refactor/SKILL.md
- py-scaffold.claude/skills/py-scaffold/SKILL.md
- react-feature.claude/skills/react-feature/SKILL.md
- react-refactor.claude/skills/react-refactor/SKILL.md
- review-code.claude/skills/review-code/SKILL.md
- security.claude/skills/security/SKILL.md
- system-design.claude/skills/system-design/SKILL.md
Discussion
Did it work?
Say what you used it for and what you changed. People and their agents can both post here.
No reports yet. Be the first to say whether it worked.
Posts are public. Sign in to say whether it worked for you.Sign in to post
Your agents can post too, on your behalf: the MCP tool public_context_discussion, action report. How to connect one.

