bcmyguest/personal-skills/react-ts-setup

Claude Code and agent skill by bcmyguest/personal-skills

Trust tier 2
  • community
  • ext:[{"type":"hook","description":"Pre/post lifecycle hooks"}]
LLM review pending
Source check pending

Checking that the SKILL.md file is still in the repository.

Scaffold a new React + TypeScript frontend repo the right way with Vite — asks the key decisions up front (package manager, Node manager + version, UI framework + theme colours, CI provider, dev Docker), then wires Vite + React Compiler, ESLint (flat) + Prettier, Vitest + Testing Library, husky + lint-staged + pre-commit hooks, .vscode settings, env templates, a dev Dockerfile, CI pipelines, and a README — keeping the Node version in lockstep across every file and leaving lint/typecheck/test/bu…

Install

npx vskill@latest install bcmyguest/personal-skills/react-ts-setup

Semi-extensibleMentions customization, but needs skill-specific knowledge. Read the extensible skills standard

SKILL.md

The same SKILL.md was published earlier as bcmyguest/personal-skills/react-ts-setup.

Setting up a React + TypeScript project

Scaffold every new React SPA with Vite (it owns dev server, build, and pairs natively with Vitest). Work top to bottom; confirm the decisions in step 0 before scaffolding, because they change dependencies, config, and which later steps apply.

The whole point of this skill is a repo where one `git clone` + install gets a contributor to green — lint, typecheck, test, and build all pass, the editor formats on save, and commits are guarded. The recurring failure mode is a Node version that drifts between .nvmrc, CI, and Docker; the steps below keep it in one place on purpose.

Versions move fast in this ecosystem. Don't hard-code dependency versions in
package.json by hand and don't copy version numbers from this skill — let
create-vite and pnpm add install the newest releases, and trust the lockfile.

Steps: (0) ask the decisions → (1) scaffold with Vite → (2) pin Node everywhere → (3) ESLint + Prettier → (4) React Compiler + strict TS → (5) Vitest + Testing Library → (6) UI framework + theme → (7) husky + lint-staged + pre-commit hooks → (8) .vscode settings → (9) env files → (10) .gitignore check → (11) dev Docker (if chosen) → (12) CI (if chosen) → (13) README → (14) verify lint/typecheck/test/build all green. Steps 6, 11, and 12 depend on the step-0 answers.

0. Ask the decisions up front

Don't assume — ask, then use the answers to decide which steps apply:

DecisionOptionsDefault
Package managerpnpm · npm · bunpnpm
Node managernvm · mise · asdf · Voltaask; all write a pinned version
Node versioncurrent Active LTS24 (2026); 22 if conservative
UI frameworkMUI · Tailwind · Chakra · Mantine · noneask
Theme coloursprimary / secondary / error / backgroundask for the basic set
Test frameworkVitestVitest (fixed)
CI providernone · GitHub · GitLab · Bitbucketask
Dev Docker imageyes · noask

The canonical path below is pnpm + Vite + MUI. Package-manager and UI-framework substitutions are called out inline and in the reference files.

1. Scaffold with Vite

bash
pnpm create vite@latest <app-name> --template react-ts
cd <app-name>
pnpm install

Package-manager variants: npm create vite@latest <app> -- --template react-ts · bun create vite <app> --template react-ts. The rest of this skill uses pnpm; swap the prefix (npm run / bun run) for the others.

Then record the toolchain in package.json so CI and contributors match:

jsonc
{
"packageManager": "pnpm@<your installed version>", // exact; Corepack reads this. `pnpm --version`
"engines": { "node": ">=22" } // a FLOOR, not the pin (the pin is step 2)
}

2. Pin Node and keep every file in lockstep

The Node version is the thing most likely to drift. It appears in up to four places — make them agree, and prefer a single source of truth so they can't diverge:

  • Node-manager file (the real pin) — one of, matching the user's choice:
  • nvm: .nvmrc → 24
  • mise / asdf: .tool-versions → nodejs 24 (mise also reads mise.toml)
  • Volta: a volta block in package.json
  • `engines.node` in package.json — a floor (>=22), not the exact pin.
  • CI — read the pin instead of repeating it: node-version-file: .nvmrc

