Skip to content

AI8 min read

AI Coding Assistants for React Developers: A Workflow

A practical AI coding assistant workflow for React developers: how to prompt, review AI-generated code, test it, and where AI helps or quietly hurts.

An AI coding assistant helps React developers most when you treat it like a fast junior pair programmer: give it clear context, ask for small changes, and review everything it writes as if it were a pull request from someone new to the codebase. It is very good at boilerplate, tests, refactors and explaining unfamiliar code. It is unreliable on architecture decisions, version-specific APIs and anything security-sensitive, unless you check it.

I lead a React team at AITC International, so I think about these tools both as a developer and as the person who reviews the code they produce. This is not a ranking of products. Editor-integrated assistants, chat-based assistants and terminal or agent-style tools all have strengths, and they keep improving. What lasts is the workflow, so that is what this post is about.

Key takeaways

  • Context beats clever prompts. Tell the assistant your versions, conventions and the files involved.
  • Work in small, reviewable steps. Large one-shot generations hide bugs.
  • Review AI code harder than human code on three points: outdated APIs, unnecessary effects and missing edge cases.
  • Tests are your contract. Write or review the tests first, then let the assistant make them pass.
  • Use AI for speed on known patterns, not for decisions you cannot evaluate yourself.

Where AI coding assistants help vs hurt

This is how I would split the work between you and the assistant:

Task AI helps a lot Be careful
Boilerplate (forms, types, API clients) Yes Check it matches your conventions
Writing tests for existing code Yes Tests can assert the current bug as "correct"
Refactoring (rename, extract component) Yes Verify behaviour did not change
Explaining unfamiliar code Yes Explanations can be confidently wrong
Migrations between library versions Partly Models often mix old and new APIs
Performance work Partly Needs profiling data, not guesses
State architecture, data flow design Rarely Decisions need product context the tool lacks
Auth, payments, permissions Rarely Always human-reviewed, line by line
Accessibility Partly Generated markup often skips labels and focus handling

The pattern: AI is strong where there is a well-known right answer and weak where the answer depends on your product, your users or a version released after the model was trained.

A practical AI coding workflow for React

This is the loop I recommend. It works with any tool.

1. Set the context once

Most assistants support a project instruction file or custom instructions. Put the things you repeat in every prompt there:

  • React version, framework and router (for example React 19 with Next.js App Router)
  • State and data libraries (TanStack Query, Zustand, React Hook Form with Zod)
  • Styling approach (Tailwind v4, CSS Modules)
  • Testing tools (Vitest or Jest, React Testing Library, Playwright)
  • Conventions: file naming, where hooks live, "no default exports", "no useEffect for derived state"

This one step removes a big share of the bad suggestions, because the model stops guessing your stack.

2. Ask for a plan before code

For anything bigger than a single function, ask for a plan first: which files change, what the component tree looks like, which edge cases exist. Read the plan. It is far cheaper to fix a wrong plan than to unpick 300 lines of wrong code.

3. Generate in small slices

One component, one hook or one test file at a time. Small diffs are easy to review, and when something breaks you know which step caused it.

4. Review like it is a pull request

See the checklist below. Do not skim because it "looks right". AI output is fluent by design, and fluency is not correctness.

5. Run the tests and the app

Run type checks, lint and tests, then click through the feature. Assistants regularly produce code that type-checks and still renders the wrong thing.

6. Commit with intent

Commit after each verified slice. If the next AI step goes sideways, you can reset cleanly.

Prompts that work for React code

Vague prompts get generic code. Compare:

Weak prompt Better prompt
"Make a login form" "Create a login form using React Hook Form and Zod in app/(auth)/login/LoginForm.tsx. Email and password, show field errors under inputs, disable submit while pending, call the existing signIn server action. Follow the pattern in RegisterForm.tsx."
"Fix this bug" "This list re-renders every keystroke in the search box. Here is the component and the parent. Explain why before changing anything."
"Write tests" "Write React Testing Library tests for CartSummary: empty cart, one item, discount applied, and the error state when pricing fails. Query by role and accessible name, not test IDs."
"Optimise this" "Here is a React Profiler screenshot description: ProductGrid renders 400ms on filter change. Suggest options and their trade-offs. Do not add memoisation unless you explain why the React Compiler would not handle it."

Three habits make prompts better almost every time: name the files, point to an existing pattern to copy, and list the edge cases you care about.

