Skip to main content
Ai promptsMigration promptsReactAngularjs

Write an AngularJS to React Migration Prompt That Maps Every Concept

Build an AngularJS to React migration prompt that inventories directives, maps each concept to a React equivalent, and locks a per-component contract.

PPromptsCart Team·August 9, 2026·Updated August 9, 2026·7 min read

An AngularJS app is held together by things React doesn't have: $scope, two-way binding, dependency-injected services, and directives that mutate the DOM directly. Migrating it isn't translation. It's a concept-by-concept remap, and the failure mode is React that renders but silently loses the binding behavior the old app depended on. An AngularJS to React migration prompt makes that remap explicit: inventory first, map each concept, emit one component against a contract.

Most write-ups online show someone pasting a single component into ChatGPT and pasting the React back. That works for a contact form. It falls apart on component number forty, when a service the model didn't know about gets reinvented three different ways across three files.

The fix isn't a smarter model. It's a prompt that plans the remap once and reuses it.

Why "convert this component" misses the hard parts

Hand a model one AngularJS component and it'll give you plausible React. The problem is what it can't see: the shared service injected into half your controllers, the $rootScope event two components communicate through, the directive that reaches into the DOM on link. Convert components in isolation and each one reinvents those shared pieces.

Here's the take worth defending. The hard part of an AngularJS migration isn't JSX. It's the cross-cutting concerns AngularJS made invisible. $scope inheritance, DI singletons, digest-cycle side effects. A migration prompt earns its keep by surfacing those first, before a single component gets rewritten, so the same service becomes one React context instead of three copies.

What an AngularJS to React migration prompt does

An AngularJS to React migration prompt is a staged remapper that reads your AngularJS source, builds a concept map (directives, controllers, services, bindings), and emits React one component at a time against a fixed output contract. It plans the shared pieces before it touches a component.

Run it to:

  • Inventory every directive, controller, service, and filter in scope
  • Map each AngularJS concept to its React equivalent once, in a shared table
  • Convert ng-model bindings to useState plus explicit handlers
  • Turn injected services into hooks or context, named once and reused
  • Flag DOM-mutating directives that need a manual useRef decision
  • Emit one component per pass so nothing exceeds the context budget

That shared concept map is the difference between a clean migration and forty inconsistent rewrites.

Anatomy of the prompt

Variables
  {{angular_source}}       → the AngularJS component/module to convert
  {{shared_services}}      → injected services in scope (or let it derive)
  {{target_react_version}} → e.g. React 19 with hooks
  {{concept_map}}          → optional: a pre-agreed mapping to reuse

Prompt
  Role: you are an AngularJS-to-React migration planner.
  Task: convert {{angular_source}} to {{target_react_version}}.
  Rules:
    - Build the concept map before emitting any component.
    - Map ng-model to useState + handler; $watch to useEffect deps.
    - Flag $scope mutation and DOM-touching directives for review.

Output contract
  Return: concept map + per-component React + a review-needed list.

1. Inventory before converting

The model can't reuse a service it never catalogued. Force the inventory pass as its own section so shared pieces surface before any component is rewritten.

2. Lock the concept map

The concept map (ng-modeluseState, service → context, $watchuseEffect) gets agreed once. Feed it back in {{concept_map}} on later passes so every component converts the same way.

3. Convert one component, read the review list

Each pass emits one component plus a list of things the model wouldn't convert blindly. That list is where the real review time goes.

The concept map is the migration

Skip the concept map and you'll get React that works per file and contradicts itself across files. One component turns a service into a hook, the next into a prop, the third into a global. Lock the mapping once, reuse it every pass, and the migration stays coherent. The prompt should refuse to emit a component until the shared concepts are mapped.

Prompt-craft patterns for framework remaps

Map concepts, don't translate syntax. A prompt that goes line by line produces React that mirrors AngularJS structure instead of idiomatic hooks. Force a concept map so $scope.$watch becomes a real useEffect, not a watcher shim.

Name the binding's new state. ng-model="user.name" has to become a specific useState. Make the contract name it, so you can verify the binding survived rather than trusting the diff.

