Editor autocomplete sees your current file and maybe a few open tabs. Claude Code works differently. In the terminal it reads across your codebase and executes your actual commands, tsc, eslint, vitest, as part of the workflow. The Claude Code overview lists IDE extensions, a desktop app and a web version as well; this guide sticks to the CLI.
That distinction matters more for React/TypeScript projects than for almost any other stack. TypeScript errors don't show up until you compile. Test failures don't show up until you run tests. A tool that generates code without running your build is guessing. Claude Code isn't guessing, it's checking.
I'd rather skip the feature tour and show the workflows that actually take advantage of what the CLI approach gives you. That's what this guide covers. I've used Claude Code daily for over a year, mostly for whole tasks that change many files in one repo, plus content and automation work in the monorepo of eight Astro blogs behind this site.
The patterns work best when your TypeScript is already clean, TypeScript clean code guide covers 15 patterns including explicit return types, readonly modifiers, and discriminated unions that make Claude Code's generated code fit your codebase rather than fight it.
Project setup and CLAUDE.md
Setup matters more than the prompts. Claude Code reads a file called CLAUDE.md from your project root at the start of every session. Whatever you put there becomes its working context. Skip this file and you'll spend half your time correcting output that assumes the wrong test runner, wrong lint config, or wrong TypeScript settings.
CLAUDE.md is the single most important thing you can do to improve Claude Code output. That's not a mild suggestion, it's the one habit I'd defend against any objection. The monorepo behind this site keeps a long CLAUDE.md at its root, and one of its most important entries is the exact typecheck command, because the obvious one checks nothing (more on that below).
One honest caveat from daily use: the file is guidance, not enforcement. Claude Code still ignores repo rules and conventions written in CLAUDE.md now and then, usually deep into a long task. Write the file anyway, and back the rules that really matter with a lint rule or a CI check that fails.
What to Put in CLAUDE.md
Here's a minimal CLAUDE.md for a React/TypeScript project using Vite and Vitest:
# Project: MyApp
## TypeScript
- Config: tsconfig.json (strict: true, noUncheckedIndexedAccess: true)
- No `any` types. Use `unknown` and narrow it.
- Generic components preferred over `as` assertions.
## Commands
- Type check: npx tsc --noEmit
- Lint: npx eslint src/ --ext .ts,.tsx
- Tests: npx vitest run
- Dev: npm run dev
## Conventions
- Component files: PascalCase.tsx
- Hook files: useCamelCase.ts
- No default exports from component files
- Props interfaces named [ComponentName]Props
That's it. Fifteen lines. Now Claude Code knows what "run the type check" means, what your naming conventions are, and where your config lives.
Every team has slightly different conventions. The point isn't to use my exact file, it's to write yours down somewhere Claude Code can find it.
These conventions plug into the wider vibe coding quality framework, a scorecard that flags the patterns AI-assisted PRs tend to break before they reach review.
Component development, interface first
Start with the TypeScript interface, not the component. This is counterintuitive if you're used to writing components first and props second, but it changes the output quality significantly.
The Three-Step Pattern
Step 1, Define the props interface. Write it yourself. This is your spec.
interface DataTableProps<T extends object> {
data: T[];
columns: Array<{
key: keyof T;
label: string;
render?: (value: T[keyof T], row: T) => React.ReactNode;
}>;
onRowClick?: (row: T) => void;
loading?: boolean;
emptyMessage?: string;
}
Step 2, Ask for the implementation. Say: "Implement DataTable<T> that satisfies the DataTableProps<T> interface above." Claude Code sees the complete contract. It doesn't have to guess what onRowClick should do when the user clicks, the type signature tells it.
Step 3, Ask for tests. "Write Vitest tests for DataTable<T> covering: renders loading state, renders empty message when data is empty, calls onRowClick with the correct row on click." Because Claude Code already has the component implementation in context, it writes tests against the actual component, not a hypothetical one.
Why does this work so well? TypeScript interfaces are unambiguous. Plain English descriptions ("make a table component that shows rows") leave enormous room for interpretation. An interface leaves almost none.
My view: the interface is the prompt. A type signature strips out the guesswork that vague prose forces the model into. I haven't measured the difference, so take that as an opinion you can test on your own component, not a benchmark.
A props interface is the tightest prompt you can write: it leaves the model almost nothing to interpret.
Refactoring across multiple files
This is where an agent genuinely beats single-file autocomplete. When you ask Claude Code to refactor, it searches the codebase for the files involved before editing them. It isn't limited to the file you have open. For one bloated component rather than a cross-file rename, see refactoring a large React component, seams first.
Here's the refactor I'd reach for first. Suppose you've defined a new type:
type UserSession = {
userId: string;
permissions: Permission[];
expiresAt: Date;
refreshToken: string;
};
Tell Claude Code: "Refactor all authentication hooks to use UserSession instead of the current { id: string; token: string } shape. Update all call sites." It will identify every file importing the old type, update them, and then run tsc --noEmit to verify. If compilation fails, it reads the error output and iterates.
That last part matters. The verify-and-fix loop means regressions surface during the session, not when you push. A missed call site three files deep is exactly what tsc --noEmit reports, and it reports it in seconds instead of after a CI run.
There's one trap, and this repo fell into it. The root tsconfig.json here uses project references with "files": [], so a bare npx tsc --noEmit at the root reports success while checking nothing. If your CLAUDE.md names that command, the loop verifies nothing and still looks green. Name the per-project command instead.
Extracting Large Components
The same approach works for splitting a large component into smaller pieces. Give Claude Code the target: "Extract UserProfileCard into three components, Avatar, UserStats, and ContactLinks. Move the shared style constants to a separate file. Run tsc after." It handles the seam boundaries and updates imports automatically.
The multi-file work that impressed me most wasn't a component split, though. It was migrations. In my own projects Claude Code moved code to TypeScript 7 (tsgo), Node 24 or 26, Vitest in place of Jest, and pnpm, and it fixed the API breakage each one caused quickly. That's tedious, mechanical, many-file work, and it's where the tool earns its keep.
For the CI side of the same loop, our CI/CD quality gates guide walks through wiring GitHub Actions gates and an AI reviewer to catch the issues Claude Code's local pass can miss.
Debugging from the full error
Paste the TypeScript error. The full error. Don't summarize it. Claude Code traces the error back through the type definitions, finds where the mismatch originated, and proposes a fix at the root cause rather than a cast that silences it downstream.
For React prop drilling issues specifically, where a type error surfaces three components below where the problem actually lives, this is genuinely useful. You can ask: "This error is in UserCard. Trace why profile.address is possibly undefined given how UserCard receives its props from ProfilePage." It follows the chain.
Running the test suite is even more useful. Tell Claude Code: "Run the test suite and fix any failing tests." It executes vitest run, reads the failure output, finds the cause, and patches it. You're handing it a feedback loop, not just a prompt.
Where does it struggle with debugging? Discriminated union exhaustiveness. It usually notices a missing case in a switch statement, but complex nested unions with multiple discriminants sometimes produce a patch that compiles but handles the missing case incorrectly. Always read the logic, not just the green type check.
Permissions: what it may touch
A tool that runs your commands can run other commands too. Claude Code's answer is a permissions block in .claude/settings.json, which you commit so the whole team shares it. When you click "Yes, and don't ask again" on a Bash prompt, the rule lands in .claude/settings.local.json at the repository root instead, per the permissions docs. The same answer on a file edit isn't saved anywhere; it lasts until the session ends. For a Vite and Vitest project, this is a sane starting point:
{
"permissions": {
"allow": [
"Bash(npm run *)",
"Bash(npx vitest *)",
"Bash(npx tsc --noEmit *)"
],
"ask": [
"Bash(git push *)"
],
"deny": [
"Read(./.env)",
"Read(./.env.*)",
"Bash(curl *)"
]
}
}
Two rules from the docs decide how this behaves. First, rules are evaluated deny, then ask, then allow, and the first match wins regardless of how specific a rule is, so an allow entry can't carve an exception out of a deny. Second, a Read deny also blocks the Edit and Write tools on that path. NotebookEdit is the exception the docs name, so a path that no tool may change wants an Edit deny as well.
Now the catch nobody puts in a quick-start. Read and Edit deny rules cover Claude's own file tools and the file commands it recognizes in Bash, such as cat, head, tail, sed and tee. They don't cover a program that opens files itself. npm run dev starts Vite, and Vite loads .env files on its own, so the allow rule above hands that file to a process the deny rule never sees. Is that a bug? No, and the docs say so plainly: Bash rules aren't a security boundary around a program. The Bash(curl *) deny has the same weakness. The docs' own table shows it stopping curl https://example.com and missing /usr/bin/curl and sh -c 'curl ...'.
For enforcement by the operating system, turn on the sandbox with /sandbox, or set sandbox.enabled to true in a settings file. It uses Seatbelt on macOS and needs bubblewrap and socat on Linux and WSL2; native Windows runs commands unsandboxed. The limits apply to the shell commands Claude runs and to the processes they start.
Two details in the sandboxing docs decide whether that actually protects .env, and it's easy to miss both. The sandbox's default is read access to the entire computer, so switching it on doesn't hide the file by itself. What hides it is the Read deny rule, which Claude Code merges into the sandbox configuration (or an explicit sandbox.filesystem.denyRead entry). And a command that fails inside the sandbox can be retried outside it, where an allow rule that matches the command approves the retry with no prompt. Bash(npm run *) above is exactly such a rule. Set "allowUnsandboxedCommands": false under sandbox if you want that door closed.
{
"sandbox": {
"enabled": true,
"allowUnsandboxedCommands": false
}
}
Expect a side effect: with .env denied inside the sandbox, a dev server that needs those variables won't get them from the file. The deny rule is doing its job. I re-read every statement in this section against the permissions and sandboxing docs on November 25, 2026, when the newest Claude Code on npm was 2.1.332; the previous check was against 2.1.280 on September 29. This is a reading of the documentation, not a penetration test of the sandbox.
If you connect external tools, the same thinking applies to MCP servers, which get their own rule syntax. The MCP server guide covers what those connections can expose. A concrete example for React work is Storybook's MCP addon, which hands the agent your real component props instead of its guesses, and the Storybook MCP setup shows where that connection quietly degrades.
Where Claude Code falls short
Be honest about this. A tool that never fails isn't a real tool, it's marketing. Context window is the amount of project text a model can hold in memory at once before it starts dropping earlier files from consideration, and it's the single biggest limiting factor for how well Claude Code performs on a large React codebase. Three specific limits show up repeatedly: visual work, since the model reasons about a screenshot's pixels rather than rendering the app live; large codebases, where files outside the slice of the repo it has read in the session start getting missed; and generated test logic, which sometimes asserts what the code currently does rather than what it should do. These aren't bugs so much as inherent tradeoffs of a text-based coding agent, and the practical fix for the codebase-size problem is scoping every request to a specific directory or hook rather than the whole repository. Three more come from daily use rather than from the model: it does more than you asked, it works in instalments, and it costs money and quota.
Visual work. Claude Code can accept an image (drag a screenshot in, or point it at a file path) and reason about what's in it, but it's still reading pixels, not rendering your app live. Paste a Figma screenshot and ask for matching CSS and you'll get a reasonable first pass, not a pixel-perfect match. Expect to iterate a couple of times against the actual rendered page.
Large codebases. Claude Code's context window is large but not infinite. On large codebases, you'll see it miss files it should have considered. Scope your requests tightly. "Refactor the authentication module" on a 300-file project is a worse prompt than "Refactor useAuthState in src/hooks/auth/."
Test logic. Generated tests sometimes assert the right behavior and sometimes assert whatever the implementation happens to do. There's a difference between "this test confirms the component works correctly" and "this test confirms the component does what it currently does." Read the assertions. Don't just check that the tests pass.
Doing more than you asked. Ask for one fix and you'll sometimes get that fix plus a renamed variable, a reformatted file and a "cleanup" nobody requested. Read the whole diff, not just the part you asked about, and say in the prompt what it must not touch.
Work in instalments. I ran a loop where Copilot reviewed the PR and Claude Code fixed what it flagged. After about ten rounds the code still wasn't "perfect" in Copilot's eyes, even though it had worked correctly for a while; every new comment was about style or naming, not logic. Neither tool will tell you to stop, so you have to decide when the code works and reads well enough.
Cost and usage limits. Daily use runs into them. Long agent sessions burn through the usage allowance faster than short, scoped requests do, which is one more argument for scoping.
These are the real edges. They're not dealbreakers, they're just the parts where you stay in the loop.
Strengths and weak spots in React work
| Strength | Limitation | |
|---|---|---|
| Multi-file refactors | Searches the codebase, updates call sites, runs tsc to verify | Misses files on large codebases unless the request is scoped |
| Debugging | Traces TypeScript errors to root cause across prop drilling | Complex nested discriminated unions can compile but mishandle a case |
| Testing | Writes tests against the actual implementation in context | Sometimes asserts current behavior, not correct behavior |
| Visual work | Can accept and reason about a pasted screenshot or image file | No live rendering; matching a design still takes a couple of iterations |
The feedback loop
What makes Claude Code worth using on React and TypeScript work is that it takes part in the actual build cycle; the code it writes in isolation is nothing special. The verify-and-fix loop refers to Claude Code running your actual build, lint, and test commands after making a change and reading the failure output to correct itself, rather than handing you code it has never executed. Generate, compile, test, fix, all in one session, all against your real project configuration. What it catches is the unglamorous kind of regression: a missed call site, a prop type that no longer lines up, the kind of thing that would otherwise surface as a red CI run twenty minutes later.
Because it runs the same commands you'd run, it often sees a failure before you do. Autocomplete can't.
Set up your CLAUDE.md. Define your interfaces first. Scope your requests. Then let the compile-test-fix loop do its work.