Reviewing AI-generated code: a checklist

These are the issues that show up most often in AI-written React code. Print it, pin it, use it.

Correctness and versions

  • Uses APIs that exist in your installed versions (check against package.json, not memory)
  • No deprecated patterns, such as class components, defaultProps on function components, or old router APIs
  • Server and client boundaries are right ("use client" only where needed, no secrets in client code)

React-specific smells

  • No useEffect used to compute derived state or to sync props into state (React's own guide, You Might Not Need an Effect, covers why). See also useEffect mistakes
  • No manual useMemo/useCallback sprinkled everywhere if you use the React Compiler
  • Keys are stable IDs, not array indexes, for dynamic lists
  • Loading, empty and error states all exist

Security and data

  • User input is validated on the server, not only in the form
  • No dangerouslySetInnerHTML with unsanitised content
  • Permission checks happen server-side
  • No invented package names (check every new import actually exists on npm before installing)

Quality

  • Matches your naming and folder conventions
  • Accessible: labels, roles, keyboard focus, visible focus styles
  • You can explain every line to a teammate

That last item is the one I would never relax. If you cannot explain it, it should not get merged.

Testing AI-written code

Tests matter more with AI, not less, because the assistant can produce a lot of plausible code quickly.

  • Write the test cases yourself, or at least the list of cases. Then let the assistant implement them. You decide what "correct" means.
  • Watch for tests that mirror the implementation. An AI asked to "write tests for this component" will often assert whatever the code currently does, bugs included.
  • Prefer behaviour-level tests. React Testing Library queries by role and text survive refactors, which matters when an assistant rewrites internals.
  • Add an end-to-end test for critical flows. Login, checkout and anything involving money should have a Playwright (or similar) test that a human wrote or carefully reviewed.
  • Run tests in CI on every AI-assisted PR. Same rules as everyone else.

Where AI quietly hurts a React codebase

The obvious failures (code that does not compile) are easy. The quiet ones cost more:

  1. Pattern drift. Five assistants' suggestions over six months produce five ways to fetch data. Your project instruction file and code review keep this in check.
  2. Unnecessary abstractions. Assistants like to add wrapper components, generic hooks and config objects nobody asked for. Simple, boring code is easier to maintain.
  3. Outdated knowledge. Models are trained on older code. Expect suggestions from previous React, Next.js or library versions, especially right after a major release.
  4. Skill erosion. If you never write a reducer or debug a render loop yourself, you lose the judgement needed to review AI code. Solve some problems by hand on purpose.
  5. Review fatigue. Large AI-generated PRs get rubber-stamped. Keep PRs small, whoever (or whatever) wrote them.

How teams should adopt AI tools

If you lead a team, a few ground rules help more than picking the "right" product:

  • Agree on which data can be shared with which tool, and check your clients' contracts. Some client code cannot leave approved systems.
  • Share one project instruction file in the repository so everyone's assistant gets the same context.
  • Keep the same review bar for AI-assisted code. Label it in the PR if that helps reviewers.
  • Let people choose their tools within those rules. Developers work differently, and preferences change as products improve.
  • Revisit the setup every few months. This space moves fast.

The fundamentals still decide whether you can use these tools well. If you want to check yours, my list of senior React developer interview questions is a good self-test.

FAQ

Which AI coding assistant is best for React development?

There is no single best tool. Editor-integrated assistants are good for inline completion, chat and agent-style tools are better for multi-file changes, and most teams benefit from trying two or three on their own codebase. The workflow around the tool matters more than the brand.

Is AI-generated React code safe to ship?

Only after the same review and tests you would apply to a colleague's pull request. AI code often looks correct while using outdated APIs, missing edge cases or adding unnecessary effects, so treat it as a draft.

How should I prompt an AI assistant for React code?

Give it context: your React and framework versions, the relevant files, the conventions you follow and the exact behaviour you want, including edge cases. Ask for a plan first on larger changes, then implement in small steps.

Will AI coding assistants make junior developers worse?

They can if juniors accept code they do not understand. Used with a rule that every line must be explainable in review, they can speed up learning instead.

Wrapping up

AI coding assistants are worth using, but the gains come from the workflow: clear context, small steps, strict review and tests you trust. Pick whichever tools fit how you work, keep the same quality bar for every line, and keep practising the fundamentals that let you judge what the tools produce.

  • #ai
  • #react
  • #code-review
  • #productivity
  • #testing