Quarantine the unconvertible. Directives that mutate the DOM, $rootScope events, digest-cycle hacks. These don't have clean React equivalents. The contract should route them to a review-needed list, not let the model invent a fragile workaround.

Where Claude and ChatGPT diverge on binding conversion

The two models handle two-way binding differently, and it shows. Claude tends to convert ng-model into a useState value with an explicit onChange and comments the original binding inline, which makes the mapping easy to audit. GPT-4o writes terser React but will sometimes collapse a $watch into inline logic that loses the dependency tracking, unless the "map $watch to useEffect with explicit deps" rule sits on the final line where it stays in attention.

Both models will quietly reinvent a shared service per component if the concept map isn't pinned. So pin it, and pass it back every call. Watch the stale-closure trap too: a $scope value read inside a converted callback can capture an old render's state, which AngularJS never had to worry about. Pin the model version, because a converter that started mapping services differently after an update is a regression you'll only catch when a component misbehaves in production.

How this fits the broader migration

An AngularJS-to-React move is one framework migration among many. The staging discipline, inventory and reversible steps, is the same logic that drives any major version bump. For the general structure, the framework migration prompt covers the staged-rollout pattern this builds on. If your migration also changes the language under the framework, the cross-language refactor prompt handles idiom preservation.

Variables you'll set

VariableRequiredWhat it is
{{angular_source}}YesThe AngularJS component or module to convert
{{shared_services}}RecommendedInjected services in scope
{{target_react_version}}YesTarget React version and conventions
{{concept_map}}OptionalA pre-agreed mapping to reuse across passes

Getting started

  1. Copy the staged structure into ChatGPT, Claude, or Gemini.
  2. Paste one component or module into {{angular_source}}, not the whole app.
  3. List injected services in {{shared_services}} so the inventory is complete.
  4. Run it and read the concept map before any component code.
  5. Save the concept map and feed it back via {{concept_map}} next pass.
  6. Work the review-needed list by hand before you call a component done.

For a migration spanning many components with the inventory and staging already wired in, the Framework Migration Harness Playbook runs the full sequence.

Browse the migration prompt packs
Skip the setup

The Framework Migration Harness Playbook does this end-to-end: a {{source_framework}} and {{target_framework}} pair feeds a breaking-change-mapper that ties each concept to an exact edit, then a staged-rollout-plan sequences independently verifiable steps so an AngularJS-to-React move ships component by component instead of in one unreviewable PR. It's part of The Complete AI Prompts Bundle, a one-time lifetime license to the whole catalog plus future packs, which pays off if you run more than one migration a year.

Get the Framework Migration Harness Playbook

Once components are converted, you'll want to verify the React actually behaves like the AngularJS it replaced. The Cross-Language Refactor Harness locks an output contract per file for exactly that kind of behavior-preserving check. New to buying packs versus rolling your own? Start with how to choose a reusable AI prompt pack.

See the Cross-Language Refactor Harness
FAQ

Common questions

Can one prompt migrate a whole AngularJS app to React?
Not in one shot, and you shouldn't try. An AngularJS to React migration prompt works per component or per module: it inventories the directives, controllers, and services in scope, maps each AngularJS concept to its React equivalent, then emits one component at a time against a locked output contract. Feeding a whole app into a single call blows the context window and produces React that compiles but quietly drops behavior.
How does the prompt handle two-way data binding?
It maps `ng-model` two-way binding to a `useState` value plus an onChange handler, and `$scope.$watch` to a `useEffect` with an explicit dependency array. The output contract forces the model to name which state each binding becomes, so you can check the mapping rather than trust a blind rewrite. Implicit `$scope` mutation is the part that breaks silently, so the prompt flags it for review instead of guessing.
Which model is better for AngularJS to React conversion?
Claude tends to preserve component structure and comment the AngularJS-to-React mapping inline, which makes review faster. GPT-4o produces terser React but needs the per-component output contract restated on the final line or it merges several directives into one component. For either, pin the model version, because a planner that subtly changed how it maps services is a regression you won't notice until a component misbehaves.
Stop reading. Start shipping.

Get the prompt packs this guide is built on

Ready-to-paste prompts with documented variables and usage guides for ChatGPT, Claude, and Gemini. One-time payment, own it forever.