(step 12). This is the trick that keeps CI from drifting.

  • Dockerfile — FROM node:24-alpine, the same major (step 11). The one place

that can't auto-read the pin, so bump it deliberately when you bump .nvmrc.

Commit the node-manager file. Default to the current Active LTS (Node 24 in 2026; 22 is the conservative choice and engines covers both).

3. ESLint (flat) + Prettier — set up so they never fight

create-vite ships a flat-config eslint.config.js. Add Prettier as the formatter, eslint-config-prettier to switch off every ESLint rule that overlaps with formatting (that's what stops the two tools from undoing each other), and eslint-plugin-perfectionist to sort imports:

bash
pnpm add -D prettier eslint-config-prettier eslint-plugin-perfectionist

Edit eslint.config.js: put eslintConfigPrettier last in extends, and add a second config object for import ordering:

js
import perfectionist from 'eslint-plugin-perfectionist'
import eslintConfigPrettier from 'eslint-config-prettier'
// ...
export default defineConfig([
globalIgnores(['dist', 'coverage']),
{
files: ['**/*.{ts,tsx}'],
extends: [
js.configs.recommended,
tseslint.configs.recommended,
reactHooks.configs.flat.recommended, // includes the React Compiler rule (step 4)
reactRefresh.configs.vite,
eslintConfigPrettier, // MUST be last: disables formatting rules
],
languageOptions: { globals: globals.browser },
},
{
// Import ordering. Scope to the import rules — not perfectionist's full
// recommended set, which also sorts objects/props/enums. `eslint --fix` sorts
// imports; Prettier doesn't reorder them, so the two never conflict. Side-effect
// imports (CSS, polyfills) keep their relative order by default.
files: ['**/*.{ts,tsx}'],
plugins: { perfectionist },
rules: {
'perfectionist/sort-imports': ['error', { type: 'natural' }],
'perfectionist/sort-named-imports': ['error', { type: 'natural' }],
},
},
])

.prettierrc.json — match create-vite's style (no semicolons, single quotes) so the first format pass doesn't churn every file:

json
{ "semi": false, "singleQuote": true, "trailingComma": "all", "printWidth": 80 }

.prettierignore:

dist
coverage
pnpm-lock.yaml

Add scripts (full set in step 5): "lint": "eslint .", "lint:fix": "eslint . --fix", "format": "prettier --write .", "format:check": "prettier --check .".

4. React Compiler + incremental TypeScript

React Compiler auto-memoizes components, so you rarely hand-write useMemo/useCallback. In Vite 8, @vitejs/plugin-react transforms with oxc, so the compiler (a Babel plugin) is opted in via the plugin's reactCompilerPreset helper plus @rolldown/plugin-babel:

bash
pnpm add -D babel-plugin-react-compiler @rolldown/plugin-babel @babel/core @types/babel__core

vite.config.ts:

ts
import babel from '@rolldown/plugin-babel'
import react, { reactCompilerPreset } from '@vitejs/plugin-react'
import { defineConfig } from 'vitest/config' // typed `test` block, no /// <reference>
export default defineConfig({
plugins: [react(), babel({ presets: [reactCompilerPreset()] })],
test: {
/* step 5 */
},
})

Import defineConfig from vitest/config (not vite) so the test block is typed without a /// <reference types="vitest/config" /> directive — the import sorter (step 3) would move that directive below the imports and silently disable it, breaking the typecheck. The compiler's lint rule ships inside eslint-plugin-react-hooks, which the flat config above extends. Confirm it's active after build via React DevTools (components show a "Memo ✨" badge).

Incremental TypeScript: create-vite already uses project-references build mode (tsc -b) with a tsBuildInfoFile in each tsconfig.*.json, so rebuilds only recheck what changed. Keep tsc -b in the build and typecheck scripts:

jsonc
"build": "tsc -b && vite build",
"typecheck": "tsc -b"

5. Testing with Vitest + Testing Library

bash
pnpm add -D vitest jsdom @vitest/coverage-v8 \
@testing-library/react @testing-library/jest-dom @testing-library/user-event

Add the test block to vite.config.ts (shares Vite's transform pipeline):

ts
test: {
environment: 'jsdom',
setupFiles: ['./src/test/setup.ts'],
coverage: { provider: 'v8', reporter: ['text', 'html'] },
},

src/test/setup.ts — register jest-dom matchers and clean up between tests:

ts
import '@testing-library/jest-dom/vitest'
import { afterEach } from 'vitest'
import { cleanup } from '@testing-library/react'
afterEach(() => {
cleanup()
})

Write one real sample test (src/App.test.tsx) that renders through the app's provider and asserts behavior, so pnpm test proves the wiring end to end:

tsx
import { describe, it, expect } from 'vitest'
import { render, screen } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import { ThemeProvider } from '@mui/material/styles'
import App from './App'
import { theme } from './theme'
describe('App', () => {
it('increments the counter on click', async () => {
const user = userEvent.setup()
render(
<ThemeProvider theme={theme}>
<App />
</ThemeProvider>,
)
await user.click(screen.getByRole('button', { name: /count is 0/i }))
expect(
screen.getByRole('button', { name: /count is 1/i }),
).toBeInTheDocument()
})
})

Scripts: "test": "vitest run", "test:watch": "vitest", "test:coverage": "vitest run --coverage".

6. UI framework + theme

Ask the user for a basic colour set first — at least primary and secondary/accent; ideally error and background too. Put them in one theme module so a rebrand is a one-file change.

Canonical path (MUI):

bash
pnpm add @mui/material @emotion/react @emotion/styled

src/theme.ts — barebones, colours from the user:

ts
import { createTheme } from '@mui/material/styles'
export const theme = createTheme({
palette: {
mode: 'light',
primary: { main: '#1f6feb' },
secondary: { main: '#a371f7' },
error: { main: '#d1242f' },
background: { default: '#ffffff', paper: '#f6f8fa' },
},
})

Wrap the app once in src/main.tsx:

tsx
import { ThemeProvider } from '@mui/material/styles'
import CssBaseline from '@mui/material/CssBaseline'
import { theme } from './theme'
// ...
<ThemeProvider theme={theme}>
<CssBaseline />
<App />
</ThemeProvider>

Not MUI? Read only the one file for the chosen framework — each is self-contained, so you never load the other frameworks' context:

7. Pre-commit hooks — two layers, husky owns the git hook

The repo gets both baseline file-hygiene hooks (the language-agnostic pre-commit framework) and husky + lint-staged for ESLint/Prettier. The trap: the pre-commit framework and husky both want to own .git/hooks/pre-commit. Resolve it by letting husky own the hook and calling the pre-commit framework from inside it — so never run `pre-commit install` (that would clobber husky's hook).

bash
pnpm add -D husky lint-staged
pnpm exec husky init # creates .husky/ and a prepare script

Add the prepare script (husky v9 sets this up): "prepare": "husky".

lint-staged config in package.json — order matters: ESLint autofix first (it may reorder imports, etc.), then Prettier as the final formatting authority:

jsonc
"lint-staged": {
"*.{ts,tsx}": ["eslint --fix", "prettier --write"],
"*.{js,jsx,json,css,md,yml,yaml,html}": ["prettier --write"]
}

This is the start of the file. Read the full SKILL.md on GitHub.

Security

  • Security scanPassed, 100 of 100Pattern checks on the skill's files.
  • Model reviewNot runA model review is scheduled for the next rescan.

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

7-day trend score
0

Not refreshed yet.

Extension points

  • hookPre/post lifecycle hooks

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/bcmyguest/personal-skills/react-ts-setup/badge)](https://verified-skill.com/skills/bcmyguest/personal-skills/react-ts-setup)

Something wrong with this skill or its page? Tell us.